Registered Member
|
I'm trying to use the elements of a column as the new elements of a matrix as follows:
Essentially I want H to be made up of the 9 elements in the col(8) return value. The same as doing H << 1, 2, 3, ... 9. But when I do this I get an assertion failed because the col(8) return value has a larger number of cols. Sounds fair, so how do I reshape the col(8) return value to fit in H? (Of course I could do it with a small loop or writing out the arguments but an elegant library as Eigen must have a nicer way of doing this). I'm using Eigen 2.0.15 btw. |
Registered Member
|
Normally I'd say use Map to reshape the underlying plain array as a 3x3 matrix, but in your case that is relying on matrixV being stored in column-major order, which doesn't seem to be worth it. Why don't you slice it in 3 parts?
H << svd.matrixV().col(8).start(3), svd.matrixV().col(8).segment(3,3), svd.matrixV().col(8).end(3);
Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list! |
Registered Member
|
That's indeed quite a good solution - I never thought about using segment().
Thanks very much for your help. |
Registered users: Bing [Bot], blue_bullet, Google [Bot], rockscient, Yahoo [Bot]