[Numpy-discussion] sparse matrix dot product

Sebastian Walter sebastian.walter@gmail....
Thu May 28 09:26:28 CDT 2009


I'd be interested to see the benchmark ;)



On Thu, May 28, 2009 at 4:14 PM, Nicolas Rougier
<Nicolas.Rougier@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@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>


More information about the Numpy-discussion mailing list