1998-02-01 09:37:08 +08:00
|
|
|
#undef abs
|
|
|
|
#include <math.h>
|
2002-06-01 20:38:32 +08:00
|
|
|
double
|
|
|
|
f__cabs (double real, double imag)
|
1998-02-01 09:37:08 +08:00
|
|
|
{
|
2002-06-01 20:38:32 +08:00
|
|
|
double temp;
|
1998-02-01 09:37:08 +08:00
|
|
|
|
2002-06-01 20:38:32 +08:00
|
|
|
if (real < 0)
|
|
|
|
real = -real;
|
|
|
|
if (imag < 0)
|
|
|
|
imag = -imag;
|
|
|
|
if (imag > real)
|
|
|
|
{
|
|
|
|
temp = real;
|
|
|
|
real = imag;
|
|
|
|
imag = temp;
|
|
|
|
}
|
|
|
|
if ((real + imag) == real)
|
|
|
|
return (real);
|
1998-02-01 09:37:08 +08:00
|
|
|
|
2002-06-01 20:38:32 +08:00
|
|
|
temp = imag / real;
|
|
|
|
temp = real * sqrt (1.0 + temp * temp); /*overflow!! */
|
|
|
|
return (temp);
|
1998-02-01 09:37:08 +08:00
|
|
|
}
|