[SciPy-User] Working with sparse matrices

coolhead.pranay at gmail.com coolhead.pranay at gmail.com
Mon Apr 4 22:38:00 EDT 2011


Hi,

I am working with huge sparse matrices(20K * 20K) using the scipy.sparse
package. In each iteration of the algorithm I need to compute matrix product
of this matrix with itself, store the result in the same matrix and then
raise the value of each non zero entry in the matrix by a constant number.

What would be the ideal format of the sparse matrix that I need to use in
this scenario. I am currently using coo_matrix to construct the sparse
matrix and then converted it to "csr" format for working in the loop. But I
am getting ScipyEfficiencyWarning.

#Function is something like this

def algo(inpfile):
  mat = read_sparse_from_file(inpfile) #inpfile contains the actual
matrix..reads line by line and returns a csc_matrix
  for i in range(10):
       mat = mat.dot(mat)
       mat =  my_exponent(mat,exp) #my_exponent is a function that computes
raises each element to "exp" and does some other stuff...returns csc matrix

Thanks,
Pranay Anchuri
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20110404/a2ff1f40/attachment.html>


More information about the SciPy-User mailing list