Handle INF and NAN

This commit is contained in:
Martin Kroeker 2024-07-31 14:27:04 +02:00 committed by GitHub
parent 37e3c5ff9d
commit 4a226732d8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 48 additions and 27 deletions

View File

@ -95,21 +95,31 @@ int CNAME(BLASLONG n, BLASLONG dummy0, BLASLONG dummy1, FLOAT da, FLOAT *x,
if (inc_x == 1) {
if (da == 0.0) {
if (da == 0.0 || !isfinite(da)) {
if (dummy2 == 0) {
BLASLONG n1 = n & -32;
if (n1 > 0) {
BLASLONG n1 = n & -32;
if (n1 > 0) {
sscal_kernel_32_zero(n1, x);
j = n1;
}
sscal_kernel_32_zero(n1, x);
j = n1;
while (j < n) {
x[j] = 0.0;
j++;
}
} else {
float res = 0.0;
if (!isfinite(da)) res = NAN;
while (j < n) {
if (isfinite(x[i]))
x[j] = res;
else
x[j] = NAN;
j++;
}
}
while (j < n) {
x[j] = 0.0;
j++;
}
} else {
BLASLONG n1 = n & -32;
@ -126,26 +136,37 @@ int CNAME(BLASLONG n, BLASLONG dummy0, BLASLONG dummy1, FLOAT da, FLOAT *x,
} else {
if (da == 0.0) {
if (da == 0.0 || !isfinite(da)) {
if (dummy2 == 0) {
BLASLONG n1 = n & -2;
BLASLONG n1 = n & -2;
while (j < n1) {
while (j < n1) {
x[i] = 0.0;
x[i + inc_x] = 0.0;
x[i] = 0.0;
x[i + inc_x] = 0.0;
i += inc_x * 2;
j += 2;
i += inc_x * 2;
j += 2;
}
while (j < n) {
x[i] = 0.0;
i += inc_x;
j++;
}
}
while (j < n) {
x[i] = 0.0;
i += inc_x;
j++;
}
} else {
while (j < n) {
float res = 0.0;
if (!isfinite(da)) res = NAN;
if (isfinite(x[i]))
x[i] = res;
else
x[i] = NAN;
i += inc_x;
j++;
}
}
} else {
BLASLONG n1 = n & -2;