[SciPy-dev] sparse array indexing.

Viral Shah vshah@interactivesupercomputing....
Mon Apr 14 13:45:15 CDT 2008


Nathan, and others,

A few more questions about the sparse array manipulation. Also, is  
there a sparse document in the works other than the one at http://www.scipy.org/SciPy_Tutorial 
  ? I would be more than happy to put all that I am finding out in a  
document. But if one is in the works, I can edit that instead.

1. I notice that A[I, J] behaves differently than in Matlab. This is  
documented. My question is, if one wants Matlab like behaviour, is  
there a better way to do this than A[I, :], A[:, J] ?

2. Do the sparse data structures support deletion ? I got the svn, and  
it seems that the delete function that works on numpy arrays does not  
work on sparse arrays, yet. Until I figure this out, I am doing  
deletion with:

     def deleterowcol(self, A, delrow, delcol):
         A = A.tocsc()

         m = A.shape[0]
         n = A.shape[1]

         keep = delete (arange(0, m), delrow)
         A = A[keep, :]

         keep = delete (arange(0, m), delcol)
         A = A[:, keep]

         return A

3. How do I get the rows and columns as vectors out of the coo format,  
so that I can do the equivalent of find() in MATLAB ?

4. I forwarded the SuperLU bug to the upstream author, Sherry Li.  
Perhaps she will fix it in the next release. In general,  I believe  
that Sherry does not spend much time maintaining the sequential  
SuperLU, but Tim Davis does support UMFPACK more actively. But UMFPACK  
does not have single precision.. So the solution for the default  
sparse direct solver is not as obvious. I would vote in favour of  
UMFPACK being the default solver for double precision, if its possible  
to put it in the scipy tree.

-viral



More information about the Scipy-dev mailing list