[SciPy-user] Unexpected typecasting when adding sparse.lil_matrix

Tony S Yu tonyyu@MIT....
Thu Sep 11 10:03:06 CDT 2008


This may be expected behavior, but I found it surprising. Addition (or  
any other simple operation) of two lil sparse matrices returns a csc  
sparse matrix. The scipy website suggests that csc and csr matrices  
are more efficient than lil matrices for multiplication and inversion  
(and I guess for addition too), but this typecasting is still a little  
surprising. I was just curious if this is intentional.

Thanks,
-Tony

#~~~~~~~~~

In [1]: import scipy.sparse as sparse

In [2]: A = sparse.lil_eye([3, 3])

In [3]: A + A

Out[3]:
<3x3 sparse matrix of type '<type 'numpy.float64'>'
	with 3 stored elements (space for 3)
	in Compressed Sparse Column format>



More information about the SciPy-user mailing list