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

Slicing a matrix to row/colum where diag>0

Tags: None
(comma "," separated)
Ruben80
Registered Member
Posts
1
Karma
0
I'm new to Eigen and trying to port some existing python code to C++.

I have a matrix and want to keep only those row/columns where the diagonal term is larger than 0.

I managed to get an array of bool with the positive diagonal positions,

VectorXd Diag = M.diagonal();
Array<bool, Dynamic, 1> iPos = Array<bool, Dynamic, 1>(n);
iPos = (Diag.array() > 0);

However slicing seems not to be possible with an array of booleans, so I either need to convert to an array of int (but how?) or I need to do this differently alltogether.

Any advice?


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot], rblackwell