diff liboctave/dSparse.cc @ 5610:9761b7d24e9e

[project @ 2006-02-09 09:12:02 by dbateman]
author dbateman
date Thu, 09 Feb 2006 09:12:03 +0000
parents 2857357f9d3c
children 512d0d11ae39
line wrap: on
line diff
--- a/liboctave/dSparse.cc	Thu Feb 09 02:30:00 2006 +0000
+++ b/liboctave/dSparse.cc	Thu Feb 09 09:12:03 2006 +0000
@@ -44,6 +44,7 @@
 #include "oct-sparse.h"
 #include "sparse-util.h"
 #include "SparsedbleCHOL.h"
+#include "SparseQR.h"
 
 #include "oct-sort.h"
 
@@ -697,7 +698,7 @@
 
 SparseMatrix 
 SparseMatrix::dinverse (SparseType &mattyp, octave_idx_type& info, 
-			double& rcond, const bool force, 
+			double& rcond, const bool, 
 			const bool calccond) const
 {
   SparseMatrix retval;
@@ -751,7 +752,7 @@
 
 SparseMatrix 
 SparseMatrix::tinverse (SparseType &mattyp, octave_idx_type& info, 
-			double& rcond, const bool force, 
+			double& rcond, const bool, 
 			const bool calccond) const
 {
   SparseMatrix retval;
@@ -989,7 +990,7 @@
 
 SparseMatrix
 SparseMatrix::inverse (SparseType &mattype, octave_idx_type& info, 
-		       double& rcond, int force, int calc_cond) const
+		       double& rcond, int, int calc_cond) const
 {
   int typ = mattype.type (false);
   SparseMatrix ret;
@@ -5154,7 +5155,6 @@
 				   &Numeric, control, info) ;
       UMFPACK_DNAME (free_symbolic) (&Symbolic) ;
 
-#ifdef HAVE_LSSOLVE
       rcond = Info (UMFPACK_RCOND);
       volatile double rcond_plus_one = rcond + 1.0;
 
@@ -5173,9 +5173,7 @@
 	       rcond);
 
 	}
-      else
-#endif 
-	if (status < 0)
+      else if (status < 0)
 	  {
 	    (*current_liboctave_error_handler) 
 	      ("SparseMatrix::solve numeric factorization failed");
@@ -5337,9 +5335,7 @@
 		      ("SparseMatrix::solve matrix singular to machine precision, rcond = %g",
 		       rcond);
 	      
-#ifdef HAVE_LSSOLVE
 		  return retval;
-#endif
 		}
 
 	      cholmod_dense *X;
@@ -5410,25 +5406,6 @@
 		    }
 		}
 
-#ifndef HAVE_LSSOLVE
-	      rcond = Info (UMFPACK_RCOND);
-	      volatile double rcond_plus_one = rcond + 1.0;
-
-	      if (status == UMFPACK_WARNING_singular_matrix || 
-		  rcond_plus_one == 1.0 || xisnan (rcond))
-		{
-		  err = -2;
-
-		  if (sing_handler)
-		    sing_handler (rcond);
-		  else
-		    (*current_liboctave_error_handler)
-		      ("SparseMatrix::solve matrix singular to machine precision, rcond = %g",
-		       rcond);
-	      
-		}
-#endif
-		
 	      UMFPACK_DNAME (report_info) (control, info);
 		
 	      UMFPACK_DNAME (free_numeric) (&Numeric);
@@ -5589,9 +5566,7 @@
 		      ("SparseMatrix::solve matrix singular to machine precision, rcond = %g",
 		       rcond);
 	      
-#ifdef HAVE_LSSOLVE
 		  return retval;
-#endif
 		}
 
 	      cholmod_sparse *X;
@@ -5699,25 +5674,6 @@
 
 	      retval.maybe_compress ();
 
-#ifndef HAVE_LSSOLVE
-	      rcond = Info (UMFPACK_RCOND);
-	      volatile double rcond_plus_one = rcond + 1.0;
-
-	      if (status == UMFPACK_WARNING_singular_matrix || 
-		  rcond_plus_one == 1.0 || xisnan (rcond))
-		{
-		  err = -2;
-	      
-		  if (sing_handler)
-		    sing_handler (rcond);
-		  else
-		    (*current_liboctave_error_handler)
-		      ("SparseMatrix::solve matrix singular to machine precision, rcond = %g",
-		       rcond);
-
-		}
-#endif
-
 	      UMFPACK_DNAME (report_info) (control, info);
 
 	      UMFPACK_DNAME (free_numeric) (&Numeric);
