diff --git a/liboctave/array/CMatrix.cc b/liboctave/array/CMatrix.cc index 397467f..51ec826 100644 --- a/liboctave/array/CMatrix.cc +++ b/liboctave/array/CMatrix.cc @@ -1135,7 +1135,7 @@ ComplexMatrix::finverse (MatrixType &mattype, octave_idx_type& info, anorm = retval.abs ().sum ().row (static_cast(0)).max (); // Work around bug #45577, LAPACK crashes Octave if norm is NaN - if (xisnan (anorm)) + if (xisnan (anorm) || xisinf (anorm)) info = -1; else F77_XFCN (zgetrf, ZGETRF, (nc, nc, tmp_data, nr, pipvt, info)); @@ -1160,7 +1160,7 @@ ComplexMatrix::finverse (MatrixType &mattype, octave_idx_type& info, info = -1; } - if (info == -1 && ! force) + if ((info == -1 && ! force) || xisinf (anorm)) retval = *this; // Restore contents. else { @@ -2238,7 +2238,7 @@ ComplexMatrix::fsolve (MatrixType &mattype, const ComplexMatrix& b, .max (); // Work around bug #45577, LAPACK crashes Octave if norm is NaN - if (xisnan (anorm)) + if (xisnan (anorm) || xisinf (anorm)) info = -2; else F77_XFCN (zgetrf, ZGETRF, (nr, nr, tmp_data, nr, pipvt, info)); @@ -2301,6 +2301,11 @@ ComplexMatrix::fsolve (MatrixType &mattype, const ComplexMatrix& b, mattype.mark_as_rectangular (); } } + if (xisinf (anorm)) + { + retval = ComplexMatrix (b.rows (), b.cols (), Complex (0, 0)); + mattype.mark_as_full (); + } } return retval;