Registered Member
|
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. |
Moderator
|
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(); |
Registered users: Bing [Bot], daret, Google [Bot], sandyvee, Sogou [Bot]