[SciPy-user] sparse behaviour?

Stefan van der Walt stefan at sun.ac.za
Mon Oct 9 18:48:53 CDT 2006


On Mon, Oct 09, 2006 at 11:39:24AM +0200, koara at atlas.cz wrote:
> i decided to represent some of my large matrices as sparse matrices. My initial assumption was that the exposed operations and interfaces are the same (only the inner representation changes), so that my code would require no changes. However my code broke down immediately; is this how things are and my assumtpion was incorrect, or is something wrong?
> 
> an example (getting covariance matrix) of code that didn't make it:
> 
> n1 = matrix([[0,0,1,0],[0,0,0,2]])
> s1 = sparse.lil_matrix(n1)
> cov(n1) # OK
> cov(s1) # shape mismatch
> exception---------------------------------------

Currently, scipy.cov calls numpy.cov, which knows nothing about sparse
matrices.  I don't think there is any reason why it can't be done,
it's just that no one has taken the time to implement it.

Regards
Stéfan


More information about the SciPy-user mailing list