[Numpy-discussion] sparse matrix dot product
Sebastian Walter
sebastian.walter at gmail.com
Thu May 28 10:26:28 EDT 2009
I'd be interested to see the benchmark ;)
On Thu, May 28, 2009 at 4:14 PM, Nicolas Rougier
<Nicolas.Rougier at loria.fr> wrote:
>
> Hi,
>
> I'm now testing dot product and using the following:
>
> import numpy as np, scipy.sparse as sp
>
> A = np.matrix(np.zeros((5,10)))
> B = np.zeros((10,1))
> print (A*B).shape
> print np.dot(A,B).shape
>
> A = sp.csr_matrix(np.zeros((5,10)))
> B = sp.csr_matrix((10,1))
> print (A*B).shape
> print np.dot(A,B).shape
>
> A = sp.csr_matrix(np.zeros((5,10)))
> B = np.zeros((10,1))
> print (A*B).shape
> print np.dot(A,B).shape
>
>
> I got:
>
> (5, 1)
> (5, 1)
> (5, 1)
> (5, 1)
> (5, 1)
> (10, 1)
>
>
> Obviously, the last computation is not a dot product, but I got no
> warning at all. Is that the expected behavior ?
>
>
> By the way, I wrote a speed benchmark for dot product using the
> different flavors of sparse matrices and I wonder if it should go
> somewhere in documentation (in anycase, if anyone interested, I can post
> the benchmark program and result).
>
> Nicolas
>
>
>
>
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
More information about the NumPy-Discussion
mailing list