Skip to content

Commit 5925178

Browse files
authored
Merge pull request #3924 from martin-frbg/numpy22025
Avoid overflow from division in GETF2 potentially causing NaN
2 parents f580802 + 3d27cbd commit 5925178

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

lapack/getf2/getf2_k.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ blasint CNAME(blas_arg_t *args, BLASLONG *range_m, BLASLONG *range_n, FLOAT *sa,
9999
jp--;
100100
temp1 = *(b + jp);
101101

102-
if (temp1 != ZERO) {
102+
//if (temp1 != ZERO) {
103+
if (fabs(temp1) > 1.e-305) {
103104
temp1 = dp1 / temp1;
104105

105106
if (jp != j) {

lapack/getf2/zgetf2_k.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,9 @@ blasint CNAME(blas_arg_t *args, BLASLONG *range_m, BLASLONG *range_n, FLOAT *sa,
105105
temp1 = *(b + jp * 2 + 0);
106106
temp2 = *(b + jp * 2 + 1);
107107

108-
if ((temp1 != ZERO) || (temp2 != ZERO)) {
109-
108+
// if ((temp1 != ZERO) || (temp2 != ZERO)) {
109+
if ((fabs(temp1) > 1.e-305) || (fabs(temp2) > 1.e-305)) {
110+
110111
if (jp != j) {
111112
SWAP_K(j + 1, 0, 0, ZERO, ZERO, a + j * 2, lda,
112113
a + jp * 2, lda, NULL, 0);

0 commit comments

Comments
 (0)