[SciPy-user] scipy.sparse and dot product

Stefan van der Walt stefan@sun.ac...
Thu Jul 19 05:33:46 CDT 2007


On Thu, Jul 19, 2007 at 09:34:14AM +0200, lorenzo bolla wrote:
> does this seem weird to you, too?
>  
> -----------------------------------------------------------------
>  
> In [34]: A = scipy.sparse.spdiags([[1,2,3]],0,3,3)
> 
> In [35]: x = scipy.array([1,2,3])
> 
> In [36]: scipy.dot(A,x)
> Out[36]:
> array([  (0, 0) 1.0
>   (1, 1)        2.0
>   (2, 2)        3.0,
>          (0, 0) 2.0
>   (1, 1)        4.0
>   (2, 2)        6.0,
>          (0, 0) 3.0
>   (1, 1)        6.0
>   (2, 2)        9.0], dtype=object) # <--- a matrix with repeated
> entries???

The numpy 'dot'-function does not know about sparse matrices.  You
might want to try

A.dot(x) or A*x

I don't think the elementwise-product has been implemented yet.

Regards
Stéfan


More information about the SciPy-user mailing list