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

Got iterator types?

Tags: None
(comma "," separated)
firosiro
Registered Member
Posts
1
Karma
0

Got iterator types?

Fri Aug 04, 2017 6:39 am
As a newbie, I am surprised that I haven't been able to get iterators for Eigen arrays or matrices. I want to get the number of non-zero entries in a matrix, but it's not clear what is the neatest approach. If there were iterators, I could use std::count_if()
Thanks.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Got iterator types?

Tue Aug 08, 2017 8:25 pm
Say we have:

MatrixXd A;

You can get a pair of iterators with A.data() and A.data()+A.size(), but better use Eigen's language:

nnz = (A.array() == 0).count();


Bookmarks



Who is online

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