Arrayed row or column indexing in Eigen

394 Views Asked by At

I'm trying to achieve row indexing of a matrix using an array of indices in Eigen-3.2.0 whose Matlab equivalent is the following: consider a matrix A:

>> A = [2 3 0 ; 1 9 2 ; 4 7 2]

A =

     2     3     0
     1     9     2
     4     7     2

>> A( [1 3 2 1 3], : )

ans =

     2     3     0
     4     7     2
     1     9     2
     2     3     0
     4     7     2

I've been able to obtain an array of row indices ( of the type MatrixXd::Index ) which contains the numbers (1, 3, 2, 1, 3). But I've not been able to figure out a way of applying this array to the Matlab-like indexing described above. Is this even possible in Eigen? Or is there a smarter way of doing it? Any help at all will be great.

Thanks!

0

There are 0 best solutions below