[SciPy-user] scipy.sparse and dot product

lorenzo bolla lbolla at gmail.com
Thu Jul 19 03:34:14 EDT 2007


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???
In [37]: scipy.dot(A.todense(),x)
Out[37]: matrix([[ 1.,  4.,  9.]]) # <--- ok

In [38]: A*x
Out[38]: array([ 1.,  4.,  9.]) # <--- ok

In [39]: A.todense()*x
Out[39]: matrix([[ 1.,  4.,  9.]]) <--- ok
 -----------------------------------------------------------------

L.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20070719/fdbf63df/attachment.html>


More information about the SciPy-User mailing list