[SciPy-User] scipy.sparse.csr_matrix: Refills with same graph, different values

Nico Schlömer nico.schloemer@gmail....
Tue Oct 12 03:18:24 CDT 2010

Hi all,

I do computations with a sparse matrix the values of which need to
change, but never the sparsity structure.
Until now, every time the values change, I tossed away the old matrix,
create a new lil_matrix, and then use .tocsr() to get what I want.
This seems really wasteful, though, as this way, all the sparsity
information is computed anew.
I've tried setting the values in the csr_matrix -- one created --
directly, but even though they go into spots where there's a nonzero
already, this operation seems slow. Also, I don't know of a way to
zero-out a csr_matrix while keeping the sparsity information.

Any hints on this?


More information about the SciPy-User mailing list