Skip to content

Commit

Permalink
Handle NAN and INF
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-frbg authored Jan 12, 2024
1 parent d1ead06 commit b57627c
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions kernel/zarch/zscal.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,15 @@ int CNAME(BLASLONG n, BLASLONG dummy0, BLASLONG dummy1, FLOAT da_r, FLOAT da_i,

while (j < n1) {

temp0 = -da_i * x[i + 1];
if (isnan(x[i]) || isinf(x[i]))
temp0 = NAN;
else
temp0 = -da_i * x[i + 1];
x[i + 1] = da_i * x[i];
x[i] = temp0;
if (isnan(x[i + inc_x]) || isinf(x[i + inc_x]))
temp1 = NAN;
else
temp1 = -da_i * x[i + 1 + inc_x];
x[i + 1 + inc_x] = da_i * x[i + inc_x];
x[i + inc_x] = temp1;
Expand All @@ -246,7 +252,10 @@ int CNAME(BLASLONG n, BLASLONG dummy0, BLASLONG dummy1, FLOAT da_r, FLOAT da_i,

while (j < n) {

temp0 = -da_i * x[i + 1];
if (isnan(x[i]) || isinf(x[i]))
temp0 = NAN;
else
temp0 = -da_i * x[i + 1];
x[i + 1] = da_i * x[i];
x[i] = temp0;
i += inc_x;
Expand Down Expand Up @@ -347,7 +356,10 @@ int CNAME(BLASLONG n, BLASLONG dummy0, BLASLONG dummy1, FLOAT da_r, FLOAT da_i,

while (j < n) {

temp0 = -da_i * x[i + 1];
if (isnan(x[i]) || isinf(x[i]))
temp0 = NAN;
else
temp0 = -da_i * x[i + 1];
x[i + 1] = da_i * x[i];
x[i] = temp0;
i += 2;
Expand Down

0 comments on commit b57627c

Please sign in to comment.