/* wrapper powl */ long double __powl (long double x, long double y) { long double z = __ieee754_powl (x, y); if (__builtin_expect (!__finitel (z), 0)) { if (_LIB_VERSION != _IEEE_) { if (__isnanl (x)) { if (y == 0.0L) /* pow(NaN,0.0) */ return __kernel_standard_l (x, y, 242); } else if (__finitel (x) && __finitel (y)) { if (__isnanl (z)) /* pow neg**non-int */ return __kernel_standard_l (x, y, 224); else if (x == 0.0L && y < 0.0L) { if (signbit (x) && signbit (z)) /* pow(-0.0,negative) */ return __kernel_standard_l (x, y, 223); else /* pow(+0.0,negative) */ return __kernel_standard_l (x, y, 243); } else /* pow overflow */ return __kernel_standard_l (x, y, 221); } } } else if (__builtin_expect (z == 0.0L, 0) && __finitel (x) && __finitel (y) && _LIB_VERSION != _IEEE_) { if (x == 0.0L) { if (y == 0.0L) /* pow(0.0,0.0) */ return __kernel_standard_l (x, y, 220); } else /* pow underflow */ return __kernel_standard_l (x, y, 222); } return z; }
/* wrapper powl */ long double __powl (long double x, long double y) { long double z = __ieee754_powl (x, y); if (__glibc_unlikely (!isfinite (z))) { if (_LIB_VERSION != _IEEE_) { if (isfinite (x) && isfinite (y)) { if (isnan (z)) /* pow neg**non-int */ return __kernel_standard_l (x, y, 224); else if (x == 0.0L && y < 0.0L) { if (signbit (x) && signbit (z)) /* pow(-0.0,negative) */ return __kernel_standard_l (x, y, 223); else /* pow(+0.0,negative) */ return __kernel_standard_l (x, y, 243); } else /* pow overflow */ return __kernel_standard_l (x, y, 221); } } } else if (__builtin_expect (z == 0.0L, 0) && isfinite (x) && x != 0 && isfinite (y) && _LIB_VERSION != _IEEE_) /* pow underflow */ return __kernel_standard_l (x, y, 222); return z; }
static long double gammal_positive (long double x, int *exp2_adj) { int local_signgam; if (x < 0.5L) { *exp2_adj = 0; return __ieee754_expl (__ieee754_lgammal_r (x + 1, &local_signgam)) / x; } else if (x <= 1.5L) { *exp2_adj = 0; return __ieee754_expl (__ieee754_lgammal_r (x, &local_signgam)); } else if (x < 12.5L) { /* Adjust into the range for using exp (lgamma). */ *exp2_adj = 0; long double n = __ceill (x - 1.5L); long double x_adj = x - n; long double eps; long double prod = __gamma_productl (x_adj, 0, n, &eps); return (__ieee754_expl (__ieee754_lgammal_r (x_adj, &local_signgam)) * prod * (1.0L + eps)); } else { long double eps = 0; long double x_eps = 0; long double x_adj = x; long double prod = 1; if (x < 24.0L) { /* Adjust into the range for applying Stirling's approximation. */ long double n = __ceill (24.0L - x); x_adj = x + n; x_eps = (x - (x_adj - n)); prod = __gamma_productl (x_adj - n, x_eps, n, &eps); } /* The result is now gamma (X_ADJ + X_EPS) / (PROD * (1 + EPS)). Compute gamma (X_ADJ + X_EPS) using Stirling's approximation, starting by computing pow (X_ADJ, X_ADJ) with a power of 2 factored out. */ long double exp_adj = -eps; long double x_adj_int = __roundl (x_adj); long double x_adj_frac = x_adj - x_adj_int; int x_adj_log2; long double x_adj_mant = __frexpl (x_adj, &x_adj_log2); if (x_adj_mant < M_SQRT1_2l) { x_adj_log2--; x_adj_mant *= 2.0L; } *exp2_adj = x_adj_log2 * (int) x_adj_int; long double ret = (__ieee754_powl (x_adj_mant, x_adj) * __ieee754_exp2l (x_adj_log2 * x_adj_frac) * __ieee754_expl (-x_adj) * __ieee754_sqrtl (2 * M_PIl / x_adj) / prod); exp_adj += x_eps * __ieee754_logl (x_adj); long double bsum = gamma_coeff[NCOEFF - 1]; long double x_adj2 = x_adj * x_adj; for (size_t i = 1; i <= NCOEFF - 1; i++) bsum = bsum / x_adj2 + gamma_coeff[NCOEFF - 1 - i]; exp_adj += bsum / x_adj; return ret + ret * __expm1l (exp_adj); } }