0

I was wondering why this doesn't work with Eigen:

MatrixXd A = MatrixXd::Random(3, 10);
Array<double, 1, Dynamic> x = Array<double, 1, Dynamic>::Random(10);
MatrixXd y = x.matrix() * A.transpose();

while this works:

MatrixXd A = MatrixXd::Random(3, 10);
Array<double, 1, Dynamic> x = Array<double, 1, Dynamic>::Random(10);
MatrixXd y = MatrixXd(x) * A.transpose();

and this also works:

MatrixXd A = MatrixXd::Random(3, 10);
ArrayXXd x = Array<double, 1, Dynamic>::Random(10);
MatrixXd y = x.matrix() * A.transpose();

My compiler gives me the following error message for the first example (clang-500.2.79):

code/Eigen/src/Core/ArrayWrapper.h:178:56: error: cannot initialize return object of type 'ScalarWithConstIfNotLvalue *' (aka 'double *') with an rvalue of type 'const Scalar *' (aka 'const double *') inline ScalarWithConstIfNotLvalue* data() { return m_expression.data(); }

Lucas
  • 738
  • 7
  • 19
  • 3
    Works for me with both gcc and clang, with both Eigen 3.1 and 3.2. Please provide a self-contained example with the Eigen version. – ggael Dec 09 '13 at 14:00
  • The version of Eigen I used was 3.1.2. I downloaded a more recent version (3.1.4) and now it compiles without problems. Thanks ggael. – Lucas Dec 09 '13 at 16:46

0 Answers0