Reply to topic

Get multiple rows - cols from matrix

jonharington
Registered Member
Posts
1
Karma
0
Hello,

I have been googling for a while now, but cant find the answer to this simple question.

In matlab i can do this:

rows = [1 3 5 9];
A = rand(10);
B = A(rows, : );

How do i do this in eigen? It does not seem like it is possible? The closest thing i have found is

MatrixXd a(10,10);
a.row(1);

,but I want to get multiple rows/cols

Thanks.
User avatar ggael
Moderator
Posts
3431
Karma
19
OS
either do a for loop, or use the devel branch:
Code: Select all
using Eigen::placeholders::all;
a(rows,all);

where rows can be {1,3,5,9}, a std::vector<int>, a std::array<int>, a VectorXi, or anything like that...

 
Reply to topic

Bookmarks



Who is online

Registered users: Bing [Bot], burnessduan, Clancularius, Exabot [Bot], Google [Bot], Majestic-12 [Bot], ScottBeebiWan, Sogou [Bot], Yahoo [Bot]