Mercurial > hg > octave-nkf
changeset 5064:a6755bc45f15
[project @ 2004-11-04 16:34:57 by jwe]
author | jwe |
---|---|
date | Thu, 04 Nov 2004 16:34:57 +0000 |
parents | 1c4a00f4bfb9 |
children | 1312d3af9eb0 |
files | src/ChangeLog src/DLD-FUNCTIONS/det.cc src/DLD-FUNCTIONS/inv.cc |
diffstat | 3 files changed, 26 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,8 +1,10 @@ 2004-11-04 John W. Eaton <jwe@octave.org> - * DLD-FUNCTIONS/inv.cc (Finv): Declare rcond volatile and check value. + * DLD-FUNCTIONS/inv.cc (Finv): Check rcond value returned from + LAPACK routines, and be careful to avoid optimizing away the + 1+rcond == 1.0 check. * DLD-FUNCTIONS/det.cc (Fdet): Likewise. - + 2004-11-03 John W. Eaton <jwe@octave.org> * data.cc (Fsize): Return 1 if requested dimension is larger than
--- a/src/DLD-FUNCTIONS/det.cc +++ b/src/DLD-FUNCTIONS/det.cc @@ -80,20 +80,23 @@ if (! error_state) { int info; - volatile double rcond = 0.0; - + double rcond = 0.0; if (nargout > 1) { DET det = m.determinant (info, rcond); retval(1) = rcond; - retval(0) = ((info == -1 || 1.0 + rcond == 1.0) + volatile double xrcond = rcond; + xrcond += 1.0; + retval(0) = ((info == -1 || xrcond == 1.0) ? 0.0 : det.value ()); } else { DET det = m.determinant (info); - retval(0) = ((info == -1 || 1.0 + rcond == 1.0) + volatile double xrcond = rcond; + xrcond += 1.0; + retval(0) = ((info == -1 || xrcond == 1.0) ? 0.0 : det.value ()); } } @@ -105,19 +108,23 @@ if (! error_state) { int info; - volatile double rcond = 0.0; + double rcond = 0.0; if (nargout > 1) { ComplexDET det = m.determinant (info, rcond); retval(1) = rcond; - retval(0) = ((info == -1 || 1.0 + rcond == 1.0) + volatile double xrcond = rcond; + xrcond += 1.0; + retval(0) = ((info == -1 || xrcond == 1.0) ? Complex (0.0) : det.value ()); } else { ComplexDET det = m.determinant (info); - retval(0) = ((info == -1 | 1.0 + rcond == 1.0) + volatile double xrcond = rcond; + xrcond += 1.0; + retval(0) = ((info == -1 || xrcond == 1.0) ? Complex (0.0) : det.value ()); } }
--- a/src/DLD-FUNCTIONS/inv.cc +++ b/src/DLD-FUNCTIONS/inv.cc @@ -74,7 +74,7 @@ if (! error_state) { int info; - volatile double rcond = 0.0; + double rcond = 0.0; Matrix result = m.inverse (info, rcond, 1); @@ -83,7 +83,9 @@ retval(0) = result; - if (nargout < 2 && (info == -1 || 1.0 + rcond == 1.0)) + volatile double xrcond = rcond; + xrcond += 1.0; + if (nargout < 2 && (info == -1 || xrcond == 1.0)) warning ("inverse: matrix singular to machine precision,\ rcond = %g", rcond); } @@ -95,7 +97,7 @@ if (! error_state) { int info; - volatile double rcond = 0.0; + double rcond = 0.0; ComplexMatrix result = m.inverse (info, rcond, 1); @@ -104,7 +106,9 @@ retval(0) = result; - if (nargout < 2 && (info == -1 || 1.0 + rcond == 1.0)) + volatile double xrcond = rcond; + xrcond += 1.0; + if (nargout < 2 && (info == -1 || xrcond == 1.0)) warning ("inverse: matrix singular to machine precision,\ rcond = %g", rcond); }