@@ -5868,9 +5824,7 @@
 		      ("SparseMatrix::solve matrix singular to machine precision, rcond = %g",
 		       rcond);
 	      
-#ifdef HAVE_LSSOLVE
 		  return retval;
-#endif
 		}
 
 	      cholmod_dense *X;
@@ -5960,25 +5914,6 @@
 		    retval (i, j) = Complex (Xx[i], Xz[i]);
 		}
 
-#ifndef HAVE_LSSOLVE
-	      rcond = Info (UMFPACK_RCOND);
-	      volatile double rcond_plus_one = rcond + 1.0;
-
-	      if (status == UMFPACK_WARNING_singular_matrix || 
-		  rcond_plus_one == 1.0 || xisnan (rcond))
-		{
-		  err = -2;
-
-		  if (sing_handler)
-		    sing_handler (rcond);
-		  else
-		    (*current_liboctave_error_handler)
-		      ("SparseMatrix::solve matrix singular to machine precision, rcond = %g",
-		       rcond);
-
-		}
-#endif
-
 	      UMFPACK_DNAME (report_info) (control, info);
 
 	      UMFPACK_DNAME (free_numeric) (&Numeric);
@@ -6140,9 +6075,7 @@
 		      ("SparseMatrix::solve matrix singular to machine precision, rcond = %g",
 		       rcond);
 	      
-#ifdef HAVE_LSSOLVE
 		  return retval;
-#endif
 		}
 
 	      cholmod_sparse *X;
@@ -6261,25 +6194,6 @@
 
 	      retval.maybe_compress ();
 
-#ifndef HAVE_LSSOLVE
-	      rcond = Info (UMFPACK_RCOND);
-	      volatile double rcond_plus_one = rcond + 1.0;
-
-	      if (status == UMFPACK_WARNING_singular_matrix || 
-		  rcond_plus_one == 1.0 || xisnan (rcond))
-		{
-		  err = -2;
-
-		  if (sing_handler)
-		    sing_handler (rcond);
-		  else
-		    (*current_liboctave_error_handler)
-		      ("SparseMatrix::solve matrix singular to machine precision, rcond = %g",
-		       rcond);
-
-		}
-#endif
-
 	      UMFPACK_DNAME (report_info) (control, info);
 
 	      UMFPACK_DNAME (free_numeric) (&Numeric);
@@ -6761,12 +6675,9 @@
 }
 
 Matrix
-SparseMatrix::lssolve (const Matrix& b, octave_idx_type& info, octave_idx_type& rank) const
-{
-  info = -1;
-  (*current_liboctave_error_handler) 
-    ("SparseMatrix::lssolve not implemented yet");
-  return Matrix ();
+SparseMatrix::lssolve (const Matrix& b, octave_idx_type& info, octave_idx_type&) const
+{
+  return qrsolve (*this, b, info);
 }
 
 SparseMatrix
@@ -6785,12 +6696,9 @@
 }
 
 SparseMatrix
-SparseMatrix::lssolve (const SparseMatrix& b, octave_idx_type& info, octave_idx_type& rank) const
-{
-  info = -1;
-  (*current_liboctave_error_handler) 
-    ("SparseMatrix::lssolve not implemented yet");
-  return SparseMatrix ();
+SparseMatrix::lssolve (const SparseMatrix& b, octave_idx_type& info, octave_idx_type&) const
+{
+  return qrsolve (*this, b, info);
 }
 
 ComplexMatrix
@@ -6809,12 +6717,9 @@
 }
 
 ComplexMatrix
-SparseMatrix::lssolve (const ComplexMatrix& b, octave_idx_type& info, octave_idx_type& rank) const
-{
-  info = -1;
-  (*current_liboctave_error_handler) 
-    ("SparseMatrix::lssolve not implemented yet");
-  return ComplexMatrix ();
+SparseMatrix::lssolve (const ComplexMatrix& b, octave_idx_type& info, octave_idx_type&) const
+{
+  return qrsolve (*this, b, info);
 }
 
 SparseComplexMatrix
@@ -6834,12 +6739,9 @@
 
 SparseComplexMatrix
 SparseMatrix::lssolve (const SparseComplexMatrix& b, octave_idx_type& info, 
-		       octave_idx_type& rank) const
-{
-  info = -1;
-  (*current_liboctave_error_handler) 
-    ("SparseMatrix::lssolve not implemented yet");
-  return SparseComplexMatrix ();
+		       octave_idx_type&) const
+{
+  return qrsolve (*this, b, info);
 }
 
 ColumnVector