void test_small(void) { static const double tests[] = { /* csqrt(a + bI) = x + yI */ /* a b x y */ 1.0, M_PI_4, M_SQRT2 * 0.5 * M_E, M_SQRT2 * 0.5 * M_E, -1.0, M_PI_4, M_SQRT2 * 0.5 / M_E, M_SQRT2 * 0.5 / M_E, 2.0, M_PI_2, 0.0, M_E * M_E, M_LN2, M_PI, -2.0, 0.0, }; double a, b; double x, y; int i; for (i = 0; i < N(tests); i += 4) { a = tests[i]; b = tests[i + 1]; x = tests[i + 2]; y = tests[i + 3]; test_tol(cexp, cpackl(a, b), cpackl(x, y), 3 * DBL_ULP()); /* float doesn't have enough precision to pass these tests */ if (x == 0 || y == 0) continue; test_tol(cexpf, cpackl(a, b), cpackl(x, y), 1 * FLT_ULP()); } }
/* Tests for 0 */ void test_zero(void) { /* cexp(0) = 1, no exceptions raised */ testall(0.0, 1.0, ALL_STD_EXCEPT, 0, 1); testall(-0.0, 1.0, ALL_STD_EXCEPT, 0, 1); testall(cpackl(0.0, -0.0), cpackl(1.0, -0.0), ALL_STD_EXCEPT, 0, 1); testall(cpackl(-0.0, -0.0), cpackl(1.0, -0.0), ALL_STD_EXCEPT, 0, 1); }
// FIXME long double complex casinl(long double complex z) { long double complex w; long double x, y; x = creall(z); y = cimagl(z); w = cpackl(1.0 - (x - y)*(x + y), -2.0*x*y); return clogl(cpackl(-y, x) + csqrtl(w)); }
/* Tests for 0 */ void test_zero(void) { long double complex zero = cpackl(0.0, 0.0); /* csinh(0) = ctanh(0) = 0; ccosh(0) = 1 (no exceptions raised) */ testall_odd(csinh, zero, zero, ALL_STD_EXCEPT, 0, CS_BOTH); testall_odd(csin, zero, zero, ALL_STD_EXCEPT, 0, CS_BOTH); testall_even(ccosh, zero, 1.0, ALL_STD_EXCEPT, 0, CS_BOTH); testall_even(ccos, zero, cpackl(1.0, -0.0), ALL_STD_EXCEPT, 0, CS_BOTH); testall_odd(ctanh, zero, zero, ALL_STD_EXCEPT, 0, CS_BOTH); testall_odd(ctan, zero, zero, ALL_STD_EXCEPT, 0, CS_BOTH); }
long double complex cprojl(long double complex z) { if (!isinf(creall(z)) && !isinf(cimagl(z))) return (z); else return (cpackl(INFINITY, copysignl(0.0, cimagl(z)))); }
void test_imaginaries(void) { int i; for (i = 0; i < N(finites); i++) { test(cexp, cpackl(0.0, finites[i]), cpackl(cos(finites[i]), sin(finites[i])), ALL_STD_EXCEPT & ~FE_INEXACT, 0, 1); test(cexp, cpackl(-0.0, finites[i]), cpackl(cos(finites[i]), sin(finites[i])), ALL_STD_EXCEPT & ~FE_INEXACT, 0, 1); test(cexpf, cpackl(0.0, finites[i]), cpackl(cosf(finites[i]), sinf(finites[i])), ALL_STD_EXCEPT & ~FE_INEXACT, 0, 1); test(cexpf, cpackl(-0.0, finites[i]), cpackl(cosf(finites[i]), sinf(finites[i])), ALL_STD_EXCEPT & ~FE_INEXACT, 0, 1); } }
void test_reals(void) { int i; for (i = 0; i < N(finites); i++) { /* XXX could check exceptions more meticulously */ test(cexp, cpackl(finites[i], 0.0), cpackl(exp(finites[i]), 0.0), FE_INVALID | FE_DIVBYZERO, 0, 1); test(cexp, cpackl(finites[i], -0.0), cpackl(exp(finites[i]), -0.0), FE_INVALID | FE_DIVBYZERO, 0, 1); test(cexpf, cpackl(finites[i], 0.0), cpackl(expf(finites[i]), 0.0), FE_INVALID | FE_DIVBYZERO, 0, 1); test(cexpf, cpackl(finites[i], -0.0), cpackl(expf(finites[i]), -0.0), FE_INVALID | FE_DIVBYZERO, 0, 1); } }
/* * Tests for NaN inputs. */ void test_nan() { long double complex nan_nan = cpackl(NAN, NAN); long double complex z; /* * IN CSINH CCOSH CTANH * NaN,NaN NaN,NaN NaN,NaN NaN,NaN * finite,NaN NaN,NaN [inval] NaN,NaN [inval] NaN,NaN [inval] * NaN,finite NaN,NaN [inval] NaN,NaN [inval] NaN,NaN [inval] * NaN,Inf NaN,NaN [inval] NaN,NaN [inval] NaN,NaN [inval] * Inf,NaN +-Inf,NaN Inf,NaN 1,+-0 * 0,NaN +-0,NaN NaN,+-0 NaN,NaN [inval] * NaN,0 NaN,0 NaN,+-0 NaN,0 */ z = nan_nan; testall_odd(csinh, z, nan_nan, ALL_STD_EXCEPT, 0, 0); testall_even(ccosh, z, nan_nan, ALL_STD_EXCEPT, 0, 0); testall_odd(ctanh, z, nan_nan, ALL_STD_EXCEPT, 0, 0); testall_odd(csin, z, nan_nan, ALL_STD_EXCEPT, 0, 0); testall_even(ccos, z, nan_nan, ALL_STD_EXCEPT, 0, 0); testall_odd(ctan, z, nan_nan, ALL_STD_EXCEPT, 0, 0); z = cpackl(42, NAN); testall_odd(csinh, z, nan_nan, OPT_INVALID, 0, 0); testall_even(ccosh, z, nan_nan, OPT_INVALID, 0, 0); /* XXX We allow a spurious inexact exception here. */ testall_odd(ctanh, z, nan_nan, OPT_INVALID & ~FE_INEXACT, 0, 0); testall_odd(csin, z, nan_nan, OPT_INVALID, 0, 0); testall_even(ccos, z, nan_nan, OPT_INVALID, 0, 0); testall_odd(ctan, z, nan_nan, OPT_INVALID, 0, 0); z = cpackl(NAN, 42); testall_odd(csinh, z, nan_nan, OPT_INVALID, 0, 0); testall_even(ccosh, z, nan_nan, OPT_INVALID, 0, 0); testall_odd(ctanh, z, nan_nan, OPT_INVALID, 0, 0); testall_odd(csin, z, nan_nan, OPT_INVALID, 0, 0); testall_even(ccos, z, nan_nan, OPT_INVALID, 0, 0); /* XXX We allow a spurious inexact exception here. */ testall_odd(ctan, z, nan_nan, OPT_INVALID & ~FE_INEXACT, 0, 0); z = cpackl(NAN, INFINITY); testall_odd(csinh, z, nan_nan, OPT_INVALID, 0, 0); testall_even(ccosh, z, nan_nan, OPT_INVALID, 0, 0); testall_odd(ctanh, z, nan_nan, OPT_INVALID, 0, 0); testall_odd(csin, z, cpackl(NAN, INFINITY), ALL_STD_EXCEPT, 0, 0); testall_even(ccos, z, cpackl(INFINITY, NAN), ALL_STD_EXCEPT, 0, CS_IMAG); testall_odd(ctan, z, cpackl(0, 1), ALL_STD_EXCEPT, 0, CS_IMAG); z = cpackl(INFINITY, NAN); testall_odd(csinh, z, cpackl(INFINITY, NAN), ALL_STD_EXCEPT, 0, 0); testall_even(ccosh, z, cpackl(INFINITY, NAN), ALL_STD_EXCEPT, 0, CS_REAL); testall_odd(ctanh, z, cpackl(1, 0), ALL_STD_EXCEPT, 0, CS_REAL); testall_odd(csin, z, nan_nan, OPT_INVALID, 0, 0); testall_even(ccos, z, nan_nan, OPT_INVALID, 0, 0); testall_odd(ctan, z, nan_nan, OPT_INVALID, 0, 0); z = cpackl(0, NAN); testall_odd(csinh, z, cpackl(0, NAN), ALL_STD_EXCEPT, 0, 0); testall_even(ccosh, z, cpackl(NAN, 0), ALL_STD_EXCEPT, 0, 0); testall_odd(ctanh, z, nan_nan, OPT_INVALID, 0, 0); testall_odd(csin, z, cpackl(0, NAN), ALL_STD_EXCEPT, 0, CS_REAL); testall_even(ccos, z, cpackl(NAN, 0), ALL_STD_EXCEPT, 0, 0); testall_odd(ctan, z, cpackl(0, NAN), ALL_STD_EXCEPT, 0, CS_REAL); z = cpackl(NAN, 0); testall_odd(csinh, z, cpackl(NAN, 0), ALL_STD_EXCEPT, 0, CS_IMAG); testall_even(ccosh, z, cpackl(NAN, 0), ALL_STD_EXCEPT, 0, 0); testall_odd(ctanh, z, cpackl(NAN, 0), ALL_STD_EXCEPT, 0, CS_IMAG); testall_odd(csin, z, cpackl(NAN, 0), ALL_STD_EXCEPT, 0, 0); testall_even(ccos, z, cpackl(NAN, 0), ALL_STD_EXCEPT, 0, 0); testall_odd(ctan, z, nan_nan, OPT_INVALID, 0, 0); }
long double complex csqrtl(long double complex z) { long double complex result; long double a, b; long double t; int scale; a = creall(z); b = cimagl(z); /* Handle special cases. */ if (z == 0) return (cpackl(0, b)); if (isinf(b)) return (cpackl(INFINITY, b)); if (isnan(a)) { t = (b - b) / (b - b); /* raise invalid if b is not a NaN */ return (cpackl(a, t)); /* return NaN + NaN i */ } if (isinf(a)) { /* * csqrt(inf + NaN i) = inf + NaN i * csqrt(inf + y i) = inf + 0 i * csqrt(-inf + NaN i) = NaN +- inf i * csqrt(-inf + y i) = 0 + inf i */ if (signbit(a)) return (cpackl(fabsl(b - b), copysignl(a, b))); else return (cpackl(a, copysignl(b - b, b))); } /* * The remaining special case (b is NaN) is handled just fine by * the normal code path below. */ /* Scale to avoid overflow. */ if (fabsl(a) >= THRESH || fabsl(b) >= THRESH) { a *= 0.25; b *= 0.25; scale = 1; } else { scale = 0; } /* Algorithm 312, CACM vol 10, Oct 1967. */ if (a >= 0) { t = sqrtl((a + hypotl(a, b)) * 0.5); result = cpackl(t, b / (2 * t)); } else { t = sqrtl((-a + hypotl(a, b)) * 0.5); result = cpackl(fabsl(b) / (2 * t), copysignl(t, b)); } /* Rescale. */ if (scale) return (result * 2); else return (result); }
long double complex conjl(long double complex z) { return (cpackl(creall(z), -cimagl(z))); }
void test_small(void) { /* * z = 0.5 + i Pi/4 * sinh(z) = (sinh(0.5) + i cosh(0.5)) * sqrt(2)/2 * cosh(z) = (cosh(0.5) + i sinh(0.5)) * sqrt(2)/2 * tanh(z) = (2cosh(0.5)sinh(0.5) + i) / (2 cosh(0.5)**2 - 1) * z = -0.5 + i Pi/2 * sinh(z) = cosh(0.5) * cosh(z) = -i sinh(0.5) * tanh(z) = -coth(0.5) * z = 1.0 + i 3Pi/4 * sinh(z) = (-sinh(1) + i cosh(1)) * sqrt(2)/2 * cosh(z) = (-cosh(1) + i sinh(1)) * sqrt(2)/2 * tanh(z) = (2cosh(1)sinh(1) - i) / (2cosh(1)**2 - 1) */ static const struct { long double a, b; long double sinh_a, sinh_b; long double cosh_a, cosh_b; long double tanh_a, tanh_b; } tests[] = { { 0.5L, 0.78539816339744830961566084581987572L, 0.36847002415910435172083660522240710L, 0.79735196663945774996093142586179334L, 0.79735196663945774996093142586179334L, 0.36847002415910435172083660522240710L, 0.76159415595576488811945828260479359L, 0.64805427366388539957497735322615032L }, { -0.5L, 1.57079632679489661923132169163975144L, 0.0L, 1.12762596520638078522622516140267201L, 0.0L, -0.52109530549374736162242562641149156L, -2.16395341373865284877000401021802312L, 0.0L }, { 1.0L, 2.35619449019234492884698253745962716L, -0.83099273328405698212637979852748608L, 1.09112278079550143030545602018565236L, -1.09112278079550143030545602018565236L, 0.83099273328405698212637979852748609L, 0.96402758007581688394641372410092315L, -0.26580222883407969212086273981988897L } }; long double complex z; int i; for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) { z = cpackl(tests[i].a, tests[i].b); testall_odd_tol(csinh, z, cpackl(tests[i].sinh_a, tests[i].sinh_b), 1.1); testall_even_tol(ccosh, z, cpackl(tests[i].cosh_a, tests[i].cosh_b), 1.1); testall_odd_tol(ctanh, z, cpackl(tests[i].tanh_a, tests[i].tanh_b), 1.1); } }
long double complex cprojl(long double complex z) { if (isinf(creall(z)) || isinf(cimagl(z))) return cpackl(INFINITY, copysignl(0.0, creall(z))); return z; }
/* Test inputs with a real part r that would overflow exp(r). */ void test_large(void) { test_tol(cexp, cpackl(709.79, 0x1p-1074), cpackl(INFINITY, 8.94674309915433533273e-16), DBL_ULP()); test_tol(cexp, cpackl(1000, 0x1p-1074), cpackl(INFINITY, 9.73344457300016401328e+110), DBL_ULP()); test_tol(cexp, cpackl(1400, 0x1p-1074), cpackl(INFINITY, 5.08228858149196559681e+284), DBL_ULP()); test_tol(cexp, cpackl(900, 0x1.23456789abcdep-1020), cpackl(INFINITY, 7.42156649354218408074e+83), DBL_ULP()); test_tol(cexp, cpackl(1300, 0x1.23456789abcdep-1020), cpackl(INFINITY, 3.87514844965996756704e+257), DBL_ULP()); test_tol(cexpf, cpackl(88.73, 0x1p-149), cpackl(INFINITY, 4.80265603e-07), 2 * FLT_ULP()); test_tol(cexpf, cpackl(90, 0x1p-149), cpackl(INFINITY, 1.7101492622e-06f), 2 * FLT_ULP()); test_tol(cexpf, cpackl(192, 0x1p-149), cpackl(INFINITY, 3.396809344e+38f), 2 * FLT_ULP()); test_tol(cexpf, cpackl(120, 0x1.234568p-120), cpackl(INFINITY, 1.1163382522e+16f), 2 * FLT_ULP()); test_tol(cexpf, cpackl(170, 0x1.234568p-120), cpackl(INFINITY, 5.7878851079e+37f), 2 * FLT_ULP()); }
void test_inf(void) { int i; /* cexp(x + inf i) = NaN + NaNi and raises invalid */ for (i = 0; i < N(finites); i++) { testall(cpackl(finites[i], INFINITY), cpackl(NAN, NAN), ALL_STD_EXCEPT, FE_INVALID, 1); } /* cexp(-inf + yi) = 0 * (cos(y) + sin(y)i) */ /* XXX shouldn't raise an inexact exception */ testall(cpackl(-INFINITY, M_PI_4), cpackl(0.0, 0.0), ALL_STD_EXCEPT & ~FE_INEXACT, 0, 1); testall(cpackl(-INFINITY, 3 * M_PI_4), cpackl(-0.0, 0.0), ALL_STD_EXCEPT & ~FE_INEXACT, 0, 1); testall(cpackl(-INFINITY, 5 * M_PI_4), cpackl(-0.0, -0.0), ALL_STD_EXCEPT & ~FE_INEXACT, 0, 1); testall(cpackl(-INFINITY, 7 * M_PI_4), cpackl(0.0, -0.0), ALL_STD_EXCEPT & ~FE_INEXACT, 0, 1); testall(cpackl(-INFINITY, 0.0), cpackl(0.0, 0.0), ALL_STD_EXCEPT, 0, 1); testall(cpackl(-INFINITY, -0.0), cpackl(0.0, -0.0), ALL_STD_EXCEPT, 0, 1); /* cexp(inf + yi) = inf * (cos(y) + sin(y)i) (except y=0) */ /* XXX shouldn't raise an inexact exception */ testall(cpackl(INFINITY, M_PI_4), cpackl(INFINITY, INFINITY), ALL_STD_EXCEPT & ~FE_INEXACT, 0, 1); testall(cpackl(INFINITY, 3 * M_PI_4), cpackl(-INFINITY, INFINITY), ALL_STD_EXCEPT & ~FE_INEXACT, 0, 1); testall(cpackl(INFINITY, 5 * M_PI_4), cpackl(-INFINITY, -INFINITY), ALL_STD_EXCEPT & ~FE_INEXACT, 0, 1); testall(cpackl(INFINITY, 7 * M_PI_4), cpackl(INFINITY, -INFINITY), ALL_STD_EXCEPT & ~FE_INEXACT, 0, 1); /* cexp(inf + 0i) = inf + 0i */ testall(cpackl(INFINITY, 0.0), cpackl(INFINITY, 0.0), ALL_STD_EXCEPT, 0, 1); testall(cpackl(INFINITY, -0.0), cpackl(INFINITY, -0.0), ALL_STD_EXCEPT, 0, 1); }
/* * Tests for NaN. The signs of the results are indeterminate unless the * imaginary part is 0. */ void test_nan() { int i; /* cexp(x + NaNi) = NaN + NaNi and optionally raises invalid */ /* cexp(NaN + yi) = NaN + NaNi and optionally raises invalid (|y|>0) */ for (i = 0; i < N(finites); i++) { testall(cpackl(finites[i], NAN), cpackl(NAN, NAN), ALL_STD_EXCEPT & ~FE_INVALID, 0, 0); if (finites[i] == 0.0) continue; /* XXX FE_INEXACT shouldn't be raised here */ testall(cpackl(NAN, finites[i]), cpackl(NAN, NAN), ALL_STD_EXCEPT & ~(FE_INVALID | FE_INEXACT), 0, 0); } /* cexp(NaN +- 0i) = NaN +- 0i */ testall(cpackl(NAN, 0.0), cpackl(NAN, 0.0), ALL_STD_EXCEPT, 0, 1); testall(cpackl(NAN, -0.0), cpackl(NAN, -0.0), ALL_STD_EXCEPT, 0, 1); /* cexp(inf + NaN i) = inf + nan i */ testall(cpackl(INFINITY, NAN), cpackl(INFINITY, NAN), ALL_STD_EXCEPT, 0, 0); /* cexp(-inf + NaN i) = 0 */ testall(cpackl(-INFINITY, NAN), cpackl(0.0, 0.0), ALL_STD_EXCEPT, 0, 0); /* cexp(NaN + NaN i) = NaN + NaN i */ testall(cpackl(NAN, NAN), cpackl(NAN, NAN), ALL_STD_EXCEPT, 0, 0); }
void test_inf(void) { static const long double finites[] = { 0, M_PI / 4, 3 * M_PI / 4, 5 * M_PI / 4, }; long double complex z, c, s; int i; /* * IN CSINH CCOSH CTANH * Inf,Inf +-Inf,NaN inval +-Inf,NaN inval 1,+-0 * Inf,finite Inf cis(finite) Inf cis(finite) 1,0 sin(2 finite) * 0,Inf +-0,NaN inval NaN,+-0 inval NaN,NaN inval * finite,Inf NaN,NaN inval NaN,NaN inval NaN,NaN inval */ z = cpackl(INFINITY, INFINITY); testall_odd(csinh, z, cpackl(INFINITY, NAN), ALL_STD_EXCEPT, FE_INVALID, 0); testall_even(ccosh, z, cpackl(INFINITY, NAN), ALL_STD_EXCEPT, FE_INVALID, 0); testall_odd(ctanh, z, cpackl(1, 0), ALL_STD_EXCEPT, 0, CS_REAL); testall_odd(csin, z, cpackl(NAN, INFINITY), ALL_STD_EXCEPT, FE_INVALID, 0); testall_even(ccos, z, cpackl(INFINITY, NAN), ALL_STD_EXCEPT, FE_INVALID, 0); testall_odd(ctan, z, cpackl(0, 1), ALL_STD_EXCEPT, 0, CS_REAL); /* XXX We allow spurious inexact exceptions here (hard to avoid). */ for (i = 0; i < sizeof(finites) / sizeof(finites[0]); i++) { z = cpackl(INFINITY, finites[i]); c = INFINITY * cosl(finites[i]); s = finites[i] == 0 ? finites[i] : INFINITY * sinl(finites[i]); testall_odd(csinh, z, cpackl(c, s), OPT_INEXACT, 0, CS_BOTH); testall_even(ccosh, z, cpackl(c, s), OPT_INEXACT, 0, CS_BOTH); testall_odd(ctanh, z, cpackl(1, 0 * sin(finites[i] * 2)), OPT_INEXACT, 0, CS_BOTH); z = cpackl(finites[i], INFINITY); testall_odd(csin, z, cpackl(s, c), OPT_INEXACT, 0, CS_BOTH); testall_even(ccos, z, cpackl(c, -s), OPT_INEXACT, 0, CS_BOTH); testall_odd(ctan, z, cpackl(0 * sin(finites[i] * 2), 1), OPT_INEXACT, 0, CS_BOTH); } z = cpackl(0, INFINITY); testall_odd(csinh, z, cpackl(0, NAN), ALL_STD_EXCEPT, FE_INVALID, 0); testall_even(ccosh, z, cpackl(NAN, 0), ALL_STD_EXCEPT, FE_INVALID, 0); testall_odd(ctanh, z, cpackl(NAN, NAN), ALL_STD_EXCEPT, FE_INVALID, 0); z = cpackl(INFINITY, 0); testall_odd(csin, z, cpackl(NAN, 0), ALL_STD_EXCEPT, FE_INVALID, 0); testall_even(ccos, z, cpackl(NAN, 0), ALL_STD_EXCEPT, FE_INVALID, 0); testall_odd(ctan, z, cpackl(NAN, NAN), ALL_STD_EXCEPT, FE_INVALID, 0); z = cpackl(42, INFINITY); testall_odd(csinh, z, cpackl(NAN, NAN), ALL_STD_EXCEPT, FE_INVALID, 0); testall_even(ccosh, z, cpackl(NAN, NAN), ALL_STD_EXCEPT, FE_INVALID, 0); /* XXX We allow a spurious inexact exception here. */ testall_odd(ctanh, z, cpackl(NAN, NAN), OPT_INEXACT, FE_INVALID, 0); z = cpackl(INFINITY, 42); testall_odd(csin, z, cpackl(NAN, NAN), ALL_STD_EXCEPT, FE_INVALID, 0); testall_even(ccos, z, cpackl(NAN, NAN), ALL_STD_EXCEPT, FE_INVALID, 0); /* XXX We allow a spurious inexact exception here. */ testall_odd(ctan, z, cpackl(NAN, NAN), OPT_INEXACT, FE_INVALID, 0); }
/* Tests along the real and imaginary axes. */ void test_axes(void) { static const long double nums[] = { M_PI / 4, M_PI / 2, 3 * M_PI / 4, 5 * M_PI / 4, 3 * M_PI / 2, 7 * M_PI / 4, }; long double complex z; int i; for (i = 0; i < sizeof(nums) / sizeof(nums[0]); i++) { /* Real axis */ z = cpackl(nums[i], 0.0); testall_odd_tol(csinh, z, cpackl(sinh(nums[i]), 0), 0); testall_even_tol(ccosh, z, cpackl(cosh(nums[i]), 0), 0); testall_odd_tol(ctanh, z, cpackl(tanh(nums[i]), 0), 1); testall_odd_tol(csin, z, cpackl(sin(nums[i]), copysign(0, cos(nums[i]))), 0); testall_even_tol(ccos, z, cpackl(cos(nums[i]), -copysign(0, sin(nums[i]))), 0); testall_odd_tol(ctan, z, cpackl(tan(nums[i]), 0), 1); /* Imaginary axis */ z = cpackl(0.0, nums[i]); testall_odd_tol(csinh, z, cpackl(copysign(0, cos(nums[i])), sin(nums[i])), 0); testall_even_tol(ccosh, z, cpackl(cos(nums[i]), copysign(0, sin(nums[i]))), 0); testall_odd_tol(ctanh, z, cpackl(0, tan(nums[i])), 1); testall_odd_tol(csin, z, cpackl(0, sinh(nums[i])), 0); testall_even_tol(ccos, z, cpackl(cosh(nums[i]), -0.0), 0); testall_odd_tol(ctan, z, cpackl(0, tanh(nums[i])), 1); } }
long double complex cacoshl(long double complex z) { z = cacosl(z); return cpackl(-cimagl(z), creall(z)); }
/* Test inputs that might cause overflow in a sloppy implementation. */ void test_large(void) { long double complex z; /* tanh() uses a threshold around x=22, so check both sides. */ z = cpackl(21, 0.78539816339744830961566084581987572L); testall_odd_tol(ctanh, z, cpackl(1.0, 1.14990445285871196133287617611468468e-18L), 1); z++; testall_odd_tol(ctanh, z, cpackl(1.0, 1.55622644822675930314266334585597964e-19L), 1); z = cpackl(355, 0.78539816339744830961566084581987572L); testall_odd_tol(ctanh, z, cpackl(1.0, 8.95257245135025991216632140458264468e-309L), 1); z = cpackl(30, 0x1p1023L); testall_odd_tol(ctanh, z, cpackl(1.0, -1.62994325413993477997492170229268382e-26L), 1); z = cpackl(1, 0x1p1023L); testall_odd_tol(ctanh, z, cpackl(0.878606311888306869546254022621986509L, -0.225462792499754505792678258169527424L), 1); z = cpackl(710.6, 0.78539816339744830961566084581987572L); testall_odd_tol(csinh, z, cpackl(1.43917579766621073533185387499658944e308L, 1.43917579766621073533185387499658944e308L), 1); testall_even_tol(ccosh, z, cpackl(1.43917579766621073533185387499658944e308L, 1.43917579766621073533185387499658944e308L), 1); z = cpackl(1500, 0.78539816339744830961566084581987572L); testall_odd(csinh, z, cpackl(INFINITY, INFINITY), OPT_INEXACT, FE_OVERFLOW, CS_BOTH); testall_even(ccosh, z, cpackl(INFINITY, INFINITY), OPT_INEXACT, FE_OVERFLOW, CS_BOTH); }
long double complex csinl(long double complex z) { z = csinhl(cpackl(-cimagl(z), creall(z))); return cpackl(cimagl(z), -creall(z)); }