Registered Member
|
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 |
Moderator
|
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.
|
Registered Member
|
Hi,
Can you please tell me the outerstride usage? Thanks |
Moderator
|
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 ; } |
Registered users: Bing [Bot], Evergrowing, Google [Bot], rockscient