New user self-registration is currently disabled. Please email eigen-core-team @ lists.tuxfamily.org if you need an account.
Bug 1343 - Matrix expressions cannot be used to initialize ArrayXd
Matrix expressions cannot be used to initialize ArrayXd
Status: RESOLVED FIXED
Product: Eigen
Classification: Unclassified
Component: Core - expression templates
3.3 (current stable)
All All
: Normal Compilation Problem
Assigned To: Nobody
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2016-11-17 20:00 UTC by Yixuan Qiu
Modified: 2016-11-18 14:02 UTC (History)
3 users (show)



Attachments

Description Yixuan Qiu 2016-11-17 20:00:26 UTC
Hi All,

I just found an issue that newly appeared in the 3.3 version. The problem is that a matrix-vector multiplication cannot be used to initialize an ArrayXd object. See the minimal example below:

=====================================================================

#include <Eigen/Core>

using Eigen::MatrixXd;
using Eigen::VectorXd;
using Eigen::ArrayXd;

int main()
{
    MatrixXd m1 = MatrixXd::Random(10, 10);
    VectorXd v1 = VectorXd::Random(10);
    
    ArrayXd a1 = v1;       // This is fine
    ArrayXd a2 = m1 * v1;  // OK on 3.2 but fails on 3.3
    
    return 0;
}

=====================================================================

OS: Fedora 25 64-bit
Compiler: GCC 6.2/clang 3.8



Thank you.


Best,
Yixuan
Comment 1 Yixuan Qiu 2016-11-17 20:09:09 UTC
A possibly related one:

=====================================================================

#include <Eigen/Core>

using Eigen::MatrixXd;

int main()
{
    MatrixXd m1 = MatrixXd::Random(10, 10);
    
    MatrixXd m2 = m1.selfadjointView<Eigen::Lower>(); // Fine
    MatrixXd m3 = MatrixXd::Zero(10, 10);
    m3 += m1.selfadjointView<Eigen::Lower>(); // Fails on 3.3
    
    return 0;
}

=====================================================================


Maybe coming from the new mechanism of expression evaluation?


Best,
Yixuan
Comment 2 Gael Guennebaud 2016-11-18 09:20:22 UTC
For the 1st one, the problem is that in 3.2, the expression turned out to be evaluated as:

ArrayXd a2 = (m1*v1).eval()

(this was not the case if a2 is a VectorXf). In 3.3, the implementation is more general, and it thus reveals this issue. Fixed:

https://bitbucket.org/eigen/eigen/commits/25c392fdbf64/
3.3: https://bitbucket.org/eigen/eigen/commits/669d7bf13a67/

For the second one, the generic EigenBase2EigenBase assignment was lacking -= and +=, fixed:

https://bitbucket.org/eigen/eigen/commits/0e78c04fea69/
3.3: https://bitbucket.org/eigen/eigen/commits/9b63b9758a3f/
Comment 3 Yixuan Qiu 2016-11-18 14:02:12 UTC
Thank you Gael!

Note You need to log in before you can comment on or make changes to this bug.