void _CDTOCD(d_complex_t *ret_val, d_complex_t x, d_complex_t y) { _f_real16 __atan2l(_f_real16 ax, _f_real16 bx); _f_real16 __cosl(_f_real16 ax); _f_real16 __expl(_f_real16 ax); _f_real16 __logl(_f_real16 ax); _f_real16 __sinl(_f_real16 ax); _f_real16 __sqrtl(_f_real16 ax); _f_real16 a; _f_real16 b; _f_real16 c; _f_real16 d; _f_real16 one; _f_real16 two; REGISTER_16 realx; REGISTER_16 imagx; _f_real16 loglabsx, atn2l, expltwo; if (x.real == 0.0 && x.imag == 0.0) { if (y.real == 0.0 && y.imag == 0.0) { ret_val->real = _DBL_NaN; ret_val->imag = _DBL_NaN; } else { ret_val->real = (_f_real16) 0.0; ret_val->imag = (_f_real16) 0.0; } return; } realx.f = x.real; imagx.f = x.imag; a = x.real; b = x.imag; c = y.real; d = y.imag; /* clear sign bit */ realx.ui[0] &= ~IEEE_128_64_SIGN_BIT; imagx.ui[0] &= ~IEEE_128_64_SIGN_BIT; atn2l = __atan2l(b,a); if (realx.f > imagx.f) loglabsx = __logl(realx.f * __sqrtl(1.0 + (imagx.f/realx.f) * (imagx.f/realx.f))); else loglabsx = __logl(imagx.f * __sqrtl(1.0 + (realx.f/imagx.f) * (realx.f/imagx.f))); one = d * loglabsx + c * atn2l; two = c * loglabsx - d * atn2l; expltwo = __expl(two); ret_val->real = expltwo * __cosl(one); ret_val->imag = expltwo * __sinl(one); }
_f_real16 _CDABS(d_complex_t z) { _f_real16 __sqrtl(_f_real16 x); _f_real16 __fabsl(_f_real16 x); _f_real16 real = __fabsl(z.real); _f_real16 imag = __fabsl(z.imag); _f_real16 ret_val; if (real == 0.0 && imag == 0.0) return((_f_real16) 0.0); if (real > imag) ret_val = real * __sqrtl((_f_real16) 1.0 + (imag/real) * (imag/real)); else ret_val = imag * __sqrtl((_f_real16) 1.0 + (real/imag) * (real/imag)); return (ret_val); }
long double __ieee754_acoshl(long double x) { long double t; u_int64_t lx; int64_t hx; GET_LDOUBLE_WORDS64(hx,lx,x); if(hx<0x3fff000000000000LL) { /* x < 1 */ return (x-x)/(x-x); } else if(hx >=0x4035000000000000LL) { /* x > 2**54 */ if(hx >=0x7fff000000000000LL) { /* x is inf of NaN */ return x+x; } else return __ieee754_logl(x)+ln2; /* acoshl(huge)=logl(2x) */ } else if(((hx-0x3fff000000000000LL)|lx)==0) { return 0.0L; /* acosh(1) = 0 */ } else if (hx > 0x4000000000000000LL) { /* 2**28 > x > 2 */ t=x*x; return __ieee754_logl(2.0L*x-one/(x+__ieee754_sqrtl(t-one))); } else { /* 1<x<2 */ t = x-one; return __log1pl(t+__sqrtl(2.0L*t+t*t)); } }
_f_real16 _DSQRT_( _f_real16 *x ) { _f_real16 __sqrtl(_f_real16 y); return ((_f_real16) __sqrtl((_f_real16) *x)); }