From 7f8f037a36c05d3d8cf0ffc74db2202e64b95a22 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Sat, 22 Jun 2024 16:03:30 +0200 Subject: [PATCH] handle INF and NAN in input --- kernel/power/sscal.c | 57 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 13 deletions(-) diff --git a/kernel/power/sscal.c b/kernel/power/sscal.c index 65572a8c1f..12246b0a38 100644 --- a/kernel/power/sscal.c +++ b/kernel/power/sscal.c @@ -74,14 +74,38 @@ static void sscal_kernel_16_zero( BLASLONG n, FLOAT *x ) for( i=0; i> 2) & 0x7; for (j = 0; j < align; j++) { - x[j] = 0.0; + if (isfinite(x[j])) + x[j] = 0.0; + else + x[j] = NAN; } } BLASLONG n1 = (n-j) & -32; @@ -129,8 +156,10 @@ int CNAME(BLASLONG n, BLASLONG dummy0, BLASLONG dummy1, FLOAT da, FLOAT *x, BLAS while(j < n) { - - x[j]=0.0; + if (isfinite(x[j])) + x[j]=0.0; + else + x[j]=NAN; j++; } @@ -178,8 +207,10 @@ int CNAME(BLASLONG n, BLASLONG dummy0, BLASLONG dummy1, FLOAT da, FLOAT *x, BLAS while(j < n) { - - x[i]=0.0; + if (isfinite(x[i])) + x[i]=0.0; + else + x[i]=NAN; i += inc_x ; j++; }