/* Test whether a basic catanl 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 = catanl(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.) catanl(%.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.) catanl(%.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(90.01, 13.37), CMPLXL(0xc.7abad77c938cc76p-3L, 0xd.39b7e734bff5e51p-13L), CMPLXL(0xc.7abad77c938cc77p-3L, 0xd.39b7e734bff5e52p-13L), CMPLXL(0xc.7abad77c938cc78p-3L, 0xd.39b7e734bff5e53p-13L), 0); test(2, CMPLXL(-12.34, 13.37), CMPLXL(-0xc.448ed218e860132p-3L, 0xa.54acca3480165cbp-8L), CMPLXL(-0xc.448ed218e860131p-3L, 0xa.54acca3480165ccp-8L), CMPLXL(-0xc.448ed218e86013p-3L, 0xa.54acca3480165cdp-8L), 0); test(3, CMPLXL(nanl(""), 13.37), CMPLXL(nanl(""), nanl("")), CMPLXL(nanl(""), nanl("")), CMPLXL(nanl(""), nanl("")), 0); test(4, CMPLXL(strtold("inf", NULL), 13.37), CMPLXL(0xc.90fdaa22168c234p-3L, -0x0.000000000000001p-16385L), CMPLXL(0xc.90fdaa22168c235p-3L, 0x0.0p+0L), CMPLXL(0xc.90fdaa22168c236p-3L, 0x0.000000000000001p-16385L), 0); test(5, CMPLXL(strtold("-inf", NULL), 13.37), CMPLXL(-0xc.90fdaa22168c236p-3L, -0x0.000000000000001p-16385L), CMPLXL(-0xc.90fdaa22168c235p-3L, 0x0.0p+0L), CMPLXL(-0xc.90fdaa22168c234p-3L, 0x0.000000000000001p-16385L), 0); test(6, CMPLXL(0.0, 13.37), CMPLXL(0xc.90fdaa22168c234p-3L, 0x9.97721b3ef6a9191p-7L), CMPLXL(0xc.90fdaa22168c235p-3L, 0x9.97721b3ef6a9192p-7L), CMPLXL(0xc.90fdaa22168c236p-3L, 0x9.97721b3ef6a9193p-7L), 0); test(7, CMPLXL(90.01, -12.34), CMPLXL(0xc.7aa88fdc750e645p-3L, -0xc.3ee9604e75076b9p-13L), CMPLXL(0xc.7aa88fdc750e646p-3L, -0xc.3ee9604e75076b8p-13L), CMPLXL(0xc.7aa88fdc750e647p-3L, -0xc.3ee9604e75076b7p-13L), 0); test(8, CMPLXL(-12.34, -12.34), CMPLXL(-0xc.3deb05ffb75c884p-3L, -0xa.5c84744ebb0cbc3p-8L), CMPLXL(-0xc.3deb05ffb75c883p-3L, -0xa.5c84744ebb0cbc2p-8L), CMPLXL(-0xc.3deb05ffb75c882p-3L, -0xa.5c84744ebb0cbc1p-8L), 0); test(9, CMPLXL(nanl(""), -12.34), CMPLXL(nanl(""), nanl("")), CMPLXL(nanl(""), nanl("")), CMPLXL(nanl(""), nanl("")), 0); test(10, CMPLXL(strtold("inf", NULL), -12.34), CMPLXL(0xc.90fdaa22168c234p-3L, -0x0.000000000000001p-16385L), CMPLXL(0xc.90fdaa22168c235p-3L, -0x0.0p+0L), CMPLXL(0xc.90fdaa22168c236p-3L, 0x0.000000000000001p-16385L), 0); test(11, CMPLXL(strtold("-inf", NULL), -12.34), CMPLXL(-0xc.90fdaa22168c236p-3L, -0x0.000000000000001p-16385L), CMPLXL(-0xc.90fdaa22168c235p-3L, -0x0.0p+0L), CMPLXL(-0xc.90fdaa22168c234p-3L, 0x0.000000000000001p-16385L), 0); test(12, CMPLXL(0.0, -12.34), CMPLXL(0xc.90fdaa22168c234p-3L, -0xa.6543e963f66f744p-7L), CMPLXL(0xc.90fdaa22168c235p-3L, -0xa.6543e963f66f743p-7L), CMPLXL(0xc.90fdaa22168c236p-3L, -0xa.6543e963f66f742p-7L), 0); test(13, CMPLXL(90.01, nanl("")), CMPLXL(nanl(""), nanl("")), CMPLXL(nanl(""), nanl("")), CMPLXL(nanl(""), nanl("")), 0); test(14, CMPLXL(-12.34, 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(0xc.90fdaa22168c234p-3L, -0x0.000000000000001p-16385L), CMPLXL(0xc.90fdaa22168c235p-3L, 0x0.0p+0L), CMPLXL(0xc.90fdaa22168c236p-3L, 0x0.000000000000001p-16385L), 0 | MF_ANYSIGN2); test(17, CMPLXL(strtold("-inf", NULL), nanl("")), CMPLXL(-0xc.90fdaa22168c236p-3L, -0x0.000000000000001p-16385L), CMPLXL(-0xc.90fdaa22168c235p-3L, 0x0.0p+0L), CMPLXL(-0xc.90fdaa22168c234p-3L, 0x0.000000000000001p-16385L), 0 | MF_ANYSIGN2); test(18, CMPLXL(0.0, nanl("")), CMPLXL(nanl(""), nanl("")), CMPLXL(nanl(""), nanl("")), CMPLXL(nanl(""), nanl("")), 0); test(19, CMPLXL(90.01, strtold("inf", NULL)), CMPLXL(0xc.90fdaa22168c234p-3L, -0x0.000000000000001p-16385L), CMPLXL(0xc.90fdaa22168c235p-3L, 0x0.0p+0L), CMPLXL(0xc.90fdaa22168c236p-3L, 0x0.000000000000001p-16385L), 0); test(20, CMPLXL(-12.34, strtold("inf", NULL)), CMPLXL(-0xc.90fdaa22168c236p-3L, -0x0.000000000000001p-16385L), CMPLXL(-0xc.90fdaa22168c235p-3L, 0x0.0p+0L), CMPLXL(-0xc.90fdaa22168c234p-3L, 0x0.000000000000001p-16385L), 0); test(21, CMPLXL(nanl(""), strtold("inf", NULL)), CMPLXL(nanl(""), -0x0.000000000000001p-16385L), CMPLXL(nanl(""), 0x0.0p+0L), CMPLXL(nanl(""), 0x0.000000000000001p-16385L), 0); test(22, CMPLXL(strtold("inf", NULL), strtold("inf", NULL)), CMPLXL(0xc.90fdaa22168c234p-3L, -0x0.000000000000001p-16385L), CMPLXL(0xc.90fdaa22168c235p-3L, 0x0.0p+0L), CMPLXL(0xc.90fdaa22168c236p-3L, 0x0.000000000000001p-16385L), 0); test(23, CMPLXL(strtold("-inf", NULL), strtold("inf", NULL)), CMPLXL(-0xc.90fdaa22168c236p-3L, -0x0.000000000000001p-16385L), CMPLXL(-0xc.90fdaa22168c235p-3L, 0x0.0p+0L), CMPLXL(-0xc.90fdaa22168c234p-3L, 0x0.000000000000001p-16385L), 0); test(24, CMPLXL(0.0, strtold("inf", NULL)), CMPLXL(0xc.90fdaa22168c234p-3L, -0x0.000000000000001p-16385L), CMPLXL(0xc.90fdaa22168c235p-3L, 0x0.0p+0L), CMPLXL(0xc.90fdaa22168c236p-3L, 0x0.000000000000001p-16385L), 0); test(25, CMPLXL(90.01, strtold("-inf", NULL)), CMPLXL(0xc.90fdaa22168c234p-3L, -0x0.000000000000001p-16385L), CMPLXL(0xc.90fdaa22168c235p-3L, -0x0.0p+0L), CMPLXL(0xc.90fdaa22168c236p-3L, 0x0.000000000000001p-16385L), 0); test(26, CMPLXL(-12.34, strtold("-inf", NULL)), CMPLXL(-0xc.90fdaa22168c236p-3L, -0x0.000000000000001p-16385L), CMPLXL(-0xc.90fdaa22168c235p-3L, -0x0.0p+0L), CMPLXL(-0xc.90fdaa22168c234p-3L, 0x0.000000000000001p-16385L), 0); test(27, CMPLXL(nanl(""), strtold("-inf", NULL)), CMPLXL(nanl(""), -0x0.000000000000001p-16385L), CMPLXL(nanl(""), -0x0.0p+0L), CMPLXL(nanl(""), 0x0.000000000000001p-16385L), 0); test(28, CMPLXL(strtold("inf", NULL), strtold("-inf", NULL)), CMPLXL(0xc.90fdaa22168c234p-3L, -0x0.000000000000001p-16385L), CMPLXL(0xc.90fdaa22168c235p-3L, -0x0.0p+0L), CMPLXL(0xc.90fdaa22168c236p-3L, 0x0.000000000000001p-16385L), 0); test(29, CMPLXL(strtold("-inf", NULL), strtold("-inf", NULL)), CMPLXL(-0xc.90fdaa22168c236p-3L, -0x0.000000000000001p-16385L), CMPLXL(-0xc.90fdaa22168c235p-3L, -0x0.0p+0L), CMPLXL(-0xc.90fdaa22168c234p-3L, 0x0.000000000000001p-16385L), 0); test(30, CMPLXL(0.0, strtold("-inf", NULL)), CMPLXL(0xc.90fdaa22168c234p-3L, -0x0.000000000000001p-16385L), CMPLXL(0xc.90fdaa22168c235p-3L, -0x0.0p+0L), CMPLXL(0xc.90fdaa22168c236p-3L, 0x0.000000000000001p-16385L), 0); test(31, CMPLXL(90.01, 0.0), CMPLXL(0xc.7a3d21128d128d6p-3L, -0x0.000000000000001p-16385L), CMPLXL(0xc.7a3d21128d128d7p-3L, 0x0.0p+0L), CMPLXL(0xc.7a3d21128d128d8p-3L, 0x0.000000000000001p-16385L), 0); test(32, CMPLXL(-12.34, 0.0), CMPLXL(-0xb.eb636ea52065e7dp-3L, -0x0.000000000000001p-16385L), CMPLXL(-0xb.eb636ea52065e7cp-3L, 0x0.0p+0L), CMPLXL(-0xb.eb636ea52065e7bp-3L, 0x0.000000000000001p-16385L), 0); test(33, CMPLXL(nanl(""), 0.0), CMPLXL(nanl(""), -0x0.000000000000001p-16385L), CMPLXL(nanl(""), 0x0.0p+0L), CMPLXL(nanl(""), 0x0.000000000000001p-16385L), 0); test(34, CMPLXL(strtold("inf", NULL), 0.0), CMPLXL(0xc.90fdaa22168c234p-3L, -0x0.000000000000001p-16385L), CMPLXL(0xc.90fdaa22168c235p-3L, 0x0.0p+0L), CMPLXL(0xc.90fdaa22168c236p-3L, 0x0.000000000000001p-16385L), 0); test(35, CMPLXL(strtold("-inf", NULL), 0.0), CMPLXL(-0xc.90fdaa22168c236p-3L, -0x0.000000000000001p-16385L), CMPLXL(-0xc.90fdaa22168c235p-3L, 0x0.0p+0L), CMPLXL(-0xc.90fdaa22168c234p-3L, 0x0.000000000000001p-16385L), 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; }