[SciPy-user] sparse matrix multiplication

Andrew Swan andrew.swan at swiftdsl.com.au
Wed Mar 2 04:20:57 CST 2005


Hi - I am wondering if there is a problem with the following code:

from scipy_base import *
from scipy.sparse import csc_matrix, dok_matrix
x = dok_matrix()
x[0,0] = 2
x[1,1] = 1
x[2,1] = 1
y = csc_matrix(x)
yt = y.transp()
yy = yt * y
print yy.todense()

The print statement gives:

[[ 4.  0.]
 [ 2.  0.]]

When the answer I was expecting was:

array([[4, 0],
       [0, 2]])

Thanks in advance...
---- Msg sent via - People Telecom Webmail



More information about the SciPy-user mailing list