long double __sinhl (long double x) { long double z = __ieee754_sinhl (x); if (__builtin_expect (!__finitel (z), 0) && __finitel (x) && _LIB_VERSION != _IEEE_) return __kernel_standard_l (x, x, 225); /* sinh overflow */ return z; }
__complex__ long double __ctanl (__complex__ long double x) { __complex__ long double res; if (!isfinite (__real__ x) || !isfinite (__imag__ x)) { if (__isinfl (__imag__ x)) { __real__ res = __copysignl (0.0, __real__ x); __imag__ res = __copysignl (1.0, __imag__ x); } else if (__real__ x == 0.0) { res = x; } else { __real__ res = __nanl (""); __imag__ res = __nanl (""); #ifdef FE_INVALID if (__isinfl (__real__ x)) feraiseexcept (FE_INVALID); #endif } } else { long double sin2rx, cos2rx; long double den; __sincosl (2.0 * __real__ x, &sin2rx, &cos2rx); den = cos2rx + __ieee754_coshl (2.0 * __imag__ x); __real__ res = sin2rx / den; __imag__ res = __ieee754_sinhl (2.0 * __imag__ x) / den; } return res; }
__complex__ long double __ccoshl (__complex__ long double x) { __complex__ long double retval; int rcls = fpclassify (__real__ x); int icls = fpclassify (__imag__ x); if (__glibc_likely (rcls >= FP_ZERO)) { /* Real part is finite. */ if (__glibc_likely (icls >= FP_ZERO)) { /* Imaginary part is finite. */ const int t = (int) ((LDBL_MAX_EXP - 1) * M_LN2l); long double sinix, cosix; if (__glibc_likely (fabsl (__imag__ x) > LDBL_MIN)) { __sincosl (__imag__ x, &sinix, &cosix); } else { sinix = __imag__ x; cosix = 1.0; } if (fabsl (__real__ x) > t) { long double exp_t = __ieee754_expl (t); long double rx = fabsl (__real__ x); if (signbit (__real__ x)) sinix = -sinix; rx -= t; sinix *= exp_t / 2.0L; cosix *= exp_t / 2.0L; if (rx > t) { rx -= t; sinix *= exp_t; cosix *= exp_t; } if (rx > t) { /* Overflow (original real part of x > 3t). */ __real__ retval = LDBL_MAX * cosix; __imag__ retval = LDBL_MAX * sinix; } else { long double exp_val = __ieee754_expl (rx); __real__ retval = exp_val * cosix; __imag__ retval = exp_val * sinix; } } else { __real__ retval = __ieee754_coshl (__real__ x) * cosix; __imag__ retval = __ieee754_sinhl (__real__ x) * sinix; } math_check_force_underflow_complex (retval); } else { __imag__ retval = __real__ x == 0.0 ? 0.0 : __nanl (""); __real__ retval = __nanl ("") + __nanl (""); if (icls == FP_INFINITE) feraiseexcept (FE_INVALID); } } else if (rcls == FP_INFINITE) { /* Real part is infinite. */ if (__glibc_likely (icls > FP_ZERO)) { /* Imaginary part is finite. */ long double sinix, cosix; if (__glibc_likely (fabsl (__imag__ x) > LDBL_MIN)) { __sincosl (__imag__ x, &sinix, &cosix); } else { sinix = __imag__ x; cosix = 1.0; } __real__ retval = __copysignl (HUGE_VALL, cosix); __imag__ retval = (__copysignl (HUGE_VALL, sinix) * __copysignl (1.0, __real__ x)); } else if (icls == FP_ZERO) { /* Imaginary part is 0.0. */ __real__ retval = HUGE_VALL; __imag__ retval = __imag__ x * __copysignl (1.0, __real__ x); } else { /* The addition raises the invalid exception. */ __real__ retval = HUGE_VALL; __imag__ retval = __nanl ("") + __nanl (""); if (icls == FP_INFINITE) feraiseexcept (FE_INVALID); } } else { __real__ retval = __nanl (""); __imag__ retval = __imag__ x == 0.0 ? __imag__ x : __nanl (""); } return retval; }
__complex__ long double __ctanl (__complex__ long double x) { __complex__ long double res; if (__builtin_expect (!isfinite (__real__ x) || !isfinite (__imag__ x), 0)) { if (__isinf_nsl (__imag__ x)) { __real__ res = __copysignl (0.0, __real__ x); __imag__ res = __copysignl (1.0, __imag__ x); } else if (__real__ x == 0.0) { res = x; } else { __real__ res = __nanl (""); __imag__ res = __nanl (""); if (__isinf_nsl (__real__ x)) feraiseexcept (FE_INVALID); } } else { long double sinrx, cosrx; long double den; const int t = (int) ((LDBL_MAX_EXP - 1) * M_LN2l / 2); int rcls = fpclassify (__real__ x); /* tan(x+iy) = (sin(2x) + i*sinh(2y))/(cos(2x) + cosh(2y)) = (sin(x)*cos(x) + i*sinh(y)*cosh(y)/(cos(x)^2 + sinh(y)^2). */ if (__builtin_expect (rcls != FP_SUBNORMAL, 1)) { __sincosl (__real__ x, &sinrx, &cosrx); } else { sinrx = __real__ x; cosrx = 1.0; } if (fabsl (__imag__ x) > t) { /* Avoid intermediate overflow when the real part of the result may be subnormal. Ignoring negligible terms, the imaginary part is +/- 1, the real part is sin(x)*cos(x)/sinh(y)^2 = 4*sin(x)*cos(x)/exp(2y). */ long double exp_2t = __ieee754_expl (2 * t); __imag__ res = __copysignl (1.0, __imag__ x); __real__ res = 4 * sinrx * cosrx; __imag__ x = fabsl (__imag__ x); __imag__ x -= t; __real__ res /= exp_2t; if (__imag__ x > t) { /* Underflow (original imaginary part of x has absolute value > 2t). */ __real__ res /= exp_2t; } else __real__ res /= __ieee754_expl (2 * __imag__ x); } else { long double sinhix, coshix; if (fabsl (__imag__ x) > LDBL_MIN) { sinhix = __ieee754_sinhl (__imag__ x); coshix = __ieee754_coshl (__imag__ x); } else { sinhix = __imag__ x; coshix = 1.0L; } if (fabsl (sinhix) > fabsl (cosrx) * LDBL_EPSILON) den = cosrx * cosrx + sinhix * sinhix; else den = cosrx * cosrx; __real__ res = sinrx * cosrx / den; __imag__ res = sinhix * coshix / den; } } return res; }
__complex__ long double __ctanhl (__complex__ long double x) { __complex__ long double res; if (!isfinite (__real__ x) || !isfinite (__imag__ x)) { if (__isinfl (__real__ x)) { __real__ res = __copysignl (1.0L, __real__ x); __imag__ res = __copysignl (0.0L, __imag__ x); } else if (__imag__ x == 0.0) { res = x; } else { __real__ res = __nanl (""); __imag__ res = __nanl (""); #ifdef FE_INVALID if (__isinfl (__imag__ x)) feraiseexcept (FE_INVALID); #endif } } else { long double sinix, cosix; long double den; const int t = (int) ((LDBL_MAX_EXP - 1) * M_LN2l / 2.0L); /* tanh(x+iy) = (sinh(2x) + i*sin(2y))/(cosh(2x) + cos(2y)) = (sinh(x)*cosh(x) + i*sin(y)*cos(y))/(sinh(x)^2 + cos(y)^2). */ __sincosl (__imag__ x, &sinix, &cosix); if (fabsl (__real__ x) > t) { /* Avoid intermediate overflow when the imaginary part of the result may be subnormal. Ignoring negligible terms, the real part is +/- 1, the imaginary part is sin(y)*cos(y)/sinh(x)^2 = 4*sin(y)*cos(y)/exp(2x). */ long double exp_2t = __ieee754_expl (2 * t); __real__ res = __copysignl (1.0L, __real__ x); __imag__ res = 4 * sinix * cosix; __real__ x = fabsl (__real__ x); __real__ x -= t; __imag__ res /= exp_2t; if (__real__ x > t) { /* Underflow (original real part of x has absolute value > 2t). */ __imag__ res /= exp_2t; } else __imag__ res /= __ieee754_expl (2.0L * __real__ x); } else { long double sinhrx, coshrx; if (fabs (__real__ x) > LDBL_MIN) { sinhrx = __ieee754_sinhl (__real__ x); coshrx = __ieee754_coshl (__real__ x); } else { sinhrx = __real__ x; coshrx = 1.0L; } if (fabsl (sinhrx) > fabsl (cosix) * ldbl_eps) den = sinhrx * sinhrx + cosix * cosix; else den = cosix * cosix; __real__ res = sinhrx * (coshrx / den); __imag__ res = sinix * (cosix / den); } /* __gcc_qmul does not respect -0.0 so we need the following fixup. */ if ((__real__ res == 0.0L) && (__real__ x == 0.0L)) __real__ res = __real__ x; if ((__real__ res == 0.0L) && (__imag__ x == 0.0L)) __imag__ res = __imag__ x; } return res; }
__complex__ long double __csinl (__complex__ long double x) { __complex__ long double retval; int negate = signbit (__real__ x); int rcls = fpclassify (__real__ x); int icls = fpclassify (__imag__ x); __real__ x = fabsl (__real__ x); if (__builtin_expect (icls >= FP_ZERO, 1)) { /* Imaginary part is finite. */ if (__builtin_expect (rcls >= FP_ZERO, 1)) { /* Real part is finite. */ const int t = (int) ((LDBL_MAX_EXP - 1) * M_LN2l); long double sinix, cosix; if (__builtin_expect (rcls != FP_SUBNORMAL, 1)) { __sincosl (__real__ x, &sinix, &cosix); } else { sinix = __real__ x; cosix = 1.0; } if (fabsl (__imag__ x) > t) { long double exp_t = __ieee754_expl (t); long double ix = fabsl (__imag__ x); if (signbit (__imag__ x)) cosix = -cosix; ix -= t; sinix *= exp_t / 2.0L; cosix *= exp_t / 2.0L; if (ix > t) { ix -= t; sinix *= exp_t; cosix *= exp_t; } if (ix > t) { /* Overflow (original imaginary part of x > 3t). */ __real__ retval = LDBL_MAX * sinix; __imag__ retval = LDBL_MAX * cosix; } else { long double exp_val = __ieee754_expl (ix); __real__ retval = exp_val * sinix; __imag__ retval = exp_val * cosix; } } else { __real__ retval = __ieee754_coshl (__imag__ x) * sinix; __imag__ retval = __ieee754_sinhl (__imag__ x) * cosix; } if (negate) __real__ retval = -__real__ retval; if (fabsl (__real__ retval) < LDBL_MIN) { volatile long double force_underflow = __real__ retval * __real__ retval; (void) force_underflow; } if (fabsl (__imag__ retval) < LDBL_MIN) { volatile long double force_underflow = __imag__ retval * __imag__ retval; (void) force_underflow; } } else { if (icls == FP_ZERO) { /* Imaginary part is 0.0. */ __real__ retval = __nanl (""); __imag__ retval = __imag__ x; if (rcls == FP_INFINITE) feraiseexcept (FE_INVALID); } else { __real__ retval = __nanl (""); __imag__ retval = __nanl (""); feraiseexcept (FE_INVALID); } } } else if (icls == FP_INFINITE) { /* Imaginary part is infinite. */ if (rcls == FP_ZERO) { /* Real part is 0.0. */ __real__ retval = __copysignl (0.0, negate ? -1.0 : 1.0); __imag__ retval = __imag__ x; } else if (rcls > FP_ZERO) { /* Real part is finite. */ long double sinix, cosix; if (__builtin_expect (rcls != FP_SUBNORMAL, 1)) { __sincosl (__real__ x, &sinix, &cosix); } else { sinix = __real__ x; cosix = 1.0; } __real__ retval = __copysignl (HUGE_VALL, sinix); __imag__ retval = __copysignl (HUGE_VALL, cosix); if (negate) __real__ retval = -__real__ retval; if (signbit (__imag__ x)) __imag__ retval = -__imag__ retval; } else { /* The addition raises the invalid exception. */ __real__ retval = __nanl (""); __imag__ retval = HUGE_VALL; if (rcls == FP_INFINITE) feraiseexcept (FE_INVALID); } } else { if (rcls == FP_ZERO) __real__ retval = __copysignl (0.0, negate ? -1.0 : 1.0); else __real__ retval = __nanl (""); __imag__ retval = __nanl (""); } return retval; }