[SciPy-user] Sparse matrices

Travis Oliphant oliphant at ee.byu.edu
Wed Nov 10 13:55:02 CST 2004


Nils Wagner wrote:

> Hi all,
>
> from scipy import *
> A = sparse.dok_matrix()
>
> for i in range(3):
>  A[i,i] = 0.0+0.0j
> # A[i,i] = 0.1+0.0j
>
> n,m = A.shape
> print n,m
> print A
>
>
> n, m should be equal to 3, but this is only valid for non-zero entries.
>
> Am I missing something ?

Entering a zero value into a sparse matrix causes no storage and 
therefore no shape changes.  A remains an empty sparse matrix.   What 
are you trying to do?


-Travis



More information about the SciPy-user mailing list