Reputation: 801
How can you reorder the rows (or columns) of an Eigen
matrix without copying them? You can use Eigen::Map
to reshape them without copying the data, so I'm assuming there is some way to change the ordering as well, but there does not seem to be an example in the documentation.
Upvotes: 1
Views: 2121
Reputation: 18827
You can multiply your matrix by a PermutationMatrix
, or by a Transpositions
matrix. If you multiply P * A
, then the rows of A
are permuted according to the indexes in P
. The product itself is lazy, i.e., it is only evaluated when needed (however, there are no strong guarantees when temporaries are constructed, when evaluating more complex expressions).
Upvotes: 3