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

got iterator types?

Tags: None
(comma "," separated)
xaffeine
Registered Member
Posts
24
Karma
0

got iterator types?

Tue Apr 29, 2014 6:41 pm
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().
User avatar
benoitsteiner
Registered Member
Posts
13
Karma
0

Re: got iterator types?

Tue Apr 29, 2014 8:30 pm
If A is your dense matrix of array, the following expression should count the number of non zeros coefficients: (A != 0).count();


xaffeine
Registered Member
Posts
24
Karma
0

Re: got iterator types?

Wed Apr 30, 2014 5:18 pm
That makes sense. For general iteration, should I use myMat.data() and myMat.data()+myMat.size() in places where I would have used begin() and end() on a standard container?


Bookmarks



Who is online

Registered users: Baidu [Spider], Bing [Bot], Google [Bot], rblackwell