There are a lot of 'abs' functions - cabs(), labs(), etc.
The generally accepted dogma is that you should use a macro for functions like sgn(), abs(), etc because they are faster - a lot faster.
Kinda like this:
You can also force 'inlining' by using macros -Code:#define abs(c) ( (c<0) ? (-1)*c : c )
This does a complex reciprocal for instance.
arg & out are type Complex (a struct)
Code:#define LCMPLXrecip(arg,out) \ { long denom; denom = lsqr((arg).x) + lsqr((arg).y);\ if(denom==0L) overflow=1; else {(out).x = divide((arg).x,denom,bitshift);\ (out).y = -divide((arg).y,denom,bitshift);}}




Reply With Quote