You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
494 B
C
34 lines
494 B
C
#ifdef KR_headers
|
|
extern double sqrt();
|
|
double f__cabs(real, imag) double real, imag;
|
|
#else
|
|
#undef abs
|
|
#include "math.h"
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
double f__cabs(double real, double imag)
|
|
#endif
|
|
{
|
|
double temp;
|
|
|
|
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);
|
|
|
|
temp = imag/real;
|
|
temp = real*sqrt(1.0 + temp*temp); /*overflow!!*/
|
|
return(temp);
|
|
}
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|