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

Iterator for Rows/columns

Tags: None
(comma "," separated)
anjishnub
Registered Member
Posts
3
Karma
0

Iterator for Rows/columns

Fri Apr 29, 2016 1:43 pm
Can anyone tell me what is a way to create an iterator through a row/column of an eigen matrix?

Does A.row(i).begin() work? The InnerIterator method seems to work only for sparse matrices.

Thanks in advance
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Iterator for Rows/columns

Wed May 04, 2016 11:28 am
For a column of a column-major matrix, you can use: A.col(j).data(), A.col(j).data()+A.rows() as begin/end pair. For a row, it is more tricky because you have to use A.outerStride() as the increment.
anjishnub
Registered Member
Posts
3
Karma
0

Re: Iterator for Rows/columns

Mon May 09, 2016 12:39 pm
Hi,

Can you please tell me the outerstride usage? Thanks
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Iterator for Rows/columns

Sun May 15, 2016 8:53 am
A.outerStride() is the number of elements to skip from column to the next one. So you can loop over a row as:


for(double *it=A.row(i).data(); it<A.row(i).data()+A.size(); it+=A.outerSrtride()) {
*it ;
}


Bookmarks



Who is online

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