Registered Member
|
Dear Eigen users,
I have been using Eigen 3 and I arrived to this question, I may be missing something on the assignment so I would appreciate your hints. Here is a piece of sample code that reproduces the problem. //--------
//--------- here the output this is the matrix 1 2 3 4 5 6 m.block(1,0,1,3) 4 5 6 this is the vector Eigen::Vector3d v = m.block(1,0,1,3) 4 2 5 this is the vector r = m.row(1) 4 5 6 Why are block and row commands here stored differently on Vector3d, I was expecting them to be equivalent. Thanks, Nicolas |
Moderator
|
Vector3d is a column vector, use RowVector3d for a row vector.
m.block(1,0,1,3) or m.row(1) are row vectors, but Eigen allows implicit transposition when copying a row vector to a column one (and conversely). So basically, when you do: r = m.row(1) Eigen actually performs: r = m.row(1).transpose() |
Registered Member
|
I tried this example (Eigen 3.3.0), and this program crashed (see below). So you won't see this confusing outputs.
eigen/Eigen/src/Core/PlainObjectBase.h:279: void Eigen::PlainObjectBase<Derived>::resize(Eigen::Index, Eigen::Index) [with Derived = Eigen::Matrix<double, 3, 1>; Eigen::Index = long int]: Assertion `(!(RowsAtCompileTime!=Dynamic) || (rows==RowsAtCompileTime)) && (!(ColsAtCompileTime!=Dynamic) || (cols==ColsAtCompileTime)) && (!(RowsAtCompileTime==Dynamic && MaxRowsAtCompileTime!=Dynamic) || (rows<=MaxRowsAtCompileTime)) && (!(ColsAtCompileTime==Dynamic && MaxColsAtCompileTime!=Dynamic) || (cols<=MaxColsAtCompileTime)) && rows>=0 && cols>=0 && "Invalid sizes when resizing a matrix or array."' failed. |
Registered users: abc72656, Bing [Bot], daret, Google [Bot], Sogou [Bot], Yahoo [Bot]