[SciPy-user] fast max() on sparse matrices
Mon Jan 5 19:42:36 CST 2009
On Mon, Jan 5, 2009 at 8:04 PM, Peter Skomoroch
> You said:
> "... some matrices permit duplicate entries.
> Currently, we implicitly sum duplicate values together (e.g. when
> computing sparse matrix-vector products) and when converting to other
> Could you elaborate on that a bit? I'm trying to track down a nasty bug
> right now where the result of a sparse matrix-matrix product (A_sparse *
> B_dense) does not agree with the corresponding dense product (A_dense *
It's a little costly to detect the presence of duplicates in the CSR,
CSC, and COO formats so we adopt the convention that a matrix with
duplicates should behave as if those duplicates were summed together.
If A and B are sparse matrices then A * B should be close to
dot(A.toarray(), B.toarray()). The only difference between the two
would be due to to order of operations.
Note that there's another oddity w.r.t. sorting of the indices in the
CSR/CSC formats. Certain operations will shuffle the nonzeros about,
so it's dangerous to share arrays between multiple CSR/CSC matrices.
I suspect Robert's suggestion might be the source of your problems.
If not, try to reduce the problem to something small and reproduceable
and we'll try to sort it out.
Nathan Bell firstname.lastname@example.org
More information about the SciPy-user