Registered Member
|
Documentation on 'reverse' is lacking regarding whether it does in-place reverse or not.
I have a VectorXd called e.g. test and is filled with 5 numbers, from 1 to 5: 1 2 3 4 5 This does nothing: test.reverse(); This however does something: test = test.reverse(); 5 4 3 4 5 This looks like in-place reversing that doesn't use intermediate storage. Do I always have to put the output of reverse into a new vector or is there a simple way to get a vector reversed without doubling the storage? |
Registered Member
|
Solved it by doing it with a temporary vector...
VectorXd tmp = test.reverse(); test = tmp; |
Moderator
|
well, the documentation says:
Returns: an expression of the reverse of *this. So just like any other functions (transpose, normalize, adjoint, replicate) it's clear that it does nothing until the expression gets assigned to another object. http://eigen.tuxfamily.org/dox/classEig ... ce4b4649e2 There is also a reverseInPlace() function. |
Registered Member
|
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]