[eigen] Strange operator behaviour

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]




I have observed a very strange behaviour using the ?: operator.

If I run the following progrom:



#include <iostream>

#include <Eigen/Core>



using namespace Eigen;

using namespace std;



int main(int argc, char* argv[])

{

  MatrixXd A(2,2);

  A << 11, 12,

    21, 22;

  bool flag = false;



  cout << "Matrix A:\n" << A << endl<<endl;

  MatrixXd B  = flag ? A.transpose() : A;

  cout << "Matrix B:\n" << B << endl<<endl;

  cout << "Matrix A after:\n" << A << endl<<endl;

  cout << "Flag: "<< (flag ? "true" : "false") <<endl;

}



I get this surprising output:



Matrix A:

11 12

21 22



Matrix B:

11 21

12 22



Matrix A after:

11 12

21 22



Flag: false



Does anybody have an idea, why B is initialized with A.transpose() instead

of A?

I am using Visual Studio 2012 Update4 and Eigen3.2.2

Does Eigen3.2.2 somewhere overrides the ?: operator with some strange side

effects?



I am very confused.



mwb



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/