Question w.r.t. sparse matrices
![](https://secure.gravatar.com/avatar/d41fa6e1fe29e6c5c5821b5a3f31f190.jpg?s=120&d=mm&r=g)
Hi, Consider the sparse vector
x <420x1 sparse matrix of type '<type 'float64scalar'>' with 2 stored elements (space for 2) in Compressed Sparse Row format> print x (3, 0) 1.0 (30, 0) 1.0
x.getnnz() yields the number of nonzero elements
x.getnnz() 2
How can I obtain the pattern of x ? I mean the indices of nonzero elements. Nils
![](https://secure.gravatar.com/avatar/d41fa6e1fe29e6c5c5821b5a3f31f190.jpg?s=120&d=mm&r=g)
Nils Wagner wrote:
Hi,
Consider the sparse vector
x <420x1 sparse matrix of type '<type 'float64scalar'>' with 2 stored elements (space for 2) in Compressed Sparse Row format> print x (3, 0) 1.0 (30, 0) 1.0
x.getnnz() yields the number of nonzero elements
x.getnnz() 2
How can I obtain the pattern of x ? I mean the indices of nonzero elements.
Nils
_______________________________________________ SciPy-user mailing list SciPy-user@scipy.net http://www.scipy.net/mailman/listinfo/scipy-user
Sorry for replying to myself. It seems to be not implemented yet.
where (x <>0) Traceback (most recent call last): File "<stdin>", line 1, in ? File "/usr/lib/python2.4/site-packages/scipy/sparse/sparse.py", line 160, in __cmp__ raise TypeError, "comparison of sparse matrices not implemented" TypeError: comparison of sparse matrices not implemented
Nils
participants (1)
-
Nils Wagner