[SciPy-user] Left hand sparse matrix multiplication

Nathan Bell wnbell@gmail....
Wed Oct 8 14:28:05 CDT 2008

On Wed, Oct 8, 2008 at 11:41 AM, James Philbin <philbinj@gmail.com> wrote:
> I'm trying to compute x*A where x is a dense row vector and A is a
> sparse CSC matrix. A.rmatvec seems to do what I want but is wasteful
> as it computes:
> self.transpose().matvec( other )
> i.e. it computes A^T * x^T.
> It seems there should be a much more efficient overload for csc's
> rmatvec which doesn't involve computing the transpose. I hope i'm
> understanding things correctly.

CSR.T and CSC.T are constant time operations, they just return the
matrix in the "opposite" format.

In your case, A.T is equivalent to
shape=(A.shape[1],A.shape[0])), which simply reinterprets the CSC
format of A as the CSR format of A.T.

This does not hold for other sparse formats so there *is* some room
for improvement.

Nathan Bell wnbell@gmail.com

More information about the SciPy-user mailing list