[SciPy-User] Sparse matrix multiply
Pauli Virtanen
pav@iki...
Thu Mar 22 05:18:40 CDT 2012
22.03.2012 10:34, Jaakko Luttinen kirjoitti:
> import numpy as np
> import scipy.sparse as sp
> A = sp.rand(20,20,density=0.1)
> B = sp.rand(20,20,density=0.1)
> np.multiply(A,B).sum()
> # out: 0.76482546226069481
> Am I missing something?
> I think numpy.multiply should either return the correct answer or an
> error that it can't compute the correct answer.
The answer is the same as to your previous questions --- the Numpy
ufuncs do not deal with sparse matrices in a reasonable way. This lack
of integration between dense and sparse is a bug.
Why it does not raise an error instead, is probably that as a
consequence of the operation overloading rules defined, there is a
(nonsensical) operation that matches the call.
--
Pauli Virtanen
More information about the SciPy-User
mailing list