Boost logo

Ublas :

Subject: Re: [ublas] Question regarding sparse vector's nnz() method
From: Karl Meerbergen (Karl.Meerbergen_at_[hidden])
Date: 2010-03-11 03:29:04

We have had a debate about this many years ago. The initial definition
of nnz in old papers on matrix formats is the number of structural
non-zeros, which corresponds to filled() in ublas. In matlab,
nnz=filled, since I think that setting an element to zero deletes it
from the sparse structure.



Jesse Perla wrote:
> <al-iyaz <at>> writes:
>> To the best of my knowledge nnz() indeed stands for the Number of Non Zero
>> entries of a sparse matrix. Checking boost/numeric/ublas/matrix_sparse.hpp,
>> it does seem to be implemented accordingly.
> One problem I ran into recently was when I was setting elements of the sparse
> matrix to be 0.0. As far as I could tell, .nnz() picked these up
> as zeros (probably as designed).... if you want to find out how many
> of the elements in the matrix are filled in with something, then use .filled()
> _______________________________________________
> ublas mailing list
> ublas_at_[hidden]
> Sent to: karl.meerbergen_at_[hidden]