/* Test whether a basic catanhl invocation works. */ /* This test is generated by misc/genbasic.c. */ #include #include #include #include #include "../basic.h" #pragma STDC FENV_ACCESS ON #define MF_UNSPEC1 (1 << 0) #define MF_UNSPEC2 (1 << 1) #define MF_MAYERR (1 << 2) #define MF_ANYSIGN1 (1 << 2) #define MF_ANYSIGN2 (1 << 3) // Soft fail on rounding errors and report only one. int imprecise; void test(int variant, long double complex input1, long double complex lower, long double complex expected, long double complex upper, int flags) { long double complex output = catanhl(input1); if ( !(flags & MF_UNSPEC1) ) { long double real = creall(output); real = (flags & MF_ANYSIGN1) && real < 0.0 ? -real : real; long double lower_real = creall(lower); long double expected_real = creall(expected); long double upper_real = creall(upper); if ( !(isnan(expected_real) ? isnan(real) : isfinite(expected_real) && expected_real != 0.0 ? isfinite(real) && (real == expected_real || (lower_real < real && real < upper_real)) : real == expected_real) ) { if ( imprecise && isfinite(real) && isfinite(expected_real) ) return; warnx("(%d.) catanhl(%.4Lf + i*%.4Lf).real = %.17La, not %.17La, diff %.17La, ratio %.20Lg", variant, creall(input1), cimagl(input1), real, expected_real, real - expected_real, real / expected_real); if ( !isfinite(real) || !isfinite(expected_real) ) exit(1); imprecise = 1; } long double imag = cimagl(output); imag = (flags & MF_ANYSIGN2) && imag < 0.0 ? -imag : imag; long double lower_imag = cimagl(lower); long double expected_imag = cimagl(expected); long double upper_imag = cimagl(upper); if ( !(isnan(expected_imag) ? isnan(imag) : isfinite(expected_imag) && expected_imag != 0.0 ? isfinite(imag) && (imag == expected_imag || (lower_imag < imag && imag < upper_imag)) : imag == expected_imag) ) { if ( imprecise && isfinite(imag) && isfinite(expected_imag) ) return; warnx("(%d.) catanhl(%.4Lf + i*%.4Lf).imag = %.17La, not %.17La, diff %.17La, ratio %.20Lg", variant, creall(input1), cimagl(input1), imag, expected_imag, imag - expected_imag, imag / expected_imag); if ( !isfinite(imag) || !isfinite(expected_imag) ) exit(1); imprecise = 1; } } } int main(void) { test(1, CMPLXL(0.9001, 0.1337), CMPLXL(0x9.bd2b21167ca77dep-3L, 0xf.fd4da67ab4e1c1cp-5L), CMPLXL(0x9.bd2b21167ca77dfp-3L, 0xf.fd4da67ab4e1c1dp-5L), CMPLXL(0x9.bd2b21167ca77ep-3L, 0xf.fd4da67ab4e1c1ep-5L), 0); test(2, CMPLXL(-0.1234, 0.1337), CMPLXL(-0xf.971ea85566df65p-7L, 0x8.a24b0ec7c148c07p-6L), CMPLXL(-0xf.971ea85566df64fp-7L, 0x8.a24b0ec7c148c08p-6L), CMPLXL(-0xf.971ea85566df64ep-7L, 0x8.a24b0ec7c148c09p-6L), 0); test(3, CMPLXL(nanl(""), 0.1337), CMPLXL(nanl(""), nanl("")), CMPLXL(nanl(""), nanl("")), CMPLXL(nanl(""), nanl("")), 0); test(4, CMPLXL(strtold("inf", NULL), 0.1337), CMPLXL(-0x0.000000000000001p-16385L, 0xc.90fdaa22168c234p-3L), CMPLXL(0x0.0p+0L, 0xc.90fdaa22168c235p-3L), CMPLXL(0x0.000000000000001p-16385L, 0xc.90fdaa22168c236p-3L), 0); test(5, CMPLXL(strtold("-inf", NULL), 0.1337), CMPLXL(-0x0.000000000000001p-16385L, 0xc.90fdaa22168c234p-3L), CMPLXL(-0x0.0p+0L, 0xc.90fdaa22168c235p-3L), CMPLXL(0x0.000000000000001p-16385L, 0xc.90fdaa22168c236p-3L), 0); test(6, CMPLXL(0.0, 0.1337), CMPLXL(-0x0.000000000000001p-16385L, 0x8.81a065d9fae595fp-6L), CMPLXL(0x0.0p+0L, 0x8.81a065d9fae596p-6L), CMPLXL(0x0.000000000000001p-16385L, 0x8.81a065d9fae5961p-6L), 0); test(7, CMPLXL(0.9001, -0.1234), CMPLXL(0x9.eff0a3d74a3afp-3L, -0xf.481bd4924f9b38ap-5L), CMPLXL(0x9.eff0a3d74a3af01p-3L, -0xf.481bd4924f9b389p-5L), CMPLXL(0x9.eff0a3d74a3af02p-3L, -0xf.481bd4924f9b388p-5L), 0); test(8, CMPLXL(-0.1234, -0.1234), CMPLXL(-0xf.a1c9e50b0b3e7ddp-7L, -0xf.f3dab5959e56748p-7L), CMPLXL(-0xf.a1c9e50b0b3e7dcp-7L, -0xf.f3dab5959e56747p-7L), CMPLXL(-0xf.a1c9e50b0b3e7dbp-7L, -0xf.f3dab5959e56746p-7L), 0); test(9, CMPLXL(nanl(""), -0.1234), CMPLXL(nanl(""), nanl("")), CMPLXL(nanl(""), nanl("")), CMPLXL(nanl(""), nanl("")), 0); test(10, CMPLXL(strtold("inf", NULL), -0.1234), CMPLXL(-0x0.000000000000001p-16385L, -0xc.90fdaa22168c236p-3L), CMPLXL(0x0.0p+0L, -0xc.90fdaa22168c235p-3L), CMPLXL(0x0.000000000000001p-16385L, -0xc.90fdaa22168c234p-3L), 0); test(11, CMPLXL(strtold("-inf", NULL), -0.1234), CMPLXL(-0x0.000000000000001p-16385L, -0xc.90fdaa22168c236p-3L), CMPLXL(-0x0.0p+0L, -0xc.90fdaa22168c235p-3L), CMPLXL(0x0.000000000000001p-16385L, -0xc.90fdaa22168c234p-3L), 0); test(12, CMPLXL(0.0, -0.1234), CMPLXL(-0x0.000000000000001p-16385L, -0xf.b73b6d17796d76dp-7L), CMPLXL(0x0.0p+0L, -0xf.b73b6d17796d76cp-7L), CMPLXL(0x0.000000000000001p-16385L, -0xf.b73b6d17796d76bp-7L), 0); test(13, CMPLXL(0.9001, nanl("")), CMPLXL(nanl(""), nanl("")), CMPLXL(nanl(""), nanl("")), CMPLXL(nanl(""), nanl("")), 0); test(14, CMPLXL(-0.1234, nanl("")), CMPLXL(nanl(""), nanl("")), CMPLXL(nanl(""), nanl("")), CMPLXL(nanl(""), nanl("")), 0); test(15, CMPLXL(nanl(""), nanl("")), CMPLXL(nanl(""), nanl("")), CMPLXL(nanl(""), nanl("")), CMPLXL(nanl(""), nanl("")), 0); test(16, CMPLXL(strtold("inf", NULL), nanl("")), CMPLXL(-0x0.000000000000001p-16385L, nanl("")), CMPLXL(0x0.0p+0L, nanl("")), CMPLXL(0x0.000000000000001p-16385L, nanl("")), 0); test(17, CMPLXL(strtold("-inf", NULL), nanl("")), CMPLXL(-0x0.000000000000001p-16385L, nanl("")), CMPLXL(-0x0.0p+0L, nanl("")), CMPLXL(0x0.000000000000001p-16385L, nanl("")), 0); test(18, CMPLXL(0.0, nanl("")), CMPLXL(-0x0.000000000000001p-16385L, nanl("")), CMPLXL(0x0.0p+0L, nanl("")), CMPLXL(0x0.000000000000001p-16385L, nanl("")), 0); test(19, CMPLXL(0.9001, strtold("inf", NULL)), CMPLXL(-0x0.000000000000001p-16385L, 0xc.90fdaa22168c234p-3L), CMPLXL(0x0.0p+0L, 0xc.90fdaa22168c235p-3L), CMPLXL(0x0.000000000000001p-16385L, 0xc.90fdaa22168c236p-3L), 0); test(20, CMPLXL(-0.1234, strtold("inf", NULL)), CMPLXL(-0x0.000000000000001p-16385L, 0xc.90fdaa22168c234p-3L), CMPLXL(-0x0.0p+0L, 0xc.90fdaa22168c235p-3L), CMPLXL(0x0.000000000000001p-16385L, 0xc.90fdaa22168c236p-3L), 0); test(21, CMPLXL(nanl(""), strtold("inf", NULL)), CMPLXL(-0x0.000000000000001p-16385L, 0xc.90fdaa22168c234p-3L), CMPLXL(0x0.0p+0L, 0xc.90fdaa22168c235p-3L), CMPLXL(0x0.000000000000001p-16385L, 0xc.90fdaa22168c236p-3L), 0); test(22, CMPLXL(strtold("inf", NULL), strtold("inf", NULL)), CMPLXL(-0x0.000000000000001p-16385L, 0xc.90fdaa22168c234p-3L), CMPLXL(0x0.0p+0L, 0xc.90fdaa22168c235p-3L), CMPLXL(0x0.000000000000001p-16385L, 0xc.90fdaa22168c236p-3L), 0); test(23, CMPLXL(strtold("-inf", NULL), strtold("inf", NULL)), CMPLXL(-0x0.000000000000001p-16385L, 0xc.90fdaa22168c234p-3L), CMPLXL(-0x0.0p+0L, 0xc.90fdaa22168c235p-3L), CMPLXL(0x0.000000000000001p-16385L, 0xc.90fdaa22168c236p-3L), 0); test(24, CMPLXL(0.0, strtold("inf", NULL)), CMPLXL(-0x0.000000000000001p-16385L, 0xc.90fdaa22168c234p-3L), CMPLXL(0x0.0p+0L, 0xc.90fdaa22168c235p-3L), CMPLXL(0x0.000000000000001p-16385L, 0xc.90fdaa22168c236p-3L), 0); test(25, CMPLXL(0.9001, strtold("-inf", NULL)), CMPLXL(-0x0.000000000000001p-16385L, -0xc.90fdaa22168c236p-3L), CMPLXL(0x0.0p+0L, -0xc.90fdaa22168c235p-3L), CMPLXL(0x0.000000000000001p-16385L, -0xc.90fdaa22168c234p-3L), 0); test(26, CMPLXL(-0.1234, strtold("-inf", NULL)), CMPLXL(-0x0.000000000000001p-16385L, -0xc.90fdaa22168c236p-3L), CMPLXL(-0x0.0p+0L, -0xc.90fdaa22168c235p-3L), CMPLXL(0x0.000000000000001p-16385L, -0xc.90fdaa22168c234p-3L), 0); test(27, CMPLXL(nanl(""), strtold("-inf", NULL)), CMPLXL(-0x0.000000000000001p-16385L, -0xc.90fdaa22168c236p-3L), CMPLXL(0x0.0p+0L, -0xc.90fdaa22168c235p-3L), CMPLXL(0x0.000000000000001p-16385L, -0xc.90fdaa22168c234p-3L), 0); test(28, CMPLXL(strtold("inf", NULL), strtold("-inf", NULL)), CMPLXL(-0x0.000000000000001p-16385L, -0xc.90fdaa22168c236p-3L), CMPLXL(0x0.0p+0L, -0xc.90fdaa22168c235p-3L), CMPLXL(0x0.000000000000001p-16385L, -0xc.90fdaa22168c234p-3L), 0); test(29, CMPLXL(strtold("-inf", NULL), strtold("-inf", NULL)), CMPLXL(-0x0.000000000000001p-16385L, -0xc.90fdaa22168c236p-3L), CMPLXL(-0x0.0p+0L, -0xc.90fdaa22168c235p-3L), CMPLXL(0x0.000000000000001p-16385L, -0xc.90fdaa22168c234p-3L), 0); test(30, CMPLXL(0.0, strtold("-inf", NULL)), CMPLXL(-0x0.000000000000001p-16385L, -0xc.90fdaa22168c236p-3L), CMPLXL(0x0.0p+0L, -0xc.90fdaa22168c235p-3L), CMPLXL(0x0.000000000000001p-16385L, -0xc.90fdaa22168c234p-3L), 0); test(31, CMPLXL(0.9001, 0.0), CMPLXL(0xb.c82f15670bf673fp-3L, -0x0.000000000000001p-16385L), CMPLXL(0xb.c82f15670bf674p-3L, 0x0.0p+0L), CMPLXL(0xb.c82f15670bf6741p-3L, 0x0.000000000000001p-16385L), 0); test(32, CMPLXL(-0.1234, 0.0), CMPLXL(-0xf.e0490d7bbce3537p-7L, -0x0.000000000000001p-16385L), CMPLXL(-0xf.e0490d7bbce3536p-7L, 0x0.0p+0L), CMPLXL(-0xf.e0490d7bbce3535p-7L, 0x0.000000000000001p-16385L), 0); test(33, CMPLXL(nanl(""), 0.0), CMPLXL(nanl(""), nanl("")), CMPLXL(nanl(""), nanl("")), CMPLXL(nanl(""), nanl("")), 0); test(34, CMPLXL(strtold("inf", NULL), 0.0), CMPLXL(-0x0.000000000000001p-16385L, 0xc.90fdaa22168c234p-3L), CMPLXL(0x0.0p+0L, 0xc.90fdaa22168c235p-3L), CMPLXL(0x0.000000000000001p-16385L, 0xc.90fdaa22168c236p-3L), 0); test(35, CMPLXL(strtold("-inf", NULL), 0.0), CMPLXL(-0x0.000000000000001p-16385L, 0xc.90fdaa22168c234p-3L), CMPLXL(-0x0.0p+0L, 0xc.90fdaa22168c235p-3L), CMPLXL(0x0.000000000000001p-16385L, 0xc.90fdaa22168c236p-3L), 0); test(36, CMPLXL(0.0, 0.0), CMPLXL(-0x0.000000000000001p-16385L, -0x0.000000000000001p-16385L), CMPLXL(0x0.0p+0L, 0x0.0p+0L), CMPLXL(0x0.000000000000001p-16385L, 0x0.000000000000001p-16385L), 0); return imprecise; }