[SciPy-dev] sparsetools - new and (hopefully) improved!
Nathan Bell
wnbell at gmail.com
Sat Jan 6 03:29:12 EST 2007
On 1/5/07, Robert Cimrman <cimrman3 at ntc.zcu.cz> wrote:
> Here by 'conversion' you mean CSR->CSC->CSR and ensure_sorted_indices()
> will be based on that? If yes, and assuming that a temporary copy is
> made (am I right?) what about ensure_sorted_indices() working inplace
> (just (quick,arg)sorting row by row)?
> I would like both
> mtx2 = mtx.ensure_sorted_indices()
> mtx.ensure_sorted_indices( inplace = True ) (returning None?)
I wrote an implementation of ensure_sorted_indices() with an inplace
option and updated umfpack.py accordingly (please double check this).
For csr_matrix I have:
def ensure_sorted_indices(self,inplace=False):
"""Return a copy of this matrix where the column indices are sorted
"""
if inplace:
temp = self.tocsc().tocsr()
self.colind = temp.colind
self.indptr = temp.indptr
self.data = temp.data
else:
return self.tocsc().tocsr()
Of course this does not actually perform an inplace sort :) However
it is sufficient to make your umfpack.py work as expected.
Give this implementation a try and let me know if it's still too slow.
If it is, then we can think about how to perform a true inplace sort.
I suspect argsorting row by row will be significantly slower than
this method (due to the python overhead).
--
Nathan Bell wnbell at gmail.com
More information about the SciPy-Dev
mailing list