[Numpy-discussion] np.dot and scipy sparse matrices
Stéfan van der Walt
stefan at sun.ac.za
Thu Nov 10 13:56:39 EST 2011
On Thu, Nov 10, 2011 at 10:45 AM, Peter Prettenhofer
<peter.prettenhofer at gmail.com> wrote:
>> I don't know if np.dot is supposed to know anything about sparse
>> matrices; if so, then a fancier change may be needed.
> Ok, then I'll pass that on to the (sparse) scipy folks.
> Are there any alternative to np.dot you are aware of?
With sparse matrices, you can simply do
S = ss.csr_matrix(np.arange(9).reshape((3,3)))
x = np.array([,,])
print S * x
But I assume what you want is an easy way to handle both sparse
matrices and dense arrays with the same call? I noticed in your
comment on the sklearn list that this used to work on older versions
of numpy. If that is the case, this is probably a regression that
needs to be fixed.
More information about the NumPy-Discussion