[Scipy-svn] r2499 - in trunk/Lib: linsolve/umfpack sparse

scipy-svn at scipy.org scipy-svn at scipy.org
Sat Jan 6 02:56:27 EST 2007


Author: wnbell
Date: 2007-01-06 01:56:20 -0600 (Sat, 06 Jan 2007)
New Revision: 2499

Modified:
   trunk/Lib/linsolve/umfpack/umfpack.py
   trunk/Lib/sparse/sparse.py
Log:
added ensure_sorted_indices() to csr_matrix and csc_matrix
updated umfpack to sort indices



Modified: trunk/Lib/linsolve/umfpack/umfpack.py
===================================================================
--- trunk/Lib/linsolve/umfpack/umfpack.py	2007-01-06 07:39:53 UTC (rev 2498)
+++ trunk/Lib/linsolve/umfpack/umfpack.py	2007-01-06 07:56:20 UTC (rev 2499)
@@ -337,6 +337,9 @@
         sparsity pattern."""
         self.free_symbolic()
 
+        #row/column indices cannot be assumed to be sorted
+        mtx.ensure_sorted_indices(inplace=True)
+
         indx = self._getIndx( mtx )
         if self.isReal:
             status, self._symbolic\
@@ -370,6 +373,9 @@
 
         self.free_numeric()
 
+        #row/column indices cannot be assumed to be sorted
+        mtx.ensure_sorted_indices(inplace=True)
+
         if self._symbolic is None:
             self.symbolic( mtx )
 

Modified: trunk/Lib/sparse/sparse.py
===================================================================
--- trunk/Lib/sparse/sparse.py	2007-01-06 07:39:53 UTC (rev 2498)
+++ trunk/Lib/sparse/sparse.py	2007-01-06 07:56:20 UTC (rev 2499)
@@ -971,6 +971,17 @@
         self.nzmax = nnz
         self._check()
 
+    def ensure_sorted_indices(self,inplace=False):
+        """Return a copy of this matrix where the row indices are sorted
+        """
+        if inplace:
+            temp = self.tocsr().tocsc()
+            self.rowind = temp.rowind
+            self.indptr = temp.indptr
+            self.data   = temp.data
+        else:
+            return self.tocsr().tocsc()
+
     def copy(self):
         new = csc_matrix(self.shape, nzmax=self.nzmax, dtype=self.dtype)
         new.data = self.data.copy()
@@ -1463,6 +1474,18 @@
         self.nzmax = nnz
         self._check()
 
+    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()
+
+
     def copy(self):
         new = csr_matrix(self.shape, nzmax=self.nzmax, dtype=self.dtype)
         new.data = self.data.copy()




More information about the Scipy-svn mailing list