Mercurial > octave
changeset 31505:ec973756cb3a stable
inv: Don't call LAPACK function *gecon if matrix contains NaN values (bug #63384).
* liboctave/array/CMatrix.cc (ComplexMatrix::finverse),
liboctave/array/fCMatrix.cc (ComplexMatrix::finverse): Dont' call LAPACK
function for calculation of condition number if matrix contains NaN values.
Corresponding to the changes in 55f0173e4f08.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Tue, 22 Nov 2022 20:37:59 +0100 |
parents | e7b51b5b33f8 |
children | fb123529131b 71f9f7210b7c |
files | liboctave/array/CMatrix.cc liboctave/array/fCMatrix.cc |
diffstat | 2 files changed, 36 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/array/CMatrix.cc Mon Nov 21 09:25:29 2022 -0800 +++ b/liboctave/array/CMatrix.cc Tue Nov 22 20:37:59 2022 +0100 @@ -890,19 +890,24 @@ info = -1; else if (calc_cond) { - F77_INT zgecon_info = 0; - - // Now calculate the condition number for non-singular matrix. - char job = '1'; - Array<double> rz (dim_vector (2 * nc, 1)); - double *prz = rz.fortran_vec (); - F77_XFCN (zgecon, ZGECON, (F77_CONST_CHAR_ARG2 (&job, 1), - nc, F77_DBLE_CMPLX_ARG (tmp_data), nr, anorm, - rcon, F77_DBLE_CMPLX_ARG (pz), prz, zgecon_info - F77_CHAR_ARG_LEN (1))); - - if (zgecon_info != 0) - info = -1; + if (octave::math::isnan (anorm)) + rcon = octave::numeric_limits<double>::NaN (); + else + { + F77_INT zgecon_info = 0; + + // Now calculate the condition number for non-singular matrix. + char job = '1'; + Array<double> rz (dim_vector (2 * nc, 1)); + double *prz = rz.fortran_vec (); + F77_XFCN (zgecon, ZGECON, (F77_CONST_CHAR_ARG2 (&job, 1), + nc, F77_DBLE_CMPLX_ARG (tmp_data), nr, + anorm, rcon, F77_DBLE_CMPLX_ARG (pz), prz, + zgecon_info F77_CHAR_ARG_LEN (1))); + + if (zgecon_info != 0) + info = -1; + } } if ((info == -1 && ! force)
--- a/liboctave/array/fCMatrix.cc Mon Nov 21 09:25:29 2022 -0800 +++ b/liboctave/array/fCMatrix.cc Tue Nov 22 20:37:59 2022 +0100 @@ -893,19 +893,24 @@ info = -1; else if (calc_cond) { - F77_INT cgecon_info = 0; - - // Now calculate the condition number for non-singular matrix. - char job = '1'; - Array<float> rz (dim_vector (2 * nc, 1)); - float *prz = rz.fortran_vec (); - F77_XFCN (cgecon, CGECON, (F77_CONST_CHAR_ARG2 (&job, 1), - nc, F77_CMPLX_ARG (tmp_data), nr, anorm, - rcon, F77_CMPLX_ARG (pz), prz, cgecon_info - F77_CHAR_ARG_LEN (1))); - - if (cgecon_info != 0) - info = -1; + if (octave::math::isnan (anorm)) + rcon = octave::numeric_limits<float>::NaN (); + else + { + F77_INT cgecon_info = 0; + + // Now calculate the condition number for non-singular matrix. + char job = '1'; + Array<float> rz (dim_vector (2 * nc, 1)); + float *prz = rz.fortran_vec (); + F77_XFCN (cgecon, CGECON, (F77_CONST_CHAR_ARG2 (&job, 1), + nc, F77_CMPLX_ARG (tmp_data), nr, anorm, + rcon, F77_CMPLX_ARG (pz), prz, cgecon_info + F77_CHAR_ARG_LEN (1))); + + if (cgecon_info != 0) + info = -1; + } } if ((info == -1 && ! force)