changeset 6840:2f17d5556756

[project @ 2007-08-29 08:37:47 by dbateman]
author dbateman
date Wed, 29 Aug 2007 08:37:48 +0000
parents 40ad39648884
children 9cee629fe20c
files liboctave/CMatrix.cc liboctave/CSparse.cc liboctave/ChangeLog liboctave/dMatrix.cc liboctave/dSparse.cc
diffstat 5 files changed, 22 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/CMatrix.cc	Tue Aug 28 15:28:13 2007 +0000
+++ b/liboctave/CMatrix.cc	Wed Aug 29 08:37:48 2007 +0000
@@ -1182,7 +1182,7 @@
 
   if (typ == MatrixType::Upper || typ == MatrixType::Lower)
     ret = tinverse (mattype, info, rcond, force, calc_cond);
-  else if (typ != MatrixType::Rectangular)
+  else
     {
       if (mattype.is_hermitian ())
 	{
@@ -1201,6 +1201,9 @@
 
       if (!mattype.is_hermitian ())
 	ret = finverse(mattype, info, rcond, force, calc_cond);
+
+      if (rcond == 0.)
+	ret = ComplexMatrix (rows (), columns (), Complex (octave_Inf, 0.));
     }
 
   return ret;
--- a/liboctave/CSparse.cc	Tue Aug 28 15:28:13 2007 +0000
+++ b/liboctave/CSparse.cc	Wed Aug 29 08:37:48 2007 +0000
@@ -1012,7 +1012,7 @@
       MatrixType newtype = mattype.transpose();
       ret = transpose().tinverse (newtype, info, rcond, true, calc_cond);
     }
-  else if (typ != MatrixType::Rectangular)
+  else
     {
       if (mattype.is_hermitian())
 	{
@@ -1053,8 +1053,6 @@
 	  ret = fact.Pc().transpose() * InvU * InvL * fact.Pr();
 	}
     }
-  else
-    (*current_liboctave_error_handler) ("inverse requires square matrix");
 
   return ret;
 }
--- a/liboctave/ChangeLog	Tue Aug 28 15:28:13 2007 +0000
+++ b/liboctave/ChangeLog	Wed Aug 29 08:37:48 2007 +0000
@@ -1,3 +1,15 @@
+2007-08-29  David Bateman  <dbateman@free.fr>
+
+        * dSparse.cc (SparseMatrix SparseMatrix::inverse (MatrixType &, 
+        octave_idx_type&, double&, int, int)): Calculate with LU even for
+        matrices marked as singular.
+        * CSparse.cc (SparseComplexMatrix SparseComplexMatrix::inverse (
+        MatrixType &, octave_idx_type&, double&, int, int)): ditto.
+        * dMatrix.cc (Matrix Matrix::inverse (MatrixType &, octave_idx_type&,
+        double&, int, int)): ditto. If rcond==0 force matrix of infinities.
+        * dMatrix.cc (ComplexMatrix ComplexMatrix::inverse (MatrixType &,
+         octave_idx_type&, double&, int, int)): ditto.
+
 2007-08-27  John W. Eaton  <jwe@octave.org>
 
 	* oct-env.cc (octave_env::rooted_relative_pathname,
--- a/liboctave/dMatrix.cc	Tue Aug 28 15:28:13 2007 +0000
+++ b/liboctave/dMatrix.cc	Wed Aug 29 08:37:48 2007 +0000
@@ -851,7 +851,7 @@
 
   if (typ == MatrixType::Upper || typ == MatrixType::Lower)
     ret = tinverse (mattype, info, rcond, force, calc_cond);
-  else if (typ != MatrixType::Rectangular)
+  else
     {
       if (mattype.is_hermitian ())
 	{
@@ -870,6 +870,9 @@
 
       if (!mattype.is_hermitian ())
 	ret = finverse(mattype, info, rcond, force, calc_cond);
+
+      if (rcond == 0.)
+	ret = Matrix (rows (), columns (), octave_Inf);
     }
 
   return ret;
--- a/liboctave/dSparse.cc	Tue Aug 28 15:28:13 2007 +0000
+++ b/liboctave/dSparse.cc	Wed Aug 29 08:37:48 2007 +0000
@@ -1086,7 +1086,7 @@
       MatrixType newtype = mattype.transpose();
       ret = transpose().tinverse (newtype, info, rcond, true, calc_cond);
     }
-  else if (typ != MatrixType::Rectangular)
+  else
     {
       if (mattype.is_hermitian())
 	{
@@ -1127,8 +1127,6 @@
 	  ret = fact.Pc().transpose() * InvU * InvL * fact.Pr();
 	}
     }
-  else
-    (*current_liboctave_error_handler) ("inverse requires square matrix");
 
   return ret;
 }