Sparse Matrix Multiplications

dingo_1980 at yahoo.com dingo_1980 at yahoo.com
Mon May 12 20:53:51 EDT 2008


I was trying to create a sparse matrix using scipy.sparse (100000 X
100000) with just the first row and first column filled with ones.
Lets call this matrix Asp. This is how I created Asp

from scipy import sparse
Asp = scipy.lil_matrix(100000,100000)
for i in range(100000):
   Asp[i,0] = i
   Asp[0,i] = i
Bsp = (Asp.tocsr())*(Asp.tocsr())

This multiplication to get Bsp is taking a long time (to the order of
over an hour). Is there some other way of storing such huge sparse
matrices and doing their multiplications or is this the most optimal
way?



More information about the Python-list mailing list