Mercurial > hg > octave-nkf
changeset 5070:1e6f653ef1e3 ss-2-1-61
[project @ 2004-11-06 00:33:38 by jwe]
author | jwe |
---|---|
date | Sat, 06 Nov 2004 00:33:38 +0000 |
parents | b9dae14b5ada |
children | 7b24fd17c263 |
files | src/ChangeLog src/DLD-FUNCTIONS/det.cc |
diffstat | 2 files changed, 20 insertions(+), 36 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -2,6 +2,9 @@ * version.h (OCTAVE_VERSION): Now 2.1.61. + * DLD-FUNCTIONS/det.cc (det): Always compute rcond so we can + detect numerically singular matrices. + 2004-11-04 John W. Eaton <jwe@octave.org> * pt-colon.cc (tree_colon_expression::line,
--- a/src/DLD-FUNCTIONS/det.cc +++ b/src/DLD-FUNCTIONS/det.cc @@ -79,26 +79,16 @@ if (! error_state) { + // Always compute rcond, so we can detect numerically + // singular matrices. + int info; double rcond = 0.0; - - if (nargout > 1) - { - DET det = m.determinant (info, rcond); - retval(1) = rcond; - volatile double xrcond = rcond; - xrcond += 1.0; - retval(0) = ((info == -1 || xrcond == 1.0) - ? 0.0 : det.value ()); - } - else - { - DET det = m.determinant (info); - volatile double xrcond = rcond; - xrcond += 1.0; - retval(0) = ((info == -1 || xrcond == 1.0) - ? 0.0 : det.value ()); - } + DET det = m.determinant (info, rcond); + retval(1) = rcond; + volatile double xrcond = rcond; + xrcond += 1.0; + retval(0) = ((info == -1 || xrcond == 1.0) ? 0.0 : det.value ()); } } else if (arg.is_complex_type ()) @@ -107,26 +97,17 @@ if (! error_state) { + // Always compute rcond, so we can detect numerically + // singular matrices. + int info; double rcond = 0.0; - - if (nargout > 1) - { - ComplexDET det = m.determinant (info, rcond); - retval(1) = rcond; - 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); - volatile double xrcond = rcond; - xrcond += 1.0; - retval(0) = ((info == -1 || xrcond == 1.0) - ? Complex (0.0) : det.value ()); - } + ComplexDET det = m.determinant (info, rcond); + retval(1) = rcond; + volatile double xrcond = rcond; + xrcond += 1.0; + retval(0) = ((info == -1 || xrcond == 1.0) + ? Complex (0.0) : det.value ()); } } else