[SciPy-dev] sparsetools - new and (hopefully) improved!

Robert Cimrman cimrman3 at ntc.zcu.cz
Mon Jan 8 09:23:52 CST 2007

Nathan Bell wrote:
> 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.

OK, will check it ASAP (read: tomorrow :)).

> 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).

Well, I have some code related to sorting the sparse matrix indices
already in my feutils module (in C), so all I have to do is to implement
it into your templated C++ code, so that it works for all possible
matrix data dtypes.


More information about the Scipy-dev mailing list