This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Get multiple rows - cols from matrix

Tags: None
(comma "," separated)
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
3447
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...


Bookmarks



Who is online

Registered users: Bing [Bot], daret, Google [Bot], sandyvee, Sogou [Bot]