[Scipy-svn] r2606 - in trunk/Lib/linsolve: . umfpack/tests

scipy-svn at scipy.org scipy-svn at scipy.org
Wed Jan 24 07:53:26 CST 2007


Author: rc
Date: 2007-01-24 07:53:11 -0600 (Wed, 24 Jan 2007)
New Revision: 2606

Modified:
   trunk/Lib/linsolve/linsolve.py
   trunk/Lib/linsolve/umfpack/tests/test_umfpack.py
Log:
sparse rhs in spsolve

Modified: trunk/Lib/linsolve/linsolve.py
===================================================================
--- trunk/Lib/linsolve/linsolve.py	2007-01-24 11:34:56 UTC (rev 2605)
+++ trunk/Lib/linsolve/linsolve.py	2007-01-24 13:53:11 UTC (rev 2606)
@@ -54,6 +54,9 @@
     return mat
 
 def spsolve(A, b, permc_spec=2):
+    if isspmatrix( b ):
+        b = b.toarray()
+
     if b.ndim > 1:
         if max( b.shape ) == b.size:
             b = b.squeeze()

Modified: trunk/Lib/linsolve/umfpack/tests/test_umfpack.py
===================================================================
--- trunk/Lib/linsolve/umfpack/tests/test_umfpack.py	2007-01-24 11:34:56 UTC (rev 2605)
+++ trunk/Lib/linsolve/umfpack/tests/test_umfpack.py	2007-01-24 13:53:11 UTC (rev 2606)
@@ -63,6 +63,15 @@
         #print "Error: ", a*x-b
         assert_array_almost_equal(a*x, b)
 
+    def check_solve_sparse_rhs(self):
+        """Solve with UMFPACK: double precision, sparse rhs"""
+        linsolve.use_solver( useUmfpack = True )
+        a = self.a.astype('d')
+        b = csc_matrix( self.b )
+        x = linsolve.spsolve(a, b)
+        #print x
+        #print "Error: ", a*x-b
+        assert_array_almost_equal(a*x, self.b)
 
     def setUp(self):
         self.a = spdiags([[1, 2, 3, 4, 5], [6, 5, 8, 9, 10]], [0, 1], 5, 5)



More information about the Scipy-svn mailing list