Mercurial > hg > octave-lyh
diff liboctave/dMatrix.cc @ 15382:197774b411ec stable
rcond: use new copy of data for full factorization if positive definite cholesky factorization fails (bug #37336)
* dMatrix.cc (Matrix::rcond): Don't reuse modified matrix data if
positive definite cholesky factorization was attempted but fails.
* CMatrix.cc (ComplexMatrix::rcond): Likewise.
* fMatrix.cc (FloatMatrix::rcond): Likewise.
* fCMatrix.cc (FloatComplexMatrix::rcond): Likewise.
* rcond.cc: New tests.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 13 Sep 2012 15:14:47 -0400 |
parents | 72c96de7a403 |
children |
line wrap: on
line diff
--- a/liboctave/dMatrix.cc +++ b/liboctave/dMatrix.cc @@ -1454,13 +1454,15 @@ else if (typ == MatrixType::Full || typ == MatrixType::Hermitian) { double anorm = -1.0; - Matrix atmp = *this; - double *tmp_data = atmp.fortran_vec (); if (typ == MatrixType::Hermitian) { octave_idx_type info = 0; char job = 'L'; + + Matrix atmp = *this; + double *tmp_data = atmp.fortran_vec (); + anorm = atmp.abs().sum(). row(static_cast<octave_idx_type>(0)).max(); @@ -1495,6 +1497,9 @@ { octave_idx_type info = 0; + Matrix atmp = *this; + double *tmp_data = atmp.fortran_vec (); + Array<octave_idx_type> ipvt (dim_vector (nr, 1)); octave_idx_type *pipvt = ipvt.fortran_vec (); @@ -1760,8 +1765,10 @@ { info = 0; char job = 'L'; + Matrix atmp = *this; double *tmp_data = atmp.fortran_vec (); + anorm = atmp.abs().sum().row(static_cast<octave_idx_type>(0)).max(); F77_XFCN (dpotrf, DPOTRF, (F77_CONST_CHAR_ARG2 (&job, 1), nr, @@ -1838,6 +1845,7 @@ Matrix atmp = *this; double *tmp_data = atmp.fortran_vec (); + if(anorm < 0.) anorm = atmp.abs().sum().row(static_cast<octave_idx_type>(0)).max();