[SciPy-user] Sparse matrix usage, documentation.

Ed Schofield schofield at ftw.at
Sat May 13 07:37:24 EDT 2006


Neilen Marais wrote:
> Hi
>
> The documentation for the sparse matrix classes seem to be, well, sparse.
> Does documentation exist somewhere I'm missing, or is it simply to early
> in the development process for much documentation to be around? I may be
> able to commit some once I understand what's going on though :)
>   
I've just added some basic documentation to SVN, accessible from the
prompt with help(sparse).  I'd be very grateful if you could contribute
any more examples.  Do you think it should take the form of a wiki page,
or as an html or pdf file in the source tree?

> Right now I'd like to know more about the different sparse matrix types.
>
> I understand pretty much what coo, csc, and csr matrices are. From the
> docstrings I can more or less figure out what dok_matrix is, but what are
> dod_matrix and lnk_matrix?
>   

dod_matrix was dead code; I've now deleted it in SVN.

> For naive matrix filling (i.e. if you don't know the sparsity pattern
> before hand) dok_matrix seems to be the best choice. Are there other
> useful formats for this purpose?
>   

lil_matrix is a sparse matrix stored as a list of lists.  It should
allow efficient construction of matrices, like dok_matrix, but with more
efficient conversion to CSR format and better support for slicing and
NumPy-like fancy indexing.  So I'd recommend using lil_matrix for
construction.

> When solving the matrix using iterative techniques, would it be better to
> convert it to one of the other sparse formats first, or can the dok matrix be
> solved efficiently itself?
>   
Yes, you probably need to convert DOK and LIL matrices to either CSR or
CSC first.  If you don't, it should either convert them internally
anyway or raise an exception :)

-- Ed




More information about the SciPy-User mailing list