From: Gunter Winkler (guwi17_at_[hidden])
Date: 2007-04-26 17:01:15
Am Donnerstag, 26. April 2007 06:45 schrieb Pallav G:
> say i declare a 3 x 3 mapped_matrix. all of the
> elements are initialized to 0. say i set the value of
> 2 elements to 1 so that the matrix is like this
> 0 0 0
> 0 1 0
> 0 0 1
... compute effective size of a matrix ...
> also it would be nice to know how to many non-zero
> elements are there in the matrix at any given time.
> maybe these facilities already exist and i'm not aware
> of them? please let me know.
we have nnz(), nnz_capacity() which return the actual and maximal (until
internal reallocation) number of structural nonzeros. If you frequently
have to count nonzeros per row you may consider different sparse types:
generalized_vector_of_vector< T, row_major, vector<compressed_vector<T>
> > A;
here you can use the (undocumented?) access to the internal array of
A.data()[i].nnz(); // nnz of row i