Skip to content

Commit 6c43123

Browse files
authoredMar 29, 2023
Split test condition in LU computation - non-denormal for computation, exact zero for reporting singularity
1 parent 23f2c4c commit 6c43123

File tree

2 files changed

+40
-31
lines changed

2 files changed

+40
-31
lines changed
 

‎lapack/getf2/getf2_k.c

+14-9
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,21 @@ blasint CNAME(blas_arg_t *args, BLASLONG *range_m, BLASLONG *range_n, FLOAT *sa,
100100
jp--;
101101
temp1 = *(b + jp);
102102

103-
//if (temp1 != ZERO) {
103+
if (temp1 != ZERO) {
104+
#if defined(DOUBLE)
104105
if (fabs(temp1) >= DBL_MIN ) {
105-
temp1 = dp1 / temp1;
106-
107-
if (jp != j) {
108-
SWAP_K(j + 1, 0, 0, ZERO, a + j, lda, a + jp, lda, NULL, 0);
109-
}
110-
if (j + 1 < m) {
111-
SCAL_K(m - j - 1, 0, 0, temp1, b + j + 1, 1, NULL, 0, NULL, 0);
112-
}
106+
#else
107+
if (fabs(temp1) >= FLT_MIN ) {
108+
#endif
109+
temp1 = dp1 / temp1;
110+
111+
if (jp != j) {
112+
SWAP_K(j + 1, 0, 0, ZERO, a + j, lda, a + jp, lda, NULL, 0);
113+
}
114+
if (j + 1 < m) {
115+
SCAL_K(m - j - 1, 0, 0, temp1, b + j + 1, 1, NULL, 0, NULL, 0);
116+
}
117+
}
113118
} else {
114119
if (!info) info = j + 1;
115120
}

‎lapack/getf2/zgetf2_k.c

+26-22
Original file line numberDiff line numberDiff line change
@@ -106,30 +106,34 @@ blasint CNAME(blas_arg_t *args, BLASLONG *range_m, BLASLONG *range_n, FLOAT *sa,
106106
temp1 = *(b + jp * 2 + 0);
107107
temp2 = *(b + jp * 2 + 1);
108108

109-
// if ((temp1 != ZERO) || (temp2 != ZERO)) {
109+
if ((temp1 != ZERO) || (temp2 != ZERO)) {
110+
#if defined(DOUBLE)
110111
if ((fabs(temp1) >= DBL_MIN) || (fabs(temp2) >= DBL_MIN)) {
111-
112-
if (jp != j) {
113-
SWAP_K(j + 1, 0, 0, ZERO, ZERO, a + j * 2, lda,
112+
#else
113+
if ((fabs(temp1) >= FLT_MIN) || (fabs(temp2) >= FLT_MIN)) {
114+
#endif
115+
if (jp != j) {
116+
SWAP_K(j + 1, 0, 0, ZERO, ZERO, a + j * 2, lda,
114117
a + jp * 2, lda, NULL, 0);
115-
}
116-
117-
if (fabs(temp1) >= fabs(temp2)){
118-
ratio = temp2 / temp1;
119-
den = dp1 /(temp1 * ( 1 + ratio * ratio));
120-
temp3 = den;
121-
temp4 = -ratio * den;
122-
} else {
123-
ratio = temp1 / temp2;
124-
den = dp1 /(temp2 * ( 1 + ratio * ratio));
125-
temp3 = ratio * den;
126-
temp4 = -den;
127-
}
128-
129-
if (j + 1 < m) {
130-
SCAL_K(m - j - 1, 0, 0, temp3, temp4,
131-
b + (j + 1) * 2, 1, NULL, 0, NULL, 0);
132-
}
118+
}
119+
120+
if (fabs(temp1) >= fabs(temp2)){
121+
ratio = temp2 / temp1;
122+
den = dp1 /(temp1 * ( 1 + ratio * ratio));
123+
temp3 = den;
124+
temp4 = -ratio * den;
125+
} else {
126+
ratio = temp1 / temp2;
127+
den = dp1 /(temp2 * ( 1 + ratio * ratio));
128+
temp3 = ratio * den;
129+
temp4 = -den;
130+
}
131+
132+
if (j + 1 < m) {
133+
SCAL_K(m - j - 1, 0, 0, temp3, temp4,
134+
b + (j + 1) * 2, 1, NULL, 0, NULL, 0);
135+
}
136+
}
133137
} else {
134138
if (!info) info = j + 1;
135139
}

0 commit comments

Comments
 (0)
Please sign in to comment.