How to get an array of non-zero locations (indices) and sparse matrix values ββin Armadillo C ++?
So far, I can easily build a sparse matrix with a set of locations (as an umat object) and values ββ(as a vec object):
// batch insertion of two values at (5, 6) and (9, 9) umat locations; locations << 5 << 9 << endr << 6 << 9 << endr; vec values; values << 1.5 << 3.2 << endr; sp_mat X(locations, values, 9, 9);
How do I get places back? For example, I want to be able to do something like this:
umat nonzero_index = X.locations()
Any ideas?
source share