| 1 |
#ifdef KR_headers |
| 2 |
extern double sqrt(); |
| 3 |
double f__cabs(real, imag) double real, imag; |
| 4 |
#else |
| 5 |
#undef abs |
| 6 |
#include "math.h" |
| 7 |
#ifdef __cplusplus |
| 8 |
extern "C" { |
| 9 |
#endif |
| 10 |
double f__cabs(double real, double imag) |
| 11 |
#endif |
| 12 |
{ |
| 13 |
double temp; |
| 14 |
|
| 15 |
if(real < 0) |
| 16 |
real = -real; |
| 17 |
if(imag < 0) |
| 18 |
imag = -imag; |
| 19 |
if(imag > real){ |
| 20 |
temp = real; |
| 21 |
real = imag; |
| 22 |
imag = temp; |
| 23 |
} |
| 24 |
if((real+imag) == real) |
| 25 |
return(real); |
| 26 |
|
| 27 |
temp = imag/real; |
| 28 |
temp = real*sqrt(1.0 + temp*temp); /*overflow!!*/ |
| 29 |
return(temp); |
| 30 |
} |
| 31 |
#ifdef __cplusplus |
| 32 |
} |
| 33 |
#endif |