changeset 32207:b73ebf017461 stable

Avoid false detection of "non-real pivot" in ichol() (bug #63785) * __ichol__.cc (ichol_checkpivot_complex): Use comparison with a tolerance to avoid issuing an error when small round-off errors are present.
author Rik <rik@octave.org>
date Tue, 18 Jul 2023 14:33:15 -0700
parents fe178c793ea0
children d350f3e1faf2 591c39fb7bca
files libinterp/corefcn/__ichol__.cc
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/__ichol__.cc	Tue Jul 18 14:07:32 2023 -0700
+++ b/libinterp/corefcn/__ichol__.cc	Tue Jul 18 14:33:15 2023 -0700
@@ -27,6 +27,8 @@
 #  include "config.h"
 #endif
 
+#include <limits>
+
 #include "oct-locbuf.h"
 #include "oct-norm.h"
 
@@ -57,7 +59,7 @@
 
 bool ichol_checkpivot_complex (Complex pivot)
 {
-  if (pivot.imag () != 0)
+  if (fabs (pivot.imag ()) > std::numeric_limits<double>::epsilon())
     error ("ichol: non-real pivot encountered.  The matrix must be Hermitian.");
   else if (pivot.real () < 0)
     error ("ichol: negative pivot encountered");