[SciPy-user] Sparse matrix operations
Nils Wagner
nwagner at mecha.uni-stuttgart.de
Fri Nov 5 03:30:15 CST 2004
Travis Oliphant wrote:
> Nils Wagner wrote:
>
>> Hi all,
>>
>> How can I compute the Rayleigh quotient
>>
>> R = x' A x/(x' B x),
>>
>> where A and B are sparse matrices.
>>
>> How do I compute the matrix vector product of a sparse matrix with a
>> vector ?
>> Can I use dot(A,x) ?
>
>
> No, This won't work.
>
> dot(x,A*x ) should work
>
> -Travis
>
Now, assume that x is a rectangular (dense) matrix and A is a sparse matrix
ared = dot(transpose(x0),ma*x0)
File "/usr/lib/python2.3/site-packages/scipy/sparse/Sparse.py", line
179, in __mul__
res = csc * other
File "/usr/lib/python2.3/site-packages/scipy/sparse/Sparse.py", line
403, in __mul__
return self.matvec(other)
File "/usr/lib/python2.3/site-packages/scipy/sparse/Sparse.py", line
492, in matvec
raise ValueError, "Dimension mismatch"
ValueError: Dimension mismatch
>>> shape(x0)
(715, 10)
>>> shape(transpose(x0))
(10, 715)
>>> shape(ma)
(715, 715)
Any suggestion ?
Nils
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.net
> http://www.scipy.net/mailman/listinfo/scipy-user
More information about the SciPy-user
mailing list