1*4dc607e7SEnji Cooper /*- 2*4dc607e7SEnji Cooper * Copyright (c) 2008-2011 David Schultz <das@FreeBSD.org> 3*4dc607e7SEnji Cooper * All rights reserved. 4*4dc607e7SEnji Cooper * 5*4dc607e7SEnji Cooper * Redistribution and use in source and binary forms, with or without 6*4dc607e7SEnji Cooper * modification, are permitted provided that the following conditions 7*4dc607e7SEnji Cooper * are met: 8*4dc607e7SEnji Cooper * 1. Redistributions of source code must retain the above copyright 9*4dc607e7SEnji Cooper * notice, this list of conditions and the following disclaimer. 10*4dc607e7SEnji Cooper * 2. Redistributions in binary form must reproduce the above copyright 11*4dc607e7SEnji Cooper * notice, this list of conditions and the following disclaimer in the 12*4dc607e7SEnji Cooper * documentation and/or other materials provided with the distribution. 13*4dc607e7SEnji Cooper * 14*4dc607e7SEnji Cooper * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15*4dc607e7SEnji Cooper * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16*4dc607e7SEnji Cooper * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17*4dc607e7SEnji Cooper * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18*4dc607e7SEnji Cooper * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19*4dc607e7SEnji Cooper * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20*4dc607e7SEnji Cooper * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21*4dc607e7SEnji Cooper * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22*4dc607e7SEnji Cooper * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23*4dc607e7SEnji Cooper * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24*4dc607e7SEnji Cooper * SUCH DAMAGE. 25*4dc607e7SEnji Cooper */ 26*4dc607e7SEnji Cooper 27*4dc607e7SEnji Cooper /* 28*4dc607e7SEnji Cooper * Tests for corner cases in cexp*(). 29*4dc607e7SEnji Cooper */ 30*4dc607e7SEnji Cooper 31*4dc607e7SEnji Cooper #include <sys/cdefs.h> 32*4dc607e7SEnji Cooper __FBSDID("$FreeBSD$"); 33*4dc607e7SEnji Cooper 34*4dc607e7SEnji Cooper #include <sys/param.h> 35*4dc607e7SEnji Cooper 36*4dc607e7SEnji Cooper #include <assert.h> 37*4dc607e7SEnji Cooper #include <complex.h> 38*4dc607e7SEnji Cooper #include <fenv.h> 39*4dc607e7SEnji Cooper #include <float.h> 40*4dc607e7SEnji Cooper #include <math.h> 41*4dc607e7SEnji Cooper #include <stdio.h> 42*4dc607e7SEnji Cooper 43*4dc607e7SEnji Cooper #include "test-utils.h" 44*4dc607e7SEnji Cooper 45*4dc607e7SEnji Cooper #pragma STDC FENV_ACCESS ON 46*4dc607e7SEnji Cooper #pragma STDC CX_LIMITED_RANGE OFF 47*4dc607e7SEnji Cooper 48*4dc607e7SEnji Cooper /* 49*4dc607e7SEnji Cooper * Test that a function returns the correct value and sets the 50*4dc607e7SEnji Cooper * exception flags correctly. The exceptmask specifies which 51*4dc607e7SEnji Cooper * exceptions we should check. We need to be lenient for several 52*4dc607e7SEnji Cooper * reasons, but mainly because on some architectures it's impossible 53*4dc607e7SEnji Cooper * to raise FE_OVERFLOW without raising FE_INEXACT. In some cases, 54*4dc607e7SEnji Cooper * whether cexp() raises an invalid exception is unspecified. 55*4dc607e7SEnji Cooper * 56*4dc607e7SEnji Cooper * These are macros instead of functions so that assert provides more 57*4dc607e7SEnji Cooper * meaningful error messages. 58*4dc607e7SEnji Cooper * 59*4dc607e7SEnji Cooper * XXX The volatile here is to avoid gcc's bogus constant folding and work 60*4dc607e7SEnji Cooper * around the lack of support for the FENV_ACCESS pragma. 61*4dc607e7SEnji Cooper */ 62*4dc607e7SEnji Cooper #define test(func, z, result, exceptmask, excepts, checksign) do { \ 63*4dc607e7SEnji Cooper volatile long double complex _d = z; \ 64*4dc607e7SEnji Cooper assert(feclearexcept(FE_ALL_EXCEPT) == 0); \ 65*4dc607e7SEnji Cooper assert(cfpequal_cs((func)(_d), (result), (checksign))); \ 66*4dc607e7SEnji Cooper assert(((void)(func), fetestexcept(exceptmask) == (excepts))); \ 67*4dc607e7SEnji Cooper } while (0) 68*4dc607e7SEnji Cooper 69*4dc607e7SEnji Cooper /* Test within a given tolerance. */ 70*4dc607e7SEnji Cooper #define test_tol(func, z, result, tol) do { \ 71*4dc607e7SEnji Cooper volatile long double complex _d = z; \ 72*4dc607e7SEnji Cooper assert(cfpequal_tol((func)(_d), (result), (tol), \ 73*4dc607e7SEnji Cooper FPE_ABS_ZERO | CS_BOTH)); \ 74*4dc607e7SEnji Cooper } while (0) 75*4dc607e7SEnji Cooper 76*4dc607e7SEnji Cooper /* Test all the functions that compute cexp(x). */ 77*4dc607e7SEnji Cooper #define testall(x, result, exceptmask, excepts, checksign) do { \ 78*4dc607e7SEnji Cooper test(cexp, x, result, exceptmask, excepts, checksign); \ 79*4dc607e7SEnji Cooper test(cexpf, x, result, exceptmask, excepts, checksign); \ 80*4dc607e7SEnji Cooper } while (0) 81*4dc607e7SEnji Cooper 82*4dc607e7SEnji Cooper /* 83*4dc607e7SEnji Cooper * Test all the functions that compute cexp(x), within a given tolerance. 84*4dc607e7SEnji Cooper * The tolerance is specified in ulps. 85*4dc607e7SEnji Cooper */ 86*4dc607e7SEnji Cooper #define testall_tol(x, result, tol) do { \ 87*4dc607e7SEnji Cooper test_tol(cexp, x, result, tol * DBL_ULP()); \ 88*4dc607e7SEnji Cooper test_tol(cexpf, x, result, tol * FLT_ULP()); \ 89*4dc607e7SEnji Cooper } while (0) 90*4dc607e7SEnji Cooper 91*4dc607e7SEnji Cooper /* Various finite non-zero numbers to test. */ 92*4dc607e7SEnji Cooper static const float finites[] = 93*4dc607e7SEnji Cooper { -42.0e20, -1.0, -1.0e-10, -0.0, 0.0, 1.0e-10, 1.0, 42.0e20 }; 94*4dc607e7SEnji Cooper 95*4dc607e7SEnji Cooper 96*4dc607e7SEnji Cooper /* Tests for 0 */ 97*4dc607e7SEnji Cooper void 98*4dc607e7SEnji Cooper test_zero(void) 99*4dc607e7SEnji Cooper { 100*4dc607e7SEnji Cooper 101*4dc607e7SEnji Cooper /* cexp(0) = 1, no exceptions raised */ 102*4dc607e7SEnji Cooper testall(0.0, 1.0, ALL_STD_EXCEPT, 0, 1); 103*4dc607e7SEnji Cooper testall(-0.0, 1.0, ALL_STD_EXCEPT, 0, 1); 104*4dc607e7SEnji Cooper testall(CMPLXL(0.0, -0.0), CMPLXL(1.0, -0.0), ALL_STD_EXCEPT, 0, 1); 105*4dc607e7SEnji Cooper testall(CMPLXL(-0.0, -0.0), CMPLXL(1.0, -0.0), ALL_STD_EXCEPT, 0, 1); 106*4dc607e7SEnji Cooper } 107*4dc607e7SEnji Cooper 108*4dc607e7SEnji Cooper /* 109*4dc607e7SEnji Cooper * Tests for NaN. The signs of the results are indeterminate unless the 110*4dc607e7SEnji Cooper * imaginary part is 0. 111*4dc607e7SEnji Cooper */ 112*4dc607e7SEnji Cooper void 113*4dc607e7SEnji Cooper test_nan() 114*4dc607e7SEnji Cooper { 115*4dc607e7SEnji Cooper int i; 116*4dc607e7SEnji Cooper 117*4dc607e7SEnji Cooper /* cexp(x + NaNi) = NaN + NaNi and optionally raises invalid */ 118*4dc607e7SEnji Cooper /* cexp(NaN + yi) = NaN + NaNi and optionally raises invalid (|y|>0) */ 119*4dc607e7SEnji Cooper for (i = 0; i < nitems(finites); i++) { 120*4dc607e7SEnji Cooper printf("# Run %d..\n", i); 121*4dc607e7SEnji Cooper testall(CMPLXL(finites[i], NAN), CMPLXL(NAN, NAN), 122*4dc607e7SEnji Cooper ALL_STD_EXCEPT & ~FE_INVALID, 0, 0); 123*4dc607e7SEnji Cooper if (finites[i] == 0.0) 124*4dc607e7SEnji Cooper continue; 125*4dc607e7SEnji Cooper /* XXX FE_INEXACT shouldn't be raised here */ 126*4dc607e7SEnji Cooper testall(CMPLXL(NAN, finites[i]), CMPLXL(NAN, NAN), 127*4dc607e7SEnji Cooper ALL_STD_EXCEPT & ~(FE_INVALID | FE_INEXACT), 0, 0); 128*4dc607e7SEnji Cooper } 129*4dc607e7SEnji Cooper 130*4dc607e7SEnji Cooper /* cexp(NaN +- 0i) = NaN +- 0i */ 131*4dc607e7SEnji Cooper testall(CMPLXL(NAN, 0.0), CMPLXL(NAN, 0.0), ALL_STD_EXCEPT, 0, 1); 132*4dc607e7SEnji Cooper testall(CMPLXL(NAN, -0.0), CMPLXL(NAN, -0.0), ALL_STD_EXCEPT, 0, 1); 133*4dc607e7SEnji Cooper 134*4dc607e7SEnji Cooper /* cexp(inf + NaN i) = inf + nan i */ 135*4dc607e7SEnji Cooper testall(CMPLXL(INFINITY, NAN), CMPLXL(INFINITY, NAN), 136*4dc607e7SEnji Cooper ALL_STD_EXCEPT, 0, 0); 137*4dc607e7SEnji Cooper /* cexp(-inf + NaN i) = 0 */ 138*4dc607e7SEnji Cooper testall(CMPLXL(-INFINITY, NAN), CMPLXL(0.0, 0.0), 139*4dc607e7SEnji Cooper ALL_STD_EXCEPT, 0, 0); 140*4dc607e7SEnji Cooper /* cexp(NaN + NaN i) = NaN + NaN i */ 141*4dc607e7SEnji Cooper testall(CMPLXL(NAN, NAN), CMPLXL(NAN, NAN), 142*4dc607e7SEnji Cooper ALL_STD_EXCEPT, 0, 0); 143*4dc607e7SEnji Cooper } 144*4dc607e7SEnji Cooper 145*4dc607e7SEnji Cooper void 146*4dc607e7SEnji Cooper test_inf(void) 147*4dc607e7SEnji Cooper { 148*4dc607e7SEnji Cooper int i; 149*4dc607e7SEnji Cooper 150*4dc607e7SEnji Cooper /* cexp(x + inf i) = NaN + NaNi and raises invalid */ 151*4dc607e7SEnji Cooper for (i = 0; i < nitems(finites); i++) { 152*4dc607e7SEnji Cooper printf("# Run %d..\n", i); 153*4dc607e7SEnji Cooper testall(CMPLXL(finites[i], INFINITY), CMPLXL(NAN, NAN), 154*4dc607e7SEnji Cooper ALL_STD_EXCEPT, FE_INVALID, 1); 155*4dc607e7SEnji Cooper } 156*4dc607e7SEnji Cooper /* cexp(-inf + yi) = 0 * (cos(y) + sin(y)i) */ 157*4dc607e7SEnji Cooper /* XXX shouldn't raise an inexact exception */ 158*4dc607e7SEnji Cooper testall(CMPLXL(-INFINITY, M_PI_4), CMPLXL(0.0, 0.0), 159*4dc607e7SEnji Cooper ALL_STD_EXCEPT & ~FE_INEXACT, 0, 1); 160*4dc607e7SEnji Cooper testall(CMPLXL(-INFINITY, 3 * M_PI_4), CMPLXL(-0.0, 0.0), 161*4dc607e7SEnji Cooper ALL_STD_EXCEPT & ~FE_INEXACT, 0, 1); 162*4dc607e7SEnji Cooper testall(CMPLXL(-INFINITY, 5 * M_PI_4), CMPLXL(-0.0, -0.0), 163*4dc607e7SEnji Cooper ALL_STD_EXCEPT & ~FE_INEXACT, 0, 1); 164*4dc607e7SEnji Cooper testall(CMPLXL(-INFINITY, 7 * M_PI_4), CMPLXL(0.0, -0.0), 165*4dc607e7SEnji Cooper ALL_STD_EXCEPT & ~FE_INEXACT, 0, 1); 166*4dc607e7SEnji Cooper testall(CMPLXL(-INFINITY, 0.0), CMPLXL(0.0, 0.0), 167*4dc607e7SEnji Cooper ALL_STD_EXCEPT, 0, 1); 168*4dc607e7SEnji Cooper testall(CMPLXL(-INFINITY, -0.0), CMPLXL(0.0, -0.0), 169*4dc607e7SEnji Cooper ALL_STD_EXCEPT, 0, 1); 170*4dc607e7SEnji Cooper /* cexp(inf + yi) = inf * (cos(y) + sin(y)i) (except y=0) */ 171*4dc607e7SEnji Cooper /* XXX shouldn't raise an inexact exception */ 172*4dc607e7SEnji Cooper testall(CMPLXL(INFINITY, M_PI_4), CMPLXL(INFINITY, INFINITY), 173*4dc607e7SEnji Cooper ALL_STD_EXCEPT & ~FE_INEXACT, 0, 1); 174*4dc607e7SEnji Cooper testall(CMPLXL(INFINITY, 3 * M_PI_4), CMPLXL(-INFINITY, INFINITY), 175*4dc607e7SEnji Cooper ALL_STD_EXCEPT & ~FE_INEXACT, 0, 1); 176*4dc607e7SEnji Cooper testall(CMPLXL(INFINITY, 5 * M_PI_4), CMPLXL(-INFINITY, -INFINITY), 177*4dc607e7SEnji Cooper ALL_STD_EXCEPT & ~FE_INEXACT, 0, 1); 178*4dc607e7SEnji Cooper testall(CMPLXL(INFINITY, 7 * M_PI_4), CMPLXL(INFINITY, -INFINITY), 179*4dc607e7SEnji Cooper ALL_STD_EXCEPT & ~FE_INEXACT, 0, 1); 180*4dc607e7SEnji Cooper /* cexp(inf + 0i) = inf + 0i */ 181*4dc607e7SEnji Cooper testall(CMPLXL(INFINITY, 0.0), CMPLXL(INFINITY, 0.0), 182*4dc607e7SEnji Cooper ALL_STD_EXCEPT, 0, 1); 183*4dc607e7SEnji Cooper testall(CMPLXL(INFINITY, -0.0), CMPLXL(INFINITY, -0.0), 184*4dc607e7SEnji Cooper ALL_STD_EXCEPT, 0, 1); 185*4dc607e7SEnji Cooper } 186*4dc607e7SEnji Cooper 187*4dc607e7SEnji Cooper void 188*4dc607e7SEnji Cooper test_reals(void) 189*4dc607e7SEnji Cooper { 190*4dc607e7SEnji Cooper int i; 191*4dc607e7SEnji Cooper 192*4dc607e7SEnji Cooper for (i = 0; i < nitems(finites); i++) { 193*4dc607e7SEnji Cooper /* XXX could check exceptions more meticulously */ 194*4dc607e7SEnji Cooper printf("# Run %d..\n", i); 195*4dc607e7SEnji Cooper test(cexp, CMPLXL(finites[i], 0.0), 196*4dc607e7SEnji Cooper CMPLXL(exp(finites[i]), 0.0), 197*4dc607e7SEnji Cooper FE_INVALID | FE_DIVBYZERO, 0, 1); 198*4dc607e7SEnji Cooper test(cexp, CMPLXL(finites[i], -0.0), 199*4dc607e7SEnji Cooper CMPLXL(exp(finites[i]), -0.0), 200*4dc607e7SEnji Cooper FE_INVALID | FE_DIVBYZERO, 0, 1); 201*4dc607e7SEnji Cooper test(cexpf, CMPLXL(finites[i], 0.0), 202*4dc607e7SEnji Cooper CMPLXL(expf(finites[i]), 0.0), 203*4dc607e7SEnji Cooper FE_INVALID | FE_DIVBYZERO, 0, 1); 204*4dc607e7SEnji Cooper test(cexpf, CMPLXL(finites[i], -0.0), 205*4dc607e7SEnji Cooper CMPLXL(expf(finites[i]), -0.0), 206*4dc607e7SEnji Cooper FE_INVALID | FE_DIVBYZERO, 0, 1); 207*4dc607e7SEnji Cooper } 208*4dc607e7SEnji Cooper } 209*4dc607e7SEnji Cooper 210*4dc607e7SEnji Cooper void 211*4dc607e7SEnji Cooper test_imaginaries(void) 212*4dc607e7SEnji Cooper { 213*4dc607e7SEnji Cooper int i; 214*4dc607e7SEnji Cooper 215*4dc607e7SEnji Cooper for (i = 0; i < nitems(finites); i++) { 216*4dc607e7SEnji Cooper printf("# Run %d..\n", i); 217*4dc607e7SEnji Cooper test(cexp, CMPLXL(0.0, finites[i]), 218*4dc607e7SEnji Cooper CMPLXL(cos(finites[i]), sin(finites[i])), 219*4dc607e7SEnji Cooper ALL_STD_EXCEPT & ~FE_INEXACT, 0, 1); 220*4dc607e7SEnji Cooper test(cexp, CMPLXL(-0.0, finites[i]), 221*4dc607e7SEnji Cooper CMPLXL(cos(finites[i]), sin(finites[i])), 222*4dc607e7SEnji Cooper ALL_STD_EXCEPT & ~FE_INEXACT, 0, 1); 223*4dc607e7SEnji Cooper test(cexpf, CMPLXL(0.0, finites[i]), 224*4dc607e7SEnji Cooper CMPLXL(cosf(finites[i]), sinf(finites[i])), 225*4dc607e7SEnji Cooper ALL_STD_EXCEPT & ~FE_INEXACT, 0, 1); 226*4dc607e7SEnji Cooper test(cexpf, CMPLXL(-0.0, finites[i]), 227*4dc607e7SEnji Cooper CMPLXL(cosf(finites[i]), sinf(finites[i])), 228*4dc607e7SEnji Cooper ALL_STD_EXCEPT & ~FE_INEXACT, 0, 1); 229*4dc607e7SEnji Cooper } 230*4dc607e7SEnji Cooper } 231*4dc607e7SEnji Cooper 232*4dc607e7SEnji Cooper void 233*4dc607e7SEnji Cooper test_small(void) 234*4dc607e7SEnji Cooper { 235*4dc607e7SEnji Cooper static const double tests[] = { 236*4dc607e7SEnji Cooper /* csqrt(a + bI) = x + yI */ 237*4dc607e7SEnji Cooper /* a b x y */ 238*4dc607e7SEnji Cooper 1.0, M_PI_4, M_SQRT2 * 0.5 * M_E, M_SQRT2 * 0.5 * M_E, 239*4dc607e7SEnji Cooper -1.0, M_PI_4, M_SQRT2 * 0.5 / M_E, M_SQRT2 * 0.5 / M_E, 240*4dc607e7SEnji Cooper 2.0, M_PI_2, 0.0, M_E * M_E, 241*4dc607e7SEnji Cooper M_LN2, M_PI, -2.0, 0.0, 242*4dc607e7SEnji Cooper }; 243*4dc607e7SEnji Cooper double a, b; 244*4dc607e7SEnji Cooper double x, y; 245*4dc607e7SEnji Cooper int i; 246*4dc607e7SEnji Cooper 247*4dc607e7SEnji Cooper for (i = 0; i < nitems(tests); i += 4) { 248*4dc607e7SEnji Cooper printf("# Run %d..\n", i); 249*4dc607e7SEnji Cooper a = tests[i]; 250*4dc607e7SEnji Cooper b = tests[i + 1]; 251*4dc607e7SEnji Cooper x = tests[i + 2]; 252*4dc607e7SEnji Cooper y = tests[i + 3]; 253*4dc607e7SEnji Cooper test_tol(cexp, CMPLXL(a, b), CMPLXL(x, y), 3 * DBL_ULP()); 254*4dc607e7SEnji Cooper 255*4dc607e7SEnji Cooper /* float doesn't have enough precision to pass these tests */ 256*4dc607e7SEnji Cooper if (x == 0 || y == 0) 257*4dc607e7SEnji Cooper continue; 258*4dc607e7SEnji Cooper test_tol(cexpf, CMPLXL(a, b), CMPLXL(x, y), 1 * FLT_ULP()); 259*4dc607e7SEnji Cooper } 260*4dc607e7SEnji Cooper } 261*4dc607e7SEnji Cooper 262*4dc607e7SEnji Cooper /* Test inputs with a real part r that would overflow exp(r). */ 263*4dc607e7SEnji Cooper void 264*4dc607e7SEnji Cooper test_large(void) 265*4dc607e7SEnji Cooper { 266*4dc607e7SEnji Cooper 267*4dc607e7SEnji Cooper test_tol(cexp, CMPLXL(709.79, 0x1p-1074), 268*4dc607e7SEnji Cooper CMPLXL(INFINITY, 8.94674309915433533273e-16), DBL_ULP()); 269*4dc607e7SEnji Cooper test_tol(cexp, CMPLXL(1000, 0x1p-1074), 270*4dc607e7SEnji Cooper CMPLXL(INFINITY, 9.73344457300016401328e+110), DBL_ULP()); 271*4dc607e7SEnji Cooper test_tol(cexp, CMPLXL(1400, 0x1p-1074), 272*4dc607e7SEnji Cooper CMPLXL(INFINITY, 5.08228858149196559681e+284), DBL_ULP()); 273*4dc607e7SEnji Cooper test_tol(cexp, CMPLXL(900, 0x1.23456789abcdep-1020), 274*4dc607e7SEnji Cooper CMPLXL(INFINITY, 7.42156649354218408074e+83), DBL_ULP()); 275*4dc607e7SEnji Cooper test_tol(cexp, CMPLXL(1300, 0x1.23456789abcdep-1020), 276*4dc607e7SEnji Cooper CMPLXL(INFINITY, 3.87514844965996756704e+257), DBL_ULP()); 277*4dc607e7SEnji Cooper 278*4dc607e7SEnji Cooper test_tol(cexpf, CMPLXL(88.73, 0x1p-149), 279*4dc607e7SEnji Cooper CMPLXL(INFINITY, 4.80265603e-07), 2 * FLT_ULP()); 280*4dc607e7SEnji Cooper test_tol(cexpf, CMPLXL(90, 0x1p-149), 281*4dc607e7SEnji Cooper CMPLXL(INFINITY, 1.7101492622e-06f), 2 * FLT_ULP()); 282*4dc607e7SEnji Cooper test_tol(cexpf, CMPLXL(192, 0x1p-149), 283*4dc607e7SEnji Cooper CMPLXL(INFINITY, 3.396809344e+38f), 2 * FLT_ULP()); 284*4dc607e7SEnji Cooper test_tol(cexpf, CMPLXL(120, 0x1.234568p-120), 285*4dc607e7SEnji Cooper CMPLXL(INFINITY, 1.1163382522e+16f), 2 * FLT_ULP()); 286*4dc607e7SEnji Cooper test_tol(cexpf, CMPLXL(170, 0x1.234568p-120), 287*4dc607e7SEnji Cooper CMPLXL(INFINITY, 5.7878851079e+37f), 2 * FLT_ULP()); 288*4dc607e7SEnji Cooper } 289*4dc607e7SEnji Cooper 290*4dc607e7SEnji Cooper int 291*4dc607e7SEnji Cooper main(int argc, char *argv[]) 292*4dc607e7SEnji Cooper { 293*4dc607e7SEnji Cooper 294*4dc607e7SEnji Cooper printf("1..7\n"); 295*4dc607e7SEnji Cooper 296*4dc607e7SEnji Cooper test_zero(); 297*4dc607e7SEnji Cooper printf("ok 1 - cexp zero\n"); 298*4dc607e7SEnji Cooper 299*4dc607e7SEnji Cooper test_nan(); 300*4dc607e7SEnji Cooper printf("ok 2 - cexp nan\n"); 301*4dc607e7SEnji Cooper 302*4dc607e7SEnji Cooper test_inf(); 303*4dc607e7SEnji Cooper printf("ok 3 - cexp inf\n"); 304*4dc607e7SEnji Cooper 305*4dc607e7SEnji Cooper #if defined(__i386__) 306*4dc607e7SEnji Cooper printf("not ok 4 - cexp reals # TODO: PR # 191676 fails assertion on i386\n"); 307*4dc607e7SEnji Cooper #else 308*4dc607e7SEnji Cooper test_reals(); 309*4dc607e7SEnji Cooper printf("ok 4 - cexp reals\n"); 310*4dc607e7SEnji Cooper #endif 311*4dc607e7SEnji Cooper 312*4dc607e7SEnji Cooper test_imaginaries(); 313*4dc607e7SEnji Cooper printf("ok 5 - cexp imaginaries\n"); 314*4dc607e7SEnji Cooper 315*4dc607e7SEnji Cooper test_small(); 316*4dc607e7SEnji Cooper printf("ok 6 - cexp small\n"); 317*4dc607e7SEnji Cooper 318*4dc607e7SEnji Cooper test_large(); 319*4dc607e7SEnji Cooper printf("ok 7 - cexp large\n"); 320*4dc607e7SEnji Cooper 321*4dc607e7SEnji Cooper return (0); 322*4dc607e7SEnji Cooper } 323