Changeset View
Changeset View
Standalone View
Standalone View
lib/msun/src/s_ctanh.c
Show First 20 Lines • Show All 105 Lines • ▼ Show 20 Lines | if (ix >= 0x7ff00000) { | ||||
if ((ix & 0xfffff) | lx) /* x is NaN */ | if ((ix & 0xfffff) | lx) /* x is NaN */ | ||||
return (CMPLX(nan_mix(x, y), | return (CMPLX(nan_mix(x, y), | ||||
y == 0 ? y : nan_mix(x, y))); | y == 0 ? y : nan_mix(x, y))); | ||||
SET_HIGH_WORD(x, hx - 0x40000000); /* x = copysign(1, x) */ | SET_HIGH_WORD(x, hx - 0x40000000); /* x = copysign(1, x) */ | ||||
return (CMPLX(x, copysign(0, isinf(y) ? y : sin(y) * cos(y)))); | return (CMPLX(x, copysign(0, isinf(y) ? y : sin(y) * cos(y)))); | ||||
} | } | ||||
/* | /* | ||||
* ctanh(x + I NaN) = d(NaN) + I d(NaN) | * ctanh(+-0 + i NAN) = +-0 + i NaN | ||||
* ctanh(x +- I Inf) = dNaN + I dNaN | * ctanh(+-0 +- i Inf) = +-0 + i NaN | ||||
* ctanh(x + i NAN) = NaN + i NaN | |||||
* ctanh(x +- i Inf) = NaN + i NaN | |||||
*/ | */ | ||||
if (!isfinite(y)) | if (!isfinite(y)) | ||||
return (CMPLX(y - y, y - y)); | return (CMPLX(x ? y - y : x, y - y)); | ||||
/* | /* | ||||
* ctanh(+-huge +- I y) ~= +-1 +- I 2sin(2y)/exp(2x), using the | * ctanh(+-huge +- I y) ~= +-1 +- I 2sin(2y)/exp(2x), using the | ||||
* approximation sinh^2(huge) ~= exp(2*huge) / 4. | * approximation sinh^2(huge) ~= exp(2*huge) / 4. | ||||
* We use a modified formula to avoid spurious overflow. | * We use a modified formula to avoid spurious overflow. | ||||
*/ | */ | ||||
if (ix >= 0x40360000) { /* |x| >= 22 */ | if (ix >= 0x40360000) { /* |x| >= 22 */ | ||||
double exp_mx = exp(-fabs(x)); | double exp_mx = exp(-fabs(x)); | ||||
Show All 21 Lines |