I was wondering how to loop through all the non-zero entries of a sp_umat
(i.e., SpMat<unsigned int>
) in Armadillo, and came across this related question ( link ). That post suggests using a const_iterator
to retrieve the non-zero locations and values in sp_mat
. Can one assume that all iterators of sp_mat
(and other related types of sparse matrices in armadillo; sp_umat
in my case) support only iterators that visit non-zero entries alone? I was not able to get this sorted out from the documentation. Another related question also comes to mind: in general, does Armadillo support visiting any other locations in a sparse matrix at all by other means? Thanks very much for the help!
Asked
Active
Viewed 242 times
1
1 Answers
4
1) Yes, all iterators of sparse objects only iterate over nonzero locations. I'm sorry that isn't clear in the documentation, I'll see if maybe that can be improved.
2) Yes, you can access any location in a sparse matrix with matrix(i, j)
just like dense matrices. So in that sense the sparse and dense matrices are somewhat interchangeable.

ryan
- 839
- 4
- 13