octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #63384] Error for "inv(NaN)" with LAPACK 3.11.


From: Markus Mützel
Subject: [Octave-bug-tracker] [bug #63384] Error for "inv(NaN)" with LAPACK 3.11.0
Date: Mon, 21 Nov 2022 10:16:43 -0500 (EST)

Follow-up Comment #25, bug #63384 (project octave):

Does the following change help?

diff -r 288a917d728e liboctave/array/dMatrix.cc
--- a/liboctave/array/dMatrix.cc        Sun Nov 20 15:29:28 2022 +0100
+++ b/liboctave/array/dMatrix.cc        Mon Nov 21 15:48:48 2022 +0100
@@ -28,6 +28,7 @@
 #endif
 
 #include <algorithm>
+#include <cmath>
 #include <istream>
 #include <limits>
 #include <ostream>
@@ -596,19 +597,24 @@
     info = -1;
   else if (calc_cond)
     {
-      F77_INT dgecon_info = 0;
-
-      // Now calculate the condition number for non-singular matrix.
-      char job = '1';
-      Array<F77_INT> iz (dim_vector (nc, 1));
-      F77_INT *piz = iz.fortran_vec ();
-      F77_XFCN (dgecon, DGECON, (F77_CONST_CHAR_ARG2 (&job, 1),
-                                 nc, tmp_data, nr, anorm,
-                                 rcon, pz, piz, dgecon_info
-                                 F77_CHAR_ARG_LEN (1)));
-
-      if (dgecon_info != 0)
-        info = -1;
+      if (std::isnan (anorm))
+        rcon = std::nan ("0");
+      else
+        {
+          F77_INT dgecon_info = 0;
+
+          // Now calculate the condition number for non-singular matrix.
+          char job = '1';
+          Array<F77_INT> iz (dim_vector (nc, 1));
+          F77_INT *piz = iz.fortran_vec ();
+          F77_XFCN (dgecon, DGECON, (F77_CONST_CHAR_ARG2 (&job, 1),
+                                     nc, tmp_data, nr, anorm,
+                                     rcon, pz, piz, dgecon_info
+                                     F77_CHAR_ARG_LEN (1)));
+
+          if (dgecon_info != 0)
+            info = -1;
+        }
     }
 
   if (info == -1 && ! force)




    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?63384>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]