[SciPy-user] spare matrices

Eric Friedman ejf27@cornell....
Tue Mar 17 06:11:14 CDT 2009

Nathan Bell <wnbell <at> gmail.com> writes:

> On Mon, Mar 16, 2009 at 10:12 PM, Eric Friedman <ejf27 <at> cornell.edu> wrote:

> Yes, scipy.sparse should be competitive with MATLAB in terms of
> performance.  For instance, I use scipy.sparse with PyAMG[1] to solve
> linear systems with millions of unknowns.  With such large matrices
> you'll want to primarily use the COO, CSR, and CSC formats, whose
> operations are implemented in C++.  You'll want to avoid using
> lil_matrix and dok_matrix to construct matrices, as they are about 100
> times slower than the alternatives.  Here's a example that highlights
> the difference[2].

> [2]

Excellent -- thanks.  A few more newbie questions:

1)How do I find the detailed descriptions of functions like coo? 
Is there a good
document (which I haven't been able to find) or do I need 
to look inside the code?
For example, I don't see how to access individual elements in a coo.
Also, I'd like to be able to pull out a submatrix from a 
subset of the rows and
find the set of rows which are nonzero.

2) I tried linsolve.spsolve and it says I should use 
sparse.linalg.dsolve but
when I try that directly I can't get it to work. 
Also, is there any
documentation on dsolve or spsolve? My matrix is 
singular, but the matrix
equation is still solvable -- can it deal with that?

thanks again,

More information about the SciPy-user mailing list