Browse Source

Handle INF and NAN

pull/4829/head
Martin Kroeker GitHub 1 year ago
parent
commit
4a226732d8
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
1 changed files with 55 additions and 34 deletions
  1. +55
    -34
      kernel/zarch/sscal.c

+ 55
- 34
kernel/zarch/sscal.c 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) {

BLASLONG n1 = n & -32;
if (n1 > 0) {

sscal_kernel_32_zero(n1, x);
j = n1;
}

while (j < n) {

x[j] = 0.0;
j++;
if (da == 0.0 || !isfinite(da)) {
if (dummy2 == 0) {
BLASLONG n1 = n & -32;
if (n1 > 0) {

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++;
}
}

} 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) {

BLASLONG n1 = n & -2;

while (j < n1) {

x[i] = 0.0;
x[i + inc_x] = 0.0;

i += inc_x * 2;
j += 2;

}
while (j < n) {

x[i] = 0.0;
i += inc_x;
j++;
}

if (da == 0.0 || !isfinite(da)) {
if (dummy2 == 0) {
BLASLONG n1 = n & -2;

while (j < n1) {

x[i] = 0.0;
x[i + inc_x] = 0.0;

i += inc_x * 2;
j += 2;

}
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;



Loading…
Cancel
Save