Skip to content

Commit 4a0f863

Browse files
authored
Merge pull request #4235 from angsch/develop
Fix division by zero in [z]rotg
2 parents 617294b + db3a43c commit 4a0f863

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

interface/rotg.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,8 @@ void CNAME(FLOAT *DA, FLOAT *DB, FLOAT *C, FLOAT *S){
6666
c = da / r;
6767
s = db / r;
6868
z = ONE;
69-
if (da != ZERO) {
70-
if (ada > adb){
71-
z = s;
72-
} else {
73-
z = ONE / c;
74-
}
75-
}
69+
if (ada > adb) z = s;
70+
if ((ada <= adb) && (c != ZERO)) z = ONE / c;
7671

7772
*C = c;
7873
*S = s;

interface/zrotg.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,16 @@ void CNAME(void *VDA, void *VDB, FLOAT *C, void *VS) {
6161
*(S1 + 0) = *(DB + 0);
6262
*(S1 + 1) = *(DB + 1) *-1;
6363
if (da_r == ZERO && da_i == ZERO) {
64-
*C = ZERO;
64+
*C = ZERO;
6565
if (db_r == ZERO) {
6666
(*DA) = fabsl(db_i);
67-
*S = *S1 /da_r;
68-
*(S+1) = *(S1+1) /da_r;
67+
*S = *S1 /(*DA);
68+
*(S+1) = *(S1+1) /(*DA);
6969
return;
7070
} else if ( db_i == ZERO) {
7171
*DA = fabsl(db_r);
72-
*S = *S1 /da_r;
73-
*(S+1) = *(S1+1) /da_r;
72+
*S = *S1 /(*DA);
73+
*(S+1) = *(S1+1) /(*DA);
7474
return;
7575
} else {
7676
long double g1 = MAX( fabsl(db_r), fabsl(db_i));

0 commit comments

Comments
 (0)