Update.
[glibc.git] / math / libm-test.c
blob0c65eb174f242cf487000953d9bdcd293efecf54
1 /* Copyright (C) 1997 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Andreas Jaeger <aj@arthur.pfalz.de>, 1997.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
22 Part of testsuite for libm.
24 This file has to be included by a master file that defines:
26 Makros:
27 FUNC(function): converts general function name (like cos) to
28 name with correct suffix (e.g. cosl or cosf)
29 MATHCONST(x): like FUNC but for constants (e.g convert 0.0 to 0.0L)
30 MATHTYPE: floating point type to test
31 TEST_MSG: informal message to be displayed
32 CHOOSE(Clongdouble,Cdouble,Cfloat):
33 chooses one of the parameters as epsilon for testing
34 equality
35 PRINTF_EXPR Floating point conversion specification to print a variable
36 of type MATHTYPE with printf. PRINTF_EXPR just contains
37 the specifier, not the percent and width arguments,
38 e.g. "f"
41 /* This program isn't finished yet.
42 It has tests for acos, acosh, asin, asinh, atan, atan2, atanh,
43 cbrt, ceil, copysign, cos, cosh, exp, exp2, expm1,
44 fabs, fdim, floor, fmin, fmax, fpclassify,
45 frexp, hypot, ilogb, ldexp,
46 log, log10, log1p, log2, logb, modf, nextafter,
47 pow, scalb, scalbn, sin, sinh, sqrt, tan, tanh, trunc.
48 Tests for the other libm-functions will come later.
50 The routines using random variables are still under construction. I don't
51 like it the way it's working now and will change it.
53 Exception handling has not been implemented so far so don't get fooled
54 that these tests pass.
56 Parameter handling is primitive in the moment:
57 --verbose=[0..3] for different levels of output:
58 0: only error count
59 1: basic report on failed tests
60 2: full report on failed tests
61 3: full report on failed and passed tests (default)
62 -v for full output (equals --verbose=3)
63 -s,--silent outputs only the error count (equals --verbose=0)
66 #ifndef _GNU_SOURCE
67 # define _GNU_SOURCE
68 #endif
70 #include <complex.h>
71 #include <math.h>
72 #include <float.h>
74 #include <errno.h>
75 #include <stdlib.h>
76 #include <stdio.h>
77 #include <time.h>
78 #include <getopt.h>
80 /* TEST_EXCEPTION: tests if an exception as occured */
81 /* for the moment: does nothing */
82 /* Possible exceptions */
83 #define NO_EXCEPTION 0x0
84 #define INVALID_EXCEPTION 0x1
85 #define DIVIDE_BY_ZERO_EXCEPTION 0x2
87 #define PRINT 1
88 #define NO_PRINT 0
90 #define TEST_EXCEPTION(test) do {} while (0);
91 /* As long as no exception code is available prevent warnings. */
92 #define UNUSED __attribute__ ((unused))
94 static int noErrors;
96 static int verbose = 3;
97 static MATHTYPE minus_zero, plus_zero;
98 static MATHTYPE plus_infty, minus_infty, nan_value;
100 typedef MATHTYPE (*mathfunc) (MATHTYPE);
102 #define BUILD_COMPLEX(real, imag) \
103 ({ __complex__ MATHTYPE __retval; \
104 __real__ __retval = (real); \
105 __imag__ __retval = (imag); \
106 __retval; })
109 #define ISINF(x) \
110 (sizeof (x) == sizeof (float) ? \
111 isinff (x) \
112 : sizeof (x) == sizeof (double) ? \
113 isinf (x) : isinfl (x))
117 Test if Floating-Point stack hasn't changed
119 static void
120 fpstack_test (const char *test_name)
122 #ifdef i386
123 static int old_stack;
124 int sw;
125 asm ("fnstsw":"=a" (sw));
126 sw >>= 11;
127 sw &= 7;
128 if (sw != old_stack)
130 printf ("FP-Stack wrong after test %s\n", test_name);
131 if (verbose > 2)
132 printf ("=======> stack = %d\n", sw);
133 ++noErrors;
134 old_stack = sw;
136 #endif
141 Get a random value x with min_value < x < max_value
142 and min_value, max_value finite,
143 max_value and min_value shouldn't be too close together
145 static MATHTYPE
146 random_value (MATHTYPE min_value, MATHTYPE max_value)
148 int r;
149 MATHTYPE x;
151 r = rand ();
153 x = (max_value - min_value) / RAND_MAX * (MATHTYPE) r + min_value;
155 if ((x <= min_value) || (x >= max_value) || !isfinite (x))
156 x = (max_value - min_value) / 2 + min_value;
158 return x;
161 /* Get a random value x with x > min_value. */
162 static MATHTYPE
163 random_greater (MATHTYPE min_value)
165 return random_value (min_value, 1e6); /* CHOOSE (LDBL_MAX, DBL_MAX, FLT_MAX) */
168 /* Get a random value x with x < max_value. */
169 static MATHTYPE
170 random_less (MATHTYPE max_value)
172 return random_value (-1e6, max_value);
176 /* Test if two floating point numbers are equal. */
177 static int
178 check_equal (MATHTYPE computed, MATHTYPE supplied, MATHTYPE eps, MATHTYPE * diff)
180 /* Both plus Infinity or both minus infinity. */
181 if (ISINF (computed) && (ISINF (computed) == ISINF (supplied)))
182 return 1;
184 if (isnan (computed) && isnan (supplied)) /* isnan works for all types */
185 return 1;
187 *diff = FUNC(fabs) (computed - supplied);
189 if (*diff <= eps && (signbit (computed) == signbit (supplied) || eps != 0.0))
190 return 1;
192 return 0;
196 static void
197 output_result_bool (const char *test_name, int result)
199 if (result)
201 if (verbose > 2)
202 printf ("Pass: %s\n", test_name);
204 else
206 if (verbose)
207 printf ("Fail: %s\n", test_name);
208 ++noErrors;
211 fpstack_test (test_name);
215 static void
216 output_isvalue (const char *test_name, int result,
217 MATHTYPE value)
219 if (result)
221 if (verbose > 2)
222 printf ("Pass: %s\n", test_name);
224 else
226 if (verbose)
227 printf ("Fail: %s\n", test_name);
228 if (verbose > 1)
229 printf (" Value: %.20" PRINTF_EXPR "\n", value);
230 noErrors++;
233 fpstack_test (test_name);
237 static void
238 output_isvalue_ext (const char *test_name, int result,
239 MATHTYPE value, MATHTYPE parameter)
241 if (result)
243 if (verbose > 2)
244 printf ("Pass: %s\n", test_name);
246 else
248 if (verbose)
249 printf ("Fail: %s\n", test_name);
250 if (verbose > 1)
252 printf (" Value: %.20" PRINTF_EXPR "\n", value);
253 printf (" Parameter: %.20" PRINTF_EXPR "\n", parameter);
255 noErrors++;
258 fpstack_test (test_name);
262 static void
263 output_result (const char *test_name, int result,
264 MATHTYPE computed, MATHTYPE expected,
265 MATHTYPE difference,
266 int print_values, int print_diff)
268 if (result)
270 if (verbose > 2)
271 printf ("Pass: %s\n", test_name);
273 else
275 if (verbose)
276 printf ("Fail: %s\n", test_name);
277 if (verbose > 1 && print_values)
279 printf ("Result:\n");
280 printf (" is: %.20" PRINTF_EXPR "\n", computed);
281 printf (" should be: %.20" PRINTF_EXPR "\n", expected);
282 if (print_diff)
283 printf (" difference: %.20" PRINTF_EXPR "\n", difference);
285 noErrors++;
288 fpstack_test (test_name);
292 static void
293 output_result_ext (const char *test_name, int result,
294 MATHTYPE computed, MATHTYPE expected,
295 MATHTYPE difference,
296 MATHTYPE parameter,
297 int print_values, int print_diff)
299 if (result)
301 if (verbose > 2)
302 printf ("Pass: %s\n", test_name);
304 else
306 if (verbose)
307 printf ("Fail: %s\n", test_name);
308 if (verbose > 1 && print_values)
310 printf ("Result:\n");
311 printf (" is: %.20" PRINTF_EXPR "\n", computed);
312 printf (" should be: %.20" PRINTF_EXPR "\n", expected);
313 if (print_diff)
314 printf (" difference: %.20" PRINTF_EXPR "\n", difference);
315 printf ("Parameter: %.20" PRINTF_EXPR "\n", parameter);
317 noErrors++;
320 fpstack_test (test_name);
324 static void
325 check (const char *test_name, MATHTYPE computed, MATHTYPE expected)
327 MATHTYPE diff;
328 int result;
330 result = check_equal (computed, expected, 0, &diff);
331 output_result (test_name, result,
332 computed, expected, diff, PRINT, PRINT);
336 static void
337 check_ext (const char *test_name, MATHTYPE computed, MATHTYPE expected,
338 MATHTYPE parameter)
340 MATHTYPE diff;
341 int result;
343 result = check_equal (computed, expected, 0, &diff);
344 output_result_ext (test_name, result,
345 computed, expected, diff, parameter, PRINT, PRINT);
349 static void
350 check_eps (const char *test_name, MATHTYPE computed, MATHTYPE expected,
351 MATHTYPE epsilon)
353 MATHTYPE diff;
354 int result;
356 result = check_equal (computed, expected, epsilon, &diff);
357 output_result (test_name, result,
358 computed, expected, diff, PRINT, PRINT);
362 static void
363 check_bool (const char *test_name, int computed)
365 output_result_bool (test_name, computed);
369 static void
370 check_isnan (const char *test_name, MATHTYPE computed)
372 output_isvalue (test_name, isnan (computed), computed);
376 static void
377 check_isnan_exc (const char *test_name, MATHTYPE computed,
378 short exception UNUSED)
380 output_isvalue (test_name, isnan (computed), computed);
384 static void
385 check_isnan_ext (const char *test_name, MATHTYPE computed,
386 MATHTYPE parameter)
388 output_isvalue_ext (test_name, isnan (computed), computed, parameter);
392 /* Tests if computed is +Inf */
393 static void
394 check_isinfp (const char *test_name, MATHTYPE computed)
396 output_isvalue (test_name, (ISINF (computed) == +1), computed);
400 static void
401 check_isinfp_ext (const char *test_name, MATHTYPE computed,
402 MATHTYPE parameter)
404 output_isvalue_ext (test_name, (ISINF (computed) == +1), computed, parameter);
408 /* Tests if computed is +Inf */
409 static void
410 check_isinfp_exc (const char *test_name, MATHTYPE computed,
411 int exception UNUSED)
413 output_isvalue (test_name, (ISINF (computed) == +1), computed);
416 /* Tests if computed is -Inf */
417 static void
418 check_isinfn (const char *test_name, MATHTYPE computed)
420 output_isvalue (test_name, (ISINF (computed) == -1), computed);
424 static void
425 check_isinfn_ext (const char *test_name, MATHTYPE computed,
426 MATHTYPE parameter)
428 output_isvalue_ext (test_name, (ISINF (computed) == -1), computed, parameter);
432 /* Tests if computed is -Inf */
433 static void
434 check_isinfn_exc (const char *test_name, MATHTYPE computed,
435 int exception UNUSED)
437 output_isvalue (test_name, (ISINF (computed) == -1), computed);
441 /****************************************************************************
442 Test for single functions of libm
443 ****************************************************************************/
445 static void
446 acos_test (void)
448 MATHTYPE x;
450 check ("acos (1) == 0", FUNC(acos) (1), 0);
452 x = random_greater (1);
453 check_isnan_exc ("acos (x) == NaN + invalid exception for |x| > 1",
454 FUNC(acos) (x),
455 INVALID_EXCEPTION);
458 static void
459 acosh_test (void)
461 MATHTYPE x;
463 check ("acosh(1) == 0", FUNC(acosh) (1), 0);
464 check_isinfp ("acosh(+inf) == +inf", FUNC(acosh) (plus_infty));
466 x = random_less (1);
467 check_isnan_exc ("acosh(x) == NaN plus invalid exception if x < 1",
468 FUNC(acosh) (x), INVALID_EXCEPTION);
472 static void
473 asin_test (void)
475 MATHTYPE x;
476 check ("asin (0) == 0", FUNC(asin) (0), 0);
478 x = random_greater (1);
479 check_isnan_exc ("asin x == NaN + invalid exception for |x| > 1",
480 FUNC(asin) (x),
481 INVALID_EXCEPTION);
484 static void
485 asinh_test (void)
488 check ("asinh(+0) == +0", FUNC(asinh) (0), 0);
489 check ("asinh(-0) == -0", FUNC(asinh) (minus_zero), minus_zero);
493 static void
494 atan_test (void)
496 check ("atan (0) == 0", FUNC(atan) (0), 0);
497 check ("atan (-0) == -0", FUNC(atan) (minus_zero), minus_zero);
499 check ("atan (+inf) == pi/2", FUNC(atan) (plus_infty), M_PI_2);
500 check ("atan (-inf) == -pi/2", FUNC(atan) (minus_infty), -M_PI_2);
504 static void
505 atan2_test (void)
507 MATHTYPE x;
509 x = random_greater (0);
510 check ("atan2 (0,x) == 0 for x > 0",
511 FUNC(atan2) (0, x), 0);
512 x = random_greater (0);
513 check ("atan2 (-0,x) == -0 for x > 0",
514 FUNC(atan2) (minus_zero, x), minus_zero);
516 check ("atan2 (+0,+0) == +0", FUNC(atan2) (0, 0), 0);
517 check ("atan2 (-0,+0) == -0", FUNC(atan2) (minus_zero, 0), minus_zero);
519 x = -random_greater (0);
520 check ("atan2 (+0,x) == +pi for x < 0", FUNC(atan2) (0, x), M_PI);
522 x = -random_greater (0);
523 check ("atan2 (-0,x) == -pi for x < 0", FUNC(atan2) (minus_zero, x), -M_PI);
525 check ("atan2 (+0,-0) == +pi", FUNC(atan2) (0, minus_zero), M_PI);
526 check ("atan2 (-0,-0) == -pi", FUNC(atan2) (minus_zero, minus_zero), -M_PI);
528 x = random_greater (0);
529 check ("atan2 (y,+0) == pi/2 for y > 0", FUNC(atan2) (x, 0), M_PI_2);
531 x = random_greater (0);
532 check ("atan2 (y,-0) == pi/2 for y > 0", FUNC(atan2) (x, minus_zero), M_PI_2);
534 x = random_greater (0);
535 check ("atan2 (y,-inf) == +pi for finite y > 0",
536 FUNC(atan2) (x, minus_infty), M_PI);
538 x = -random_greater (0);
539 check ("atan2 (y,-inf) == -pi for finite y < 0",
540 FUNC(atan2) (x, minus_infty), -M_PI);
542 check ("atan2 (+inf,+inf) == +pi/4",
543 FUNC(atan2) (plus_infty, plus_infty), M_PI_4);
545 check ("atan2 (-inf,+inf) == -pi/4",
546 FUNC(atan2) (minus_infty, plus_infty), -M_PI_4);
548 check ("atan2 (+inf,-inf) == +3*pi/4",
549 FUNC(atan2) (plus_infty, minus_infty), 3 * M_PI_4);
551 check ("atan2 (-inf,-inf) == -3*pi/4",
552 FUNC(atan2) (minus_infty, minus_infty), -3 * M_PI_4);
556 static void
557 atanh_test (void)
560 check ("atanh(+0) == +0", FUNC(atanh) (0), 0);
561 check ("atanh(-0) == -0", FUNC(atanh) (minus_zero), minus_zero);
562 check_isinfp_exc ("atanh(+1) == +inf plus divide-by-zero exception",
563 FUNC(atanh) (1), DIVIDE_BY_ZERO_EXCEPTION);
564 check_isinfn_exc ("atanh(-1) == -inf plus divide-by-zero exception",
565 FUNC(atanh) (-1), DIVIDE_BY_ZERO_EXCEPTION);
569 static void
570 cbrt_test (void)
572 check ("cbrt (+0) == +0", FUNC(cbrt) (0.0), 0.0);
573 check ("cbrt (-0) == -0", FUNC(cbrt) (minus_zero), minus_zero);
575 check_isinfp ("cbrt (+inf) == +inf", FUNC(cbrt) (plus_infty));
576 check_isinfn ("cbrt (-inf) == -inf", FUNC(cbrt) (minus_infty));
577 check_isnan ("cbrt (NaN) == NaN", FUNC(cbrt) (nan_value));
579 check ("cbrt (8) == 2", FUNC(cbrt) (8), 2);
580 check ("cbrt (-27) == -3", FUNC(cbrt) (-27.0), -3.0);
584 static void
585 ceil_test (void)
587 check ("ceil (+0) == +0", FUNC(ceil) (0.0), 0.0);
588 check ("ceil (-0) == -0", FUNC(ceil) (minus_zero), minus_zero);
589 check_isinfp ("ceil (+inf) == +inf", FUNC(ceil) (plus_infty));
590 check_isinfn ("ceil (-inf) == -inf", FUNC(ceil) (minus_infty));
592 check ("ceil (pi) == 4", FUNC(ceil) (M_PI), 4.0);
593 check ("ceil (-pi) == -3", FUNC(ceil) (-M_PI), -3.0);
597 static void
598 cos_test (void)
601 check ("cos (+0) == 1", FUNC(cos) (0), 1);
602 check ("cos (-0) == 1", FUNC(cos) (minus_zero), 1);
603 check_isnan_exc ("cos (+inf) == NaN plus invalid exception",
604 FUNC(cos) (plus_infty),
605 INVALID_EXCEPTION);
606 check_isnan_exc ("cos (-inf) == NaN plus invalid exception",
607 FUNC(cos) (minus_infty),
608 INVALID_EXCEPTION);
610 check_eps ("cos (pi/3) == 0.5", FUNC(cos) (M_PI / 3.0),
611 0.5, CHOOSE (4e-18L, 1e-15L, 1e-7L));
612 check_eps ("cos (pi/2) == 0", FUNC(cos) (M_PI_2),
613 0, CHOOSE (1e-19L, 1e-16L, 1e-7L));
617 static void
618 cosh_test (void)
620 check ("cosh (+0) == 1", FUNC(cosh) (0), 1);
621 check ("cosh (-0) == 1", FUNC(cosh) (minus_zero), 1);
623 check_isinfp ("cosh (+inf) == +inf", FUNC(cosh) (plus_infty));
624 check_isinfp ("cosh (-inf) == +inf", FUNC(cosh) (minus_infty));
628 static void
629 exp_test (void)
631 check ("exp (+0) == 1", FUNC(exp) (0), 1);
632 check ("exp (-0) == 1", FUNC(exp) (minus_zero), 1);
634 check_isinfp ("exp (+inf) == +inf", FUNC(exp) (plus_infty));
635 check ("exp (-inf) == 0", FUNC(exp) (minus_infty), 0);
637 check_eps ("exp (1) == e", FUNC(exp) (1), M_E, CHOOSE (4e-18L, 0, 0));
641 static void
642 exp2_test (void)
644 errno = 0;
645 exp2(0);
646 if (errno == ENOSYS)
647 /* Function not implemented. */
648 return;
650 check ("exp2 (+0) == 1", FUNC(exp2) (0), 1);
651 check ("exp2 (-0) == 1", FUNC(exp2) (minus_zero), 1);
653 check_isinfp ("exp2 (+inf) == +inf", FUNC(exp2) (plus_infty));
654 check ("exp2 (-inf) == 0", FUNC(exp2) (minus_infty), 0);
655 check ("exp2 (10) == 1024", FUNC(exp2) (10), 1024);
659 static void
660 expm1_test (void)
662 check ("expm1 (+0) == 0", FUNC(expm1) (0), 0);
663 check ("expm1 (-0) == -0", FUNC(expm1) (minus_zero), minus_zero);
665 check_isinfp ("expm1 (+inf) == +inf", FUNC(expm1) (plus_infty));
666 check ("expm1 (-inf) == -1", FUNC(expm1) (minus_infty), -1);
668 check_eps ("expm1 (1) == e-1", FUNC(expm1) (1), M_E - 1.0,
669 CHOOSE (4e-18L, 0, 0));
675 static void
676 check_frexp (const char *test_name, MATHTYPE computed, MATHTYPE expected,
677 int comp_int, int exp_int)
679 MATHTYPE diff;
680 int result;
682 result = (check_equal (computed, expected, 0, &diff)
683 && (comp_int == exp_int));
685 if (result)
687 if (verbose > 2)
688 printf ("Pass: %s\n", test_name);
690 else
692 if (verbose)
693 printf ("Fail: %s\n", test_name);
694 if (verbose > 1)
696 printf ("Result:\n");
697 printf (" is: %.20" PRINTF_EXPR " *2^%d\n", computed, comp_int);
698 printf (" should be: %.20" PRINTF_EXPR " *2^%d\n", expected, exp_int);
699 printf (" difference: %.20" PRINTF_EXPR "\n", diff);
701 noErrors++;
703 fpstack_test (test_name);
704 output_result (test_name, result,
705 computed, expected, diff, PRINT, PRINT);
709 static void
710 frexp_test (void)
712 int x_int;
713 MATHTYPE result;
715 result = FUNC(frexp) (plus_infty, &x_int);
716 check_isinfp ("frexp (+inf, expr) == +inf", result);
718 result = FUNC(frexp) (minus_infty, &x_int);
719 check_isinfn ("frexp (-inf, expr) == -inf", result);
721 result = FUNC(frexp) (nan_value, &x_int);
722 check_isnan ("frexp (Nan, expr) == NaN", result);
724 result = FUNC(frexp) (0, &x_int);
725 check_frexp ("frexp: +0 == 0 * 2^0", result, 0, x_int, 0);
727 result = FUNC(frexp) (minus_zero, &x_int);
728 check_frexp ("frexp: -0 == -0 * 2^0", result, minus_zero, x_int, 0);
730 result = FUNC(frexp) (12.8L, &x_int);
731 check_frexp ("frexp: 12.8 == 0.8 * 2^4", result, 0.8L, x_int, 4);
733 result = FUNC(frexp) (-27.34L, &x_int);
734 check_frexp ("frexp: -27.34 == -0.854375 * 2^5", result, -0.854375L, x_int, 5);
739 #if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 1)
740 /* All floating-point numbers can be put in one of these categories. */
741 enum
743 FP_NAN,
744 #define FP_NAN FP_NAN
745 FP_INFINITE,
746 #define FP_INFINITE FP_INFINITE
747 FP_ZERO,
748 #define FP_ZERO FP_ZERO
749 FP_SUBNORMAL,
750 #define FP_SUBNORMAL FP_SUBNORMAL
751 FP_NORMAL
752 #define FP_NORMAL FP_NORMAL
754 #endif
757 static void
758 fpclassify_test (void)
760 MATHTYPE x;
762 /* fpclassify is a macro, don't give it constants as parameter */
763 check_bool ("fpclassify (NaN) == FP_NAN", fpclassify (nan_value) == FP_NAN);
764 check_bool ("fpclassify (+inf) == FP_INFINITE",
765 fpclassify (plus_infty) == FP_INFINITE);
766 check_bool ("fpclassify (-inf) == FP_INFINITE",
767 fpclassify (minus_infty) == FP_INFINITE);
768 check_bool ("fpclassify (+0) == FP_ZERO",
769 fpclassify (plus_zero) == FP_ZERO);
770 check_bool ("fpclassify (-0) == FP_ZERO",
771 fpclassify (minus_zero) == FP_ZERO);
773 x = 1000.0;
774 check_bool ("fpclassify (1000) == FP_NORMAL",
775 fpclassify (x) == FP_NORMAL);
779 static void
780 ilogb_test (void)
783 /* XXX Are these tests correct? I couldn't find any specification */
784 #if 0
785 /* the source suggests that the following calls should fail -
786 but shall we test these special cases or just ignore them? */
787 check_isinfp ("ilogb (+inf) == +inf", FUNC(ilogb) (plus_infty));
788 check_isinfp ("ilogb (-inf) == +inf", FUNC(ilogb) (minus_infty));
790 check_isinfn_exc ("ilogb (+0) == -inf plus divide-by-zero exception",
791 FUNC(ilogb) (0), DIVIDE_BY_ZERO_EXCEPTION);
793 check_isinfn_exc ("ilogb (-0) == -inf plus divide-by-zero exception",
794 FUNC(ilogb) (minus_zero), DIVIDE_BY_ZERO_EXCEPTION);
795 #endif
796 check ("ilogb (1) == 0", FUNC(ilogb) (1), 0);
797 check ("ilogb (e) == 1", FUNC(ilogb) (M_E), 1);
798 check ("ilogb (1024) == 10", FUNC(ilogb) (1024), 10);
799 check ("ilogb (-2000) == 10", FUNC(ilogb) (-2000), 10);
804 static void
805 ldexp_test (void)
807 MATHTYPE x;
809 check ("ldexp (0, 0) == 0", FUNC(ldexp) (0, 0), 0);
811 check_isinfp ("ldexp (+inf, 1) == +inf", FUNC(ldexp) (plus_infty, 1));
812 check_isinfn ("ldexp (-inf, 1) == -inf", FUNC(ldexp) (minus_infty, 1));
813 check_isnan ("ldexp (NaN, 1) == NaN", FUNC(ldexp) (nan_value, 1));
815 check ("ldexp (0.8, 4) == 12.8", FUNC(ldexp) (0.8L, 4), 12.8L);
816 check ("ldexp (-0.854375, 5) == -27.34", FUNC(ldexp) (-0.854375L, 5), -27.34L);
818 x = random_greater (0.0);
819 check_ext ("ldexp (x, 0) == x", FUNC(ldexp) (x, 0L), x, x);
824 static void
825 log_test (void)
827 check_isinfn_exc ("log (+0) == -inf", FUNC(log) (0),
828 DIVIDE_BY_ZERO_EXCEPTION);
829 check_isinfn_exc ("log (-0) == -inf", FUNC(log) (minus_zero),
830 DIVIDE_BY_ZERO_EXCEPTION);
832 check ("log (1) == 0", FUNC(log) (1), 0);
834 check_isnan_exc ("log (x) == NaN plus divide-by-zero exception if x < 0",
835 FUNC(log) (-1), INVALID_EXCEPTION);
836 check_isinfp ("log (+inf) == +inf", FUNC(log) (plus_infty));
838 check_eps ("log (e) == 1", FUNC(log) (M_E), 1, CHOOSE (1e-18L, 0, 9e-8L));
839 check_eps ("log (1/e) == -1", FUNC(log) (1.0 / M_E), -1,
840 CHOOSE (2e-18L, 0, 0));
841 check ("log (2) == M_LN2", FUNC(log) (2), M_LN2);
842 check_eps ("log (10) == M_LN10", FUNC(log) (10), M_LN10,
843 CHOOSE (1e-18L, 0, 0));
847 static void
848 log10_test (void)
850 check_isinfn_exc ("log10 (+0) == -inf", FUNC(log10) (0),
851 DIVIDE_BY_ZERO_EXCEPTION);
852 check_isinfn_exc ("log10 (-0) == -inf", FUNC(log10) (minus_zero),
853 DIVIDE_BY_ZERO_EXCEPTION);
855 check ("log10 (1) == +0", FUNC(log10) (1), 0);
857 check_isnan_exc ("log10 (x) == NaN plus divide-by-zero exception if x < 0",
858 FUNC(log10) (-1), INVALID_EXCEPTION);
860 check_isinfp ("log10 (+inf) == +inf", FUNC(log10) (plus_infty));
862 check_eps ("log10 (0.1) == -1", FUNC(log10) (0.1L), -1,
863 CHOOSE (1e-18L, 0, 0));
864 check_eps ("log10 (10) == 1", FUNC(log10) (10.0), 1,
865 CHOOSE (1e-18L, 0, 0));
866 check_eps ("log10 (100) == 2", FUNC(log10) (100.0), 2,
867 CHOOSE (1e-18L, 0, 0));
868 check ("log10 (10000) == 4", FUNC(log10) (10000.0), 4);
869 check_eps ("log10 (e) == M_LOG10E", FUNC(log10) (M_E), M_LOG10E,
870 CHOOSE (1e-18, 0, 9e-8));
874 static void
875 log1p_test (void)
877 check ("log1p (+0) == +0", FUNC(log1p) (0), 0);
878 check ("log1p (-0) == -0", FUNC(log1p) (minus_zero), minus_zero);
880 check_isinfn_exc ("log1p (-1) == -inf", FUNC(log1p) (-1),
881 DIVIDE_BY_ZERO_EXCEPTION);
882 check_isnan_exc ("log1p (x) == NaN plus divide-by-zero exception if x < -1",
883 FUNC(log1p) (-2), INVALID_EXCEPTION);
885 check_isinfp ("log1p (+inf) == +inf", FUNC(log1p) (plus_infty));
887 check_eps ("log1p (e-1) == 1", FUNC(log1p) (M_E - 1.0), 1,
888 CHOOSE (1e-18L, 0, 0));
893 static void
894 log2_test (void)
896 check_isinfn_exc ("log2 (+0) == -inf", FUNC(log2) (0),
897 DIVIDE_BY_ZERO_EXCEPTION);
898 check_isinfn_exc ("log2 (-0) == -inf", FUNC(log2) (minus_zero),
899 DIVIDE_BY_ZERO_EXCEPTION);
901 check ("log2 (1) == +0", FUNC(log2) (1), 0);
903 check_isnan_exc ("log2 (x) == NaN plus divide-by-zero exception if x < 0",
904 FUNC(log2) (-1), INVALID_EXCEPTION);
906 check_isinfp ("log2 (+inf) == +inf", FUNC(log2) (plus_infty));
908 check_eps ("log2 (e) == M_LOG2E", FUNC(log2) (M_E), M_LOG2E,
909 CHOOSE (1e-18L, 0, 0));
910 check ("log2 (2) == 1", FUNC(log2) (2.0), 1);
911 check_eps ("log2 (16) == 4", FUNC(log2) (16.0), 4, CHOOSE (1e-18L, 0, 0));
912 check ("log2 (256) == 8", FUNC(log2) (256.0), 8);
917 static void
918 logb_test (void)
920 check_isinfp ("logb (+inf) == +inf", FUNC(logb) (plus_infty));
921 check_isinfp ("logb (-inf) == +inf", FUNC(logb) (minus_infty));
923 check_isinfn_exc ("logb (+0) == -inf plus divide-by-zero exception",
924 FUNC(logb) (0), DIVIDE_BY_ZERO_EXCEPTION);
926 check_isinfn_exc ("logb (-0) == -inf plus divide-by-zero exception",
927 FUNC(logb) (minus_zero), DIVIDE_BY_ZERO_EXCEPTION);
929 check ("logb (1) == 0", FUNC(logb) (1), 0);
930 check ("logb (e) == 1", FUNC(logb) (M_E), 1);
931 check ("logb (1024) == 10", FUNC(logb) (1024), 10);
932 check ("logb (-2000) == 10", FUNC(logb) (-2000), 10);
937 static void
938 modf_test (void)
940 MATHTYPE result, intpart;
942 result = FUNC(modf) (plus_infty, &intpart);
943 check ("modf (+inf, &x) returns +0", result, 0);
944 check_isinfp ("modf (+inf, &x) set x to +inf", intpart);
946 result = FUNC(modf) (minus_infty, &intpart);
947 check ("modf (-inf, &x) returns -0", result, minus_zero);
948 check_isinfn ("modf (-inf, &x) sets x to -inf", intpart);
950 result = FUNC(modf) (nan_value, &intpart);
951 check_isnan ("modf (NaN, &x) returns NaN", result);
952 check_isnan ("modf (NaN, &x) sets x to NaN", intpart);
954 result = FUNC(modf) (0, &intpart);
955 check ("modf (0, &x) returns 0", result, 0);
956 check ("modf (0, &x) sets x to 0", intpart, 0);
958 result = FUNC(modf) (minus_zero, &intpart);
959 check ("modf (-0, &x) returns -0", result, minus_zero);
960 check ("modf (-0, &x) sets x to -0", intpart, minus_zero);
962 result = FUNC(modf) (2.5, &intpart);
963 check ("modf (2.5, &x) returns 0.5", result, 0.5);
964 check ("modf (2.5, &x) sets x to 2", intpart, 2);
966 result = FUNC(modf) (-2.5, &intpart);
967 check ("modf (-2.5, &x) returns -0.5", result, -0.5);
968 check ("modf (-2.5, &x) sets x to -2", intpart, -2);
973 static void
974 scalb_test (void)
976 MATHTYPE x;
978 check ("scalb (0, 0) == 0", FUNC(scalb) (0, 0), 0);
980 check_isinfp ("scalb (+inf, 1) == +inf", FUNC(scalb) (plus_infty, 1));
981 check_isinfn ("scalb (-inf, 1) == -inf", FUNC(scalb) (minus_infty, 1));
982 check_isnan ("scalb (NaN, 1) == NaN", FUNC(scalb) (nan_value, 1));
984 check ("scalb (0.8, 4) == 12.8", FUNC(scalb) (0.8L, 4), 12.8L);
985 check ("scalb (-0.854375, 5) == -27.34", FUNC(scalb) (-0.854375L, 5), -27.34L);
987 x = random_greater (0.0);
988 check_ext ("scalb (x, 0) == x", FUNC(scalb) (x, 0L), x, x);
992 static void
993 scalbn_test (void)
995 MATHTYPE x;
997 check ("scalbn (0, 0) == 0", FUNC(scalbn) (0, 0), 0);
999 check_isinfp ("scalbn (+inf, 1) == +inf", FUNC(scalbn) (plus_infty, 1));
1000 check_isinfn ("scalbn (-inf, 1) == -inf", FUNC(scalbn) (minus_infty, 1));
1001 check_isnan ("scalbn (NaN, 1) == NaN", FUNC(scalbn) (nan_value, 1));
1003 check ("scalbn (0.8, 4) == 12.8", FUNC(scalbn) (0.8L, 4), 12.8L);
1004 check ("scalbn (-0.854375, 5) == -27.34", FUNC(scalbn) (-0.854375L, 5), -27.34L);
1006 x = random_greater (0.0);
1007 check_ext ("scalbn (x, 0) == x", FUNC(scalbn) (x, 0L), x, x);
1011 static void
1012 sin_test (void)
1014 check ("sin (+0) == +0", FUNC(sin) (0), 0);
1015 check ("sin (-0) == -0", FUNC(sin) (minus_zero), minus_zero);
1016 check_isnan_exc ("sin (+inf) == NaN plus invalid exception",
1017 FUNC(sin) (plus_infty),
1018 INVALID_EXCEPTION);
1019 check_isnan_exc ("sin (-inf) == NaN plus invalid exception",
1020 FUNC(sin) (minus_infty),
1021 INVALID_EXCEPTION);
1023 check_eps ("sin (pi/6) == 0.5", FUNC(sin) (M_PI / 6.0), 0.5,
1024 CHOOSE (4e-18L, 0, 0));
1025 check ("sin (pi/2) == 1", FUNC(sin) (M_PI_2), 1);
1029 static void
1030 sinh_test (void)
1032 check ("sinh (+0) == +0", FUNC(sinh) (0), 0);
1033 check ("sinh (-0) == -0", FUNC(sinh) (minus_zero), minus_zero);
1035 check_isinfp ("sinh (+inf) == +inf", FUNC(sinh) (plus_infty));
1036 check_isinfn ("sinh (-inf) == -inf", FUNC(sinh) (minus_infty));
1040 static void
1041 tan_test (void)
1043 check ("tan (+0) == +0", FUNC(tan) (0), 0);
1044 check ("tan (-0) == -0", FUNC(tan) (minus_zero), minus_zero);
1045 check_isnan_exc ("tan (+inf) == NaN plus invalid exception",
1046 FUNC(tan) (plus_infty), INVALID_EXCEPTION);
1047 check_isnan_exc ("tan (-inf) == NaN plus invalid exception",
1048 FUNC(tan) (minus_infty), INVALID_EXCEPTION);
1050 check_eps ("tan (pi/4) == 1", FUNC(tan) (M_PI_4), 1,
1051 CHOOSE (2e-18L, 1e-15L, 0));
1055 static void
1056 tanh_test (void)
1058 check ("tanh (+0) == +0", FUNC(tanh) (0), 0);
1059 check ("tanh (-0) == -0", FUNC(tanh) (minus_zero), minus_zero);
1061 check ("tanh (+inf) == +1", FUNC(tanh) (plus_infty), 1);
1062 check ("tanh (-inf) == -1", FUNC(tanh) (minus_infty), -1);
1066 static void
1067 fabs_test (void)
1069 check ("fabs (+0) == +0", FUNC(fabs) (0), 0);
1070 check ("fabs (-0) == +0", FUNC(fabs) (minus_zero), 0);
1072 check_isinfp ("fabs (+inf) == +inf", FUNC(fabs) (plus_infty));
1073 check_isinfp ("fabs (-inf) == +inf", FUNC(fabs) (minus_infty));
1075 check ("fabs (+38) == 38", FUNC(fabs) (38.0), 38.0);
1076 check ("fabs (-e) == e", FUNC(fabs) (-M_E), M_E);
1080 static void
1081 floor_test (void)
1083 check ("floor (+0) == +0", FUNC(floor) (0.0), 0.0);
1084 check ("floor (-0) == -0", FUNC(floor) (minus_zero), minus_zero);
1085 check_isinfp ("floor (+inf) == +inf", FUNC(floor) (plus_infty));
1086 check_isinfn ("floor (-inf) == -inf", FUNC(floor) (minus_infty));
1088 check ("floor (pi) == 3", FUNC(floor) (M_PI), 3.0);
1089 check ("floor (-pi) == -4", FUNC(floor) (-M_PI), -4.0);
1093 static void
1094 hypot_test (void)
1096 MATHTYPE a;
1098 a = random_greater (0);
1099 check_isinfp_ext ("hypot (+inf, x) == +inf", FUNC(hypot) (plus_infty, a), a);
1100 check_isinfp_ext ("hypot (-inf, x) == +inf", FUNC(hypot) (minus_infty, a), a);
1102 check_isnan ("hypot (NaN, NaN) == NaN", FUNC(hypot) (nan_value, nan_value));
1104 a = FUNC(hypot) (12.4L, 0.7L);
1105 check ("hypot (x,y) == hypot (y,x)", FUNC(hypot) (0.7L, 12.4L), a);
1106 check ("hypot (x,y) == hypot (-x,y)", FUNC(hypot) (-12.4L, 0.7L), a);
1107 check ("hypot (x,y) == hypot (-y,x)", FUNC(hypot) (-0.7L, 12.4L), a);
1108 check ("hypot (x,y) == hypot (-x,-y)", FUNC(hypot) (-12.4L, -0.7L), a);
1109 check ("hypot (x,y) == hypot (-y,-x)", FUNC(hypot) (-0.7L, -12.4L), a);
1110 check ("hypot (x,0) == fabs (x)", FUNC(hypot) (-0.7L, 0), 0.7L);
1111 check ("hypot (x,0) == fabs (x)", FUNC(hypot) (0.7L, 0), 0.7L);
1112 check ("hypot (x,0) == fabs (x)", FUNC(hypot) (-1.0L, 0), 1.0L);
1113 check ("hypot (x,0) == fabs (x)", FUNC(hypot) (1.0L, 0), 1.0L);
1114 check ("hypot (x,0) == fabs (x)", FUNC(hypot) (-5.7e7L, 0), 5.7e7L);
1115 check ("hypot (x,0) == fabs (x)", FUNC(hypot) (5.7e7L, 0), 5.7e7L);
1119 static void
1120 pow_test (void)
1122 MATHTYPE x;
1124 check ("pow (+0, +0) == 1", FUNC(pow) (0, 0), 1);
1125 check ("pow (+0, -0) == 1", FUNC(pow) (0, minus_zero), 1);
1126 check ("pow (-0, +0) == 1", FUNC(pow) (minus_zero, 0), 1);
1127 check ("pow (-0, -0) == 1", FUNC(pow) (minus_zero, minus_zero), 1);
1129 check ("pow (+10, +0) == 1", FUNC(pow) (10, 0), 1);
1130 check ("pow (+10, -0) == 1", FUNC(pow) (10, minus_zero), 1);
1131 check ("pow (-10, +0) == 1", FUNC(pow) (-10, 0), 1);
1132 check ("pow (-10, -0) == 1", FUNC(pow) (-10, minus_zero), 1);
1134 check ("pow (NaN, +0) == 1", FUNC(pow) (nan_value, 0), 1);
1135 check ("pow (NaN, -0) == 1", FUNC(pow) (nan_value, minus_zero), 1);
1137 check_isinfp ("pow (+1.1, +inf) == +inf", FUNC(pow) (1.1, plus_infty));
1138 check_isinfp ("pow (+inf, +inf) == +inf", FUNC(pow) (plus_infty, plus_infty));
1139 check_isinfp ("pow (-1.1, +inf) == +inf", FUNC(pow) (-1.1, plus_infty));
1140 check_isinfp ("pow (-inf, +inf) == +inf", FUNC(pow) (minus_infty, plus_infty));
1142 check ("pow (0.9, +inf) == +0", FUNC(pow) (0.9L, plus_infty), 0);
1143 check ("pow (1e-7, +inf) == +0", FUNC(pow) (1e-7L, plus_infty), 0);
1144 check ("pow (-0.9, +inf) == +0", FUNC(pow) (-0.9L, plus_infty), 0);
1145 check ("pow (-1e-7, +inf) == +0", FUNC(pow) (-1e-7L, plus_infty), 0);
1147 check ("pow (+1.1, -inf) == 0", FUNC(pow) (1.1, minus_infty), 0);
1148 check ("pow (+inf, -inf) == 0", FUNC(pow) (plus_infty, minus_infty), 0);
1149 check ("pow (-1.1, -inf) == 0", FUNC(pow) (-1.1, minus_infty), 0);
1150 check ("pow (-inf, -inf) == 0", FUNC(pow) (minus_infty, minus_infty), 0);
1152 check_isinfp ("pow (0.9, -inf) == +inf", FUNC(pow) (0.9L, minus_infty));
1153 check_isinfp ("pow (1e-7, -inf) == +inf", FUNC(pow) (1e-7L, minus_infty));
1154 check_isinfp ("pow (-0.9, -inf) == +inf", FUNC(pow) (-0.9L, minus_infty));
1155 check_isinfp ("pow (-1e-7, -inf) == +inf", FUNC(pow) (-1e-7L, minus_infty));
1157 check_isinfp ("pow (+inf, 1e-7) == +inf", FUNC(pow) (plus_infty, 1e-7L));
1158 check_isinfp ("pow (+inf, 1) == +inf", FUNC(pow) (plus_infty, 1));
1159 check_isinfp ("pow (+inf, 1e7) == +inf", FUNC(pow) (plus_infty, 1e7L));
1161 check ("pow (+inf, -1e-7) == 0", FUNC(pow) (plus_infty, -1e-7L), 0);
1162 check ("pow (+inf, -1) == 0", FUNC(pow) (plus_infty, -1), 0);
1163 check ("pow (+inf, -1e7) == 0", FUNC(pow) (plus_infty, -1e7L), 0);
1165 check_isinfn ("pow (-inf, 1) == -inf", FUNC(pow) (minus_infty, 1));
1166 check_isinfn ("pow (-inf, 11) == -inf", FUNC(pow) (minus_infty, 11));
1167 check_isinfn ("pow (-inf, 1001) == -inf", FUNC(pow) (minus_infty, 1001));
1169 check_isinfp ("pow (-inf, 2) == +inf", FUNC(pow) (minus_infty, 2));
1170 check_isinfp ("pow (-inf, 12) == +inf", FUNC(pow) (minus_infty, 12));
1171 check_isinfp ("pow (-inf, 1002) == +inf", FUNC(pow) (minus_infty, 1002));
1172 check_isinfp ("pow (-inf, 0.1) == +inf", FUNC(pow) (minus_infty, 0.1));
1173 check_isinfp ("pow (-inf, 1.1) == +inf", FUNC(pow) (minus_infty, 1.1));
1174 check_isinfp ("pow (-inf, 11.1) == +inf", FUNC(pow) (minus_infty, 11.1));
1175 check_isinfp ("pow (-inf, 1001.1) == +inf", FUNC(pow) (minus_infty, 1001.1));
1177 check ("pow (-inf, -1) == -0", FUNC(pow) (minus_infty, -1), minus_zero);
1178 check ("pow (-inf, -11) == -0", FUNC(pow) (minus_infty, -11), minus_zero);
1179 check ("pow (-inf, -1001) == -0", FUNC(pow) (minus_infty, -1001), minus_zero);
1181 check ("pow (-inf, -2) == +0", FUNC(pow) (minus_infty, -2), 0);
1182 check ("pow (-inf, -12) == +0", FUNC(pow) (minus_infty, -12), 0);
1183 check ("pow (-inf, -1002) == +0", FUNC(pow) (minus_infty, -1002), 0);
1184 check ("pow (-inf, -0.1) == +0", FUNC(pow) (minus_infty, -0.1), 0);
1185 check ("pow (-inf, -1.1) == +0", FUNC(pow) (minus_infty, -1.1), 0);
1186 check ("pow (-inf, -11.1) == +0", FUNC(pow) (minus_infty, -11.1), 0);
1187 check ("pow (-inf, -1001.1) == +0", FUNC(pow) (minus_infty, -1001.1), 0);
1189 check_isnan ("pow (NaN, NaN) == NaN", FUNC(pow) (nan_value, nan_value));
1190 check_isnan ("pow (0, NaN) == NaN", FUNC(pow) (0, nan_value));
1191 check_isnan ("pow (1, NaN) == NaN", FUNC(pow) (1, nan_value));
1192 check_isnan ("pow (-1, NaN) == NaN", FUNC(pow) (-1, nan_value));
1193 check_isnan ("pow (NaN, 1) == NaN", FUNC(pow) (nan_value, 1));
1194 check_isnan ("pow (NaN, -1) == NaN", FUNC(pow) (nan_value, -1));
1196 x = random_greater (0.0);
1197 check_isnan_ext ("pow (x, NaN) == NaN", FUNC(pow) (x, nan_value), x);
1199 check_isnan_exc ("pow (+1, +inf) == NaN", FUNC(pow) (1, plus_infty),
1200 INVALID_EXCEPTION);
1201 check_isnan_exc ("pow (-1, +inf) == NaN", FUNC(pow) (-1, plus_infty),
1202 INVALID_EXCEPTION);
1203 check_isnan_exc ("pow (+1, -inf) == NaN", FUNC(pow) (1, minus_infty),
1204 INVALID_EXCEPTION);
1205 check_isnan_exc ("pow (-1, -inf) == NaN", FUNC(pow) (-1, minus_infty),
1206 INVALID_EXCEPTION);
1208 check_isnan_exc ("pow (-0.1, 1.1) == NaN", FUNC(pow) (-0.1, 1.1),
1209 INVALID_EXCEPTION);
1210 check_isnan_exc ("pow (-0.1, -1.1) == NaN", FUNC(pow) (-0.1, -1.1),
1211 INVALID_EXCEPTION);
1212 check_isnan_exc ("pow (-10.1, 1.1) == NaN", FUNC(pow) (-10.1, 1.1),
1213 INVALID_EXCEPTION);
1214 check_isnan_exc ("pow (-10.1, -1.1) == NaN", FUNC(pow) (-10.1, -1.1),
1215 INVALID_EXCEPTION);
1217 check_isinfp_exc ("pow (+0, -1) == +inf", FUNC(pow) (0, -1),
1218 DIVIDE_BY_ZERO_EXCEPTION);
1219 check_isinfp_exc ("pow (+0, -11) == +inf", FUNC(pow) (0, -11),
1220 DIVIDE_BY_ZERO_EXCEPTION);
1221 check_isinfn_exc ("pow (-0, -1) == -inf", FUNC(pow) (minus_zero, -1),
1222 DIVIDE_BY_ZERO_EXCEPTION);
1223 check_isinfn_exc ("pow (-0, -11) == -inf", FUNC(pow) (minus_zero, -11),
1224 DIVIDE_BY_ZERO_EXCEPTION);
1226 check_isinfp_exc ("pow (+0, -2) == +inf", FUNC(pow) (0, -2),
1227 DIVIDE_BY_ZERO_EXCEPTION);
1228 check_isinfp_exc ("pow (+0, -11.1) == +inf", FUNC(pow) (0, -11.1),
1229 DIVIDE_BY_ZERO_EXCEPTION);
1230 check_isinfp_exc ("pow (-0, -2) == +inf", FUNC(pow) (minus_zero, -2),
1231 DIVIDE_BY_ZERO_EXCEPTION);
1232 check_isinfp_exc ("pow (-0, -11.1) == +inf", FUNC(pow) (minus_zero, -11.1),
1233 DIVIDE_BY_ZERO_EXCEPTION);
1235 check ("pow (+0, 1) == +0", FUNC(pow) (0, 1), 0);
1236 check ("pow (+0, 11) == +0", FUNC(pow) (0, 11), 0);
1237 check ("pow (-0, 1) == -0", FUNC(pow) (minus_zero, 1), minus_zero);
1238 check ("pow (-0, 11) == -0", FUNC(pow) (minus_zero, 11), minus_zero);
1240 check ("pow (+0, 2) == +0", FUNC(pow) (0, 2), 0);
1241 check ("pow (+0, 11.1) == +0", FUNC(pow) (0, 11.1), 0);
1242 check ("pow (-0, 2) == +0", FUNC(pow) (minus_zero, 2), 0);
1243 check ("pow (-0, 11.1) == +0", FUNC(pow) (minus_zero, 11.1), 0);
1245 x = random_greater (1.0);
1246 check_isinfp_ext ("pow (x, +inf) == +inf for |x| > 1",
1247 FUNC(pow) (x, plus_infty), x);
1249 x = random_value (-1.0, 1.0);
1250 check_ext ("pow (x, +inf) == +0 for |x| < 1",
1251 FUNC(pow) (x, plus_infty), 0.0, x);
1253 x = random_greater (1.0);
1254 check_ext ("pow (x, -inf) == +0 for |x| > 1",
1255 FUNC(pow) (x, minus_infty), 0.0, x);
1257 x = random_value (-1.0, 1.0);
1258 check_isinfp_ext ("pow (x, -inf) == +inf for |x| < 1",
1259 FUNC(pow) (x, minus_infty), x);
1261 x = random_greater (0.0);
1262 check_isinfp_ext ("pow (+inf, y) == +inf for y > 0",
1263 FUNC(pow) (plus_infty, x), x);
1265 x = random_less (0.0);
1266 check_ext ("pow (+inf, y) == +0 for y < 0",
1267 FUNC(pow) (plus_infty, x), 0.0, x);
1269 x = (rand () % 1000000) * 2.0 + 1; /* Get random odd integer > 0 */
1270 check_isinfn_ext ("pow (-inf, y) == -inf for y an odd integer > 0",
1271 FUNC(pow) (minus_infty, x), x);
1273 x = ((rand () % 1000000) + 1) * 2.0; /* Get random even integer > 1 */
1274 check_isinfp_ext ("pow (-inf, y) == +inf for y > 0 and not an odd integer",
1275 FUNC(pow) (minus_infty, x), x);
1277 x = -((rand () % 1000000) * 2.0 + 1); /* Get random odd integer < 0 */
1278 check_ext ("pow (-inf, y) == -0 for y an odd integer < 0",
1279 FUNC(pow) (minus_infty, x), minus_zero, x);
1281 x = ((rand () % 1000000) + 1) * -2.0; /* Get random even integer < 0 */
1282 check_ext ("pow (-inf, y) == +0 for y < 0 and not an odd integer",
1283 FUNC(pow) (minus_infty, x), 0.0, x);
1285 x = (rand () % 1000000) * 2.0 + 1; /* Get random odd integer > 0 */
1286 check_ext ("pow (+0, y) == +0 for y an odd integer > 0",
1287 FUNC(pow) (0.0, x), 0.0, x);
1288 x = (rand () % 1000000) * 2.0 + 1; /* Get random odd integer > 0 */
1289 check_ext ("pow (-0, y) == -0 for y an odd integer > 0",
1290 FUNC(pow) (minus_zero, x), minus_zero, x);
1292 x = ((rand () % 1000000) + 1) * 2.0; /* Get random even integer > 1 */
1293 check_ext ("pow (+0, y) == +0 for y > 0 and not an odd integer",
1294 FUNC(pow) (0.0, x), 0.0, x);
1296 x = ((rand () % 1000000) + 1) * 2.0; /* Get random even integer > 1 */
1297 check_ext ("pow (-0, y) == +0 for y > 0 and not an odd integer",
1298 FUNC(pow) (minus_zero, x), 0.0, x);
1302 static void
1303 fdim_test (void)
1305 check ("fdim (+0, +0) = +0", FUNC(fdim) (0, 0), 0);
1306 check ("fdim (9, 0) = 9", FUNC(fdim) (9, 0), 9);
1307 check ("fdim (0, 9) = 0", FUNC(fdim) (0, 9), 0);
1308 check ("fdim (-9, 0) = 9", FUNC(fdim) (-9, 0), 0);
1309 check ("fdim (0, -9) = 9", FUNC(fdim) (0, -9), 9);
1311 check_isinfp ("fdim (+inf, 9) = +inf", FUNC(fdim) (plus_infty, 9));
1312 check_isinfp ("fdim (+inf, -9) = +inf", FUNC(fdim) (plus_infty, -9));
1313 check ("fdim (-inf, 9) = 0", FUNC(fdim) (minus_infty, 9), 0);
1314 check ("fdim (-inf, -9) = 0", FUNC(fdim) (minus_infty, -9), 0);
1315 check_isinfp ("fdim (+9, -inf) = +inf", FUNC(fdim) (9, minus_infty));
1316 check_isinfp ("fdim (-9, -inf) = +inf", FUNC(fdim) (-9, minus_infty));
1317 check ("fdim (9, inf) = 0", FUNC(fdim) (9, plus_infty), 0);
1318 check ("fdim (-9, inf) = 0", FUNC(fdim) (-9, plus_infty), 0);
1320 check_isnan ("fdim (0, NaN) = NaN", FUNC(fdim) (0, nan_value));
1321 check_isnan ("fdim (9, NaN) = NaN", FUNC(fdim) (9, nan_value));
1322 check_isnan ("fdim (-9, NaN) = NaN", FUNC(fdim) (-9, nan_value));
1323 check_isnan ("fdim (NaN, 9) = NaN", FUNC(fdim) (nan_value, 9));
1324 check_isnan ("fdim (NaN, -9) = NaN", FUNC(fdim) (nan_value, -9));
1325 check_isnan ("fdim (+inf, NaN) = NaN", FUNC(fdim) (plus_infty, nan_value));
1326 check_isnan ("fdim (-inf, NaN) = NaN", FUNC(fdim) (minus_infty, nan_value));
1327 check_isnan ("fdim (NaN, +inf) = NaN", FUNC(fdim) (nan_value, plus_infty));
1328 check_isnan ("fdim (NaN, -inf) = NaN", FUNC(fdim) (nan_value, minus_infty));
1329 check_isnan ("fdim (NaN, NaN) = NaN", FUNC(fdim) (nan_value, nan_value));
1333 static void
1334 fmin_test (void)
1336 check ("fmin (+0, +0) = +0", FUNC(fmin) (0, 0), 0);
1337 check ("fmin (9, 0) = 0", FUNC(fmin) (9, 0), 0);
1338 check ("fmin (0, 9) = 0", FUNC(fmin) (0, 9), 0);
1339 check ("fmin (-9, 0) = -9", FUNC(fmin) (-9, 0), -9);
1340 check ("fmin (0, -9) = -9", FUNC(fmin) (0, -9), -9);
1342 check ("fmin (+inf, 9) = 9", FUNC(fmin) (plus_infty, 9), 9);
1343 check ("fmin (9, +inf) = 9", FUNC(fmin) (9, plus_infty), 9);
1344 check ("fmin (+inf, -9) = -9", FUNC(fmin) (plus_infty, -9), -9);
1345 check ("fmin (-9, +inf) = -9", FUNC(fmin) (-9, plus_infty), -9);
1346 check_isinfn ("fmin (-inf, 9) = -inf", FUNC(fmin) (minus_infty, 9));
1347 check_isinfn ("fmin (-inf, -9) = -inf", FUNC(fmin) (minus_infty, -9));
1348 check_isinfn ("fmin (+9, -inf) = -inf", FUNC(fmin) (9, minus_infty));
1349 check_isinfn ("fmin (-9, -inf) = -inf", FUNC(fmin) (-9, minus_infty));
1351 check ("fmin (0, NaN) = 0", FUNC(fmin) (0, nan_value), 0);
1352 check ("fmin (9, NaN) = 9", FUNC(fmin) (9, nan_value), 9);
1353 check ("fmin (-9, NaN) = 9", FUNC(fmin) (-9, nan_value), -9);
1354 check ("fmin (NaN, 0) = 0", FUNC(fmin) (nan_value, 0), 0);
1355 check ("fmin (NaN, 9) = NaN", FUNC(fmin) (nan_value, 9), 9);
1356 check ("fmin (NaN, -9) = NaN", FUNC(fmin) (nan_value, -9), -9);
1357 check_isinfp ("fmin (+inf, NaN) = +inf", FUNC(fmin) (plus_infty, nan_value));
1358 check_isinfn ("fmin (-inf, NaN) = -inf", FUNC(fmin) (minus_infty, nan_value));
1359 check_isinfp ("fmin (NaN, +inf) = +inf", FUNC(fmin) (nan_value, plus_infty));
1360 check_isinfn ("fmin (NaN, -inf) = -inf", FUNC(fmin) (nan_value, minus_infty));
1361 check_isnan ("fmin (NaN, NaN) = NaN", FUNC(fmin) (nan_value, nan_value));
1365 static void
1366 fmax_test (void)
1368 check ("fmax (+0, +0) = +0", FUNC(fmax) (0, 0), 0);
1369 check ("fmax (9, 0) = 9", FUNC(fmax) (9, 0), 9);
1370 check ("fmax (0, 9) = 9", FUNC(fmax) (0, 9), 9);
1371 check ("fmax (-9, 0) = 0", FUNC(fmax) (-9, 0), 0);
1372 check ("fmax (0, -9) = 0", FUNC(fmax) (0, -9), 0);
1374 check_isinfp ("fmax (+inf, 9) = +inf", FUNC(fmax) (plus_infty, 9));
1375 check_isinfp ("fmax (9, +inf) = +inf", FUNC(fmax) (0, plus_infty));
1376 check_isinfp ("fmax (-9, +inf) = +inf", FUNC(fmax) (-9, plus_infty));
1377 check_isinfp ("fmax (+inf, -9) = +inf", FUNC(fmax) (plus_infty, -9));
1378 check ("fmax (-inf, 9) = 9", FUNC(fmax) (minus_infty, 9), 9);
1379 check ("fmax (-inf, -9) = -9", FUNC(fmax) (minus_infty, -9), -9);
1380 check ("fmax (+9, -inf) = 9", FUNC(fmax) (9, minus_infty), 9);
1381 check ("fmax (-9, -inf) = -9", FUNC(fmax) (-9, minus_infty), -9);
1383 check ("fmax (0, NaN) = 0", FUNC(fmax) (0, nan_value), 0);
1384 check ("fmax (9, NaN) = 9", FUNC(fmax) (9, nan_value), 9);
1385 check ("fmax (-9, NaN) = 9", FUNC(fmax) (-9, nan_value), -9);
1386 check ("fmax (NaN, 0) = 0", FUNC(fmax) (nan_value, 0), 0);
1387 check ("fmax (NaN, 9) = NaN", FUNC(fmax) (nan_value, 9), 9);
1388 check ("fmax (NaN, -9) = NaN", FUNC(fmax) (nan_value, -9), -9);
1389 check_isinfp ("fmax (+inf, NaN) = +inf", FUNC(fmax) (plus_infty, nan_value));
1390 check_isinfn ("fmax (-inf, NaN) = -inf", FUNC(fmax) (minus_infty, nan_value));
1391 check_isinfp ("fmax (NaN, +inf) = +inf", FUNC(fmax) (nan_value, plus_infty));
1392 check_isinfn ("fmax (NaN, -inf) = -inf", FUNC(fmax) (nan_value, minus_infty));
1393 check_isnan ("fmax (NaN, NaN) = NaN", FUNC(fmax) (nan_value, nan_value));
1397 static void
1398 nextafter_test (void)
1400 MATHTYPE x;
1402 check ("nextafter (+0, +0) = +0", FUNC(nextafter) (0, 0), 0);
1403 check ("nextafter (-0, +0) = +0", FUNC(nextafter) (minus_zero, 0), 0);
1404 check ("nextafter (+0, -0) = -0", FUNC(nextafter) (0, minus_zero),
1405 minus_zero);
1406 check ("nextafter (-0, -0) = -0", FUNC(nextafter) (minus_zero, minus_zero),
1407 minus_zero);
1409 check ("nextafter (9, 9) = 9", FUNC(nextafter) (9, 9), 9);
1410 check ("nextafter (-9, -9) = -9", FUNC(nextafter) (-9, -9), -9);
1411 check_isinfp ("nextafter (+inf, +inf) = +inf",
1412 FUNC(nextafter) (plus_infty, plus_infty));
1413 check_isinfn ("nextafter (-inf, -inf) = -inf",
1414 FUNC(nextafter) (minus_infty, minus_infty));
1416 x = rand () * 1.1;
1417 check_isnan ("nextafter (NaN, x) = NaN", FUNC(nextafter) (nan_value, x));
1418 check_isnan ("nextafter (x, NaN) = NaN", FUNC(nextafter) (x, nan_value));
1419 check_isnan ("nextafter (NaN, NaN) = NaN", FUNC(nextafter) (nan_value,
1420 nan_value));
1422 /* XXX We need the hexadecimal FP number representation here for further
1423 tests. */
1427 static void
1428 copysign_test (void)
1430 check ("copysign (0, 4) = 0", FUNC(copysign) (0, 4), 0);
1431 check ("copysign (0, -4) = -0", FUNC(copysign) (0, -4), minus_zero);
1432 check ("copysign (-0, 4) = 0", FUNC(copysign) (minus_zero, 4), 0);
1433 check ("copysign (-0, -4) = -0", FUNC(copysign) (minus_zero, -4),
1434 minus_zero);
1436 check_isinfp ("copysign (+inf, 0) = +inf", FUNC(copysign) (plus_infty, 0));
1437 check_isinfn ("copysign (+inf, -0) = -inf", FUNC(copysign) (plus_infty,
1438 minus_zero));
1439 check_isinfp ("copysign (-inf, 0) = +inf", FUNC(copysign) (minus_infty, 0));
1440 check_isinfn ("copysign (-inf, -0) = -inf", FUNC(copysign) (minus_infty,
1441 minus_zero));
1443 check ("copysign (0, +inf) = 0", FUNC(copysign) (0, plus_infty), 0);
1444 check ("copysign (0, -inf) = -0", FUNC(copysign) (0, minus_zero),
1445 minus_zero);
1446 check ("copysign (-0, +inf) = 0", FUNC(copysign) (minus_zero, plus_infty),
1448 check ("copysign (-0, -inf) = -0", FUNC(copysign) (minus_zero, minus_zero),
1449 minus_zero);
1451 /* XXX More correctly we would have to check the sign of the NaN. */
1452 check_isnan ("copysign (+NaN, 0) = +NaN", FUNC(copysign) (nan_value, 0));
1453 check_isnan ("copysign (+NaN, -0) = -NaN", FUNC(copysign) (nan_value,
1454 minus_zero));
1455 check_isnan ("copysign (-NaN, 0) = +NaN", FUNC(copysign) (-nan_value, 0));
1456 check_isnan ("copysign (-NaN, -0) = -NaN", FUNC(copysign) (-nan_value,
1457 minus_zero));
1461 static void
1462 trunc_test (void)
1464 check ("trunc(0) = 0", FUNC(trunc) (0), 0);
1465 check ("trunc(-0) = -0", FUNC(trunc) (minus_zero), minus_zero);
1466 check ("trunc(0.625) = 0", FUNC(trunc) (0.625), 0);
1467 check ("trunc(-0.625) = -0", FUNC(trunc) (-0.625), minus_zero);
1468 check ("trunc(1) = 1", FUNC(trunc) (1), 1);
1469 check ("trunc(-1) = -1", FUNC(trunc) (-1), -1);
1470 check ("trunc(1.625) = 1", FUNC(trunc) (1.625), 1);
1471 check ("trunc(-1.625) = -1", FUNC(trunc) (-1.625), -1);
1473 check ("trunc(1048580.625) = 1048580", FUNC(trunc) (1048580.625L),
1474 1048580L);
1475 check ("trunc(-1048580.625) = -1048580", FUNC(trunc) (-1048580.625L),
1476 -1048580L);
1478 check ("trunc(8388610.125) = 8388610", FUNC(trunc) (8388610.125L),
1479 8388610.0L);
1480 check ("trunc(-8388610.125) = -8388610", FUNC(trunc) (-8388610.125L),
1481 -8388610.0L);
1483 check ("trunc(4294967296.625) = 4294967296", FUNC(trunc) (4294967296.625L),
1484 4294967296.0L);
1485 check ("trunc(-4294967296.625) = -4294967296",
1486 FUNC(trunc) (-4294967296.625L), -4294967296.0L);
1488 check_isinfp ("trunc(+inf) = +inf", FUNC(trunc) (plus_infty));
1489 check_isinfn ("trunc(-inf) = -inf", FUNC(trunc) (minus_infty));
1490 check_isnan ("trunc(NaN) = NaN", FUNC(trunc) (nan_value));
1494 static void
1495 sqrt_test (void)
1497 MATHTYPE x;
1500 /* XXX Tests fuer negative x are missing */
1501 check ("sqrt (0) == 0", FUNC(sqrt) (0), 0);
1502 check_isnan ("sqrt (NaN) == NaN", FUNC(sqrt) (nan_value));
1503 check_isinfp ("sqrt (+inf) == +inf", FUNC(sqrt) (plus_infty));
1505 x = random_value (0, 10000);
1506 check_ext ("sqrt (x*x) == x", FUNC(sqrt) (x*x), x, x);
1507 check ("sqrt (4) == 2", FUNC(sqrt) (4), 2);
1511 static void
1512 remquo_test (void)
1514 int quo;
1515 MATHTYPE result;
1517 result = FUNC(remquo) (1.625, 1.0, &quo);
1518 check ("remquo(1.625, 1.0, &x) == -0.375", result, -0.375);
1519 check ("remquo(1.625, 1.0, &x) puts 1 in x", quo, 1);
1521 result = FUNC(remquo) (-1.625, 1.0, &quo);
1522 check ("remquo(-1.625, 1.0, &x) == 0.375", result, 0.375);
1523 check ("remquo(-1.625, 1.0, &x) puts -1 in x", quo, -1);
1525 result = FUNC(remquo) (1.625, -1.0, &quo);
1526 check ("remquo(1.125, -1.0, &x) == 0.125", result, 0.125);
1527 check ("remquo(1.125, -1.0, &x) puts -1 in x", quo, -1);
1529 result = FUNC(remquo) (-1.625, -1.0, &quo);
1530 check ("remquo(-1.125, -1.0, &x) == 0.125", result, 0.125);
1531 check ("remquo(-1.125, -1.0, &x) puts 1 in x", quo, 1);
1535 static void
1536 cexp_test (void)
1538 __complex__ MATHTYPE result;
1540 result = FUNC(cexp) (BUILD_COMPLEX (plus_zero, plus_zero));
1541 check ("real(cexp(0 + 0i)) = 1", __real__ result, 1);
1542 check ("imag(cexp(0 + 0i)) = 0", __imag__ result, 0);
1543 result = FUNC(cexp) (BUILD_COMPLEX (minus_zero, plus_zero));
1544 check ("real(cexp(-0 + 0i)) = 1", __real__ result, 1);
1545 check ("imag(cexp(-0 + 0i)) = 0", __imag__ result, 0);
1546 result = FUNC(cexp) (BUILD_COMPLEX (plus_zero, minus_zero));
1547 check ("real(cexp(0 - 0i)) = 1", __real__ result, 1);
1548 check ("imag(cexp(0 - 0i)) = -0", __imag__ result, minus_zero);
1549 result = FUNC(cexp) (BUILD_COMPLEX (minus_zero, minus_zero));
1550 check ("real(cexp(-0 - 0i)) = 1", __real__ result, 1);
1551 check ("imag(cexp(-0 - 0i)) = -0", __imag__ result, minus_zero);
1553 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, plus_zero));
1554 check_isinfp ("real(cexp(+inf + 0i)) = +inf", __real__ result);
1555 check ("imag(cexp(+inf + 0i)) = 0", __imag__ result, 0);
1556 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, minus_zero));
1557 check_isinfp ("real(cexp(+inf - 0i)) = +inf", __real__ result);
1558 check ("imag(cexp(+inf - 0i)) = -0", __imag__ result, minus_zero);
1560 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, plus_zero));
1561 check ("real(cexp(-inf + 0i)) = 0", __real__ result, 0);
1562 check ("imag(cexp(-inf + 0i)) = 0", __imag__ result, 0);
1563 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, minus_zero));
1564 check ("real(cexp(-inf - 0i)) = 0", __real__ result, 0);
1565 check ("imag(cexp(-inf - 0i)) = -0", __imag__ result, minus_zero);
1567 result = FUNC(cexp) (BUILD_COMPLEX (100.0, plus_infty));
1568 check_isnan ("real(cexp(x + i inf)) = NaN", __real__ result);
1569 check_isnan ("imag(cexp(x + i inf)) = NaN", __imag__ result);
1570 result = FUNC(cexp) (BUILD_COMPLEX (100.0, minus_infty));
1571 check_isnan ("real(cexp(x - i inf)) = NaN", __real__ result);
1572 check_isnan ("imag(cexp(x - i inf)) = NaN", __imag__ result);
1574 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, 2.0));
1575 check ("real(cexp(-inf + 2.0i)) = -0", __real__ result, minus_zero);
1576 check ("imag(cexp(-inf + 2.0i)) = 0", __imag__ result, 0);
1577 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, 4.0));
1578 check ("real(cexp(-inf + 4.0i)) = -0", __real__ result, minus_zero);
1579 check ("imag(cexp(-inf + 4.0i)) = -0", __imag__ result, minus_zero);
1581 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, 2.0));
1582 check_isinfn ("real(cexp(+inf + 2.0i)) = -inf", __real__ result);
1583 check_isinfp ("imag(cexp(+inf + 2.0i)) = +inf", __imag__ result);
1584 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, 4.0));
1585 check_isinfn ("real(cexp(+inf + 4.0i)) = -inf", __real__ result);
1586 check_isinfn ("imag(cexp(+inf + 4.0i)) = -inf", __imag__ result);
1588 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, plus_infty));
1589 check_isinfp ("real(cexp(+inf + i inf)) = +inf", __real__ result);
1590 check_isnan ("imag(cexp(+inf + i inf)) = NaN", __imag__ result);
1591 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, minus_infty));
1592 check_isinfp ("real(cexp(+inf - i inf)) = +inf", __real__ result);
1593 check_isnan ("imag(cexp(+inf - i inf)) = NaN", __imag__ result);
1595 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, plus_infty));
1596 check ("real(cexp(-inf + i inf)) = 0", __real__ result, 0);
1597 check ("imag(cexp(-inf + i inf)) = 0", __imag__ result, 0);
1598 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, minus_infty));
1599 check ("real(cexp(-inf - i inf)) = 0", __real__ result, 0);
1600 check ("imag(cexp(-inf - i inf)) = -0", __imag__ result, minus_zero);
1602 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, nan_value));
1603 check ("real(cexp(-inf + i NaN)) = 0", __real__ result, 0);
1604 check ("imag(cexp(-inf + i NaN)) = 0", fabs (__imag__ result), 0);
1606 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, nan_value));
1607 check_isinfp ("real(cexp(+inf + i NaN)) = +inf", __real__ result);
1608 check_isnan ("imag(cexp(+inf + i NaN)) = NaN", __imag__ result);
1610 result = FUNC(cexp) (BUILD_COMPLEX (nan_value, 1.0));
1611 check_isnan ("real(cexp(NaN + 1i)) = NaN", __real__ result);
1612 check_isnan ("imag(cexp(NaN + 1i)) = NaN", __imag__ result);
1613 result = FUNC(cexp) (BUILD_COMPLEX (nan_value, 1.0));
1614 check_isnan ("real(cexp(NaN + i inf)) = NaN", __real__ result);
1615 check_isnan ("imag(cexp(NaN + i inf)) = NaN", __imag__ result);
1616 result = FUNC(cexp) (BUILD_COMPLEX (nan_value, 1.0));
1617 check_isnan ("real(cexp(NaN + i NaN)) = NaN", __real__ result);
1618 check_isnan ("imag(cexp(NaN + i NaN)) = NaN", __imag__ result);
1620 result = FUNC(cexp) (BUILD_COMPLEX (0, nan_value));
1621 check_isnan ("real(cexp(0 + i NaN)) = NaN", __real__ result);
1622 check_isnan ("imag(cexp(0 + i NaN)) = NaN", __imag__ result);
1623 result = FUNC(cexp) (BUILD_COMPLEX (1, nan_value));
1624 check_isnan ("real(cexp(1 + i NaN)) = NaN", __real__ result);
1625 check_isnan ("imag(cexp(1 + i NaN)) = NaN", __imag__ result);
1629 static void
1630 csinh_test (void)
1632 __complex__ MATHTYPE result;
1634 result = FUNC(csinh) (BUILD_COMPLEX (0.0, 0.0));
1635 check ("real(csinh(0 + 0i)) = 0", __real__ result, 0);
1636 check ("imag(csinh(0 + 0i)) = 0", __imag__ result, 0);
1637 result = FUNC(csinh) (BUILD_COMPLEX (minus_zero, 0.0));
1638 check ("real(csinh(-0 + 0i)) = -0", __real__ result, minus_zero);
1639 check ("imag(csinh(-0 + 0i)) = 0", __imag__ result, 0);
1640 result = FUNC(csinh) (BUILD_COMPLEX (0.0, minus_zero));
1641 check ("real(csinh(0 - 0i)) = 0", __real__ result, 0);
1642 check ("imag(csinh(0 - 0i)) = -0", __imag__ result, minus_zero);
1643 result = FUNC(csinh) (BUILD_COMPLEX (minus_zero, minus_zero));
1644 check ("real(csinh(-0 - 0i)) = -0", __real__ result, minus_zero);
1645 check ("imag(csinh(-0 - 0i)) = -0", __imag__ result, minus_zero);
1647 result = FUNC(csinh) (BUILD_COMPLEX (0.0, plus_infty));
1648 check ("real(csinh(0 + i Inf)) = 0", FUNC(fabs) (__real__ result), 0);
1649 check_isnan ("imag(csinh(0 + i Inf)) = NaN", __imag__ result);
1650 result = FUNC(csinh) (BUILD_COMPLEX (minus_zero, plus_infty));
1651 check ("real(csinh(-0 + i Inf)) = -0", FUNC(fabs) (__real__ result), 0);
1652 check_isnan ("imag(csinh(-0 + i Inf)) = NaN", __imag__ result);
1653 result = FUNC(csinh) (BUILD_COMPLEX (0.0, minus_infty));
1654 check ("real(csinh(0 - i Inf)) = 0", FUNC(fabs) (__real__ result), 0);
1655 check_isnan ("imag(csinh(0 - i Inf)) = NaN", __imag__ result);
1656 result = FUNC(csinh) (BUILD_COMPLEX (minus_zero, minus_infty));
1657 check ("real(csinh(-0 - i Inf)) = -0", FUNC(fabs) (__real__ result), 0);
1658 check_isnan ("imag(csinh(-0 - i Inf)) = NaN", __imag__ result);
1660 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, 0.0));
1661 check_isinfp ("real(csinh(+Inf + 0i)) = +Inf", __real__ result);
1662 check ("imag(csinh(+Inf + 0i)) = 0", __imag__ result, 0);
1663 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, 0.0));
1664 check_isinfn ("real(csinh(-Inf + 0i)) = -Inf", __real__ result);
1665 check ("imag(csinh(-Inf + 0i)) = 0", __imag__ result, 0);
1666 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, minus_zero));
1667 check_isinfp ("real(csinh(+Inf - 0i)) = +Inf", __real__ result);
1668 check ("imag(csinh(+Inf - 0i)) = -0", __imag__ result, minus_zero);
1669 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, minus_zero));
1670 check_isinfn ("real(csinh(-Inf - 0i)) = -Inf", __real__ result);
1671 check ("imag(csinh(-Inf - 0i)) = -0", __imag__ result, minus_zero);
1673 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, plus_infty));
1674 check_isinfp ("real(csinh(+Inf + i Inf)) = +-Inf",
1675 FUNC(fabs) (__real__ result));
1676 check_isnan ("imag(csinh(+Inf + i Inf)) = NaN", __imag__ result);
1677 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, plus_infty));
1678 check_isinfp ("real(csinh(-Inf + i Inf)) = +-Inf",
1679 FUNC(fabs) (__real__ result));
1680 check_isnan ("imag(csinh(-Inf + i Inf)) = NaN", __imag__ result);
1681 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, minus_infty));
1682 check_isinfp ("real(csinh(Inf - i Inf)) = +-Inf",
1683 FUNC(fabs) (__real__ result));
1684 check_isnan ("imag(csinh(Inf - i Inf)) = NaN", __imag__ result);
1685 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, minus_infty));
1686 check_isinfp ("real(csinh(-Inf - i Inf)) = -Inf",
1687 FUNC(fabs) (__real__ result));
1688 check_isnan ("imag(csinh(-Inf - i Inf)) = NaN", __imag__ result);
1690 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, 4.625));
1691 check_isinfn ("real(csinh(+Inf + i4.625)) = -Inf", __real__ result);
1692 check_isinfn ("imag(csinh(+Inf + i4.625)) = -Inf", __imag__ result);
1693 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, 4.625));
1694 check_isinfp ("real(csinh(-Inf + i4.625)) = +Inf", __real__ result);
1695 check_isinfn ("imag(csinh(-Inf + i4.625)) = -Inf", __imag__ result);
1696 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, -4.625));
1697 check_isinfn ("real(csinh(+Inf - i4.625)) = -Inf", __real__ result);
1698 check_isinfp ("imag(csinh(+Inf - i4.625)) = +Inf", __imag__ result);
1699 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, -4.625));
1700 check_isinfp ("real(csinh(-Inf - i4.625)) = +Inf", __real__ result);
1701 check_isinfp ("imag(csinh(-Inf - i4.625)) = +Inf", __imag__ result);
1703 result = FUNC(csinh) (BUILD_COMPLEX (6.75, plus_infty));
1704 check_isnan ("real(csinh(6.75 + i Inf)) = NaN", __real__ result);
1705 check_isnan ("imag(csinh(6.75 + i Inf)) = NaN", __imag__ result);
1706 result = FUNC(csinh) (BUILD_COMPLEX (-6.75, plus_infty));
1707 check_isnan ("real(csinh(-6.75 + i Inf)) = NaN", __real__ result);
1708 check_isnan ("imag(csinh(-6.75 + i Inf)) = NaN", __imag__ result);
1709 result = FUNC(csinh) (BUILD_COMPLEX (6.75, minus_infty));
1710 check_isnan ("real(csinh(6.75 - i Inf)) = NaN", __real__ result);
1711 check_isnan ("imag(csinh(6.75 - i Inf)) = NaN", __imag__ result);
1712 result = FUNC(csinh) (BUILD_COMPLEX (-6.75, minus_infty));
1713 check_isnan ("real(csinh(-6.75 - i Inf)) = NaN", __real__ result);
1714 check_isnan ("imag(csinh(-6.75 - i Inf)) = NaN", __imag__ result);
1716 result = FUNC(csinh) (BUILD_COMPLEX (0.0, nan_value));
1717 check ("real(csinh(0 + i NaN)) = 0", FUNC(fabs) (__real__ result), 0);
1718 check_isnan ("imag(csinh(0 + i NaN)) = NaN", __imag__ result);
1719 result = FUNC(csinh) (BUILD_COMPLEX (minus_zero, nan_value));
1720 check ("real(csinh(-0 + i NaN)) = -0", FUNC(fabs) (__real__ result), 0);
1721 check_isnan ("imag(csinh(-0 + i NaN)) = NaN", __imag__ result);
1723 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, nan_value));
1724 check_isinfp ("real(csinh(+Inf + i NaN)) = +-Inf",
1725 FUNC(fabs) (__real__ result));
1726 check_isnan ("imag(csinh(+Inf + i NaN)) = NaN", __imag__ result);
1727 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, nan_value));
1728 check_isinfp ("real(csinh(-Inf + i NaN)) = +-Inf",
1729 FUNC(fabs) (__real__ result));
1730 check_isnan ("imag(csinh(-0 + i NaN)) = NaN", __imag__ result);
1732 result = FUNC(csinh) (BUILD_COMPLEX (9.0, nan_value));
1733 check_isnan ("real(csinh(9.0 + i NaN)) = NaN", __real__ result);
1734 check_isnan ("imag(csinh(9.0 + i NaN)) = NaN", __imag__ result);
1735 result = FUNC(csinh) (BUILD_COMPLEX (-9.0, nan_value));
1736 check_isnan ("real(csinh(-9.0 + i NaN)) = NaN", __real__ result);
1737 check_isnan ("imag(csinh(-9.0 + i NaN)) = NaN", __imag__ result);
1739 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, 0.0));
1740 check_isnan ("real(csinh(NaN + i0)) = NaN", __real__ result);
1741 check ("imag(csinh(NaN + i0)) = NaN", __imag__ result, 0.0);
1742 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, minus_zero));
1743 check_isnan ("real(csinh(NaN - i0)) = NaN", __real__ result);
1744 check ("imag(csinh(NaN - i0)) = NaN", __imag__ result, minus_zero);
1746 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, 10.0));
1747 check_isnan ("real(csinh(NaN + i10)) = NaN", __real__ result);
1748 check_isnan ("imag(csinh(NaN + i10)) = NaN", __imag__ result);
1749 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, -10.0));
1750 check_isnan ("real(csinh(NaN - i10)) = NaN", __real__ result);
1751 check_isnan ("imag(csinh(NaN - i10)) = NaN", __imag__ result);
1753 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, plus_infty));
1754 check_isnan ("real(csinh(NaN + i Inf)) = NaN", __real__ result);
1755 check_isnan ("imag(csinh(NaN + i Inf)) = NaN", __imag__ result);
1756 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, minus_infty));
1757 check_isnan ("real(csinh(NaN - i Inf)) = NaN", __real__ result);
1758 check_isnan ("imag(csinh(NaN - i Inf)) = NaN", __imag__ result);
1760 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, nan_value));
1761 check_isnan ("real(csinh(NaN + i NaN)) = NaN", __real__ result);
1762 check_isnan ("imag(csinh(NaN + i NaN)) = NaN", __imag__ result);
1766 static void
1767 ccosh_test (void)
1769 __complex__ MATHTYPE result;
1771 result = FUNC(ccosh) (BUILD_COMPLEX (0.0, 0.0));
1772 check ("real(ccosh(0 + 0i)) = 0", __real__ result, 1.0);
1773 check ("imag(ccosh(0 + 0i)) = 0", __imag__ result, 0);
1774 result = FUNC(ccosh) (BUILD_COMPLEX (minus_zero, 0.0));
1775 check ("real(ccosh(-0 + 0i)) = -0", __real__ result, 1.0);
1776 check ("imag(ccosh(-0 + 0i)) = 0", __imag__ result, 0);
1777 result = FUNC(ccosh) (BUILD_COMPLEX (0.0, minus_zero));
1778 check ("real(ccosh(0 - 0i)) = 0", __real__ result, 1.0);
1779 check ("imag(ccosh(0 - 0i)) = -0", __imag__ result, minus_zero);
1780 result = FUNC(ccosh) (BUILD_COMPLEX (minus_zero, minus_zero));
1781 check ("real(ccosh(-0 - 0i)) = -0", __real__ result, 1.0);
1782 check ("imag(ccosh(-0 - 0i)) = -0", __imag__ result, minus_zero);
1784 result = FUNC(ccosh) (BUILD_COMPLEX (0.0, plus_infty));
1785 check_isnan ("real(ccosh(0 + i Inf)) = NaN", __real__ result);
1786 check ("imag(ccosh(0 + i Inf)) = +-0", FUNC(fabs) (__imag__ result), 0);
1787 result = FUNC(ccosh) (BUILD_COMPLEX (minus_zero, plus_infty));
1788 check_isnan ("real(ccosh(-0 + i Inf)) = NaN", __real__ result);
1789 check ("imag(ccosh(-0 + i Inf)) = -0", FUNC(fabs) (__imag__ result), 0);
1790 result = FUNC(ccosh) (BUILD_COMPLEX (0.0, minus_infty));
1791 check_isnan ("real(ccosh(0 - i Inf)) = NaN", __real__ result);
1792 check ("imag(ccosh(0 - i Inf)) = 0", FUNC(fabs) (__imag__ result), 0);
1793 result = FUNC(ccosh) (BUILD_COMPLEX (minus_zero, minus_infty));
1794 check_isnan ("real(ccosh(-0 - i Inf)) = NaN", __real__ result);
1795 check ("imag(ccosh(-0 - i Inf)) = -0", FUNC(fabs) (__imag__ result), 0);
1797 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, 0.0));
1798 check_isinfp ("real(ccosh(+Inf + 0i)) = +Inf", __real__ result);
1799 check ("imag(ccosh(+Inf + 0i)) = 0", __imag__ result, 0);
1800 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, 0.0));
1801 check_isinfp ("real(ccosh(-Inf + 0i)) = +Inf", __real__ result);
1802 check ("imag(ccosh(-Inf + 0i)) = 0", __imag__ result, 0);
1803 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, minus_zero));
1804 check_isinfp ("real(ccosh(+Inf - 0i)) = +Inf", __real__ result);
1805 check ("imag(ccosh(+Inf - 0i)) = -0", __imag__ result, minus_zero);
1806 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, minus_zero));
1807 check_isinfp ("real(ccosh(-Inf - 0i)) = +Inf", __real__ result);
1808 check ("imag(ccosh(-Inf - 0i)) = -0", __imag__ result, minus_zero);
1810 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, plus_infty));
1811 check_isinfp ("real(ccosh(+Inf + i Inf)) = +Inf", __real__ result);
1812 check_isnan ("imag(ccosh(+Inf + i Inf)) = NaN", __imag__ result);
1813 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, plus_infty));
1814 check_isinfp ("real(ccosh(-Inf + i Inf)) = +Inf", __real__ result);
1815 check_isnan ("imag(ccosh(-Inf + i Inf)) = NaN", __imag__ result);
1816 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, minus_infty));
1817 check_isinfp ("real(ccosh(Inf - i Inf)) = +Inf", __real__ result);
1818 check_isnan ("imag(ccosh(Inf - i Inf)) = NaN", __imag__ result);
1819 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, minus_infty));
1820 check_isinfp ("real(ccosh(-Inf - i Inf)) = +Inf", __real__ result);
1821 check_isnan ("imag(ccosh(-Inf - i Inf)) = NaN", __imag__ result);
1823 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, 4.625));
1824 check_isinfn ("real(ccosh(+Inf + i4.625)) = -Inf", __real__ result);
1825 check_isinfn ("imag(ccosh(+Inf + i4.625)) = -Inf", __imag__ result);
1826 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, 4.625));
1827 check_isinfn ("real(ccosh(-Inf + i4.625)) = -Inf", __real__ result);
1828 check_isinfn ("imag(ccosh(-Inf + i4.625)) = -Inf", __imag__ result);
1829 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, -4.625));
1830 check_isinfn ("real(ccosh(+Inf - i4.625)) = -Inf", __real__ result);
1831 check_isinfp ("imag(ccosh(+Inf - i4.625)) = +Inf", __imag__ result);
1832 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, -4.625));
1833 check_isinfn ("real(ccosh(-Inf - i4.625)) = -Inf", __real__ result);
1834 check_isinfp ("imag(ccosh(-Inf - i4.625)) = +Inf", __imag__ result);
1836 result = FUNC(ccosh) (BUILD_COMPLEX (6.75, plus_infty));
1837 check_isnan ("real(ccosh(6.75 + i Inf)) = NaN", __real__ result);
1838 check_isnan ("imag(ccosh(6.75 + i Inf)) = NaN", __imag__ result);
1839 result = FUNC(ccosh) (BUILD_COMPLEX (-6.75, plus_infty));
1840 check_isnan ("real(ccosh(-6.75 + i Inf)) = NaN", __real__ result);
1841 check_isnan ("imag(ccosh(-6.75 + i Inf)) = NaN", __imag__ result);
1842 result = FUNC(ccosh) (BUILD_COMPLEX (6.75, minus_infty));
1843 check_isnan ("real(ccosh(6.75 - i Inf)) = NaN", __real__ result);
1844 check_isnan ("imag(ccosh(6.75 - i Inf)) = NaN", __imag__ result);
1845 result = FUNC(ccosh) (BUILD_COMPLEX (-6.75, minus_infty));
1846 check_isnan ("real(ccosh(-6.75 - i Inf)) = NaN", __real__ result);
1847 check_isnan ("imag(ccosh(-6.75 - i Inf)) = NaN", __imag__ result);
1849 result = FUNC(ccosh) (BUILD_COMPLEX (0.0, nan_value));
1850 check_isnan ("real(ccosh(0 + i NaN)) = NaN", __real__ result);
1851 check ("imag(ccosh(0 + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0);
1852 result = FUNC(ccosh) (BUILD_COMPLEX (minus_zero, nan_value));
1853 check_isnan ("real(ccosh(-0 + i NaN)) = NaN", __real__ result);
1854 check ("imag(ccosh(-0 + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0);
1856 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, nan_value));
1857 check_isinfp ("real(ccosh(+Inf + i NaN)) = +Inf", __real__ result);
1858 check_isnan ("imag(ccosh(+Inf + i NaN)) = NaN", __imag__ result);
1859 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, nan_value));
1860 check_isinfp ("real(ccosh(-Inf + i NaN)) = +Inf", __real__ result);
1861 check_isnan ("imag(ccosh(-0 + i NaN)) = NaN", __imag__ result);
1863 result = FUNC(ccosh) (BUILD_COMPLEX (9.0, nan_value));
1864 check_isnan ("real(ccosh(9.0 + i NaN)) = NaN", __real__ result);
1865 check_isnan ("imag(ccosh(9.0 + i NaN)) = NaN", __imag__ result);
1866 result = FUNC(ccosh) (BUILD_COMPLEX (-9.0, nan_value));
1867 check_isnan ("real(ccosh(-9.0 + i NaN)) = NaN", __real__ result);
1868 check_isnan ("imag(ccosh(-9.0 + i NaN)) = NaN", __imag__ result);
1870 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, 0.0));
1871 check_isnan ("real(ccosh(NaN + i0)) = NaN", __real__ result);
1872 check ("imag(ccosh(NaN + i0)) = NaN", __imag__ result, 0.0);
1873 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, minus_zero));
1874 check_isnan ("real(ccosh(NaN - i0)) = NaN", __real__ result);
1875 check ("imag(ccosh(NaN - i0)) = NaN", __imag__ result, minus_zero);
1877 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, 10.0));
1878 check_isnan ("real(ccosh(NaN + i10)) = NaN", __real__ result);
1879 check_isnan ("imag(ccosh(NaN + i10)) = NaN", __imag__ result);
1880 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, -10.0));
1881 check_isnan ("real(ccosh(NaN - i10)) = NaN", __real__ result);
1882 check_isnan ("imag(ccosh(NaN - i10)) = NaN", __imag__ result);
1884 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, plus_infty));
1885 check_isnan ("real(ccosh(NaN + i Inf)) = NaN", __real__ result);
1886 check_isnan ("imag(ccosh(NaN + i Inf)) = NaN", __imag__ result);
1887 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, minus_infty));
1888 check_isnan ("real(ccosh(NaN - i Inf)) = NaN", __real__ result);
1889 check_isnan ("imag(ccosh(NaN - i Inf)) = NaN", __imag__ result);
1891 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, nan_value));
1892 check_isnan ("real(ccosh(NaN + i NaN)) = NaN", __real__ result);
1893 check_isnan ("imag(ccosh(NaN + i NaN)) = NaN", __imag__ result);
1897 #if 0
1898 /* Enable these tests as soon as the functions are available. */
1899 static void
1900 cacos_test (void)
1902 __complex__ MATHTYPE result;
1904 result = FUNC(cacos) (BUILD_COMPLEX (0, 0));
1905 check ("real(cacos(0 + i0)) = pi/2", __real__ result, M_PI_2);
1906 check ("imag(cacos(0 + i0)) = -0", __imag__ result, minus_zero);
1907 result = FUNC(cacos) (BUILD_COMPLEX (minus_zero, 0));
1908 check ("real(cacos(-0 + i0)) = pi/2", __real__ result, M_PI_2);
1909 check ("imag(cacos(-0 + i0)) = -0", __imag__ result, minus_zero);
1910 result = FUNC(cacos) (BUILD_COMPLEX (0, minus_zero));
1911 check ("real(cacos(0 - i0)) = pi/2", __real__ result, M_PI_2);
1912 check ("imag(cacos(0 - i0)) = 0", __imag__ result, 0);
1913 result = FUNC(cacos) (BUILD_COMPLEX (minus_zero, minus_zero));
1914 check ("real(cacos(-0 - i0)) = pi/2", __real__ result, M_PI_2);
1915 check ("imag(cacos(-0 - i0)) = 0", __imag__ result, 0);
1917 result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, plus_infty));
1918 check ("real(cacos(-Inf + i Inf)) = 3*pi/4", __real__ result, M_PI - M_PI_4);
1919 check_isinfn ("imag(cacos(-Inf + i Inf)) = -Inf", __imag__ result);
1920 result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, minus_infty));
1921 check ("real(cacos(-Inf - i Inf)) = 3*pi/4", __real__ result, M_PI - M_PI_4);
1922 check_isinfp ("imag(cacos(-Inf - i Inf)) = +Inf", __imag__ result);
1924 result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, plus_infty));
1925 check ("real(cacos(+Inf + i Inf)) = pi/4", __real__ result, M_PI_4);
1926 check_isinfn ("imag(cacos(+Inf + i Inf)) = -Inf", __imag__ result);
1927 result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, minus_infty));
1928 check ("real(cacos(+Inf - i Inf)) = pi/4", __real__ result, M_PI_4);
1929 check_isinfp ("imag(cacos(+Inf - i Inf)) = +Inf", __imag__ result);
1931 result = FUNC(cacos) (BUILD_COMPLEX (-10.0, plus_infty));
1932 check ("real(cacos(-10.0 + i Inf)) = pi/2", __real__ result, M_PI_2);
1933 check_isinfn ("imag(cacos(-10.0 + i Inf)) = -Inf", __imag__ result);
1934 result = FUNC(cacos) (BUILD_COMPLEX (-10.0, minus_infty));
1935 check ("real(cacos(-10.0 - i Inf)) = pi/2", __real__ result, M_PI_2);
1936 check_isinfp ("imag(cacos(-10.0 - i Inf)) = +Inf", __imag__ result);
1937 result = FUNC(cacos) (BUILD_COMPLEX (0, plus_infty));
1938 check ("real(cacos(0 + i Inf)) = pi/2", __real__ result, M_PI_2);
1939 check_isinfn ("imag(cacos(0 + i Inf)) = -Inf", __imag__ result);
1940 result = FUNC(cacos) (BUILD_COMPLEX (0, minus_infty));
1941 check ("real(cacos(0 - i Inf)) = pi/2", __real__ result, M_PI_2);
1942 check_isinfp ("imag(cacos(0 - i Inf)) = +Inf", __imag__ result);
1943 result = FUNC(cacos) (BUILD_COMPLEX (0.1, plus_infty));
1944 check ("real(cacos(0.1 + i Inf)) = pi/2", __real__ result, M_PI_2);
1945 check_isinfn ("imag(cacos(0.1 + i Inf)) = -Inf", __imag__ result);
1946 result = FUNC(cacos) (BUILD_COMPLEX (0.1, minus_infty));
1947 check ("real(cacos(0.1 - i Inf)) = pi/2", __real__ result, M_PI_2);
1948 check_isinfp ("imag(cacos(0.1 - i Inf)) = +Inf", __imag__ result);
1950 result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, 0));
1951 check ("real(cacos(-Inf + i0)) = pi", __real__ result, M_PI);
1952 check_isinfn ("imag(cacos(-Inf + i0)) = -Inf", __imag__ result);
1953 result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, minus_zero));
1954 check ("real(cacos(-Inf - i0)) = pi", __real__ result, M_PI);
1955 check_isinfp ("imag(cacos(-Inf - i0)) = +Inf", __imag__ result);
1956 result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, 100));
1957 check ("real(cacos(-Inf + i100)) = pi", __real__ result, M_PI);
1958 check_isinfn ("imag(cacos(-Inf + i100)) = -Inf", __imag__ result);
1959 result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, -100));
1960 check ("real(cacos(-Inf - i100)) = pi", __real__ result, M_PI);
1961 check_isinfp ("imag(cacos(-Inf - i100)) = +Inf", __imag__ result);
1963 result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, 0));
1964 check ("real(cacos(+Inf + i0)) = 0", __real__ result, 0);
1965 check_isinfn ("imag(cacos(+Inf + i0)) = -Inf", __imag__ result);
1966 result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, minus_zero));
1967 check ("real(cacos(+Inf - i0)) = 0", __real__ result, 0);
1968 check_isinfp ("imag(cacos(+Inf - i0)) = +Inf", __imag__ result);
1969 result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, 0.5));
1970 check ("real(cacos(+Inf + i0.5)) = 0", __real__ result, 0);
1971 check_isinfn ("imag(cacos(+Inf + i0.5)) = -Inf", __imag__ result);
1972 result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, -0.5));
1973 check ("real(cacos(+Inf - i0.5)) = 0", __real__ result, 0);
1974 check_isinfp ("imag(cacos(+Inf - i0.5)) = +Inf", __imag__ result);
1976 result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, nan_value));
1977 check_isnan ("real(cacos(+Inf + i NaN)) = NaN", __real__ result);
1978 check_isinfp ("imag(cacos(+Inf + i NaN)) = +-Inf",
1979 FUNC(fabs) (__imag__ result));
1980 result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, nan_value));
1981 check_isnan ("real(cacos(-Inf + i NaN)) = NaN", __real__ result);
1982 check_isinfp ("imag(cacos(-Inf + i NaN)) = +-Inf",
1983 FUNC(fabs) (__imag__ result));
1985 result = FUNC(cacos) (BUILD_COMPLEX (0, nan_value));
1986 check ("real(cacos(0 + i NaN)) = pi/2", __real__ result, M_PI_2);
1987 check_isnan ("imag(cacos(0 + i NaN)) = NaN", __imag__ result);
1988 result = FUNC(cacos) (BUILD_COMPLEX (minus_zero, nan_value));
1989 check ("real(cacos(-0 + i NaN)) = pi/2", __real__ result, M_PI_2);
1990 check_isnan ("imag(cacos(-0 + i NaN)) = NaN", __imag__ result);
1992 result = FUNC(cacos) (BUILD_COMPLEX (nan_value, plus_infty));
1993 check_isnan ("real(cacos(NaN + i Inf)) = NaN", __real__ result);
1994 check_isinfn ("imag(cacos(NaN + i Inf)) = -Inf", __imag__ result);
1995 result = FUNC(cacos) (BUILD_COMPLEX (nan_value, minus_infty));
1996 check_isnan ("real(cacos(NaN - i Inf)) = NaN", __real__ result);
1997 check_isinfp ("imag(cacos(NaN - i Inf)) = +Inf", __imag__ result);
1999 result = FUNC(cacos) (BUILD_COMPLEX (10.5, nan_value));
2000 check_isnan ("real(cacos(10.5 + i NaN)) = NaN", __real__ result);
2001 check_isnan ("imag(cacos(10.5 + i NaN)) = NaN", __imag__ result);
2002 result = FUNC(cacos) (BUILD_COMPLEX (-10.5, nan_value));
2003 check_isnan ("real(cacos(-10.5 + i NaN)) = NaN", __real__ result);
2004 check_isnan ("imag(cacos(-10.5 + i NaN)) = NaN", __imag__ result);
2006 result = FUNC(cacos) (BUILD_COMPLEX (nan_value, 0.75));
2007 check_isnan ("real(cacos(NaN + i0.75)) = NaN", __real__ result);
2008 check_isnan ("imag(cacos(NaN + i0.75)) = NaN", __imag__ result);
2009 result = FUNC(cacos) (BUILD_COMPLEX (-10.5, nan_value));
2010 check_isnan ("real(cacos(NaN - i0.75)) = NaN", __real__ result);
2011 check_isnan ("imag(cacos(NaN - i0.75)) = NaN", __imag__ result);
2013 result = FUNC(cacos) (BUILD_COMPLEX (nan_value, nan_value));
2014 check_isnan ("real(cacos(NaN + i NaN)) = NaN", __real__ result);
2015 check_isnan ("imag(cacos(NaN + i NaN)) = NaN", __imag__ result);
2019 static void
2020 cacosh_test (void)
2022 __complex__ MATHTYPE result;
2024 result = FUNC(cacosh) (BUILD_COMPLEX (0, 0));
2025 check ("real(cacosh(0 + i0)) = 0", __real__ result, 0);
2026 check ("imag(cacosh(0 + i0)) = pi/2", __imag__ result, M_PI_2);
2027 result = FUNC(cacosh) (BUILD_COMPLEX (minus_zero, 0));
2028 check ("real(cacosh(-0 + i0)) = 0", __real__ result, 0);
2029 check ("imag(cacosh(-0 + i0)) = pi/2", __imag__ result, M_PI_2);
2030 result = FUNC(cacosh) (BUILD_COMPLEX (0, minus_zero));
2031 check ("real(cacosh(0 - i0)) = 0", __real__ result, 0);
2032 check ("imag(cacosh(0 - i0)) = -pi/2", __imag__ result, -M_PI_2);
2033 result = FUNC(cacosh) (BUILD_COMPLEX (minus_zero, minus_zero));
2034 check ("real(cacosh(-0 - i0)) = 0", __real__ result, 0);
2035 check ("imag(cacosh(-0 - i0)) = -pi/2", __imag__ result, -M_PI_2);
2037 result = FUNC(cacosh) (BUILD_COMPLEX (minus_infty, plus_infty));
2038 check_isinfp ("real(cacosh(-Inf + i Inf)) = +Inf", __real__ result);
2039 check ("imag(cacosh(-Inf + i Inf)) = 3*pi/4", __imag__ result,
2040 M_PI - M_PI_4);
2041 result = FUNC(cacosh) (BUILD_COMPLEX (minus_infty, minus_infty));
2042 check_isinfp ("real(cacosh(-Inf - i Inf)) = +Inf", __real__ result);
2043 check ("imag(cacosh(-Inf - i Inf)) = -3*pi/4", __imag__ result,
2044 M_PI_4 - M_PI);
2046 result = FUNC(cacosh) (BUILD_COMPLEX (plus_infty, plus_infty));
2047 check_isinfp ("real(cacosh(+Inf + i Inf)) = +Inf", __real__ result);
2048 check ("imag(cacosh(+Inf + i Inf)) = pi/4", __imag__ result, M_PI_4);
2049 result = FUNC(cacosh) (BUILD_COMPLEX (plus_infty, minus_infty));
2050 check_isinfp ("real(cacosh(+Inf - i Inf)) = +Inf", __real__ result);
2051 check ("imag(cacosh(+Inf - i Inf)) = -pi/4", __imag__ result, -M_PI_4);
2053 result = FUNC(cacosh) (BUILD_COMPLEX (-10.0, plus_infty));
2054 check_isinfp ("real(cacosh(-10.0 + i Inf)) = +Inf", __real__ result);
2055 check ("imag(cacosh(-10.0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
2056 result = FUNC(cacosh) (BUILD_COMPLEX (-10.0, minus_infty));
2057 check_isinfp ("real(cacosh(-10.0 - i Inf)) = +Inf", __real__ result);
2058 check ("imag(cacosh(-10.0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
2059 result = FUNC(cacosh) (BUILD_COMPLEX (0, plus_infty));
2060 check_isinfp ("real(cacosh(0 + i Inf)) = +Inf", __real__ result);
2061 check ("imag(cacosh(0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
2062 result = FUNC(cacosh) (BUILD_COMPLEX (0, minus_infty));
2063 check_isinfp ("real(cacosh(0 - i Inf)) = +Inf", __real__ result);
2064 check ("imag(cacosh(0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
2065 result = FUNC(cacosh) (BUILD_COMPLEX (0.1, plus_infty));
2066 check_isinfp ("real(cacosh(0.1 + i Inf)) = +Inf", __real__ result);
2067 check ("imag(cacosh(0.1 + i Inf)) = pi/2", __imag__ result, M_PI_2);
2068 result = FUNC(cacosh) (BUILD_COMPLEX (0.1, minus_infty));
2069 check_isinfp ("real(cacosh(0.1 - i Inf)) = +Inf", __real__ result);
2070 check ("imag(cacosh(0.1 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
2072 result = FUNC(cacosh) (BUILD_COMPLEX (minus_infty, 0));
2073 check_isinfp ("real(cacosh(-Inf + i0)) = +Inf", __real__ result);
2074 check ("imag(cacosh(-Inf + i0)) = pi", __imag__ result, M_PI);
2075 result = FUNC(cacosh) (BUILD_COMPLEX (minus_infty, minus_zero));
2076 check_isinfp ("real(cacosh(-Inf - i0)) = +Inf", __real__ result);
2077 check ("imag(cacosh(-Inf - i0)) = -pi", __imag__ result, -M_PI);
2078 result = FUNC(cacosh) (BUILD_COMPLEX (minus_infty, 100));
2079 check_isinfp ("real(cacosh(-Inf + i100)) = +Inf", __real__ result);
2080 check ("imag(cacosh(-Inf + i100)) = pi", __imag__ result, M_PI);
2081 result = FUNC(cacosh) (BUILD_COMPLEX (minus_infty, -100));
2082 check_isinfp ("real(cacosh(-Inf - i100)) = +Inf", __real__ result);
2083 check ("imag(cacosh(-Inf - i100)) = -pi", __imag__ result, -M_PI);
2085 result = FUNC(cacosh) (BUILD_COMPLEX (plus_infty, 0));
2086 check_isinfp ("real(cacosh(+Inf + i0)) = +Inf", __real__ result);
2087 check ("imag(cacosh(+Inf + i0)) = 0", __imag__ result, 0);
2088 result = FUNC(cacosh) (BUILD_COMPLEX (plus_infty, minus_zero));
2089 check_isinfp ("real(cacosh(+Inf - i0)) = +Inf", __real__ result);
2090 check ("imag(cacosh(+Inf - i0)) = -0", __imag__ result, minus_zero);
2091 result = FUNC(cacosh) (BUILD_COMPLEX (plus_infty, 0.5));
2092 check_isinfp ("real(cacosh(+Inf + i0.5)) = +Inf", __real__ result);
2093 check ("imag(cacosh(+Inf + i0.5)) = 0", __imag__ result, 0);
2094 result = FUNC(cacosh) (BUILD_COMPLEX (plus_infty, -0.5));
2095 check_isinfp ("real(cacosh(+Inf - i0.5)) = +Inf", __real__ result);
2096 check ("imag(cacosh(+Inf - i0.5)) = -0", __imag__ result, minus_zero);
2098 result = FUNC(cacosh) (BUILD_COMPLEX (plus_infty, nan_value));
2099 check_isinfp ("real(cacosh(+Inf + i NaN)) = +Inf", __real__ result);
2100 check_isnan ("imag(cacosh(+Inf + i NaN)) = NaN", __imag__ result);
2101 result = FUNC(cacosh) (BUILD_COMPLEX (minus_infty, nan_value));
2102 check_isinfp ("real(cacosh(-Inf + i NaN)) = +Inf", __real__ result);
2103 check_isnan ("imag(cacosh(-Inf + i NaN)) = NaN", __imag__ result);
2105 result = FUNC(cacosh) (BUILD_COMPLEX (0, nan_value));
2106 check_isnan ("real(cacosh(0 + i NaN)) = NaN", __real__ result);
2107 check_isnan ("imag(cacosh(0 + i NaN)) = NaN", __imag__ result);
2108 result = FUNC(cacosh) (BUILD_COMPLEX (minus_zero, nan_value));
2109 check_isnan ("real(cacosh(-0 + i NaN)) = NaN", __real__ result);
2110 check_isnan ("imag(cacosh(-0 + i NaN)) = NaN", __imag__ result);
2112 result = FUNC(cacosh) (BUILD_COMPLEX (nan_value, plus_infty));
2113 check_isinfp ("real(cacosh(NaN + i Inf)) = +Inf", __real__ result);
2114 check_isnan ("imag(cacosh(NaN + i Inf)) = NaN", __imag__ result);
2115 result = FUNC(cacosh) (BUILD_COMPLEX (nan_value, minus_infty));
2116 check_isinfp ("real(cacosh(NaN - i Inf)) = +Inf", __real__ result);
2117 check_isnan ("imag(cacosh(NaN - i Inf)) = NaN", __imag__ result);
2119 result = FUNC(cacosh) (BUILD_COMPLEX (10.5, nan_value));
2120 check_isnan ("real(cacosh(10.5 + i NaN)) = NaN", __real__ result);
2121 check_isnan ("imag(cacosh(10.5 + i NaN)) = NaN", __imag__ result);
2122 result = FUNC(cacosh) (BUILD_COMPLEX (-10.5, nan_value));
2123 check_isnan ("real(cacosh(-10.5 + i NaN)) = NaN", __real__ result);
2124 check_isnan ("imag(cacosh(-10.5 + i NaN)) = NaN", __imag__ result);
2126 result = FUNC(cacosh) (BUILD_COMPLEX (nan_value, 0.75));
2127 check_isnan ("real(cacosh(NaN + i0.75)) = NaN", __real__ result);
2128 check_isnan ("imag(cacosh(NaN + i0.75)) = NaN", __imag__ result);
2129 result = FUNC(cacosh) (BUILD_COMPLEX (-10.5, nan_value));
2130 check_isnan ("real(cacosh(NaN - i0.75)) = NaN", __real__ result);
2131 check_isnan ("imag(cacosh(NaN - i0.75)) = NaN", __imag__ result);
2133 result = FUNC(cacosh) (BUILD_COMPLEX (nan_value, nan_value));
2134 check_isnan ("real(cacosh(NaN + i NaN)) = NaN", __real__ result);
2135 check_isnan ("imag(cacosh(NaN + i NaN)) = NaN", __imag__ result);
2139 static void
2140 casinh_test (void)
2142 __complex__ MATHTYPE result;
2144 result = FUNC(casinh) (BUILD_COMPLEX (0, 0));
2145 check ("real(casinh(0 + i0)) = 0", __real__ result, 0);
2146 check ("imag(casinh(0 + i0)) = 0", __imag__ result, 0);
2147 result = FUNC(casinh) (BUILD_COMPLEX (minus_zero, 0));
2148 check ("real(casinh(-0 + i0)) = -0", __real__ result, minus_zero);
2149 check ("imag(casinh(-0 + i0)) = 0", __imag__ result, 0);
2150 result = FUNC(casinh) (BUILD_COMPLEX (0, minus_zero));
2151 check ("real(casinh(0 - i0)) = 0", __real__ result, 0);
2152 check ("imag(casinh(0 - i0)) = -0", __imag__ result, minus_zero);
2153 result = FUNC(casinh) (BUILD_COMPLEX (minus_zero, minus_zero));
2154 check ("real(casinh(-0 - i0)) = -0", __real__ result, minus_zero);
2155 check ("imag(casinh(-0 - i0)) = -0", __imag__ result, minus_zero);
2157 result = FUNC(casinh) (BUILD_COMPLEX (plus_infty, plus_infty));
2158 check_isinfp ("real(casinh(+Inf + i Inf)) = +Inf", __real__ result);
2159 check ("imag(casinh(+Inf + i Inf)) = pi/4", __imag__ result, M_PI_4);
2160 result = FUNC(casinh) (BUILD_COMPLEX (plus_infty, minus_infty));
2161 check_isinfp ("real(casinh(+Inf - i Inf)) = +Inf", __real__ result);
2162 check ("imag(casinh(+Inf - i Inf)) = -pi/4", __imag__ result, -M_PI_4);
2163 result = FUNC(casinh) (BUILD_COMPLEX (minus_infty, plus_infty));
2164 check_isinfn ("real(casinh(-Inf + i Inf)) = -Inf", __real__ result);
2165 check ("imag(casinh(-Inf + i Inf)) = pi/4", __imag__ result, M_PI_4);
2166 result = FUNC(casinh) (BUILD_COMPLEX (minus_infty, minus_infty));
2167 check_isinfn ("real(casinh(-Inf - i Inf)) = -Inf", __real__ result);
2168 check ("imag(casinh(-Inf - i Inf)) = -pi/4", __imag__ result, -M_PI_4);
2170 result = FUNC(casinh) (BUILD_COMPLEX (-10.0, plus_infty));
2171 check_isinfn ("real(casinh(-10.0 + i Inf)) = -Inf", __real__ result);
2172 check ("imag(casinh(-10.0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
2173 result = FUNC(casinh) (BUILD_COMPLEX (-10.0, minus_infty));
2174 check_isinfn ("real(casinh(-10.0 - i Inf)) = -Inf", __real__ result);
2175 check ("imag(casinh(-10.0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
2176 result = FUNC(casinh) (BUILD_COMPLEX (0, plus_infty));
2177 check_isinfp ("real(casinh(0 + i Inf)) = +Inf", __real__ result);
2178 check ("imag(casinh(0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
2179 result = FUNC(casinh) (BUILD_COMPLEX (0, minus_infty));
2180 check_isinfp ("real(casinh(0 - i Inf)) = +Inf", __real__ result);
2181 check ("imag(casinh(0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
2182 result = FUNC(casinh) (BUILD_COMPLEX (0.1, plus_infty));
2183 check_isinfp ("real(casinh(0.1 + i Inf)) = +Inf", __real__ result);
2184 check ("imag(casinh(0.1 + i Inf)) = pi/2", __imag__ result, M_PI_2);
2185 result = FUNC(casinh) (BUILD_COMPLEX (0.1, minus_infty));
2186 check_isinfp ("real(casinh(0.1 - i Inf)) = +Inf", __real__ result);
2187 check ("imag(casinh(0.1 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
2189 result = FUNC(casinh) (BUILD_COMPLEX (minus_infty, 0));
2190 check_isinfn ("real(casinh(-Inf + i0)) = -Inf", __real__ result);
2191 check ("imag(casinh(-Inf + i0)) = 0", __imag__ result, 0);
2192 result = FUNC(casinh) (BUILD_COMPLEX (minus_infty, minus_zero));
2193 check_isinfn ("real(casinh(-Inf - i0)) = -Inf", __real__ result);
2194 check ("imag(casinh(-Inf - i0)) = -0", __imag__ result, minus_zero);
2195 result = FUNC(casinh) (BUILD_COMPLEX (minus_infty, 100));
2196 check_isinfn ("real(casinh(-Inf + i100)) = -Inf", __real__ result);
2197 check ("imag(casinh(-Inf + i100)) = 0", __imag__ result, 0);
2198 result = FUNC(casinh) (BUILD_COMPLEX (minus_infty, -100));
2199 check_isinfn ("real(casinh(-Inf - i100)) = -Inf", __real__ result);
2200 check ("imag(casinh(-Inf - i100)) = -0", __imag__ result, minus_zero);
2202 result = FUNC(casinh) (BUILD_COMPLEX (plus_infty, 0));
2203 check_isinfp ("real(casinh(+Inf + i0)) = +Inf", __real__ result);
2204 check ("imag(casinh(+Inf + i0)) = 0", __imag__ result, 0);
2205 result = FUNC(casinh) (BUILD_COMPLEX (plus_infty, minus_zero));
2206 check_isinfp ("real(casinh(+Inf - i0)) = +Inf", __real__ result);
2207 check ("imag(casinh(+Inf - i0)) = -0", __imag__ result, minus_zero);
2208 result = FUNC(casinh) (BUILD_COMPLEX (plus_infty, 0.5));
2209 check_isinfp ("real(casinh(+Inf + i0.5)) = +Inf", __real__ result);
2210 check ("imag(casinh(+Inf + i0.5)) = 0", __imag__ result, 0);
2211 result = FUNC(casinh) (BUILD_COMPLEX (plus_infty, -0.5));
2212 check_isinfp ("real(casinh(+Inf - i0.5)) = +Inf", __real__ result);
2213 check ("imag(casinh(+Inf - i0.5)) = -0", __imag__ result, minus_zero);
2215 result = FUNC(casinh) (BUILD_COMPLEX (plus_infty, nan_value));
2216 check_isinfp ("real(casinh(+Inf + i NaN)) = +Inf", __real__ result);
2217 check_isnan ("imag(casinh(+Inf + i NaN)) = NaN", __imag__ result);
2218 result = FUNC(casinh) (BUILD_COMPLEX (minus_infty, nan_value));
2219 check_isinfn ("real(casinh(-Inf + i NaN)) = -Inf", __real__ result);
2220 check_isnan ("imag(casinh(-Inf + i NaN)) = NaN", __imag__ result);
2222 result = FUNC(casinh) (BUILD_COMPLEX (nan_value, 0));
2223 check_isnan ("real(casinh(NaN + i0)) = NaN", __real__ result);
2224 check ("imag(casinh(NaN + i0)) = 0", __imag__ resul, 0);
2225 result = FUNC(casinh) (BUILD_COMPLEX (minus_zero, nan_value));
2226 check_isnan ("real(casinh(NaN - i0)) = NaN", __real__ result);
2227 check ("imag(casinh(NaN - i0)) = -0", __imag__ result, minus_zero);
2229 result = FUNC(casinh) (BUILD_COMPLEX (nan_value, plus_infty));
2230 check_isinfp ("real(casinh(NaN + i Inf)) = +Inf",
2231 FUNC(fabs) (__real__ result));
2232 check_isnan ("imag(casinh(NaN + i Inf)) = NaN", __imag__ result);
2233 result = FUNC(casinh) (BUILD_COMPLEX (nan_value, minus_infty));
2234 check_isinfp ("real(casinh(NaN - i Inf)) = +Inf",
2235 FUNC(fabs) (__real__ result));
2236 check_isnan ("imag(casinh(NaN - i Inf)) = NaN", __imag__ result);
2238 result = FUNC(casinh) (BUILD_COMPLEX (10.5, nan_value));
2239 check_isnan ("real(casinh(10.5 + i NaN)) = NaN", __real__ result);
2240 check_isnan ("imag(casinh(10.5 + i NaN)) = NaN", __imag__ result);
2241 result = FUNC(casinh) (BUILD_COMPLEX (-10.5, nan_value));
2242 check_isnan ("real(casinh(-10.5 + i NaN)) = NaN", __real__ result);
2243 check_isnan ("imag(casinh(-10.5 + i NaN)) = NaN", __imag__ result);
2245 result = FUNC(casinh) (BUILD_COMPLEX (nan_value, 0.75));
2246 check_isnan ("real(casinh(NaN + i0.75)) = NaN", __real__ result);
2247 check_isnan ("imag(casinh(NaN + i0.75)) = NaN", __imag__ result);
2248 result = FUNC(casinh) (BUILD_COMPLEX (-10.5, nan_value));
2249 check_isnan ("real(casinh(NaN - i0.75)) = NaN", __real__ result);
2250 check_isnan ("imag(casinh(NaN - i0.75)) = NaN", __imag__ result);
2252 result = FUNC(casinh) (BUILD_COMPLEX (nan_value, nan_value));
2253 check_isnan ("real(casinh(NaN + i NaN)) = NaN", __real__ result);
2254 check_isnan ("imag(casinh(NaN + i NaN)) = NaN", __imag__ result);
2258 static void
2259 catanh_test (void)
2261 __complex__ MATHTYPE result;
2263 result = FUNC(catanh) (BUILD_COMPLEX (0, 0));
2264 check ("real(catanh(0 + i0)) = 0", __real__ result, 0);
2265 check ("imag(catanh(0 + i0)) = 0", __imag__ result, 0);
2266 result = FUNC(catanh) (BUILD_COMPLEX (minus_zero, 0));
2267 check ("real(catanh(-0 + i0)) = -0", __real__ result, minus_zero);
2268 check ("imag(catanh(-0 + i0)) = 0", __imag__ result, 0);
2269 result = FUNC(catanh) (BUILD_COMPLEX (0, minus_zero));
2270 check ("real(catanh(0 - i0)) = 0", __real__ result, 0);
2271 check ("imag(catanh(0 - i0)) = -0", __imag__ result, minus_zero);
2272 result = FUNC(catanh) (BUILD_COMPLEX (minus_zero, minus_zero));
2273 check ("real(catanh(-0 - i0)) = -0", __real__ result, minus_zero);
2274 check ("imag(catanh(-0 - i0)) = -0", __imag__ result, minus_zero);
2276 result = FUNC(catanh) (BUILD_COMPLEX (plus_infty, plus_infty));
2277 check ("real(catanh(+Inf + i Inf)) = 0", __real__ result, 0);
2278 check ("imag(catanh(+Inf + i Inf)) = pi/2", __imag__ result, M_PI_2);
2279 result = FUNC(catanh) (BUILD_COMPLEX (plus_infty, minus_infty));
2280 check ("real(catanh(+Inf - i Inf)) = 0", __real__ result, 0);
2281 check ("imag(catanh(+Inf - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
2282 result = FUNC(catanh) (BUILD_COMPLEX (minus_infty, plus_infty));
2283 check ("real(catanh(-Inf + i Inf)) = -0", __real__ result, minus_zero);
2284 check ("imag(catanh(-Inf + i Inf)) = pi/2", __imag__ result, M_PI_2);
2285 result = FUNC(catanh) (BUILD_COMPLEX (minus_infty, minus_infty));
2286 check ("real(catanh(-Inf - i Inf)) = -0", __real__ result, minus_zero);
2287 check ("imag(catanh(-Inf - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
2289 result = FUNC(catanh) (BUILD_COMPLEX (-10.0, plus_infty));
2290 check ("real(catanh(-10.0 + i Inf)) = -0", __real__ result, -minus_zero);
2291 check ("imag(catanh(-10.0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
2292 result = FUNC(catanh) (BUILD_COMPLEX (-10.0, minus_infty));
2293 check ("real(catanh(-10.0 - i Inf)) = -0", __real__ result, minus_infty);
2294 check ("imag(catanh(-10.0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
2295 result = FUNC(catanh) (BUILD_COMPLEX (0, plus_infty));
2296 check ("real(catanh(0 + i Inf)) = 0", __real__ result, 0);
2297 check ("imag(catanh(0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
2298 result = FUNC(catanh) (BUILD_COMPLEX (0, minus_infty));
2299 check ("real(catanh(0 - i Inf)) = 0", __real__ result, 0);
2300 check ("imag(catanh(0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
2301 result = FUNC(catanh) (BUILD_COMPLEX (0.1, plus_infty));
2302 check ("real(catanh(0.1 + i Inf)) = 0", __real__ result, 0);
2303 check ("imag(catanh(0.1 + i Inf)) = pi/2", __imag__ result, M_PI_2);
2304 result = FUNC(catanh) (BUILD_COMPLEX (0.1, minus_infty));
2305 check ("real(catanh(0.1 - i Inf)) = 0", __real__ result, 0);
2306 check ("imag(catanh(0.1 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
2308 result = FUNC(catanh) (BUILD_COMPLEX (minus_infty, 0));
2309 check ("real(catanh(-Inf + i0)) = -0", __real__ result, minus_zero);
2310 check ("imag(catanh(-Inf + i0)) = pi/2", __imag__ result, M_PI_2);
2311 result = FUNC(catanh) (BUILD_COMPLEX (minus_infty, minus_zero));
2312 check ("real(catanh(-Inf - i0)) = -0", __real__ result, minus_zero);
2313 check ("imag(catanh(-Inf - i0)) = -pi/2", __imag__ result, -M_PI_2);
2314 result = FUNC(catanh) (BUILD_COMPLEX (minus_infty, 100));
2315 check ("real(catanh(-Inf + i100)) = -0", __real__ result, minus_zero);
2316 check ("imag(catanh(-Inf + i100)) = pi/2", __imag__ result, M_PI_2);
2317 result = FUNC(catanh) (BUILD_COMPLEX (minus_infty, -100));
2318 check ("real(catanh(-Inf - i100)) = -0", __real__ result, minus_zero);
2319 check ("imag(catanh(-Inf - i100)) = -pi/2", __imag__ result, -M_PI_2);
2321 result = FUNC(catanh) (BUILD_COMPLEX (plus_infty, 0));
2322 check ("real(catanh(+Inf + i0)) = 0", __real__ result, 0);
2323 check ("imag(catanh(+Inf + i0)) = pi/2", __imag__ result, M_PI_2);
2324 result = FUNC(catanh) (BUILD_COMPLEX (plus_infty, minus_zero));
2325 check ("real(catanh(+Inf - i0)) = 0", __real__ result, 0);
2326 check ("imag(catanh(+Inf - i0)) = -pi/2", __imag__ result, -M_PI_2);
2327 result = FUNC(catanh) (BUILD_COMPLEX (plus_infty, 0.5));
2328 check ("real(catanh(+Inf + i0.5)) = 0", __real__ result, 0);
2329 check ("imag(catanh(+Inf + i0.5)) = pi/2", __imag__ result, M_PI_2);
2330 result = FUNC(catanh) (BUILD_COMPLEX (plus_infty, -0.5));
2331 check ("real(catanh(+Inf - i0.5)) = 0", __real__ result, 0);
2332 check ("imag(catanh(+Inf - i0.5)) = -pi/2", __imag__ result, -M_PI_2);
2334 result = FUNC(catanh) (BUILD_COMPLEX (0, nan_value));
2335 check ("real(catanh(0 + i NaN)) = 0", __real__ result, 0);
2336 check_isnan ("imag(catanh(+Inf + i NaN)) = NaN", __imag__ result);
2337 result = FUNC(catanh) (BUILD_COMPLEX (minus_zero, nan_value));
2338 check ("real(catanh(-0 + i NaN)) = -0", __real__ result, minus_zero);
2339 check_isnan ("imag(catanh(-Inf + i NaN)) = NaN", __imag__ result);
2341 result = FUNC(catanh) (BUILD_COMPLEX (plus_infty, nan_value));
2342 check ("real(catanh(+Inf + i NaN)) = 0", __real__ result, 0);
2343 check_isnan ("imag(catanh(+Inf + i NaN)) = NaN", __imag__ result);
2344 result = FUNC(catanh) (BUILD_COMPLEX (minus_infty, nan_value));
2345 check ("real(catanh(-Inf + i NaN)) = -0", __real__ result, minus_zero);
2346 check_isnan ("imag(catanh(-Inf + i NaN)) = NaN", __imag__ result);
2348 result = FUNC(catanh) (BUILD_COMPLEX (nan_value, 0));
2349 check_isnan ("real(catanh(NaN + i0)) = NaN", __real__ result);
2350 check_isnan ("imag(catanh(NaN + i0)) = NaN", __imag__ resul);
2351 result = FUNC(catanh) (BUILD_COMPLEX (minus_zero, nan_value));
2352 check_isnan ("real(catanh(NaN - i0)) = NaN", __real__ result);
2353 check_isnan ("imag(catanh(NaN - i0)) = NaN", __imag__ result);
2355 result = FUNC(catanh) (BUILD_COMPLEX (nan_value, plus_infty));
2356 check ("real(catanh(NaN + i Inf)) = +-0", FUNC(fabs) (__real__ result), 0);
2357 check ("imag(catanh(NaN + i Inf)) = pi/2", __imag__ result, M_PI_2);
2358 result = FUNC(catanh) (BUILD_COMPLEX (nan_value, minus_infty));
2359 check ("real(catanh(NaN - i Inf)) = +-0", FUNC(fabs) (__real__ result), 0);
2360 check ("imag(catanh(NaN - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
2362 result = FUNC(catanh) (BUILD_COMPLEX (10.5, nan_value));
2363 check_isnan ("real(catanh(10.5 + i NaN)) = NaN", __real__ result);
2364 check_isnan ("imag(catanh(10.5 + i NaN)) = NaN", __imag__ result);
2365 result = FUNC(catanh) (BUILD_COMPLEX (-10.5, nan_value));
2366 check_isnan ("real(catanh(-10.5 + i NaN)) = NaN", __real__ result);
2367 check_isnan ("imag(catanh(-10.5 + i NaN)) = NaN", __imag__ result);
2369 result = FUNC(catanh) (BUILD_COMPLEX (nan_value, 0.75));
2370 check_isnan ("real(catanh(NaN + i0.75)) = NaN", __real__ result);
2371 check_isnan ("imag(catanh(NaN + i0.75)) = NaN", __imag__ result);
2372 result = FUNC(catanh) (BUILD_COMPLEX (-10.5, nan_value));
2373 check_isnan ("real(catanh(NaN - i0.75)) = NaN", __real__ result);
2374 check_isnan ("imag(catanh(NaN - i0.75)) = NaN", __imag__ result);
2376 result = FUNC(catanh) (BUILD_COMPLEX (nan_value, nan_value));
2377 check_isnan ("real(catanh(NaN + i NaN)) = NaN", __real__ result);
2378 check_isnan ("imag(catanh(NaN + i NaN)) = NaN", __imag__ result);
2382 static void
2383 ctanh_test (void)
2385 __complex__ MATHTYPE result;
2387 result = FUNC(ctanh) (BUILD_COMPLEX (0, 0));
2388 check ("real(ctanh(0 + i0)) = 0", __real__ result, 0);
2389 check ("imag(ctanh(0 + i0)) = 0", __imag__ result, 0);
2390 result = FUNC(ctanh) (BUILD_COMPLEX (0, minus_zero));
2391 check ("real(ctanh(0 - i0)) = 0", __real__ result, 0);
2392 check ("imag(ctanh(0 - i0)) = -0", __imag__ result, minus_zero);
2393 result = FUNC(ctanh) (BUILD_COMPLEX (minus_zero, 0));
2394 check ("real(ctanh(-0 + i0)) = -0", __real__ result, minus_zero);
2395 check ("imag(ctanh(-0 + i0)) = -0", __imag__ result, 0);
2396 result = FUNC(ctanh) (BUILD_COMPLEX (minus_zero, minus_zero));
2397 check ("real(ctanh(-0 - i0)) = -0", __real__ result, minus_zero);
2398 check ("imag(ctanh(-0 - i0)) = -0", __imag__ result, minus_zero);
2400 result = FUNC(ctanh) (BUILD_COMPLEX (plus_infty, 0));
2401 check ("real(ctanh(+Inf + i0)) = 1", __real__ result, 1);
2402 check ("imag(ctanh(+Inf + i0)) = 0", __imag__ result, 0);
2403 result = FUNC(ctanh) (BUILD_COMPLEX (plus_infty, 1));
2404 check ("real(ctanh(+Inf + i1)) = 1", __real__ result, 1);
2405 check ("imag(ctanh(+Inf + i1)) = 0", __imag__ result, 0);
2406 result = FUNC(ctanh) (BUILD_COMPLEX (plus_infty, minus_zero));
2407 check ("real(ctanh(+Inf - i0)) = 1", __real__ result, 1);
2408 check ("imag(ctanh(+Inf - i0)) = -0", __imag__ result, minus_zero);
2409 result = FUNC(ctanh) (BUILD_COMPLEX (plus_infty, -1));
2410 check ("real(ctanh(+Inf - i1)) = 1", __real__ result, 1);
2411 check ("imag(ctanh(+Inf - i1)) = -0", __imag__ result, minus_zero);
2412 result = FUNC(ctanh) (BUILD_COMPLEX (minus_infty, 0));
2413 check ("real(ctanh(-Inf + i0)) = -1", __real__ result, -1);
2414 check ("imag(ctanh(-Inf + i0)) = 0", __imag__ result, 0);
2415 result = FUNC(ctanh) (BUILD_COMPLEX (minus_infty, 1));
2416 check ("real(ctanh(-Inf + i1)) = -1", __real__ result, -1);
2417 check ("imag(ctanh(-Inf + i1)) = 0", __imag__ result, 0);
2418 result = FUNC(ctanh) (BUILD_COMPLEX (pminus_infty, minus_zero));
2419 check ("real(ctanh(-Inf - i0)) = -1", __real__ result, -1);
2420 check ("imag(ctanh(-Inf - i0)) = -0", __imag__ result, minus_zero);
2421 result = FUNC(ctanh) (BUILD_COMPLEX (minus_infty, -1));
2422 check ("real(ctanh(-Inf - i1)) = -1", __real__ result, -1);
2423 check ("imag(ctanh(-Inf - i1)) = -0", __imag__ result, minus_zero);
2425 result = FUNC(ctanh) (BUILD_COMPLEX (0, plus_infty));
2426 check_isnan ("real(ctanh(0 + i Inf)) = NaN", __real__ result);
2427 check_isnan ("imag(ctanh(0 + i Inf)) = NaN", __imag__ result);
2428 result = FUNC(ctanh) (BUILD_COMPLEX (2, plus_infty));
2429 check_isnan ("real(ctanh(2 + i Inf)) = NaN", __real__ result);
2430 check_isnan ("imag(ctanh(2 + i Inf)) = NaN", __imag__ result);
2431 result = FUNC(ctanh) (BUILD_COMPLEX (0, minus_infty));
2432 check_isnan ("real(ctanh(0 - i Inf)) = NaN", __real__ result);
2433 check_isnan ("imag(ctanh(0 - i Inf)) = NaN", __imag__ result);
2434 result = FUNC(ctanh) (BUILD_COMPLEX (2, minus_infty));
2435 check_isnan ("real(ctanh(2 - i Inf)) = NaN", __real__ result);
2436 check_isnan ("imag(ctanh(2 - i Inf)) = NaN", __imag__ result);
2437 result = FUNC(ctanh) (BUILD_COMPLEX (minus_zero, plus_infty));
2438 check_isnan ("real(ctanh(-0 + i Inf)) = NaN", __real__ result);
2439 check_isnan ("imag(ctanh(-0 + i Inf)) = NaN", __imag__ result);
2440 result = FUNC(ctanh) (BUILD_COMPLEX (-2, plus_infty));
2441 check_isnan ("real(ctanh(-2 + i Inf)) = NaN", __real__ result);
2442 check_isnan ("imag(ctanh(-2 + i Inf)) = NaN", __imag__ result);
2443 result = FUNC(ctanh) (BUILD_COMPLEX (minus_zero, minus_infty));
2444 check_isnan ("real(ctanh(-0 - i Inf)) = NaN", __real__ result);
2445 check_isnan ("imag(ctanh(-0 - i Inf)) = NaN", __imag__ result);
2446 result = FUNC(ctanh) (BUILD_COMPLEX (-2, minus_infty));
2447 check_isnan ("real(ctanh(-2 - i Inf)) = NaN", __real__ result);
2448 check_isnan ("imag(ctanh(-2 - i Inf)) = NaN", __imag__ result);
2450 result = FUNC(ctanh) (BUILD_COMPLEX (plus_infty, nan_value));
2451 check ("real(ctanh(+Inf + i NaN)) = 1", __real__ result, 1);
2452 check ("imag(ctanh(+Inf + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0);
2453 result = FUNC(ctanh) (BUILD_COMPLEX (minus_infty, nan_value));
2454 check ("real(ctanh(-Inf + i NaN)) = -1", __real__ result, -1);
2455 check ("imag(ctanh(-Inf + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0);
2457 result = FUNC(ctanh) (BUILD_COMPLEX (nan_value, 0));
2458 check_isnan ("real(ctanh(NaN + i0)) = NaN", __real__ result);
2459 check ("imag(ctanh(NaN + i0)) = 0", __imag__ result, 0);
2460 result = FUNC(ctanh) (BUILD_COMPLEX (nan_value, minus_infty));
2461 check_isnan ("real(ctanh(NaN - i0)) = NaN", __real__ result);
2462 check ("imag(ctanh(NaN - i0)) = -0", __imag__ result, minus_infty);
2464 result = FUNC(ctanh) (BUILD_COMPLEX (nan_value, 0.5));
2465 check_isnan ("real(ctanh(NaN + i0.5)) = NaN", __real__ result);
2466 check_isnan ("imag(ctanh(NaN + i0.5)) = NaN", __imag__ result);
2467 result = FUNC(ctanh) (BUILD_COMPLEX (nan_value, -4.5));
2468 check_isnan ("real(ctanh(NaN - i4.5)) = NaN", __real__ result);
2469 check_isnan ("imag(ctanh(NaN - i4.5)) = NaN", __imag__ result);
2471 result = FUNC(ctanh) (BUILD_COMPLEX (0, nan_value));
2472 check_isnan ("real(ctanh(0 + i NaN)) = NaN", __real__ result);
2473 check_isnan ("imag(ctanh(0 + i NaN)) = NaN", __imag__ result);
2474 result = FUNC(ctanh) (BUILD_COMPLEX (5, nan_value));
2475 check_isnan ("real(ctanh(5 + i NaN)) = NaN", __real__ result);
2476 check_isnan ("imag(ctanh(5 + i NaN)) = NaN", __imag__ result);
2477 result = FUNC(ctanh) (BUILD_COMPLEX (minus_zero, nan_value));
2478 check_isnan ("real(ctanh(-0 + i NaN)) = NaN", __real__ result);
2479 check_isnan ("imag(ctanh(-0 + i NaN)) = NaN", __imag__ result);
2480 result = FUNC(ctanh) (BUILD_COMPLEX (-0.25, nan_value));
2481 check_isnan ("real(ctanh(-0.25 + i NaN)) = NaN", __real__ result);
2482 check_isnan ("imag(ctanh(-0.25 + i NaN)) = NaN", __imag__ result);
2484 result = FUNC(ctanh) (BUILD_COMPLEX (nan_value, nan_value));
2485 check_isnan ("real(ctanh(NaN + i NaN)) = NaN", __real__ result);
2486 check_isnan ("imag(ctanh(NaN + i NaN)) = NaN", __imag__ result);
2490 static void
2491 clog_test (void)
2493 __complex__ MATHTYPE result;
2495 result = FUNC(clog) (BUILD_COMPLEX (minus_zero, 0));
2496 check_isinfn ("real(clog(-0 + i0)) = -Inf", __real__ result);
2497 check ("imag(clog(-0 + i0)) = pi", __imag__ result, M_PI);
2498 result = FUNC(clog) (BUILD_COMPLEX (minus_zero, minus_zero));
2499 check_isinfn ("real(clog(-0 - i0)) = -Inf", __real__ result);
2500 check ("imag(clog(-0 - i0)) = -pi", __imag__ result, -M_PI);
2502 result = FUNC(clog) (BUILD_COMPLEX (0, 0));
2503 check_isinfn ("real(clog(0 + i0)) = -Inf", __real__ result);
2504 check ("imag(clog(0 + i0)) = 0", __imag__ result, 0);
2505 result = FUNC(clog) (BUILD_COMPLEX (0, minus_zero));
2506 check_isinfn ("real(clog(0 - i0)) = -Inf", __real__ result);
2507 check ("imag(clog(0 - i0)) = -0", __imag__ result, -minus_zero);
2509 result = FUNC(clog) (BUILD_COMPLEX (minus_infty, plus_infty));
2510 check_isinfp ("real(clog(-Inf + i Inf)) = +Inf", __real__ result);
2511 check ("imag(clog(-Inf + i Inf)) = 3*pi/4", __imag__ result, M_PI - M_PI_4);
2512 result = FUNC(clog) (BUILD_COMPLEX (minus_infty, minus_infty));
2513 check_isinfp ("real(clog(-Inf - i Inf)) = +Inf", __real__ result);
2514 check ("imag(clog(-Inf - i Inf)) = -3*pi/4", __imag__ result, M_PI_4 - M_PI);
2516 result = FUNC(clog) (BUILD_COMPLEX (plus_infty, plus_infty));
2517 check_isinfp ("real(clog(+Inf + i Inf)) = +Inf", __real__ result);
2518 check ("imag(clog(+Inf + i Inf)) = pi/4", __imag__ result, M_PI_4);
2519 result = FUNC(clog) (BUILD_COMPLEX (plus_infty, minus_infty));
2520 check_isinfp ("real(clog(+Inf - i Inf)) = +Inf", __real__ result);
2521 check ("imag(clog(+Inf - i Inf)) = -pi/4", __imag__ result, -M_PI_4);
2523 result = FUNC(clog) (BUILD_COMPLEX (0, plus_infty));
2524 check_isinfp ("real(clog(0 + i Inf)) = +Inf", __real__ result);
2525 check ("imag(clog(0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
2526 result = FUNC(clog) (BUILD_COMPLEX (3, plus_infty));
2527 check_isinfp ("real(clog(3 + i Inf)) = +Inf", __real__ result);
2528 check ("imag(clog(3 + i Inf)) = pi/2", __imag__ result, M_PI_2);
2529 result = FUNC(clog) (BUILD_COMPLEX (minus_zero, plus_infty));
2530 check_isinfp ("real(clog(-0 + i Inf)) = +Inf", __real__ result);
2531 check ("imag(clog(-0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
2532 result = FUNC(clog) (BUILD_COMPLEX (-3, plus_infty));
2533 check_isinfp ("real(clog(-3 + i Inf)) = +Inf", __real__ result);
2534 check ("imag(clog(-3 + i Inf)) = pi/2", __imag__ result, M_PI_2);
2535 result = FUNC(clog) (BUILD_COMPLEX (0, minus_infty));
2536 check_isinfp ("real(clog(0 - i Inf)) = +Inf", __real__ result);
2537 check ("imag(clog(0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
2538 result = FUNC(clog) (BUILD_COMPLEX (3, minus_infty));
2539 check_isinfp ("real(clog(3 - i Inf)) = +Inf", __real__ result);
2540 check ("imag(clog(3 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
2541 result = FUNC(clog) (BUILD_COMPLEX (minus_zero, minus_infty));
2542 check_isinfp ("real(clog(-0 - i Inf)) = +Inf", __real__ result);
2543 check ("imag(clog(-0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
2544 result = FUNC(clog) (BUILD_COMPLEX (-3, minus_infty));
2545 check_isinfp ("real(clog(-3 - i Inf)) = +Inf", __real__ result);
2546 check ("imag(clog(-3 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
2548 result = FUNC(clog) (BUILD_COMPLEX (minus_infty, 0));
2549 check_isinfp ("real(clog(-Inf + i0)) = +Inf", __real__ result);
2550 check ("imag(clog(-Inf + i0)) = pi", __imag__ result, M_PI);
2551 result = FUNC(clog) (BUILD_COMPLEX (minus_infty, 1));
2552 check_isinfp ("real(clog(-Inf + i1)) = +Inf", __real__ result);
2553 check ("imag(clog(-Inf + i1)) = pi", __imag__ result, M_PI);
2554 result = FUNC(clog) (BUILD_COMPLEX (minus_infty, minus_zero));
2555 check_isinfp ("real(clog(-Inf - i0)) = +Inf", __real__ result);
2556 check ("imag(clog(-Inf - i0)) = -pi", __imag__ result, -M_PI);
2557 result = FUNC(clog) (BUILD_COMPLEX (minus_infty, -1));
2558 check_isinfp ("real(clog(-Inf - i1)) = +Inf", __real__ result);
2559 check ("imag(clog(-Inf - i1)) = -pi", __imag__ result, -M_PI);
2561 result = FUNC(clog) (BUILD_COMPLEX (plus_infty, 0));
2562 check_isinfp ("real(clog(+Inf + i0)) = +Inf", __real__ result);
2563 check ("imag(clog(+Inf + i0)) = 0", __imag__ result, 0);
2564 result = FUNC(clog) (BUILD_COMPLEX (plus_infty, 1));
2565 check_isinfp ("real(clog(+Inf + i1)) = +Inf", __real__ result);
2566 check ("imag(clog(+Inf + i1)) = 0", __imag__ result, 0);
2567 result = FUNC(clog) (BUILD_COMPLEX (plus_infty, minus_zero));
2568 check_isinfp ("real(clog(+Inf - i0)) = +Inf", __real__ result);
2569 check ("imag(clog(+Inf - i0)) = -0", __imag__ result, -0);
2570 result = FUNC(clog) (BUILD_COMPLEX (plus_infty, -1));
2571 check_isinfp ("real(clog(+Inf - i1)) = +Inf", __real__ result);
2572 check ("imag(clog(+Inf - i1)) = -0", __imag__ result, -0);
2574 result = FUNC(clog) (BUILD_COMPLEX (plus_infty, nan_value));
2575 check_isinfp ("real(clog(+Inf + i NaN)) = +Inf", __real__ result);
2576 check_isnan ("imag(clog(+Inf + i NaN)) = NaN", __imag__ result);
2577 result = FUNC(clog) (BUILD_COMPLEX (minus_infty, nan_value));
2578 check_isinfp ("real(clog(-Inf + i NaN)) = +Inf", __real__ result);
2579 check_isnan ("imag(clog(-Inf + i NaN)) = NaN", __imag__ result);
2581 result = FUNC(clog) (BUILD_COMPLEX (nan_value, plus_infty));
2582 check_isinfp ("real(clog(NaN + i Inf)) = +Inf", __real__ result);
2583 check_isnan ("imag(clog(NaN + i Inf)) = NaN", __imag__ result);
2584 result = FUNC(clog) (BUILD_COMPLEX (minus_infty, nan_value));
2585 check_isinfp ("real(clog(NaN - i Inf)) = +Inf", __real__ result);
2586 check_isnan ("imag(clog(NaN - i Inf)) = NaN", __imag__ result);
2588 result = FUNC(clog) (BUILD_COMPLEX (0, nan_value));
2589 check_isnan ("real(clog(0 + i NaN)) = NaN", __real__ result);
2590 check_isnan ("imag(clog(0 + i NaN)) = NaN", __imag__ result);
2591 result = FUNC(clog) (BUILD_COMPLEX (3, nan_value));
2592 check_isnan ("real(clog(3 + i NaN)) = NaN", __real__ result);
2593 check_isnan ("imag(clog(3 + i NaN)) = NaN", __imag__ result);
2594 result = FUNC(clog) (BUILD_COMPLEX (minus_zero, nan_value));
2595 check_isnan ("real(clog(-0 + i NaN)) = NaN", __real__ result);
2596 check_isnan ("imag(clog(-0 + i NaN)) = NaN", __imag__ result);
2597 result = FUNC(clog) (BUILD_COMPLEX (-3, nan_value));
2598 check_isnan ("real(clog(-3 + i NaN)) = NaN", __real__ result);
2599 check_isnan ("imag(clog(-3 + i NaN)) = NaN", __imag__ result);
2601 result = FUNC(clog) (BUILD_COMPLEX (nan_value, 0));
2602 check_isnan ("real(clog(NaN + i0)) = NaN", __real__ result);
2603 check_isnan ("imag(clog(NaN + i0)) = NaN", __imag__ result);
2604 result = FUNC(clog) (BUILD_COMPLEX (nan_value, 5));
2605 check_isnan ("real(clog(NaN + i5)) = NaN", __real__ result);
2606 check_isnan ("imag(clog(NaN + i5)) = NaN", __imag__ result);
2607 result = FUNC(clog) (BUILD_COMPLEX (nan_value, minus_zero));
2608 check_isnan ("real(clog(NaN - i0)) = NaN", __real__ result);
2609 check_isnan ("imag(clog(NaN - i0)) = NaN", __imag__ result);
2610 result = FUNC(clog) (BUILD_COMPLEX (nan_value, -5));
2611 check_isnan ("real(clog(NaN - i5)) = NaN", __real__ result);
2612 check_isnan ("imag(clog(NaN - i5)) = NaN", __imag__ result);
2614 result = FUNC(clog) (BUILD_COMPLEX (nan_value, nan_value));
2615 check_isnan ("real(clog(NaN + i NaN)) = NaN", __real__ result);
2616 check_isnan ("imag(clog(NaN + i NaN)) = NaN", __imag__ result);
2620 static void
2621 csqrt_test (void)
2623 __complex__ MATHTYPE result;
2625 result = FUNC(csqrt) (BUILD_COMPLEX (0, 0));
2626 check ("real(csqrt(0 + i0)) = 0", __real__ result, 0);
2627 check ("imag(csqrt(0 + i0)) = 0", __imag__ result, 0);
2628 result = FUNC(csqrt) (BUILD_COMPLEX (0, minus_zero));
2629 check ("real(csqrt(0 - i0)) = 0", __real__ result, 0);
2630 check ("imag(csqrt(0 - i0)) = -0", __imag__ result, minus_zero);
2631 result = FUNC(csqrt) (BUILD_COMPLEX (minus_zero, 0));
2632 check ("real(csqrt(-0 + i0)) = 0", __real__ result, 0);
2633 check ("imag(csqrt(-0 + i0)) = 0", __imag__ result, 0);
2634 result = FUNC(csqrt) (BUILD_COMPLEX (minus_zero, minus_zero));
2635 check ("real(csqrt(-0 - i0)) = 0", __real__ result, 0);
2636 check ("imag(csqrt(-0 - i0)) = -0", __imag__ result, minus_zero);
2638 result = FUNC(csqrt) (BUILD_COMPLEX (minus_infty, 0));
2639 check ("real(csqrt(-Inf + i0)) = 0", __real__ result, 0);
2640 check_isinfp ("imag(csqrt(-Inf + i0)) = +Inf", __imag__ result);
2641 result = FUNC(csqrt) (BUILD_COMPLEX (minus_infty, 6));
2642 check ("real(csqrt(-Inf + i6)) = 0", __real__ result, 0);
2643 check_isinfp ("imag(csqrt(-Inf + i6)) = +Inf", __imag__ result);
2644 result = FUNC(csqrt) (BUILD_COMPLEX (minus_infty, minus_zero));
2645 check ("real(csqrt(-Inf - i0)) = 0", __real__ result, 0);
2646 check_isinfn ("imag(csqrt(-Inf - i0)) = -Inf", __imag__ result);
2647 result = FUNC(csqrt) (BUILD_COMPLEX (minus_infty, -6));
2648 check ("real(csqrt(-Inf - i6)) = 0", __real__ result, 0);
2649 check_isinfn ("imag(csqrt(-Inf - i6)) = -Inf", __imag__ result);
2651 result = FUNC(csqrt) (BUILD_COMPLEX (plus_infty, 0));
2652 check_isinfp ("real(csqrt(+Inf + i0)) = +Inf", __real__ result);
2653 check ("imag(csqrt(-Inf + i0)) = 0", __imag__ result, 0);
2654 result = FUNC(csqrt) (BUILD_COMPLEX (plus_infty, 6));
2655 check_isinfp ("real(csqrt(+Inf + i6)) = +Inf", __real__ result);
2656 check ("imag(csqrt(-Inf + i6)) = 0", __imag__ result, 0);
2657 result = FUNC(csqrt) (BUILD_COMPLEX (plus_infty, minus_zero));
2658 check_isinfp ("real(csqrt(+Inf - i0)) = +Inf", __real__ result);
2659 check ("imag(csqrt(-Inf - i0)) = -0", __imag__ result, minus_zero);
2660 result = FUNC(csqrt) (BUILD_COMPLEX (plus_infty, -6));
2661 check_isinfp ("real(csqrt(+Inf - i6)) = +Inf", __real__ result);
2662 check ("imag(csqrt(-Inf - i6)) = -0", __imag__ result, minus_zero);
2664 result = FUNC(csqrt) (BUILD_COMPLEX (0, plus_infty));
2665 check_isinfp ("real(csqrt(0 + i Inf)) = +Inf", __real__ result);
2666 check_isinfp ("imag(csqrt(0 + i Inf)) = +Inf", __imag__ result);
2667 result = FUNC(csqrt) (BUILD_COMPLEX (4, plus_infty));
2668 check_isinfp ("real(csqrt(4 + i Inf)) = +Inf", __real__ result);
2669 check_isinfp ("imag(csqrt(4 + i Inf)) = +Inf", __imag__ result);
2670 result = FUNC(csqrt) (BUILD_COMPLEX (plus_infty, plus_infty));
2671 check_isinfp ("real(csqrt(+Inf + i Inf)) = +Inf", __real__ result);
2672 check_isinfp ("imag(csqrt(+Inf + i Inf)) = +Inf", __imag__ result);
2673 result = FUNC(csqrt) (BUILD_COMPLEX (minus_zero, plus_infty));
2674 check_isinfp ("real(csqrt(-0 + i Inf)) = +Inf", __real__ result);
2675 check_isinfp ("imag(csqrt(-0 + i Inf)) = +Inf", __imag__ result);
2676 result = FUNC(csqrt) (BUILD_COMPLEX (-4, plus_infty));
2677 check_isinfp ("real(csqrt(-4 + i Inf)) = +Inf", __real__ result);
2678 check_isinfp ("imag(csqrt(-4 + i Inf)) = +Inf", __imag__ result);
2679 result = FUNC(csqrt) (BUILD_COMPLEX (minus_infty, plus_infty));
2680 check_isinfp ("real(csqrt(-Inf + i Inf)) = +Inf", __real__ result);
2681 check_isinfp ("imag(csqrt(-Inf + i Inf)) = +Inf", __imag__ result);
2682 result = FUNC(csqrt) (BUILD_COMPLEX (0, minus_infty));
2683 check_isinfp ("real(csqrt(0 - i Inf)) = +Inf", __real__ result);
2684 check_isinfn ("imag(csqrt(0 - i Inf)) = -Inf", __imag__ result);
2685 result = FUNC(csqrt) (BUILD_COMPLEX (4, minus_infty));
2686 check_isinfp ("real(csqrt(4 - i Inf)) = +Inf", __real__ result);
2687 check_isinfn ("imag(csqrt(4 - i Inf)) = -Inf", __imag__ result);
2688 result = FUNC(csqrt) (BUILD_COMPLEX (plus_infty, minus_infty));
2689 check_isinfp ("real(csqrt(+Inf - i Inf)) = +Inf", __real__ result);
2690 check_isinfn ("imag(csqrt(+Inf - i Inf)) = -Inf", __imag__ result);
2691 result = FUNC(csqrt) (BUILD_COMPLEX (minus_zero, minus_infty));
2692 check_isinfp ("real(csqrt(-0 - i Inf)) = +Inf", __real__ result);
2693 check_isinfn ("imag(csqrt(-0 - i Inf)) = -Inf", __imag__ result);
2694 result = FUNC(csqrt) (BUILD_COMPLEX (-4, minus_infty));
2695 check_isinfp ("real(csqrt(-4 - i Inf)) = +Inf", __real__ result);
2696 check_isinfn ("imag(csqrt(-4 - i Inf)) = -Inf", __imag__ result);
2697 result = FUNC(csqrt) (BUILD_COMPLEX (minus_infty, minus_infty));
2698 check_isinfp ("real(csqrt(-Inf - i Inf)) = +Inf", __real__ result);
2699 check_isinfn ("imag(csqrt(-Inf - i Inf)) = -Inf", __imag__ result);
2701 result = FUNC(csqrt) (BUILD_COMPLEX (minus_infty, nan_value));
2702 check_isnan ("real(csqrt(-Inf + i NaN)) = NaN", __real__ result);
2703 check_isinfp ("imag(csqrt(-Inf + i NaN)) = +-Inf",
2704 FUNC(fabs) (__imag__ result));
2706 result = FUNC(csqrt) (BUILD_COMPLEX (plus_infty, nan_value));
2707 check_isinfp ("real(csqrt(+Inf + i NaN)) = +Inf", __real__ result);
2708 check_isnan ("imag(csqrt(+Inf + i NaN)) = NaN", __imag__ result);
2710 result = FUNC(csqrt) (BUILD_COMPLEX (0, nan_value));
2711 check_isnan ("real(csqrt(0 + i NaN)) = NaN", __real__ result);
2712 check_isnan ("imag(csqrt(0 + i NaN)) = NaN", __imag__ result);
2713 result = FUNC(csqrt) (BUILD_COMPLEX (1, nan_value));
2714 check_isnan ("real(csqrt(1 + i NaN)) = NaN", __real__ result);
2715 check_isnan ("imag(csqrt(1 + i NaN)) = NaN", __imag__ result);
2716 result = FUNC(csqrt) (BUILD_COMPLEX (minus_zero, nan_value));
2717 check_isnan ("real(csqrt(-0 + i NaN)) = NaN", __real__ result);
2718 check_isnan ("imag(csqrt(-0 + i NaN)) = NaN", __imag__ result);
2719 result = FUNC(csqrt) (BUILD_COMPLEX (-1, nan_value));
2720 check_isnan ("real(csqrt(-1 + i NaN)) = NaN", __real__ result);
2721 check_isnan ("imag(csqrt(-1 + i NaN)) = NaN", __imag__ result);
2723 result = FUNC(csqrt) (BUILD_COMPLEX (nan_value, 0));
2724 check_isnan ("real(csqrt(NaN + i0)) = NaN", __real__ result);
2725 check_isnan ("imag(csqrt(NaN + i0)) = NaN", __imag__ result);
2726 result = FUNC(csqrt) (BUILD_COMPLEX (nan_value, 8));
2727 check_isnan ("real(csqrt(NaN + i8)) = NaN", __real__ result);
2728 check_isnan ("imag(csqrt(NaN + i8)) = NaN", __imag__ result);
2729 result = FUNC(csqrt) (BUILD_COMPLEX (nan_value, minus_zero));
2730 check_isnan ("real(csqrt(NaN - i0)) = NaN", __real__ result);
2731 check_isnan ("imag(csqrt(NaN - i0)) = NaN", __imag__ result);
2732 result = FUNC(csqrt) (BUILD_COMPLEX (nan_value, -8));
2733 check_isnan ("real(csqrt(NaN - i8)) = NaN", __real__ result);
2734 check_isnan ("imag(csqrt(NaN - i8)) = NaN", __imag__ result);
2736 result = FUNC(csqrt) (BUILD_COMPLEX (nan_value, nan_value));
2737 check_isnan ("real(csqrt(NaN + i NaN)) = NaN", __real__ result);
2738 check_isnan ("imag(csqrt(NaN + i NaN)) = NaN", __imag__ result);
2740 #endif
2743 static void
2744 inverse_func_pair_test (const char *test_name,
2745 mathfunc f1, mathfunc inverse,
2746 MATHTYPE x, MATHTYPE epsilon)
2748 MATHTYPE a, b, difference;
2749 int result;
2751 a = f1 (x);
2752 (void) &a;
2753 b = inverse (a);
2754 (void) &b;
2756 result = check_equal (b, x, epsilon, &difference);
2757 output_result (test_name, result,
2758 b, x, difference, PRINT, PRINT);
2762 static void
2763 inverse_functions (void)
2765 inverse_func_pair_test ("asin(sin(x)) == x",
2766 FUNC(sin), FUNC(asin), 1.0, CHOOSE (2e-18L, 0, 1e-7L));
2767 inverse_func_pair_test ("sin(asin(x)) == x",
2768 FUNC(asin), FUNC(sin), 1.0, 0.0);
2770 inverse_func_pair_test ("acos(cos(x)) == x",
2771 FUNC(cos), FUNC(acos), 1.0, CHOOSE (4e-18L, 1e-15L, 0));
2772 inverse_func_pair_test ("cos(acos(x)) == x",
2773 FUNC(acos), FUNC(cos), 1.0, 0.0);
2774 inverse_func_pair_test ("atan(tan(x)) == x",
2775 FUNC(tan), FUNC(atan), 1.0, CHOOSE (2e-18L, 0, 0));
2776 inverse_func_pair_test ("tan(atan(x)) == x",
2777 FUNC(atan), FUNC(tan), 1.0, CHOOSE (2e-18L, 1e-15L, 0));
2779 inverse_func_pair_test ("asinh(sinh(x)) == x",
2780 FUNC(sinh), FUNC(asinh), 1.0, CHOOSE (1e-18L, 0, 1e-7));
2781 inverse_func_pair_test ("sinh(asinh(x)) == x",
2782 FUNC(asinh), FUNC(sinh), 1.0, CHOOSE (2e-18L, 0, 0));
2784 inverse_func_pair_test ("acosh(cosh(x)) == x",
2785 FUNC(cosh), FUNC(acosh), 1.0, CHOOSE (1e-18L, 1e-15L, 0));
2786 inverse_func_pair_test ("cosh(acosh(x)) == x",
2787 FUNC(acosh), FUNC(cosh), 1.0, 0.0);
2789 inverse_func_pair_test ("atanh(tanh(x)) == x",
2790 FUNC(tanh), FUNC(atanh), 1.0, CHOOSE (1e-18L, 1e-15L, 0));
2791 inverse_func_pair_test ("tanh(atanh(x)) == x",
2792 FUNC(atanh), FUNC(tanh), 1.0, 0.0);
2796 /* Test sin and cos with the identity: sin(x)^2 + cos(x)^2 = 1. */
2797 static void
2798 identities1_test (MATHTYPE x, MATHTYPE epsilon)
2800 MATHTYPE res1, res2, res3, diff;
2801 int result;
2803 res1 = FUNC(sin) (x);
2804 (void) &res1;
2805 res2 = FUNC(cos) (x);
2806 (void) &res2;
2807 res3 = res1 * res1 + res2 * res2;
2808 (void) &res3;
2810 result = check_equal (res3, 1.0, epsilon, &diff);
2811 output_result_ext ("sin^2 + cos^2 == 1", result,
2812 res3, 1.0, diff, x, PRINT, PRINT);
2816 /* Test sin, cos, tan with the following relation: tan = sin/cos. */
2817 static void
2818 identities2_test (MATHTYPE x, MATHTYPE epsilon)
2820 MATHTYPE res1, res2, res3, res4, diff;
2821 int result;
2823 res1 = FUNC(sin) (x);
2824 (void) &res1;
2825 res2 = FUNC(cos) (x);
2826 (void) &res2;
2827 res3 = FUNC(tan) (x);
2828 (void) &res3;
2829 res4 = res1 / res2;
2830 (void) &res4;
2832 result = check_equal (res4, res3, epsilon, &diff);
2833 output_result_ext ("sin/cos == tan", result,
2834 res4, res3, diff, x, PRINT, PRINT);
2838 /* Test cosh and sinh with the identity cosh^2 - sinh^2 = 1. */
2839 static void
2840 identities3_test (MATHTYPE x, MATHTYPE epsilon)
2842 MATHTYPE res1, res2, res3, diff;
2843 int result;
2845 res1 = FUNC(sinh) (x);
2846 (void) &res1;
2847 res2 = FUNC(cosh) (x);
2848 (void) &res2;
2849 res3 = res2 * res2 - res1 * res1;
2850 (void) &res3;
2852 result = check_equal (res3, 1.0, epsilon, &diff);
2853 output_result_ext ("cosh^2 - sinh^2 == 1", result,
2854 res3, 1.0, diff, x, PRINT, PRINT);
2858 static void
2859 identities (void)
2861 identities1_test (0.2L, CHOOSE (1e-18L, 0, 2e-7));
2862 identities1_test (0.9L, CHOOSE (1e-18L, 0, 0));
2863 identities1_test (0, 0);
2864 identities1_test (-1, CHOOSE (1e-18L, 0, 1e-7));
2866 identities2_test (0.2L, CHOOSE (0, 1e-16, 0));
2867 identities2_test (0.9L, CHOOSE (0, 1e-15, 0));
2868 identities2_test (0, 0);
2869 identities2_test (-1, CHOOSE (1e-18L, 1e-15, 0));
2871 identities3_test (0.2L, CHOOSE (1e-18L, 0, 1e-7));
2872 identities3_test (0.9L, CHOOSE (1e-18L, 1e-15, 1e-6));
2873 identities3_test (0, CHOOSE (0, 0, 1e-6));
2874 identities3_test (-1, CHOOSE (1e-18L, 0, 1e-6));
2879 Let's test that basic arithmetic is working
2880 tests: Infinity and NaN
2882 static void
2883 basic_tests (void)
2885 /* variables are declared volatile to forbid some compiler
2886 optimizations */
2887 volatile MATHTYPE Inf_var, NaN_var, zero_var, one_var;
2888 MATHTYPE x1, x2;
2890 zero_var = 0.0;
2891 one_var = 1.0;
2892 NaN_var = nan_value;
2893 Inf_var = one_var / zero_var;
2895 (void) &zero_var;
2896 (void) &one_var;
2897 (void) &NaN_var;
2898 (void) &Inf_var;
2900 check_isinfp ("isinf (inf) == +1", Inf_var);
2901 check_isinfn ("isinf (-inf) == -1", -Inf_var);
2902 check_bool ("!isinf (1)", !(FUNC(isinf) (one_var)));
2903 check_bool ("!isinf (NaN)", !(FUNC(isinf) (NaN_var)));
2905 check_isnan ("isnan (NaN)", NaN_var);
2906 check_isnan ("isnan (-NaN)", -NaN_var);
2907 check_bool ("!isnan (1)", !(FUNC(isnan) (one_var)));
2908 check_bool ("!isnan (inf)", !(FUNC(isnan) (Inf_var)));
2910 check_bool ("inf == inf", Inf_var == Inf_var);
2911 check_bool ("-inf == -inf", -Inf_var == -Inf_var);
2912 check_bool ("inf != -inf", Inf_var != -Inf_var);
2913 check_bool ("NaN != NaN", NaN_var != NaN_var);
2916 the same tests but this time with NAN from <nan.h>
2917 NAN is a double const
2919 check_bool ("isnan (NAN)", isnan (NAN));
2920 check_bool ("isnan (-NAN)", isnan (-NAN));
2921 check_bool ("!isinf (NAN)", !(isinf (NAN)));
2922 check_bool ("!isinf (-NAN)", !(isinf (-NAN)));
2923 check_bool ("NAN != NAN", NAN != NAN);
2926 And again with the value returned by the `nan' function.
2928 check_bool ("isnan (NAN)", isnan (FUNC(nan) ("")));
2929 check_bool ("isnan (-NAN)", isnan (-FUNC(nan) ("")));
2930 check_bool ("!isinf (NAN)", !(isinf (FUNC(nan) (""))));
2931 check_bool ("!isinf (-NAN)", !(isinf (-FUNC(nan) (""))));
2932 check_bool ("NAN != NAN", FUNC(nan) ("") != FUNC(nan) (""));
2934 /* test if EPSILON is ok */
2935 x1 = MATHCONST (1.0);
2936 x2 = x1 + CHOOSE (LDBL_EPSILON, DBL_EPSILON, FLT_EPSILON);
2937 check_bool ("1 != 1+EPSILON", x1 != x2);
2939 x1 = MATHCONST (1.0);
2940 x2 = x1 - CHOOSE (LDBL_EPSILON, DBL_EPSILON, FLT_EPSILON);
2941 check_bool ("1 != 1-EPSILON", x1 != x2);
2943 /* test if HUGE_VALx is ok */
2944 x1 = CHOOSE (HUGE_VALL, HUGE_VAL, HUGE_VALF);
2945 check_bool ("isinf (HUGE_VALx) == +1", ISINF (x1) == +1);
2946 x1 = -CHOOSE (HUGE_VALL, HUGE_VAL, HUGE_VALF);
2947 check_bool ("isinf (-HUGE_VALx) == -1", ISINF (x1) == -1);
2952 static void
2953 initialize (void)
2955 fpstack_test ("start *init*");
2956 plus_zero = 0.0;
2957 nan_value = plus_zero / plus_zero; /* Suppress GCC warning */
2959 minus_zero = FUNC (copysign) (0.0, -1.0);
2960 plus_infty = CHOOSE (HUGE_VALL, HUGE_VAL, HUGE_VALF);
2961 minus_infty = -CHOOSE (HUGE_VALL, HUGE_VAL, HUGE_VALF);
2963 (void) &plus_zero;
2964 (void) &nan_value;
2965 (void) &minus_zero;
2966 (void) &plus_infty;
2967 (void) &minus_infty;
2969 /* Test to make sure we start correctly. */
2970 fpstack_test ("end *init*");
2974 static struct option long_options[] =
2976 {"verbose", optional_argument, NULL, 'v'},
2977 {"silent", no_argument, NULL, 's'},
2978 {0, 0, 0, 0}
2982 static void
2983 parse_options (int argc, char *argv[])
2985 int c;
2986 int option_index;
2988 verbose = 1;
2990 while (1)
2992 c = getopt_long (argc, argv, "v::s",
2993 long_options, &option_index);
2995 /* Detect the end of the options. */
2996 if (c == -1)
2997 break;
2999 switch (c)
3001 case 'v':
3002 if (optarg)
3003 verbose = (unsigned int) strtoul (optarg, NULL, 0);
3004 else
3005 verbose = 3;
3006 break;
3007 case 's':
3008 verbose = 0;
3009 default:
3010 break;
3017 main (int argc, char *argv[])
3019 parse_options (argc, argv);
3021 initialize ();
3022 printf (TEST_MSG);
3023 basic_tests ();
3025 acos_test ();
3026 acosh_test ();
3027 asin_test ();
3028 asinh_test ();
3029 atan_test ();
3030 atanh_test ();
3031 atan2_test ();
3032 cbrt_test ();
3033 ceil_test ();
3034 cos_test ();
3035 cosh_test ();
3036 exp_test ();
3037 exp2_test ();
3038 expm1_test ();
3039 frexp_test ();
3040 ilogb_test ();
3041 ldexp_test ();
3042 log_test ();
3043 log10_test ();
3044 log1p_test ();
3045 log2_test ();
3046 logb_test ();
3047 modf_test ();
3048 scalb_test ();
3049 scalbn_test ();
3050 sin_test ();
3051 sinh_test ();
3052 tan_test ();
3053 tanh_test ();
3054 fabs_test ();
3055 floor_test ();
3056 fpclassify_test ();
3057 hypot_test ();
3058 pow_test ();
3059 fdim_test ();
3060 fmin_test ();
3061 fmax_test ();
3062 nextafter_test ();
3063 copysign_test ();
3064 sqrt_test ();
3065 trunc_test ();
3066 #if 0
3067 /* XXX I'm not sure what is the correct result. */
3068 remquo_test ();
3069 #endif
3070 cexp_test ();
3071 csinh_test ();
3072 ccosh_test ();
3074 identities ();
3075 inverse_functions ();
3077 if (noErrors)
3079 printf ("\n%d errors occured.\n", noErrors);
3080 exit (1);
3082 printf ("\n All tests passed sucessfully.\n");
3083 exit (0);