# How to use the basic Sparse matrix operations (multiplication, .etc) in PyCUDA

I try to use sparse matrix operations in GPU in Python and now try to use PyCUDA with theano. But I can't find how to do sparse matrix and vector multiplication. I only got an example showing how to solve $A\cdot x=b$ using CG from the library document. Is there any document or example detailing how to do some basic sparse matrix operations?

By the way, is there another python library that can do sparse matrix operations in GPU?

• Yes, but CG is built on (sparse) matrix-vector multiplication. The relevant lines are 30-31, where the sparse matvec operator spmv is defined for a matrix $A$ given in scipy.sparse.crs format. If you look at the cg source (line 123), you see that $b=Ax$ is then computed via b=spmv(x). – Christian Clason May 23 '15 at 15:17
• It would be good to put that into the answer since it's definitely not easy to spot in the code (and in fact spmv is never explicitly invoked in that source file, only passed to CG). – cfh May 23 '15 at 22:05