changeset 31431:84e8f0bf83f7

assert.m: Avoid out-of-memory errors for sparse matrices (bug #63277) * assert.m: Avoid use of "! isfinite" for sparse matrices.
author Rik <rik@octave.org>
date Tue, 15 Nov 2022 09:36:55 -0800
parents 21b5e1c4d36e
children df8bdaf1164b
files scripts/testfun/assert.m
diffstat 1 files changed, 17 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/testfun/assert.m	Tue Nov 15 09:13:42 2022 -0800
+++ b/scripts/testfun/assert.m	Tue Nov 15 09:36:55 2022 -0800
@@ -347,8 +347,14 @@
               A_null_real = real (A);
               B_null_real = real (B);
             endif
-            exclude = errseen ...
-                      | ! isfinite (A_null_real) & ! isfinite (B_null_real);
+            if (issparse (errseen))
+              exclude = errseen ...
+                        | isnan (A_null_real) | isinf (A_null_real) ...
+                        | isnan (B_null_real) | isinf (B_null_real);
+            else
+              exclude = errseen ...
+                        | ! isfinite (A_null_real) & ! isfinite (B_null_real);
+            endif
             A_null_real(exclude) = 0;
             B_null_real(exclude) = 0;
 
@@ -358,8 +364,15 @@
             else
               A_null_imag = imag (A);
               B_null_imag = imag (B);
-              exclude = errseen ...
-                        | ! isfinite (A_null_imag) & ! isfinite (B_null_imag);
+              if (issparse (errseen))
+                exclude = errseen ...
+                          | isnan (A_null_imag) | isinf (A_null_imag) ...
+                          | isnan (B_null_imag) | isinf (B_null_imag);
+              else
+                exclude = errseen ...
+                          | ! isfinite (A_null_imag) & ! isfinite (B_null_imag);
+              endif
+
               A_null_imag(exclude) = 0;
               B_null_imag(exclude) = 0;
               A_null = complex (A_null_real, A_null_imag);