Skip to content

Commit 6876ae0

Browse files
committed
Fix division by zero in zrotg
The cases [ c s ] * [ 0 ] = [ |db_i| ] [-s c ] [ i*db_i ] [ 0 ] and [ c s ] * [ 0 ] = [ |db_r| ] [-s c ] [ db_r ] [ 0 ] computed s incorrectly. To flip the entries of vector, s should be conjg(db)/|db| and not conjg(db) / da, where da == 0.0.
1 parent bb2f1ec commit 6876ae0

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

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)