Commit | Line | Data |
---|---|---|
23ec3622 | 1 | /* |
41ef90cb | 2 | * @(#)zabs.c 5.2 %G% |
23ec3622 KM |
3 | */ |
4 | ||
41ef90cb | 5 | #ifdef tahoe |
23ec3622 KM |
6 | /* THIS IS BASED ON TAHOE FP REPRESENTATION */ |
7 | #include <tahoemath/FP.h> | |
8 | ||
9 | double zabs(real, imag) | |
10 | double real, imag; | |
11 | { | |
12 | double temp, sqrt(); | |
13 | ||
14 | if(real < 0) | |
15 | *(long int *)&real ^= SIGN_BIT; | |
16 | if(imag < 0) | |
17 | *(long int *)&imag ^= SIGN_BIT; | |
18 | if(imag > real){ | |
19 | temp = real; | |
20 | real = imag; | |
21 | imag = temp; | |
22 | } | |
23 | if(imag == 0.) /* if((real+imag) == real) */ | |
24 | return(real); | |
25 | ||
26 | temp = imag/real; | |
27 | temp = real*sqrt(1.0 + temp*temp); /*overflow!!*/ | |
28 | return(temp); | |
29 | } | |
41ef90cb | 30 | #endif tahoe |