[eigen] bug in data() on col/row |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
Hi
I just discovered a nasty "bug" - depending on how you look at it - in
Eigen, see the following program:
#include <eigen2/Eigen/Core>
using namespace Eigen;
using namespace std;
void copy(const float *from, float *to)
{
for(int i=0;i<3;i++)
to[i] = from[i];
}
int main(int argc, char** argv)
{
Matrix3f m;
m << 1,2,3,4,5,6,7,8,9;
cout << m << endl << endl;
float var[3];
copy(m.row(0).data(), var);
Map<Vector3f> map(var);
cout << map.transpose() << endl;
}
bschindl@hundertwasser ~ $ ./test
1 2 3
4 5 6
7 8 9
1 4 7
When I save m.row(0) in a Vector3f and output it, I of course get this:
bschindl@hundertwasser ~ $ ./test
1 2 3
4 5 6
7 8 9
1 2 3
That's a nasty thing - and can cause lots of pain...
Is there something we can do about it?
Cheers
Benjamin