Registered Member
|
I am very new to Eigen (v2.0.2) and, from the tutorial, I thought it was possible to set values for a single row of a matrix which is something I need to do. However, I am getting dimension mismatch errors originating from
Core/block.h line 247 As a test, I tried setting a row of MatrixXd G(12, 3), as follows: Vector3d tempVec = Vector3d::Ones(); G.row(3) = tempVec; This compiles but has a runtime error. Is there some way to do this row-wise assignment? [Note: I need column-wise assignment, too.] Thanks in advance. |
Moderator
|
This is because tempVec is a column vector while G.row(3) is a row vector. Actually, in most cases this transposition is automatic, however, in your case one vector has compile time size (Vector3d) while the other has a dynamic size (a row of MatrixXd) and then our test detect that even with a transposition the sizes do not match. So two solutions:
1 - you can explicitly transpose the rhs, e.g.:
2 - since it seems the number of column of G is known at compile time I suggest you to declare it like this:
Now, Benoit and I have to decide whether we want to allow automatic transpositions in such a case. The test in Assign.h could be:
|
Registered users: Bing [Bot], Google [Bot], Sogou [Bot]