1999-09-18 10:51:31 +00:00
|
|
|
#undef abs
|
|
|
|
#include <math.h>
|
2003-07-11 03:42:19 +00:00
|
|
|
double
|
|
|
|
f__cabs (double real, double imag)
|
1999-09-18 10:51:31 +00:00
|
|
|
{
|
2003-07-11 03:42:19 +00:00
|
|
|
double temp;
|
1999-09-18 10:51:31 +00:00
|
|
|
|
2003-07-11 03:42:19 +00: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);
|
1999-09-18 10:51:31 +00:00
|
|
|
|
2003-07-11 03:42:19 +00:00
|
|
|
temp = imag / real;
|
|
|
|
temp = real * sqrt (1.0 + temp * temp); /*overflow!! */
|
|
|
|
return (temp);
|
1999-09-18 10:51:31 +00:00
|
|
|
}
|