Update.
[glibc.git] / math / libm-test.c
blobf35ef41423728ed3bad3323e6d973513c6cb56d9
1 /* Copyright (C) 1997, 1998 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Andreas Jaeger <aj@arthur.rhein-neckar.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".
39 PRINTF_XEXPR Like PRINTF_EXPR, but print in hexadecimal format.
42 /* This program isn't finished yet.
43 It has tests for:
44 acos, acosh, asin, asinh, atan, atan2, atanh,
45 cbrt, ceil, copysign, cos, cosh, erf, erfc, exp, exp2, expm1,
46 fabs, fdim, floor, fma, fmax, fmin, fmod, fpclassify,
47 frexp, gamma, hypot,
48 ilogb, isfinite, isinf, isnan, isnormal,
49 ldexp, lgamma, log, log10, log1p, log2, logb,
50 modf, nearbyint, nextafter,
51 pow, remainder, remquo, rint, lrint, llrint,
52 round, lround, llround,
53 scalb, scalbn, signbit, sin, sincos, sinh, sqrt, tan, tanh, trunc
55 and for the following complex math functions:
56 cabs, cacos, cacosh, carg, casin, casinh, catan, catanh,
57 ccos, ccosh, cexp, clog, cpow, csin, csinh, csqrt, ctan, ctanh.
59 At the moment the following functions aren't tested:
60 conj, cproj, cimag, creal, drem,
61 j0, j1, jn, y0, y1, yn,
62 significand,
63 nan, comparison macros (isless,isgreater,...).
65 The routines using random variables are still under construction. I don't
66 like it the way it's working now and will change it.
68 Parameter handling is primitive in the moment:
69 --verbose=[0..4] for different levels of output:
70 0: only error count
71 1: basic report on failed tests (default)
72 2: full report on failed tests
73 3: full report on failed and passed tests
74 4: additional report on exceptions
75 -v for full output (equals --verbose=4)
76 -s,--silent outputs only the error count (equals --verbose=0)
79 /* "Philosophy":
81 This suite tests some aspects of the correct implementation of
82 mathematical functions in libm. Some simple, specific parameters
83 are tested for correctness but there's no exhaustive
84 testing. Handling of specific inputs (e.g. infinity, not-a-number)
85 is also tested. Correct handling of exceptions is checked
86 against. These implemented tests should check all cases that are
87 specified in ISO C 9X.
89 Exception testing: At the moment only divide-by-zero and invalid
90 exceptions are tested. Overflow/underflow and inexact exceptions
91 aren't checked at the moment.
93 NaN values: There exist signalling and quiet NaNs. This implementation
94 only uses signalling NaN as parameter but does not differenciate
95 between the two kinds of NaNs as result.
97 Inline functions: Inlining functions should give an improvement in
98 speed - but not in precission. The inlined functions return
99 reasonable values for a reasonable range of input values. The
100 result is not necessarily correct for all values and exceptions are
101 not correctly raised in all cases. Problematic input and return
102 values are infinity, not-a-number and minus zero. This suite
103 therefore does not check these specific inputs and the exception
104 handling for inlined mathematical functions - just the "reasonable"
105 values are checked.
107 Beware: The tests might fail for any of the following reasons:
108 - Tests are wrong
109 - Functions are wrong
110 - Floating Point Unit not working properly
111 - Compiler has errors
113 With e.g. gcc 2.7.2.2 the test for cexp fails because of a compiler error.
117 #ifndef _GNU_SOURCE
118 # define _GNU_SOURCE
119 #endif
121 #include <complex.h>
122 #include <math.h>
123 #include <float.h>
124 #include <fenv.h>
126 #include <errno.h>
127 #include <stdlib.h>
128 #include <stdio.h>
129 #include <getopt.h>
131 /* Possible exceptions */
132 #define NO_EXCEPTION 0x0
133 #define INVALID_EXCEPTION 0x1
134 #define DIVIDE_BY_ZERO_EXCEPTION 0x2
136 #define PRINT 1
137 #define NO_PRINT 0
139 /* Various constants (we must supply them precalculated for accuracy). */
140 #define M_PI_6 .52359877559829887308L
142 static int noErrors; /* number of errors */
143 static int noTests; /* number of tests (without testing exceptions) */
144 static int noExcTests; /* number of tests for exception flags */
146 static int verbose = 3;
147 static MATHTYPE minus_zero, plus_zero;
148 static MATHTYPE plus_infty, minus_infty, nan_value;
150 typedef MATHTYPE (*mathfunc) (MATHTYPE);
152 #define BUILD_COMPLEX(real, imag) \
153 ({ __complex__ MATHTYPE __retval; \
154 __real__ __retval = (real); \
155 __imag__ __retval = (imag); \
156 __retval; })
159 #define ISINF(x) \
160 (sizeof (x) == sizeof (float) ? \
161 isinff (x) \
162 : sizeof (x) == sizeof (double) ? \
163 isinf (x) : isinfl (x))
167 Test if Floating-Point stack hasn't changed
169 static void
170 fpstack_test (const char *test_name)
172 #ifdef i386
173 static int old_stack;
174 int sw;
175 asm ("fnstsw":"=a" (sw));
176 sw >>= 11;
177 sw &= 7;
178 if (sw != old_stack)
180 printf ("FP-Stack wrong after test %s\n", test_name);
181 if (verbose > 2)
182 printf ("=======> stack = %d\n", sw);
183 ++noErrors;
184 old_stack = sw;
186 #endif
191 Get a random value x with min_value < x < max_value
192 and min_value, max_value finite,
193 max_value and min_value shouldn't be too close together
195 static MATHTYPE
196 random_value (MATHTYPE min_value, MATHTYPE max_value)
198 int r;
199 MATHTYPE x;
201 r = rand ();
203 x = (max_value - min_value) / RAND_MAX * (MATHTYPE) r + min_value;
205 if ((x <= min_value) || (x >= max_value) || !isfinite (x))
206 x = (max_value - min_value) / 2 + min_value;
208 /* Make sure the RNG has no influence on the exceptions. */
209 feclearexcept (FE_ALL_EXCEPT);
211 return x;
214 /* Get a random value x with x > min_value. */
215 static MATHTYPE
216 random_greater (MATHTYPE min_value)
218 return random_value (min_value, 1e6); /* CHOOSE (LDBL_MAX, DBL_MAX, FLT_MAX) */
221 /* Get a random value x with x < max_value. */
222 static MATHTYPE
223 random_less (MATHTYPE max_value)
225 return random_value (-1e6, max_value);
229 static void
230 output_new_test (const char *test_name)
232 if (verbose > 2)
233 printf ("\nTesting: %s\n", test_name);
237 static void
238 output_pass_value (void)
240 if (verbose > 2)
241 printf ("Pass: Value Ok.\n");
245 static void
246 output_fail_value (const char * test_name)
248 if (verbose > 0 && verbose < 3)
249 printf ("Fail: %s\n", test_name);
250 if (verbose >= 3)
251 printf ("Fail:\n");
255 /* Test whether a given exception was raised. */
256 static void
257 test_single_exception (const char *test_name,
258 short int exception,
259 short int exc_flag,
260 int fe_flag,
261 const char *flag_name)
263 #ifndef TEST_INLINE
264 if (exception & exc_flag)
266 if (fetestexcept (fe_flag))
268 if (verbose > 3)
269 printf ("Pass: Exception \"%s\" set\n", flag_name);
271 else
273 if (verbose && verbose < 3)
274 printf ("Fail: %s: Exception \"%s\" not set\n",
275 test_name, flag_name);
276 if (verbose >= 3)
277 printf ("Fail: Exception \"%s\" not set\n",
278 flag_name);
279 ++noErrors;
282 else
284 if (fetestexcept (fe_flag))
286 if (verbose && verbose < 3)
287 printf ("Fail: %s: Exception \"%s\" set\n",
288 test_name, flag_name);
289 if (verbose >= 3)
290 printf ("Fail: Exception \"%s\" set\n",
291 flag_name);
292 ++noErrors;
294 else
296 if (verbose > 3)
297 printf ("Pass: Exception \"%s\" not set\n",
298 flag_name);
301 #endif
305 /* Test whether exception given by EXCEPTION are raised. */
306 static void
307 test_not_exception (const char *test_name, short int exception)
309 ++noExcTests;
310 #ifdef FE_DIVBYZERO
311 if ((exception & DIVIDE_BY_ZERO_EXCEPTION) == 0)
312 test_single_exception (test_name, exception,
313 DIVIDE_BY_ZERO_EXCEPTION, FE_DIVBYZERO,
314 "Divide by zero");
315 #endif
316 #ifdef FE_INVALID
317 if ((exception & INVALID_EXCEPTION) == 0)
318 test_single_exception (test_name, exception, INVALID_EXCEPTION, FE_INVALID,
319 "Invalid operation");
320 #endif
321 feclearexcept (FE_ALL_EXCEPT);
325 /* Test whether exceptions given by EXCEPTION are raised. */
326 static void
327 test_exceptions (const char *test_name, short int exception)
329 ++noExcTests;
330 #ifdef FE_DIVBYZERO
331 test_single_exception (test_name, exception,
332 DIVIDE_BY_ZERO_EXCEPTION, FE_DIVBYZERO,
333 "Divide by zero");
334 #endif
335 #ifdef FE_INVALID
336 test_single_exception (test_name, exception, INVALID_EXCEPTION, FE_INVALID,
337 "Invalid operation");
338 #endif
339 feclearexcept (FE_ALL_EXCEPT);
343 /* Test if two floating point numbers are equal. */
344 static int
345 check_equal (MATHTYPE computed, MATHTYPE supplied, MATHTYPE eps, MATHTYPE * diff)
347 int ret_value;
349 /* Both plus Infinity or both minus infinity. */
350 if (ISINF (computed) && (ISINF (computed) == ISINF (supplied)))
351 return 1;
353 if (isnan (computed) && isnan (supplied)) /* isnan works for all types */
354 return 1;
356 *diff = FUNC(fabs) (computed - supplied);
359 ret_value = (*diff <= eps &&
360 (signbit (computed) == signbit (supplied) || eps != 0.0));
362 /* Make sure the subtraction/comparsion have no influence on the exceptions. */
363 feclearexcept (FE_ALL_EXCEPT);
365 return ret_value;
370 static void
371 output_result_bool (const char *test_name, int result)
373 ++noTests;
374 if (result)
376 output_pass_value ();
378 else
380 output_fail_value (test_name);
381 if (verbose > 1)
382 printf (" Value: %d\n", result);
383 ++noErrors;
386 fpstack_test (test_name);
390 static void
391 output_isvalue (const char *test_name, int result,
392 MATHTYPE value)
394 ++noTests;
395 if (result)
397 output_pass_value ();
399 else
401 output_fail_value (test_name);
402 if (verbose > 1)
403 printf (" Value: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR "\n",
404 value, value);
405 ++noErrors;
408 fpstack_test (test_name);
412 static void
413 output_isvalue_ext (const char *test_name, int result,
414 MATHTYPE value, MATHTYPE parameter)
416 ++noTests;
417 if (result)
419 output_pass_value ();
421 else
423 output_fail_value (test_name);
424 if (verbose > 1)
426 printf (" Value: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR "\n",
427 value, value);
428 printf (" Parameter: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR "\n",
429 parameter, parameter);
431 noErrors++;
434 fpstack_test (test_name);
438 static void
439 output_result (const char *test_name, int result,
440 MATHTYPE computed, MATHTYPE expected,
441 MATHTYPE difference,
442 int print_values, int print_diff)
444 ++noTests;
445 if (result)
447 output_pass_value ();
449 else
451 output_fail_value (test_name);
452 if (verbose > 1 && print_values)
454 printf ("Result:\n");
455 printf (" is: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR "\n",
456 computed, computed);
457 printf (" should be: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR "\n",
458 expected, expected);
459 if (print_diff)
460 printf (" difference: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR
461 "\n", difference, difference);
463 ++noErrors;
466 fpstack_test (test_name);
470 static void
471 output_result_ext (const char *test_name, int result,
472 MATHTYPE computed, MATHTYPE expected,
473 MATHTYPE difference,
474 MATHTYPE parameter,
475 int print_values, int print_diff)
477 ++noTests;
478 if (result)
480 output_pass_value ();
482 else
484 output_fail_value (test_name);
485 if (verbose > 1 && print_values)
487 printf ("Result:\n");
488 printf (" is: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR "\n",
489 computed, computed);
490 printf (" should be: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR "\n",
491 expected, expected);
492 if (print_diff)
493 printf (" difference: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR
494 "\n", difference, difference);
495 printf ("Parameter: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR "\n",
496 parameter, parameter);
498 ++noErrors;
501 fpstack_test (test_name);
505 check that computed and expected values are the same
507 static void
508 check (const char *test_name, MATHTYPE computed, MATHTYPE expected)
510 MATHTYPE diff;
511 int result;
513 output_new_test (test_name);
514 test_exceptions (test_name, NO_EXCEPTION);
515 result = check_equal (computed, expected, 0, &diff);
516 output_result (test_name, result,
517 computed, expected, diff, PRINT, PRINT);
522 check that computed and expected values are the same,
523 outputs the parameter to the function
525 static void
526 check_ext (const char *test_name, MATHTYPE computed, MATHTYPE expected,
527 MATHTYPE parameter)
529 MATHTYPE diff;
530 int result;
532 output_new_test (test_name);
533 test_exceptions (test_name, NO_EXCEPTION);
534 result = check_equal (computed, expected, 0, &diff);
535 output_result_ext (test_name, result,
536 computed, expected, diff, parameter, PRINT, PRINT);
541 check that computed and expected values are the same and
542 checks also for exception flags
544 static void
545 check_exc (const char *test_name, MATHTYPE computed, MATHTYPE expected,
546 short exception)
548 MATHTYPE diff;
549 int result;
551 output_new_test (test_name);
552 test_exceptions (test_name, exception);
553 result = check_equal (computed, expected, 0, &diff);
554 output_result (test_name, result,
555 computed, expected, diff, PRINT, PRINT);
559 check that computed and expected values are close enough
561 static void
562 check_eps (const char *test_name, MATHTYPE computed, MATHTYPE expected,
563 MATHTYPE epsilon)
565 MATHTYPE diff;
566 int result;
568 output_new_test (test_name);
569 test_exceptions (test_name, NO_EXCEPTION);
570 result = check_equal (computed, expected, epsilon, &diff);
571 output_result (test_name, result,
572 computed, expected, diff, PRINT, PRINT);
576 check a boolean condition
578 static void
579 check_bool (const char *test_name, int computed)
581 output_new_test (test_name);
582 test_exceptions (test_name, NO_EXCEPTION);
583 output_result_bool (test_name, computed);
589 check that computed and expected values are equal (int values)
591 static void
592 check_int (const char *test_name, int computed, int expected)
594 int diff = computed - expected;
595 int result = diff == 0;
597 output_new_test (test_name);
598 test_exceptions (test_name, NO_EXCEPTION);
600 if (result)
602 output_pass_value ();
604 else
606 output_fail_value (test_name);
607 if (verbose > 1)
609 printf ("Result:\n");
610 printf (" is: %d\n", computed);
611 printf (" should be: %d\n", expected);
613 noErrors++;
616 fpstack_test (test_name);
621 check that computed and expected values are equal (long int values)
623 static void
624 check_long (const char *test_name, long int computed, long int expected)
626 long int diff = computed - expected;
627 int result = diff == 0;
629 ++noTests;
630 output_new_test (test_name);
631 test_exceptions (test_name, NO_EXCEPTION);
633 if (result)
635 output_pass_value ();
637 else
639 output_fail_value (test_name);
640 if (verbose > 1)
642 printf ("Result:\n");
643 printf (" is: %ld\n", computed);
644 printf (" should be: %ld\n", expected);
646 noErrors++;
649 fpstack_test (test_name);
653 check that computed and expected values are equal (long long int values)
655 static void
656 check_longlong (const char *test_name, long long int computed,
657 long long int expected)
659 long long int diff = computed - expected;
660 int result = diff == 0;
662 ++noTests;
663 output_new_test (test_name);
664 test_exceptions (test_name, NO_EXCEPTION);
666 if (result)
668 output_pass_value ();
670 else
672 output_fail_value (test_name);
673 if (verbose > 1)
675 printf ("Result:\n");
676 printf (" is: %lld\n", computed);
677 printf (" should be: %lld\n", expected);
679 noErrors++;
682 fpstack_test (test_name);
686 check that computed value is not-a-number
688 static void
689 check_isnan (const char *test_name, MATHTYPE computed)
691 output_new_test (test_name);
692 test_exceptions (test_name, NO_EXCEPTION);
693 output_isvalue (test_name, isnan (computed), computed);
698 check that computed value is not-a-number and test for exceptions
700 static void
701 check_isnan_exc (const char *test_name, MATHTYPE computed,
702 short exception)
704 output_new_test (test_name);
705 test_exceptions (test_name, exception);
706 output_isvalue (test_name, isnan (computed), computed);
711 check that computed value is not-a-number and test for exceptions
713 static void
714 check_isnan_maybe_exc (const char *test_name, MATHTYPE computed,
715 short exception)
717 output_new_test (test_name);
718 test_not_exception (test_name, exception);
719 output_isvalue (test_name, isnan (computed), computed);
723 check that computed value is not-a-number and supply parameter
725 #ifndef TEST_INLINE
726 static void
727 check_isnan_ext (const char *test_name, MATHTYPE computed,
728 MATHTYPE parameter)
730 output_new_test (test_name);
731 test_exceptions (test_name, NO_EXCEPTION);
732 output_isvalue_ext (test_name, isnan (computed), computed, parameter);
734 #endif
737 check that computed value is not-a-number, test for exceptions
738 and supply parameter
740 static void
741 check_isnan_exc_ext (const char *test_name, MATHTYPE computed,
742 short exception, MATHTYPE parameter)
744 output_new_test (test_name);
745 test_exceptions (test_name,exception);
746 output_isvalue_ext (test_name, isnan (computed), computed, parameter);
750 /* Tests if computed is +Inf */
751 static void
752 check_isinfp (const char *test_name, MATHTYPE computed)
754 output_new_test (test_name);
755 test_exceptions (test_name, NO_EXCEPTION);
756 output_isvalue (test_name, (ISINF (computed) == +1), computed);
760 static void
761 check_isinfp_ext (const char *test_name, MATHTYPE computed,
762 MATHTYPE parameter)
764 output_new_test (test_name);
765 test_exceptions (test_name, NO_EXCEPTION);
766 output_isvalue_ext (test_name, (ISINF (computed) == +1), computed, parameter);
770 /* Tests if computed is +Inf */
771 static void
772 check_isinfp_exc (const char *test_name, MATHTYPE computed,
773 int exception)
775 output_new_test (test_name);
776 test_exceptions (test_name, exception);
777 output_isvalue (test_name, (ISINF (computed) == +1), computed);
780 /* Tests if computed is -Inf */
781 static void
782 check_isinfn (const char *test_name, MATHTYPE computed)
784 output_new_test (test_name);
785 test_exceptions (test_name, NO_EXCEPTION);
786 output_isvalue (test_name, (ISINF (computed) == -1), computed);
790 #ifndef TEST_INLINE
791 static void
792 check_isinfn_ext (const char *test_name, MATHTYPE computed,
793 MATHTYPE parameter)
795 output_new_test (test_name);
796 test_exceptions (test_name, NO_EXCEPTION);
797 output_isvalue_ext (test_name, (ISINF (computed) == -1), computed, parameter);
799 #endif
802 /* Tests if computed is -Inf */
803 static void
804 check_isinfn_exc (const char *test_name, MATHTYPE computed,
805 int exception)
807 output_new_test (test_name);
808 test_exceptions (test_name, exception);
809 output_isvalue (test_name, (ISINF (computed) == -1), computed);
813 /* This is to prevent messages from the SVID libm emulation. */
815 matherr (struct exception *x __attribute__ ((unused)))
817 return 1;
821 /****************************************************************************
822 Test for single functions of libm
823 ****************************************************************************/
825 static void
826 acos_test (void)
828 #ifndef TEST_INLINE
829 MATHTYPE x;
831 x = random_greater (1);
832 check_isnan_exc ("acos (x) == NaN plus invalid exception for |x| > 1",
833 FUNC(acos) (x),
834 INVALID_EXCEPTION);
836 x = random_less (1);
837 check_isnan_exc ("acos (x) == NaN plus invalid exception for |x| > 1",
838 FUNC(acos) (x),
839 INVALID_EXCEPTION);
840 #endif
841 check ("acos (0) == pi/2", FUNC(acos) (0), M_PI_2);
842 check ("acos (-0) == pi/2", FUNC(acos) (minus_zero), M_PI_2);
844 check ("acos (1) == 0", FUNC(acos) (1), 0);
845 check ("acos (-1) == pi", FUNC(acos) (-1), M_PI);
847 check_eps ("acos (0.5) == pi/3", FUNC(acos) (0.5), M_PI_6 * 2.0,
848 CHOOSE (1e-18, 0, 0));
849 check_eps ("acos (-0.5) == 2*pi/3", FUNC(acos) (-0.5), M_PI_6 * 4.0,
850 CHOOSE (1e-17, 0, 0));
852 check_eps ("acos (0.7) == 0.795398830...", FUNC(acos) (0.7),
853 0.7953988301841435554L, CHOOSE(7e-17L, 0, 0));
858 static void
859 acosh_test (void)
861 #ifndef TEST_INLINE
862 MATHTYPE x;
864 check_isinfp ("acosh(+inf) == +inf", FUNC(acosh) (plus_infty));
866 x = random_less (1);
867 check_isnan_exc ("acosh(x) == NaN plus invalid exception if x < 1",
868 FUNC(acosh) (x), INVALID_EXCEPTION);
869 #endif
871 check ("acosh(1) == 0", FUNC(acosh) (1), 0);
872 check_eps ("acosh(7) == 2.633915793...", FUNC(acosh) (7),
873 2.6339157938496334172L, CHOOSE (3e-19, 0, 0));
877 static void
878 asin_test (void)
880 #ifndef TEST_INLINE
881 MATHTYPE x;
883 x = random_greater (1);
884 check_isnan_exc ("asin x == NaN plus invalid exception for |x| > 1",
885 FUNC(asin) (x),
886 INVALID_EXCEPTION);
888 x = random_less (1);
889 check_isnan_exc ("asin x == NaN plus invalid exception for |x| > 1",
890 FUNC(asin) (x),
891 INVALID_EXCEPTION);
892 #endif
894 check ("asin (0) == 0", FUNC(asin) (0), 0);
895 check ("asin (-0) == -0", FUNC(asin) (minus_zero), minus_zero);
896 check_eps ("asin (0.5) == pi/6", FUNC(asin) (0.5), M_PI_6,
897 CHOOSE(3.5e-18, 0, 2e-7));
898 check_eps ("asin (-0.5) == -pi/6", FUNC(asin) (-0.5), -M_PI_6,
899 CHOOSE(3.5e-18, 0, 2e-7));
900 check ("asin (1.0) == pi/2", FUNC(asin) (1.0), M_PI_2);
901 check ("asin (-1.0) == -pi/2", FUNC(asin) (-1.0), -M_PI_2);
902 check_eps ("asin (0.7) == 0.775397496...", FUNC(asin) (0.7),
903 0.7753974966107530637L, CHOOSE(7e-17L, 2e-16, 0));
907 static void
908 asinh_test (void)
911 check ("asinh(+0) == +0", FUNC(asinh) (0), 0);
912 #ifndef TEST_INLINE
913 check ("asinh(-0) == -0", FUNC(asinh) (minus_zero), minus_zero);
914 check_isinfp ("asinh(+inf) == +inf", FUNC(asinh) (plus_infty));
915 check_isinfn ("asinh(-inf) == -inf", FUNC(asinh) (minus_infty));
916 #endif
917 check_eps ("asinh(0.7) == 0.652666566...", FUNC(asinh) (0.7),
918 0.652666566082355786L, CHOOSE(4e-17L, 0, 0));
923 static void
924 atan_test (void)
926 check ("atan (0) == 0", FUNC(atan) (0), 0);
927 check ("atan (-0) == -0", FUNC(atan) (minus_zero), minus_zero);
929 check ("atan (+inf) == pi/2", FUNC(atan) (plus_infty), M_PI_2);
930 check ("atan (-inf) == -pi/2", FUNC(atan) (minus_infty), -M_PI_2);
932 check_eps ("atan (1) == pi/4", FUNC(atan) (1), M_PI_4,
933 CHOOSE (1e-18, 0, 0));
934 check_eps ("atan (-1) == -pi/4", FUNC(atan) (1), M_PI_4,
935 CHOOSE (1e-18, 0, 0));
937 check_eps ("atan (0.7) == 0.610725964...", FUNC(atan) (0.7),
938 0.6107259643892086165L, CHOOSE(3e-17L, 0, 0));
942 static void
943 atan2_test (void)
945 MATHTYPE x;
947 x = random_greater (0);
948 check ("atan2 (0,x) == 0 for x > 0",
949 FUNC(atan2) (0, x), 0);
950 x = random_greater (0);
951 check ("atan2 (-0,x) == -0 for x > 0",
952 FUNC(atan2) (minus_zero, x), minus_zero);
954 check ("atan2 (+0,+0) == +0", FUNC(atan2) (0, 0), 0);
955 check ("atan2 (-0,+0) == -0", FUNC(atan2) (minus_zero, 0), minus_zero);
957 x = -random_greater (0);
958 check ("atan2 (+0,x) == +pi for x < 0", FUNC(atan2) (0, x), M_PI);
960 x = -random_greater (0);
961 check ("atan2 (-0,x) == -pi for x < 0", FUNC(atan2) (minus_zero, x), -M_PI);
963 check ("atan2 (+0,-0) == +pi", FUNC(atan2) (0, minus_zero), M_PI);
964 check ("atan2 (-0,-0) == -pi", FUNC(atan2) (minus_zero, minus_zero), -M_PI);
966 x = random_greater (0);
967 check ("atan2 (y,+0) == pi/2 for y > 0", FUNC(atan2) (x, 0), M_PI_2);
969 x = random_greater (0);
970 check ("atan2 (y,-0) == pi/2 for y > 0", FUNC(atan2) (x, minus_zero), M_PI_2);
972 x = random_less (0);
973 check ("atan2 (y,+0) == -pi/2 for y < 0", FUNC(atan2) (x, 0), -M_PI_2);
975 x = random_less (0);
976 check ("atan2 (y,-0) == -pi/2 for y < 0", FUNC(atan2) (x, minus_zero), -M_PI_2);
978 x = random_greater (0);
979 check ("atan2 (y,inf) == +0 for finite y > 0",
980 FUNC(atan2) (x, plus_infty), 0);
982 x = -random_greater (0);
983 check ("atan2 (y,inf) == -0 for finite y < 0",
984 FUNC(atan2) (x, plus_infty), minus_zero);
986 x = random_value (-1e4, 1e4);
987 check ("atan2(+inf, x) == pi/2 for finite x",
988 FUNC(atan2) (plus_infty, x), M_PI_2);
990 x = random_value (-1e4, 1e4);
991 check ("atan2(-inf, x) == -pi/2 for finite x",
992 FUNC(atan2) (minus_infty, x), -M_PI_2);
994 x = random_greater (0);
995 check ("atan2 (y,-inf) == +pi for finite y > 0",
996 FUNC(atan2) (x, minus_infty), M_PI);
998 x = -random_greater (0);
999 check ("atan2 (y,-inf) == -pi for finite y < 0",
1000 FUNC(atan2) (x, minus_infty), -M_PI);
1002 check ("atan2 (+inf,+inf) == +pi/4",
1003 FUNC(atan2) (plus_infty, plus_infty), M_PI_4);
1005 check ("atan2 (-inf,+inf) == -pi/4",
1006 FUNC(atan2) (minus_infty, plus_infty), -M_PI_4);
1008 check ("atan2 (+inf,-inf) == +3*pi/4",
1009 FUNC(atan2) (plus_infty, minus_infty), 3 * M_PI_4);
1011 check ("atan2 (-inf,-inf) == -3*pi/4",
1012 FUNC(atan2) (minus_infty, minus_infty), -3 * M_PI_4);
1014 /* FIXME: Add some specific tests */
1015 check_eps ("atan2 (0.7,1) == 0.61072...", FUNC(atan2) (0.7,1),
1016 0.6107259643892086165L, CHOOSE(3e-17L, 0, 0));
1017 check_eps ("atan2 (0.4,0.0003) == 1.57004...", FUNC(atan2) (0.4, 0.0003),
1018 1.5700463269355215718L, CHOOSE(2e-19L, 0, 0));
1023 static void
1024 atanh_test (void)
1026 #ifndef TEST_INLINE
1027 MATHTYPE x;
1028 #endif
1030 check ("atanh(+0) == +0", FUNC(atanh) (0), 0);
1031 #ifndef TEST_INLINE
1032 check ("atanh(-0) == -0", FUNC(atanh) (minus_zero), minus_zero);
1034 check_isinfp_exc ("atanh(+1) == +inf plus divide-by-zero exception",
1035 FUNC(atanh) (1), DIVIDE_BY_ZERO_EXCEPTION);
1036 check_isinfn_exc ("atanh(-1) == -inf plus divide-by-zero exception",
1037 FUNC(atanh) (-1), DIVIDE_BY_ZERO_EXCEPTION);
1039 x = random_greater (1.0);
1040 check_isnan_exc_ext ("atanh (x) == NaN plus invalid exception if |x| > 1",
1041 FUNC(atanh) (x), INVALID_EXCEPTION, x);
1043 x = random_less (1.0);
1044 check_isnan_exc_ext ("atanh (x) == NaN plus invalid exception if |x| > 1",
1045 FUNC(atanh) (x), INVALID_EXCEPTION, x);
1047 #endif
1048 check_eps ("atanh(0.7) == 0.867300527...", FUNC(atanh) (0.7),
1049 0.8673005276940531944L, CHOOSE(9e-17L, 2e-16, 0));
1053 static void
1054 cbrt_test (void)
1056 check ("cbrt (+0) == +0", FUNC(cbrt) (0.0), 0.0);
1057 check ("cbrt (-0) == -0", FUNC(cbrt) (minus_zero), minus_zero);
1059 #ifndef TEST_INLINE
1060 check_isinfp ("cbrt (+inf) == +inf", FUNC(cbrt) (plus_infty));
1061 check_isinfn ("cbrt (-inf) == -inf", FUNC(cbrt) (minus_infty));
1062 check_isnan ("cbrt (NaN) == NaN", FUNC(cbrt) (nan_value));
1063 #endif
1064 check_eps ("cbrt (-0.001) == -0.1", FUNC(cbrt) (-0.001), -0.1,
1065 CHOOSE (5e-18L, 0, 0));
1066 check_eps ("cbrt (8) == 2", FUNC(cbrt) (8), 2, CHOOSE (5e-17L, 0, 0));
1067 check_eps ("cbrt (-27) == -3", FUNC(cbrt) (-27.0), -3.0,
1068 CHOOSE (3e-16L, 5e-16, 0));
1069 check_eps ("cbrt (0.970299) == 0.99", FUNC(cbrt) (0.970299), 0.99,
1070 CHOOSE (2e-17L, 0, 0));
1071 check_eps ("cbrt (0.7) == .8879040017...", FUNC(cbrt) (0.7),
1072 0.8879040017426007084L, CHOOSE(2e-17L, 6e-16, 0));
1077 static void
1078 ceil_test (void)
1080 check ("ceil (+0) == +0", FUNC(ceil) (0.0), 0.0);
1081 check ("ceil (-0) == -0", FUNC(ceil) (minus_zero), minus_zero);
1082 check_isinfp ("ceil (+inf) == +inf", FUNC(ceil) (plus_infty));
1083 check_isinfn ("ceil (-inf) == -inf", FUNC(ceil) (minus_infty));
1085 check ("ceil (pi) == 4", FUNC(ceil) (M_PI), 4.0);
1086 check ("ceil (-pi) == -3", FUNC(ceil) (-M_PI), -3.0);
1090 static void
1091 cos_test (void)
1094 check ("cos (+0) == 1", FUNC(cos) (0), 1);
1095 check ("cos (-0) == 1", FUNC(cos) (minus_zero), 1);
1096 check_isnan_exc ("cos (+inf) == NaN plus invalid exception",
1097 FUNC(cos) (plus_infty),
1098 INVALID_EXCEPTION);
1099 check_isnan_exc ("cos (-inf) == NaN plus invalid exception",
1100 FUNC(cos) (minus_infty),
1101 INVALID_EXCEPTION);
1103 check_eps ("cos (pi/3) == 0.5", FUNC(cos) (M_PI_6 * 2.0),
1104 0.5, CHOOSE (4e-18L, 1e-15L, 1e-7L));
1105 check_eps ("cos (2*pi/3) == -0.5", FUNC(cos) (M_PI_6 * 4.0),
1106 -0.5, CHOOSE (4e-18L, 1e-15L, 1e-7L));
1107 check_eps ("cos (pi/2) == 0", FUNC(cos) (M_PI_2),
1108 0, CHOOSE (1e-19L, 1e-16L, 1e-7L));
1110 check_eps ("cos (0.7) == 0.7648421872...", FUNC(cos) (0.7),
1111 0.7648421872844884262L, CHOOSE(3e-17, 2e-16, 0));
1114 static void
1115 cosh_test (void)
1117 check ("cosh (+0) == 1", FUNC(cosh) (0), 1);
1118 check ("cosh (-0) == 1", FUNC(cosh) (minus_zero), 1);
1120 #ifndef TEST_INLINE
1121 check_isinfp ("cosh (+inf) == +inf", FUNC(cosh) (plus_infty));
1122 check_isinfp ("cosh (-inf) == +inf", FUNC(cosh) (minus_infty));
1123 #endif
1125 check_eps ("cosh (0.7) == 1.2551690056...", FUNC(cosh) (0.7),
1126 1.255169005630943018L, CHOOSE(4e-17L, 0, 0));
1130 static void
1131 erf_test (void)
1133 errno = 0;
1134 FUNC(erf) (0);
1135 if (errno == ENOSYS)
1136 /* Function not implemented. */
1137 return;
1139 check ("erf (+0) == +0", FUNC(erf) (0), 0);
1140 check ("erf (-0) == -0", FUNC(erf) (minus_zero), minus_zero);
1141 check ("erf (+inf) == +1", FUNC(erf) (plus_infty), 1);
1142 check ("erf (-inf) == -1", FUNC(erf) (minus_infty), -1);
1144 check_eps ("erf (0.7) == 0.6778011938...", FUNC(erf) (0.7),
1145 0.67780119383741847297L, CHOOSE(0, 2e-16, 0));
1149 static void
1150 erfc_test (void)
1152 errno = 0;
1153 FUNC(erfc) (0);
1154 if (errno == ENOSYS)
1155 /* Function not implemented. */
1156 return;
1158 check ("erfc (+inf) == 0", FUNC(erfc) (plus_infty), 0.0);
1159 check ("erfc (-inf) == 2", FUNC(erfc) (minus_infty), 2.0);
1160 check ("erfc (+0) == 1", FUNC(erfc) (0.0), 1.0);
1161 check ("erfc (-0) == 1", FUNC(erfc) (minus_zero), 1.0);
1163 check_eps ("erfc (0.7) == 0.3221988061...", FUNC(erfc) (0.7),
1164 0.32219880616258152702L, CHOOSE(0, 6e-17, 0));
1168 static void
1169 exp_test (void)
1171 check ("exp (+0) == 1", FUNC(exp) (0), 1);
1172 check ("exp (-0) == 1", FUNC(exp) (minus_zero), 1);
1174 #ifndef TEST_INLINE
1175 check_isinfp ("exp (+inf) == +inf", FUNC(exp) (plus_infty));
1176 check ("exp (-inf) == 0", FUNC(exp) (minus_infty), 0);
1177 #endif
1178 check_eps ("exp (1) == e", FUNC(exp) (1), M_E, CHOOSE (4e-18L, 5e-16, 0));
1180 check_eps ("exp (2) == e^2", FUNC(exp) (2), M_E * M_E,
1181 CHOOSE (1e-18, 0, 0));
1182 check_eps ("exp (3) == e^3", FUNC(exp) (3), M_E * M_E * M_E,
1183 CHOOSE (1.5e-17, 0, 0));
1184 check_eps ("exp (0.7) == 2.0137527074...", FUNC(exp) (0.7),
1185 2.0137527074704765216L, CHOOSE(9e-17L, 0, 0));
1189 static void
1190 exp2_test (void)
1192 errno = 0;
1193 FUNC(exp2) (0);
1194 if (errno == ENOSYS)
1195 /* Function not implemented. */
1196 return;
1198 check ("exp2 (+0) == 1", FUNC(exp2) (0), 1);
1199 check ("exp2 (-0) == 1", FUNC(exp2) (minus_zero), 1);
1201 check_isinfp ("exp2 (+inf) == +inf", FUNC(exp2) (plus_infty));
1202 check ("exp2 (-inf) == 0", FUNC(exp2) (minus_infty), 0);
1203 check ("exp2 (10) == 1024", FUNC(exp2) (10), 1024);
1204 check ("exp2 (-1) == 0.5", FUNC(exp2) (-1), 0.5);
1205 check_isinfp ("exp2 (1e6) == +inf", FUNC(exp2) (1e6));
1206 check ("exp2 (-1e6) == 0", FUNC(exp2) (-1e6), 0);
1207 check_eps ("exp2 (0.7) == 1.6245047927...", FUNC(exp2) (0.7),
1208 1.6245047927124710452L, CHOOSE(6e-17L, 0, 6e-8));
1212 static void
1213 expm1_test (void)
1215 check ("expm1 (+0) == 0", FUNC(expm1) (0), 0);
1216 #ifndef TEST_INLINE
1217 check ("expm1 (-0) == -0", FUNC(expm1) (minus_zero), minus_zero);
1219 check_isinfp ("expm1 (+inf) == +inf", FUNC(expm1) (plus_infty));
1220 check ("expm1 (-inf) == -1", FUNC(expm1) (minus_infty), -1);
1221 #endif
1223 check_eps ("expm1 (1) == e-1", FUNC(expm1) (1), M_E - 1.0,
1224 CHOOSE (4e-18L, 0, 2e-7));
1226 check_eps ("expm1 (0.7) == 1.01375...", FUNC(expm1) (0.7),
1227 1.0137527074704765216L, CHOOSE(9e-17L, 0, 0));
1233 static void
1234 check_frexp (const char *test_name, MATHTYPE computed, MATHTYPE expected,
1235 int comp_int, int exp_int)
1237 MATHTYPE diff;
1238 int result;
1240 result = (check_equal (computed, expected, 0, &diff)
1241 && (comp_int == exp_int));
1243 if (result)
1245 if (verbose > 2)
1246 printf ("Pass: %s\n", test_name);
1248 else
1250 if (verbose)
1251 printf ("Fail: %s\n", test_name);
1252 if (verbose > 1)
1254 printf ("Result:\n");
1255 printf (" is: %.20" PRINTF_EXPR " *2^%d %.20"
1256 PRINTF_XEXPR "*2^%d\n",
1257 computed, comp_int, computed, comp_int);
1258 printf (" should be: %.20" PRINTF_EXPR " *2^%d %.20"
1259 PRINTF_XEXPR "*2^%d\n",
1260 expected, exp_int, expected, exp_int);
1261 printf (" difference: %.20" PRINTF_EXPR " %.20" PRINTF_XEXPR "\n",
1262 diff, diff);
1264 noErrors++;
1266 fpstack_test (test_name);
1267 output_result (test_name, result,
1268 computed, expected, diff, PRINT, PRINT);
1272 static void
1273 frexp_test (void)
1275 int x_int;
1276 MATHTYPE result;
1278 result = FUNC(frexp) (plus_infty, &x_int);
1279 check_isinfp ("frexp (+inf, expr) == +inf", result);
1281 result = FUNC(frexp) (minus_infty, &x_int);
1282 check_isinfn ("frexp (-inf, expr) == -inf", result);
1284 result = FUNC(frexp) (nan_value, &x_int);
1285 check_isnan ("frexp (Nan, expr) == NaN", result);
1287 result = FUNC(frexp) (0, &x_int);
1288 check_frexp ("frexp: +0 == 0 * 2^0", result, 0, x_int, 0);
1290 result = FUNC(frexp) (minus_zero, &x_int);
1291 check_frexp ("frexp: -0 == -0 * 2^0", result, minus_zero, x_int, 0);
1293 result = FUNC(frexp) (12.8L, &x_int);
1294 check_frexp ("frexp: 12.8 == 0.8 * 2^4", result, 0.8L, x_int, 4);
1296 result = FUNC(frexp) (-27.34L, &x_int);
1297 check_frexp ("frexp: -27.34 == -0.854375 * 2^5", result, -0.854375L, x_int, 5);
1302 #if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 1)
1303 /* All floating-point numbers can be put in one of these categories. */
1304 enum
1306 FP_NAN,
1307 #define FP_NAN FP_NAN
1308 FP_INFINITE,
1309 #define FP_INFINITE FP_INFINITE
1310 FP_ZERO,
1311 #define FP_ZERO FP_ZERO
1312 FP_SUBNORMAL,
1313 #define FP_SUBNORMAL FP_SUBNORMAL
1314 FP_NORMAL
1315 #define FP_NORMAL FP_NORMAL
1317 #endif
1320 static void
1321 fpclassify_test (void)
1323 MATHTYPE x;
1325 /* fpclassify is a macro, don't give it constants as parameter */
1326 check_bool ("fpclassify (NaN) == FP_NAN", fpclassify (nan_value) == FP_NAN);
1327 check_bool ("fpclassify (+inf) == FP_INFINITE",
1328 fpclassify (plus_infty) == FP_INFINITE);
1329 check_bool ("fpclassify (-inf) == FP_INFINITE",
1330 fpclassify (minus_infty) == FP_INFINITE);
1331 check_bool ("fpclassify (+0) == FP_ZERO",
1332 fpclassify (plus_zero) == FP_ZERO);
1333 check_bool ("fpclassify (-0) == FP_ZERO",
1334 fpclassify (minus_zero) == FP_ZERO);
1336 x = 1000.0;
1337 check_bool ("fpclassify (1000) == FP_NORMAL",
1338 fpclassify (x) == FP_NORMAL);
1342 static void
1343 isfinite_test (void)
1345 check_bool ("isfinite (0) != 0", isfinite (0));
1346 check_bool ("isfinite (-0) != 0", isfinite (minus_zero));
1347 check_bool ("isfinite (10) != 0", isfinite (10));
1348 check_bool ("isfinite (+inf) == 0", isfinite (plus_infty) == 0);
1349 check_bool ("isfinite (-inf) == 0", isfinite (minus_infty) == 0);
1350 check_bool ("isfinite (NaN) == 0", isfinite (nan_value) == 0);
1354 static void
1355 isnormal_test (void)
1357 check_bool ("isnormal (0) == 0", isnormal (0) == 0);
1358 check_bool ("isnormal (-0) == 0", isnormal (minus_zero) == 0);
1359 check_bool ("isnormal (10) != 0", isnormal (10));
1360 check_bool ("isnormal (+inf) == 0", isnormal (plus_infty) == 0);
1361 check_bool ("isnormal (-inf) == 0", isnormal (minus_infty) == 0);
1362 check_bool ("isnormal (NaN) == 0", isnormal (nan_value) == 0);
1367 static void
1368 signbit_test (void)
1370 MATHTYPE x;
1372 check_bool ("signbit (+0) == 0", signbit (0) == 0);
1373 check_bool ("signbit (-0) != 0", signbit (minus_zero));
1374 check_bool ("signbit (+inf) == 0", signbit (plus_infty) == 0);
1375 check_bool ("signbit (-inf) != 0", signbit (minus_infty));
1377 x = random_less (0);
1378 check_bool ("signbit (x) != 0 for x < 0", signbit (x));
1380 x = random_greater (0);
1381 check_bool ("signbit (x) == 0 for x > 0", signbit (x) == 0);
1387 gamma has different semantics depending on _LIB_VERSION:
1388 if _LIB_VERSION is _SVID, gamma is just an alias for lgamma,
1389 otherwise gamma is the real gamma function as definied in ISO C 9X.
1391 static void
1392 gamma_test (void)
1394 int save_lib_version = _LIB_VERSION;
1395 errno = 0;
1396 FUNC(gamma) (1);
1397 if (errno == ENOSYS)
1398 /* Function not implemented. */
1399 return;
1400 feclearexcept (FE_ALL_EXCEPT);
1403 _LIB_VERSION = _SVID_;
1405 check_isinfp ("gamma (+inf) == +inf", FUNC(gamma) (plus_infty));
1406 check_isinfp_exc ("gamma (0) == +inf plus divide by zero exception",
1407 FUNC(gamma) (0), DIVIDE_BY_ZERO_EXCEPTION);
1409 check_isinfp_exc ("gamma (x) == +inf plus divide by zero exception for integer x <= 0",
1410 FUNC(gamma) (-3), DIVIDE_BY_ZERO_EXCEPTION);
1411 check_isnan_exc ("gamma (-inf) == NaN plus invalid exception",
1412 FUNC(gamma) (minus_infty), INVALID_EXCEPTION);
1414 signgam = 0;
1415 check ("gamma (1) == 0", FUNC(gamma) (1), 0);
1416 check_int ("gamma (0) sets signgam to 1", signgam, 1);
1418 signgam = 0;
1419 check ("gamma (3) == M_LN2", FUNC(gamma) (3), M_LN2);
1420 check_int ("gamma (3) sets signgam to 1", signgam, 1);
1422 signgam = 0;
1423 check_eps ("gamma (0.5) == log(sqrt(pi))", FUNC(gamma) (0.5),
1424 FUNC(log) (FUNC(sqrt) (M_PI)), CHOOSE (0, 1e-15, 1e-7));
1425 check_int ("gamma (0.5) sets signgam to 1", signgam, 1);
1427 signgam = 0;
1428 check_eps ("gamma (-0.5) == log(2*sqrt(pi))", FUNC(gamma) (-0.5),
1429 FUNC(log) (2*FUNC(sqrt) (M_PI)), CHOOSE (0, 1e-15, 0));
1431 check_int ("gamma (-0.5) sets signgam to -1", signgam, -1);
1434 _LIB_VERSION = _IEEE_;
1436 check_isinfp ("gamma (+inf) == +inf", FUNC(gamma) (plus_infty));
1437 check_isnan_exc ("gamma (0) == NaN plus invalid exception",
1438 FUNC(gamma) (0), INVALID_EXCEPTION);
1440 check_isnan_exc_ext ("gamma (x) == NaN plus invalid exception for integer x <= 0",
1441 FUNC(gamma) (-2), INVALID_EXCEPTION, -2);
1442 check_isnan_exc ("gamma (-inf) == NaN plus invalid exception",
1443 FUNC(gamma) (minus_infty), INVALID_EXCEPTION);
1445 #ifdef TODO
1446 check_eps ("gamma (0.5) == sqrt(pi)", FUNC(gamma) (0.5), FUNC(sqrt) (M_PI),
1447 CHOOSE (0, 5e-16, 2e-7));
1448 #endif
1449 check_eps ("gamma (-0.5) == -2*sqrt(pi)", FUNC(gamma) (-0.5),
1450 -2*FUNC(sqrt) (M_PI), CHOOSE (0, 5e-16, 3e-7));
1452 check ("gamma (1) == 1", FUNC(gamma) (1), 1);
1453 check ("gamma (4) == 6", FUNC(gamma) (4), 6);
1455 check_eps ("gamma (0.7) == 1.29805...", FUNC(gamma) (0.7),
1456 1.29805533264755778568L, CHOOSE(0, 3e-16, 2e-7));
1457 check ("gamma (1.2) == 0.91816...", FUNC(gamma) (1.2), 0.91816874239976061064L);
1459 _LIB_VERSION = save_lib_version;
1463 static void
1464 lgamma_test (void)
1466 errno = 0;
1467 FUNC(lgamma) (0);
1468 if (errno == ENOSYS)
1469 /* Function not implemented. */
1470 return;
1471 feclearexcept (FE_ALL_EXCEPT);
1473 check_isinfp ("lgamma (+inf) == +inf", FUNC(lgamma) (plus_infty));
1474 check_isinfp_exc ("lgamma (0) == +inf plus divide by zero exception",
1475 FUNC(lgamma) (0), DIVIDE_BY_ZERO_EXCEPTION);
1477 check_isinfp_exc ("lgamma (x) == +inf plus divide by zero exception for integer x <= 0",
1478 FUNC(lgamma) (-3), DIVIDE_BY_ZERO_EXCEPTION);
1479 check_isnan_exc ("lgamma (-inf) == NaN plus invalid exception",
1480 FUNC(lgamma) (minus_infty), INVALID_EXCEPTION);
1482 signgam = 0;
1483 check ("lgamma (1) == 0", FUNC(lgamma) (1), 0);
1484 check_int ("lgamma (0) sets signgam to 1", signgam, 1);
1486 signgam = 0;
1487 check ("lgamma (3) == M_LN2", FUNC(lgamma) (3), M_LN2);
1488 check_int ("lgamma (3) sets signgam to 1", signgam, 1);
1490 signgam = 0;
1491 check_eps ("lgamma (0.5) == log(sqrt(pi))", FUNC(lgamma) (0.5),
1492 FUNC(log) (FUNC(sqrt) (M_PI)), CHOOSE (0, 1e-15, 1e-7));
1493 check_int ("lgamma (0.5) sets signgam to 1", signgam, 1);
1495 signgam = 0;
1496 check_eps ("lgamma (-0.5) == log(2*sqrt(pi))", FUNC(lgamma) (-0.5),
1497 FUNC(log) (2*FUNC(sqrt) (M_PI)), CHOOSE (0, 1e-15, 0));
1499 check_int ("lgamma (-0.5) sets signgam to -1", signgam, -1);
1501 signgam = 0;
1502 check_eps ("lgamma (0.7) == 0.26086...", FUNC(lgamma) (0.7),
1503 0.26086724653166651439L, CHOOSE(0, 6e-17, 3e-8));
1504 check_int ("lgamma (0.7) sets signgam to 1", signgam, 1);
1506 signgam = 0;
1507 check_eps ("lgamma (1.2) == -0.08537...", FUNC(lgamma) (1.2),
1508 -0.853740900033158497197e-1L, CHOOSE(0, 2e-17, 2e-8));
1509 check_int ("lgamma (1.2) sets signgam to 1", signgam, 1);
1514 static void
1515 ilogb_test (void)
1517 int i;
1519 check_int ("ilogb (1) == 0", FUNC(ilogb) (1), 0);
1520 check_int ("ilogb (e) == 1", FUNC(ilogb) (M_E), 1);
1521 check_int ("ilogb (1024) == 10", FUNC(ilogb) (1024), 10);
1522 check_int ("ilogb (-2000) == 10", FUNC(ilogb) (-2000), 10);
1524 /* XXX We have a problem here: the standard does not tell us whether
1525 exceptions are allowed/required. ignore them for now. */
1526 i = FUNC (ilogb) (0.0);
1527 feclearexcept (FE_ALL_EXCEPT);
1528 check_int ("ilogb (0) == FP_ILOGB0", i, FP_ILOGB0);
1529 i = FUNC(ilogb) (nan_value);
1530 feclearexcept (FE_ALL_EXCEPT);
1531 check_int ("ilogb (NaN) == FP_ILOGBNAN", i, FP_ILOGBNAN);
1536 static void
1537 ldexp_test (void)
1539 MATHTYPE x;
1541 check ("ldexp (0, 0) == 0", FUNC(ldexp) (0, 0), 0);
1543 check_isinfp ("ldexp (+inf, 1) == +inf", FUNC(ldexp) (plus_infty, 1));
1544 check_isinfn ("ldexp (-inf, 1) == -inf", FUNC(ldexp) (minus_infty, 1));
1545 check_isnan ("ldexp (NaN, 1) == NaN", FUNC(ldexp) (nan_value, 1));
1547 check ("ldexp (0.8, 4) == 12.8", FUNC(ldexp) (0.8L, 4), 12.8L);
1548 check ("ldexp (-0.854375, 5) == -27.34", FUNC(ldexp) (-0.854375L, 5), -27.34L);
1550 x = random_greater (0.0);
1551 check_ext ("ldexp (x, 0) == x", FUNC(ldexp) (x, 0L), x, x);
1556 static void
1557 log_test (void)
1559 check_isinfn_exc ("log (+0) == -inf plus divide-by-zero exception",
1560 FUNC(log) (0), DIVIDE_BY_ZERO_EXCEPTION);
1561 check_isinfn_exc ("log (-0) == -inf plus divide-by-zero exception",
1562 FUNC(log) (minus_zero), DIVIDE_BY_ZERO_EXCEPTION);
1564 check ("log (1) == 0", FUNC(log) (1), 0);
1566 check_isnan_exc ("log (x) == NaN plus invalid exception if x < 0",
1567 FUNC(log) (-1), INVALID_EXCEPTION);
1568 check_isinfp ("log (+inf) == +inf", FUNC(log) (plus_infty));
1570 check_eps ("log (e) == 1", FUNC(log) (M_E), 1, CHOOSE (1e-18L, 0, 9e-8L));
1571 check_eps ("log (1/e) == -1", FUNC(log) (1.0 / M_E), -1,
1572 CHOOSE (2e-18L, 0, 0));
1573 check ("log (2) == M_LN2", FUNC(log) (2), M_LN2);
1574 check_eps ("log (10) == M_LN10", FUNC(log) (10), M_LN10,
1575 CHOOSE (1e-18L, 0, 0));
1576 check_eps ("log (0.7) == -0.3566749439...", FUNC(log) (0.7),
1577 -0.35667494393873237891L, CHOOSE(7e-17L, 6e-17, 3e-8));
1581 static void
1582 log10_test (void)
1584 check_isinfn_exc ("log10 (+0) == -inf plus divide-by-zero exception",
1585 FUNC(log10) (0), DIVIDE_BY_ZERO_EXCEPTION);
1586 check_isinfn_exc ("log10 (-0) == -inf plus divide-by-zero exception",
1587 FUNC(log10) (minus_zero), DIVIDE_BY_ZERO_EXCEPTION);
1589 check ("log10 (1) == +0", FUNC(log10) (1), 0);
1591 check_isnan_exc ("log10 (x) == NaN plus invalid exception if x < 0",
1592 FUNC(log10) (-1), INVALID_EXCEPTION);
1594 check_isinfp ("log10 (+inf) == +inf", FUNC(log10) (plus_infty));
1596 check_eps ("log10 (0.1) == -1", FUNC(log10) (0.1L), -1,
1597 CHOOSE (1e-18L, 0, 0));
1598 check_eps ("log10 (10) == 1", FUNC(log10) (10.0), 1,
1599 CHOOSE (1e-18L, 0, 0));
1600 check_eps ("log10 (100) == 2", FUNC(log10) (100.0), 2,
1601 CHOOSE (1e-18L, 0, 0));
1602 check ("log10 (10000) == 4", FUNC(log10) (10000.0), 4);
1603 check_eps ("log10 (e) == M_LOG10E", FUNC(log10) (M_E), M_LOG10E,
1604 CHOOSE (1e-18, 0, 9e-8));
1605 check_eps ("log10 (0.7) == -0.1549019599...", FUNC(log10) (0.7),
1606 -0.15490195998574316929L, CHOOSE(3e-17L, 3e-17, 0));
1610 static void
1611 log1p_test (void)
1613 check ("log1p (+0) == +0", FUNC(log1p) (0), 0);
1614 check ("log1p (-0) == -0", FUNC(log1p) (minus_zero), minus_zero);
1616 check_isinfn_exc ("log1p (-1) == -inf plus divide-by-zero exception",
1617 FUNC(log1p) (-1), DIVIDE_BY_ZERO_EXCEPTION);
1618 check_isnan_exc ("log1p (x) == NaN plus invalid exception if x < -1",
1619 FUNC(log1p) (-2), INVALID_EXCEPTION);
1621 check_isinfp ("log1p (+inf) == +inf", FUNC(log1p) (plus_infty));
1623 check_eps ("log1p (e-1) == 1", FUNC(log1p) (M_E - 1.0), 1,
1624 CHOOSE (1e-18L, 0, 6e-8));
1626 check_eps ("log1p (-0.3) == -0.35667...", FUNC(log1p) (-0.3),
1627 -0.35667494393873237891L, CHOOSE(2e-17L, 6e-17, 3e-8));
1631 static void
1632 log2_test (void)
1634 check_isinfn_exc ("log2 (+0) == -inf plus divide-by-zero exception",
1635 FUNC(log2) (0), DIVIDE_BY_ZERO_EXCEPTION);
1636 check_isinfn_exc ("log2 (-0) == -inf plus divide-by-zero exception",
1637 FUNC(log2) (minus_zero), DIVIDE_BY_ZERO_EXCEPTION);
1639 check ("log2 (1) == +0", FUNC(log2) (1), 0);
1641 check_isnan_exc ("log2 (x) == NaN plus invalid exception if x < 0",
1642 FUNC(log2) (-1), INVALID_EXCEPTION);
1644 check_isinfp ("log2 (+inf) == +inf", FUNC(log2) (plus_infty));
1646 check_eps ("log2 (e) == M_LOG2E", FUNC(log2) (M_E), M_LOG2E,
1647 CHOOSE (1e-18L, 0, 0));
1648 check ("log2 (2) == 1", FUNC(log2) (2.0), 1);
1649 check_eps ("log2 (16) == 4", FUNC(log2) (16.0), 4, CHOOSE (1e-18L, 0, 0));
1650 check ("log2 (256) == 8", FUNC(log2) (256.0), 8);
1651 check_eps ("log2 (0.7) == -0.5145731728...", FUNC(log2) (0.7),
1652 -0.51457317282975824043L, CHOOSE(1e-16L, 2e-16, 6e-8));
1657 static void
1658 logb_test (void)
1660 check_isinfp ("logb (+inf) == +inf", FUNC(logb) (plus_infty));
1661 check_isinfp ("logb (-inf) == +inf", FUNC(logb) (minus_infty));
1663 check_isinfn_exc ("logb (+0) == -inf plus divide-by-zero exception",
1664 FUNC(logb) (0), DIVIDE_BY_ZERO_EXCEPTION);
1666 check_isinfn_exc ("logb (-0) == -inf plus divide-by-zero exception",
1667 FUNC(logb) (minus_zero), DIVIDE_BY_ZERO_EXCEPTION);
1669 check ("logb (1) == 0", FUNC(logb) (1), 0);
1670 check ("logb (e) == 1", FUNC(logb) (M_E), 1);
1671 check ("logb (1024) == 10", FUNC(logb) (1024), 10);
1672 check ("logb (-2000) == 10", FUNC(logb) (-2000), 10);
1677 static void
1678 modf_test (void)
1680 MATHTYPE result, intpart;
1682 result = FUNC(modf) (plus_infty, &intpart);
1683 check ("modf (+inf, &x) returns +0", result, 0);
1684 check_isinfp ("modf (+inf, &x) set x to +inf", intpart);
1686 result = FUNC(modf) (minus_infty, &intpart);
1687 check ("modf (-inf, &x) returns -0", result, minus_zero);
1688 check_isinfn ("modf (-inf, &x) sets x to -inf", intpart);
1690 result = FUNC(modf) (nan_value, &intpart);
1691 check_isnan ("modf (NaN, &x) returns NaN", result);
1692 check_isnan ("modf (NaN, &x) sets x to NaN", intpart);
1694 result = FUNC(modf) (0, &intpart);
1695 check ("modf (0, &x) returns 0", result, 0);
1696 check ("modf (0, &x) sets x to 0", intpart, 0);
1698 result = FUNC(modf) (minus_zero, &intpart);
1699 check ("modf (-0, &x) returns -0", result, minus_zero);
1700 check ("modf (-0, &x) sets x to -0", intpart, minus_zero);
1702 result = FUNC(modf) (2.5, &intpart);
1703 check ("modf (2.5, &x) returns 0.5", result, 0.5);
1704 check ("modf (2.5, &x) sets x to 2", intpart, 2);
1706 result = FUNC(modf) (-2.5, &intpart);
1707 check ("modf (-2.5, &x) returns -0.5", result, -0.5);
1708 check ("modf (-2.5, &x) sets x to -2", intpart, -2);
1710 result = FUNC(modf) (20, &intpart);
1711 check ("modf (20, &x) returns 0", result, 0);
1712 check ("modf (20, &x) sets x to 20", intpart, 20);
1714 result = FUNC(modf) (21, &intpart);
1715 check ("modf (21, &x) returns 0", result, 0);
1716 check ("modf (21, &x) sets x to 21", intpart, 21);
1718 result = FUNC(modf) (89.6, &intpart);
1719 check_eps ("modf (89.6, &x) returns 0.6", result, 0.6,
1720 CHOOSE(6e-15L, 6e-15, 2e-6));
1721 check ("modf (89.6, &x) sets x to 89", intpart, 89);
1725 static void
1726 scalb_test (void)
1728 MATHTYPE x;
1730 check_isnan ("scalb (2, 0.5) == NaN", FUNC(scalb) (2, 0.5));
1731 check_isnan ("scalb (3, -2.5) == NaN", FUNC(scalb) (3, -2.5));
1733 check_isnan ("scalb (0, NaN) == NaN", FUNC(scalb) (0, nan_value));
1734 check_isnan ("scalb (1, NaN) == NaN", FUNC(scalb) (1, nan_value));
1736 x = random_greater (0.0);
1737 check ("scalb (x, 0) == 0", FUNC(scalb) (x, 0), x);
1738 x = random_greater (0.0);
1739 check ("scalb (-x, 0) == 0", FUNC(scalb) (-x, 0), -x);
1741 check_isnan_exc ("scalb (+0, +inf) == NaN plus invalid exception",
1742 FUNC(scalb) (0, plus_infty), INVALID_EXCEPTION);
1743 check_isnan_exc ("scalb (-0, +inf) == NaN plus invalid exception",
1744 FUNC(scalb) (minus_zero, plus_infty), INVALID_EXCEPTION);
1746 check ("scalb (+0, 2) == +0", FUNC(scalb) (0, 2), 0);
1747 check ("scalb (-0, 4) == -0", FUNC(scalb) (minus_zero, -4), minus_zero);
1748 check ("scalb (+0, 0) == +0", FUNC(scalb) (0, 0), 0);
1749 check ("scalb (-0, 0) == -0", FUNC(scalb) (minus_zero, 0), minus_zero);
1750 check ("scalb (+0, -1) == +0", FUNC(scalb) (0, -1), 0);
1751 check ("scalb (-0, -10) == -0", FUNC(scalb) (minus_zero, -10), minus_zero);
1752 check ("scalb (+0, -inf) == +0", FUNC(scalb) (0, minus_infty), 0);
1753 check ("scalb (-0, -inf) == -0", FUNC(scalb) (minus_zero, minus_infty),
1754 minus_zero);
1756 check_isinfp ("scalb (+inf, -1) == +inf", FUNC(scalb) (plus_infty, -1));
1757 check_isinfn ("scalb (-inf, -10) == -inf", FUNC(scalb) (minus_infty, -10));
1758 check_isinfp ("scalb (+inf, 0) == +inf", FUNC(scalb) (plus_infty, 0));
1759 check_isinfn ("scalb (-inf, 0) == -inf", FUNC(scalb) (minus_infty, 0));
1760 check_isinfp ("scalb (+inf, 2) == +inf", FUNC(scalb) (plus_infty, 2));
1761 check_isinfn ("scalb (-inf, 100) == -inf", FUNC(scalb) (minus_infty, 100));
1763 x = random_greater (0.0);
1764 check ("scalb (x, -inf) == 0", FUNC(scalb) (x, minus_infty), 0.0);
1765 check ("scalb (-x, -inf) == -0", FUNC(scalb) (-x, minus_infty), minus_zero);
1767 x = random_greater (0.0);
1768 check_isinfp ("scalb (x, +inf) == +inf", FUNC(scalb) (x, plus_infty));
1769 x = random_greater (0.0);
1770 check_isinfn ("scalb (-x, +inf) == -inf", FUNC(scalb) (-x, plus_infty));
1771 check_isinfp ("scalb (+inf, +inf) == +inf",
1772 FUNC(scalb) (plus_infty, plus_infty));
1773 check_isinfn ("scalb (-inf, +inf) == -inf",
1774 FUNC(scalb) (minus_infty, plus_infty));
1776 check_isnan ("scalb (+inf, -inf) == NaN",
1777 FUNC(scalb) (plus_infty, minus_infty));
1778 check_isnan ("scalb (-inf, -inf) == NaN",
1779 FUNC(scalb) (minus_infty, minus_infty));
1781 check_isnan ("scalb (NaN, 1) == NaN", FUNC(scalb) (nan_value, 1));
1782 check_isnan ("scalb (1, NaN) == NaN", FUNC(scalb) (1, nan_value));
1783 check_isnan ("scalb (NaN, 0) == NaN", FUNC(scalb) (nan_value, 0));
1784 check_isnan ("scalb (0, NaN) == NaN", FUNC(scalb) (0, nan_value));
1785 check_isnan ("scalb (NaN, +inf) == NaN",
1786 FUNC(scalb) (nan_value, plus_infty));
1787 check_isnan ("scalb (+inf, NaN) == NaN",
1788 FUNC(scalb) (plus_infty, nan_value));
1789 check_isnan ("scalb (NaN, NaN) == NaN", FUNC(scalb) (nan_value, nan_value));
1791 check ("scalb (0.8, 4) == 12.8", FUNC(scalb) (0.8L, 4), 12.8L);
1792 check ("scalb (-0.854375, 5) == -27.34", FUNC(scalb) (-0.854375L, 5), -27.34L);
1796 static void
1797 scalbn_test (void)
1799 MATHTYPE x;
1801 check ("scalbn (0, 0) == 0", FUNC(scalbn) (0, 0), 0);
1803 check_isinfp ("scalbn (+inf, 1) == +inf", FUNC(scalbn) (plus_infty, 1));
1804 check_isinfn ("scalbn (-inf, 1) == -inf", FUNC(scalbn) (minus_infty, 1));
1805 check_isnan ("scalbn (NaN, 1) == NaN", FUNC(scalbn) (nan_value, 1));
1807 check ("scalbn (0.8, 4) == 12.8", FUNC(scalbn) (0.8L, 4), 12.8L);
1808 check ("scalbn (-0.854375, 5) == -27.34", FUNC(scalbn) (-0.854375L, 5), -27.34L);
1810 x = random_greater (0.0);
1811 check_ext ("scalbn (x, 0) == x", FUNC(scalbn) (x, 0L), x, x);
1815 static void
1816 sin_test (void)
1818 check ("sin (+0) == +0", FUNC(sin) (0), 0);
1819 check ("sin (-0) == -0", FUNC(sin) (minus_zero), minus_zero);
1820 check_isnan_exc ("sin (+inf) == NaN plus invalid exception",
1821 FUNC(sin) (plus_infty),
1822 INVALID_EXCEPTION);
1823 check_isnan_exc ("sin (-inf) == NaN plus invalid exception",
1824 FUNC(sin) (minus_infty),
1825 INVALID_EXCEPTION);
1827 check_eps ("sin (pi/6) == 0.5", FUNC(sin) (M_PI_6),
1828 0.5, CHOOSE (4e-18L, 0, 0));
1829 check_eps ("sin (-pi/6) == -0.5", FUNC(sin) (-M_PI_6),
1830 -0.5, CHOOSE (4e-18L, 0, 0));
1831 check ("sin (pi/2) == 1", FUNC(sin) (M_PI_2), 1);
1832 check ("sin (-pi/2) == -1", FUNC(sin) (-M_PI_2), -1);
1833 check_eps ("sin (0.7) == 0.6442176872...", FUNC(sin) (0.7),
1834 0.64421768723769105367L, CHOOSE(4e-17L, 0, 0));
1838 static void
1839 sinh_test (void)
1841 check ("sinh (+0) == +0", FUNC(sinh) (0), 0);
1843 #ifndef TEST_INLINE
1844 check ("sinh (-0) == -0", FUNC(sinh) (minus_zero), minus_zero);
1846 check_isinfp ("sinh (+inf) == +inf", FUNC(sinh) (plus_infty));
1847 check_isinfn ("sinh (-inf) == -inf", FUNC(sinh) (minus_infty));
1848 #endif
1850 check_eps ("sinh (0.7) == 0.7585837018...", FUNC(sinh) (0.7),
1851 0.75858370183953350346L, CHOOSE(6e-17L, 0, 6e-8));
1855 static void
1856 sincos_test (void)
1858 MATHTYPE sin_res, cos_res;
1859 fenv_t fenv;
1861 FUNC(sincos) (0, &sin_res, &cos_res);
1862 fegetenv (&fenv);
1863 check ("sincos (+0, &sin, &cos) puts +0 in sin", sin_res, 0);
1864 fesetenv (&fenv);
1865 check ("sincos (+0, &sin, &cos) puts 1 in cos", cos_res, 1);
1867 FUNC(sincos) (minus_zero, &sin_res, &cos_res);
1868 fegetenv (&fenv);
1869 check ("sincos (-0, &sin, &cos) puts -0 in sin", sin_res, minus_zero);
1870 fesetenv (&fenv);
1871 check ("sincos (-0, &sin, &cos) puts 1 in cos", cos_res, 1);
1873 FUNC(sincos) (plus_infty, &sin_res, &cos_res);
1874 fegetenv (&fenv);
1875 check_isnan_exc ("sincos (+inf, &sin, &cos) puts NaN in sin plus invalid exception",
1876 sin_res, INVALID_EXCEPTION);
1877 fesetenv (&fenv);
1878 check_isnan_exc ("sincos (+inf, &sin, &cos) puts NaN in cos plus invalid exception",
1879 cos_res, INVALID_EXCEPTION);
1881 FUNC(sincos) (minus_infty, &sin_res, &cos_res);
1882 fegetenv (&fenv);
1883 check_isnan_exc ("sincos (-inf,&sin, &cos) puts NaN in sin plus invalid exception",
1884 sin_res, INVALID_EXCEPTION);
1885 fesetenv (&fenv);
1886 check_isnan_exc ("sincos (-inf,&sin, &cos) puts NaN in cos plus invalid exception",
1887 cos_res, INVALID_EXCEPTION);
1889 FUNC(sincos) (M_PI_2, &sin_res, &cos_res);
1890 fegetenv (&fenv);
1891 check ("sincos (pi/2, &sin, &cos) puts 1 in sin", sin_res, 1);
1892 fesetenv (&fenv);
1893 check_eps ("sincos (pi/2, &sin, &cos) puts 0 in cos", cos_res, 0,
1894 CHOOSE (1e-18L, 1e-16, 1e-7));
1896 FUNC(sincos) (M_PI_6, &sin_res, &cos_res);
1897 check_eps ("sincos (pi/6, &sin, &cos) puts 0.5 in sin", sin_res, 0.5,
1898 CHOOSE (5e-18L, 0, 0));
1900 FUNC(sincos) (M_PI_6*2.0, &sin_res, &cos_res);
1901 check_eps ("sincos (pi/3, &sin, &cos) puts 0.5 in cos", cos_res, 0.5,
1902 CHOOSE (5e-18L, 1e-15, 1e-7));
1904 FUNC(sincos) (0.7, &sin_res, &cos_res);
1905 check_eps ("sincos (0.7, &sin, &cos) puts 0.6442176872... in sin", sin_res,
1906 0.64421768723769105367L, CHOOSE(4e-17L, 0, 0));
1907 check_eps ("sincos (0.7, &sin, &cos) puts 0.7648421872... in cos", cos_res,
1908 0.76484218728448842626L, CHOOSE(3e-17L, 2e-16, 0));
1912 static void
1913 tan_test (void)
1915 check ("tan (+0) == +0", FUNC(tan) (0), 0);
1916 check ("tan (-0) == -0", FUNC(tan) (minus_zero), minus_zero);
1917 check_isnan_exc ("tan (+inf) == NaN plus invalid exception",
1918 FUNC(tan) (plus_infty), INVALID_EXCEPTION);
1919 check_isnan_exc ("tan (-inf) == NaN plus invalid exception",
1920 FUNC(tan) (minus_infty), INVALID_EXCEPTION);
1922 check_eps ("tan (pi/4) == 1", FUNC(tan) (M_PI_4), 1,
1923 CHOOSE (2e-18L, 1e-15L, 2e-7));
1924 check_eps ("tan (0.7) == 0.8422883804...", FUNC(tan) (0.7),
1925 0.84228838046307944813L, CHOOSE(8e-17L, 0, 0));
1929 static void
1930 tanh_test (void)
1932 check ("tanh (+0) == +0", FUNC(tanh) (0), 0);
1933 #ifndef TEST_INLINE
1934 check ("tanh (-0) == -0", FUNC(tanh) (minus_zero), minus_zero);
1936 check ("tanh (+inf) == +1", FUNC(tanh) (plus_infty), 1);
1937 check ("tanh (-inf) == -1", FUNC(tanh) (minus_infty), -1);
1938 #endif
1939 check_eps ("tanh (0.7) == 0.6043677771...", FUNC(tanh) (0.7),
1940 0.60436777711716349631L, CHOOSE(3e-17L, 0, 0));
1944 static void
1945 fabs_test (void)
1947 check ("fabs (+0) == +0", FUNC(fabs) (0), 0);
1948 check ("fabs (-0) == +0", FUNC(fabs) (minus_zero), 0);
1950 check_isinfp ("fabs (+inf) == +inf", FUNC(fabs) (plus_infty));
1951 check_isinfp ("fabs (-inf) == +inf", FUNC(fabs) (minus_infty));
1953 check ("fabs (+38) == 38", FUNC(fabs) (38.0), 38.0);
1954 check ("fabs (-e) == e", FUNC(fabs) (-M_E), M_E);
1958 static void
1959 floor_test (void)
1961 check ("floor (+0) == +0", FUNC(floor) (0.0), 0.0);
1962 check ("floor (-0) == -0", FUNC(floor) (minus_zero), minus_zero);
1963 check_isinfp ("floor (+inf) == +inf", FUNC(floor) (plus_infty));
1964 check_isinfn ("floor (-inf) == -inf", FUNC(floor) (minus_infty));
1966 check ("floor (pi) == 3", FUNC(floor) (M_PI), 3.0);
1967 check ("floor (-pi) == -4", FUNC(floor) (-M_PI), -4.0);
1971 static void
1972 hypot_test (void)
1974 MATHTYPE a;
1976 a = random_greater (0);
1977 check_isinfp_ext ("hypot (+inf, x) == +inf", FUNC(hypot) (plus_infty, a), a);
1978 check_isinfp_ext ("hypot (-inf, x) == +inf", FUNC(hypot) (minus_infty, a), a);
1980 #ifndef TEST_INLINE
1981 check_isinfp ("hypot (+inf, NaN) == +inf", FUNC(hypot) (minus_infty, nan_value));
1982 check_isinfp ("hypot (-inf, NaN) == +inf", FUNC(hypot) (minus_infty, nan_value));
1983 #endif
1985 check_isnan ("hypot (NaN, NaN) == NaN", FUNC(hypot) (nan_value, nan_value));
1987 a = FUNC(hypot) (12.4L, 0.7L);
1988 check ("hypot (x,y) == hypot (y,x)", FUNC(hypot) (0.7L, 12.4L), a);
1989 check ("hypot (x,y) == hypot (-x,y)", FUNC(hypot) (-12.4L, 0.7L), a);
1990 check ("hypot (x,y) == hypot (-y,x)", FUNC(hypot) (-0.7L, 12.4L), a);
1991 check ("hypot (x,y) == hypot (-x,-y)", FUNC(hypot) (-12.4L, -0.7L), a);
1992 check ("hypot (x,y) == hypot (-y,-x)", FUNC(hypot) (-0.7L, -12.4L), a);
1993 check ("hypot (x,0) == fabs (x)", FUNC(hypot) (-0.7L, 0), 0.7L);
1994 check ("hypot (x,0) == fabs (x)", FUNC(hypot) (0.7L, 0), 0.7L);
1995 check ("hypot (x,0) == fabs (x)", FUNC(hypot) (-1.0L, 0), 1.0L);
1996 check ("hypot (x,0) == fabs (x)", FUNC(hypot) (1.0L, 0), 1.0L);
1997 check ("hypot (x,0) == fabs (x)", FUNC(hypot) (-5.7e7L, 0), 5.7e7L);
1998 check ("hypot (x,0) == fabs (x)", FUNC(hypot) (5.7e7L, 0), 5.7e7L);
2000 check_eps ("hypot (0.7,1.2) == 1.38924...", FUNC(hypot) (0.7, 1.2),
2001 1.3892443989449804508L, CHOOSE(7e-17L, 3e-16, 0));
2005 static void
2006 pow_test (void)
2008 MATHTYPE x;
2010 check ("pow (+0, +0) == 1", FUNC(pow) (0, 0), 1);
2011 check ("pow (+0, -0) == 1", FUNC(pow) (0, minus_zero), 1);
2012 check ("pow (-0, +0) == 1", FUNC(pow) (minus_zero, 0), 1);
2013 check ("pow (-0, -0) == 1", FUNC(pow) (minus_zero, minus_zero), 1);
2015 check ("pow (+10, +0) == 1", FUNC(pow) (10, 0), 1);
2016 check ("pow (+10, -0) == 1", FUNC(pow) (10, minus_zero), 1);
2017 check ("pow (-10, +0) == 1", FUNC(pow) (-10, 0), 1);
2018 check ("pow (-10, -0) == 1", FUNC(pow) (-10, minus_zero), 1);
2020 check ("pow (NaN, +0) == 1", FUNC(pow) (nan_value, 0), 1);
2021 check ("pow (NaN, -0) == 1", FUNC(pow) (nan_value, minus_zero), 1);
2023 #ifndef TEST_INLINE
2024 check_isinfp ("pow (+1.1, +inf) == +inf", FUNC(pow) (1.1, plus_infty));
2025 check_isinfp ("pow (+inf, +inf) == +inf", FUNC(pow) (plus_infty, plus_infty));
2026 check_isinfp ("pow (-1.1, +inf) == +inf", FUNC(pow) (-1.1, plus_infty));
2027 check_isinfp ("pow (-inf, +inf) == +inf", FUNC(pow) (minus_infty, plus_infty));
2029 check ("pow (0.9, +inf) == +0", FUNC(pow) (0.9L, plus_infty), 0);
2030 check ("pow (1e-7, +inf) == +0", FUNC(pow) (1e-7L, plus_infty), 0);
2031 check ("pow (-0.9, +inf) == +0", FUNC(pow) (-0.9L, plus_infty), 0);
2032 check ("pow (-1e-7, +inf) == +0", FUNC(pow) (-1e-7L, plus_infty), 0);
2034 check ("pow (+1.1, -inf) == 0", FUNC(pow) (1.1, minus_infty), 0);
2035 check ("pow (+inf, -inf) == 0", FUNC(pow) (plus_infty, minus_infty), 0);
2036 check ("pow (-1.1, -inf) == 0", FUNC(pow) (-1.1, minus_infty), 0);
2037 check ("pow (-inf, -inf) == 0", FUNC(pow) (minus_infty, minus_infty), 0);
2039 check_isinfp ("pow (0.9, -inf) == +inf", FUNC(pow) (0.9L, minus_infty));
2040 check_isinfp ("pow (1e-7, -inf) == +inf", FUNC(pow) (1e-7L, minus_infty));
2041 check_isinfp ("pow (-0.9, -inf) == +inf", FUNC(pow) (-0.9L, minus_infty));
2042 check_isinfp ("pow (-1e-7, -inf) == +inf", FUNC(pow) (-1e-7L, minus_infty));
2044 check_isinfp ("pow (+inf, 1e-7) == +inf", FUNC(pow) (plus_infty, 1e-7L));
2045 check_isinfp ("pow (+inf, 1) == +inf", FUNC(pow) (plus_infty, 1));
2046 check_isinfp ("pow (+inf, 1e7) == +inf", FUNC(pow) (plus_infty, 1e7L));
2048 check ("pow (+inf, -1e-7) == 0", FUNC(pow) (plus_infty, -1e-7L), 0);
2049 check ("pow (+inf, -1) == 0", FUNC(pow) (plus_infty, -1), 0);
2050 check ("pow (+inf, -1e7) == 0", FUNC(pow) (plus_infty, -1e7L), 0);
2052 check_isinfn ("pow (-inf, 1) == -inf", FUNC(pow) (minus_infty, 1));
2053 check_isinfn ("pow (-inf, 11) == -inf", FUNC(pow) (minus_infty, 11));
2054 check_isinfn ("pow (-inf, 1001) == -inf", FUNC(pow) (minus_infty, 1001));
2056 check_isinfp ("pow (-inf, 2) == +inf", FUNC(pow) (minus_infty, 2));
2057 check_isinfp ("pow (-inf, 12) == +inf", FUNC(pow) (minus_infty, 12));
2058 check_isinfp ("pow (-inf, 1002) == +inf", FUNC(pow) (minus_infty, 1002));
2059 check_isinfp ("pow (-inf, 0.1) == +inf", FUNC(pow) (minus_infty, 0.1));
2060 check_isinfp ("pow (-inf, 1.1) == +inf", FUNC(pow) (minus_infty, 1.1));
2061 check_isinfp ("pow (-inf, 11.1) == +inf", FUNC(pow) (minus_infty, 11.1));
2062 check_isinfp ("pow (-inf, 1001.1) == +inf", FUNC(pow) (minus_infty, 1001.1));
2064 check ("pow (-inf, -1) == -0", FUNC(pow) (minus_infty, -1), minus_zero);
2065 check ("pow (-inf, -11) == -0", FUNC(pow) (minus_infty, -11), minus_zero);
2066 check ("pow (-inf, -1001) == -0", FUNC(pow) (minus_infty, -1001), minus_zero);
2068 check ("pow (-inf, -2) == +0", FUNC(pow) (minus_infty, -2), 0);
2069 check ("pow (-inf, -12) == +0", FUNC(pow) (minus_infty, -12), 0);
2070 check ("pow (-inf, -1002) == +0", FUNC(pow) (minus_infty, -1002), 0);
2071 check ("pow (-inf, -0.1) == +0", FUNC(pow) (minus_infty, -0.1), 0);
2072 check ("pow (-inf, -1.1) == +0", FUNC(pow) (minus_infty, -1.1), 0);
2073 check ("pow (-inf, -11.1) == +0", FUNC(pow) (minus_infty, -11.1), 0);
2074 check ("pow (-inf, -1001.1) == +0", FUNC(pow) (minus_infty, -1001.1), 0);
2076 check_isnan ("pow (NaN, NaN) == NaN", FUNC(pow) (nan_value, nan_value));
2077 check_isnan ("pow (0, NaN) == NaN", FUNC(pow) (0, nan_value));
2078 check_isnan ("pow (1, NaN) == NaN", FUNC(pow) (1, nan_value));
2079 check_isnan ("pow (-1, NaN) == NaN", FUNC(pow) (-1, nan_value));
2080 check_isnan ("pow (NaN, 1) == NaN", FUNC(pow) (nan_value, 1));
2081 check_isnan ("pow (NaN, -1) == NaN", FUNC(pow) (nan_value, -1));
2083 x = random_greater (0.0);
2084 check_isnan_ext ("pow (x, NaN) == NaN", FUNC(pow) (x, nan_value), x);
2086 check_isnan_exc ("pow (+1, +inf) == NaN plus invalid exception",
2087 FUNC(pow) (1, plus_infty), INVALID_EXCEPTION);
2088 check_isnan_exc ("pow (-1, +inf) == NaN plus invalid exception",
2089 FUNC(pow) (-1, plus_infty), INVALID_EXCEPTION);
2090 check_isnan_exc ("pow (+1, -inf) == NaN plus invalid exception",
2091 FUNC(pow) (1, minus_infty), INVALID_EXCEPTION);
2092 check_isnan_exc ("pow (-1, -inf) == NaN plus invalid exception",
2093 FUNC(pow) (-1, minus_infty), INVALID_EXCEPTION);
2095 check_isnan_exc ("pow (-0.1, 1.1) == NaN plus invalid exception",
2096 FUNC(pow) (-0.1, 1.1), INVALID_EXCEPTION);
2097 check_isnan_exc ("pow (-0.1, -1.1) == NaN plus invalid exception",
2098 FUNC(pow) (-0.1, -1.1), INVALID_EXCEPTION);
2099 check_isnan_exc ("pow (-10.1, 1.1) == NaN plus invalid exception",
2100 FUNC(pow) (-10.1, 1.1), INVALID_EXCEPTION);
2101 check_isnan_exc ("pow (-10.1, -1.1) == NaN plus invalid exception",
2102 FUNC(pow) (-10.1, -1.1), INVALID_EXCEPTION);
2104 check_isinfp_exc ("pow (+0, -1) == +inf plus divide-by-zero exception",
2105 FUNC(pow) (0, -1), DIVIDE_BY_ZERO_EXCEPTION);
2106 check_isinfp_exc ("pow (+0, -11) == +inf plus divide-by-zero exception",
2107 FUNC(pow) (0, -11), DIVIDE_BY_ZERO_EXCEPTION);
2108 check_isinfn_exc ("pow (-0, -1) == -inf plus divide-by-zero exception",
2109 FUNC(pow) (minus_zero, -1), DIVIDE_BY_ZERO_EXCEPTION);
2110 check_isinfn_exc ("pow (-0, -11) == -inf plus divide-by-zero exception",
2111 FUNC(pow) (minus_zero, -11), DIVIDE_BY_ZERO_EXCEPTION);
2113 check_isinfp_exc ("pow (+0, -2) == +inf plus divide-by-zero exception",
2114 FUNC(pow) (0, -2), DIVIDE_BY_ZERO_EXCEPTION);
2115 check_isinfp_exc ("pow (+0, -11.1) == +inf plus divide-by-zero exception",
2116 FUNC(pow) (0, -11.1), DIVIDE_BY_ZERO_EXCEPTION);
2117 check_isinfp_exc ("pow (-0, -2) == +inf plus divide-by-zero exception",
2118 FUNC(pow) (minus_zero, -2), DIVIDE_BY_ZERO_EXCEPTION);
2119 check_isinfp_exc ("pow (-0, -11.1) == +inf plus divide-by-zero exception",
2120 FUNC(pow) (minus_zero, -11.1), DIVIDE_BY_ZERO_EXCEPTION);
2121 #endif
2123 check ("pow (+0, 1) == +0", FUNC(pow) (0, 1), 0);
2124 check ("pow (+0, 11) == +0", FUNC(pow) (0, 11), 0);
2125 #ifndef TEST_INLINE
2126 check ("pow (-0, 1) == -0", FUNC(pow) (minus_zero, 1), minus_zero);
2127 check ("pow (-0, 11) == -0", FUNC(pow) (minus_zero, 11), minus_zero);
2128 #endif
2130 check ("pow (+0, 2) == +0", FUNC(pow) (0, 2), 0);
2131 check ("pow (+0, 11.1) == +0", FUNC(pow) (0, 11.1), 0);
2133 #ifndef TEST_INLINE
2134 check ("pow (-0, 2) == +0", FUNC(pow) (minus_zero, 2), 0);
2135 check ("pow (-0, 11.1) == +0", FUNC(pow) (minus_zero, 11.1), 0);
2137 x = random_greater (1.0);
2138 check_isinfp_ext ("pow (x, +inf) == +inf for |x| > 1",
2139 FUNC(pow) (x, plus_infty), x);
2141 x = random_value (-1.0, 1.0);
2142 check_ext ("pow (x, +inf) == +0 for |x| < 1",
2143 FUNC(pow) (x, plus_infty), 0.0, x);
2145 x = random_greater (1.0);
2146 check_ext ("pow (x, -inf) == +0 for |x| > 1",
2147 FUNC(pow) (x, minus_infty), 0.0, x);
2149 x = random_value (-1.0, 1.0);
2150 check_isinfp_ext ("pow (x, -inf) == +inf for |x| < 1",
2151 FUNC(pow) (x, minus_infty), x);
2153 x = random_greater (0.0);
2154 check_isinfp_ext ("pow (+inf, y) == +inf for y > 0",
2155 FUNC(pow) (plus_infty, x), x);
2157 x = random_less (0.0);
2158 check_ext ("pow (+inf, y) == +0 for y < 0",
2159 FUNC(pow) (plus_infty, x), 0.0, x);
2161 x = (rand () % 1000000) * 2.0 + 1; /* Get random odd integer > 0 */
2162 check_isinfn_ext ("pow (-inf, y) == -inf for y an odd integer > 0",
2163 FUNC(pow) (minus_infty, x), x);
2165 x = ((rand () % 1000000) + 1) * 2.0; /* Get random even integer > 1 */
2166 check_isinfp_ext ("pow (-inf, y) == +inf for y > 0 and not an odd integer",
2167 FUNC(pow) (minus_infty, x), x);
2169 x = -((rand () % 1000000) * 2.0 + 1); /* Get random odd integer < 0 */
2170 check_ext ("pow (-inf, y) == -0 for y an odd integer < 0",
2171 FUNC(pow) (minus_infty, x), minus_zero, x);
2173 x = ((rand () % 1000000) + 1) * -2.0; /* Get random even integer < 0 */
2174 check_ext ("pow (-inf, y) == +0 for y < 0 and not an odd integer",
2175 FUNC(pow) (minus_infty, x), 0.0, x);
2176 #endif
2178 x = (rand () % 1000000) * 2.0 + 1; /* Get random odd integer > 0 */
2179 check_ext ("pow (+0, y) == +0 for y an odd integer > 0",
2180 FUNC(pow) (0.0, x), 0.0, x);
2181 #ifndef TEST_INLINE
2182 x = (rand () % 1000000) * 2.0 + 1; /* Get random odd integer > 0 */
2183 check_ext ("pow (-0, y) == -0 for y an odd integer > 0",
2184 FUNC(pow) (minus_zero, x), minus_zero, x);
2185 #endif
2187 x = ((rand () % 1000000) + 1) * 2.0; /* Get random even integer > 1 */
2188 check_ext ("pow (+0, y) == +0 for y > 0 and not an odd integer",
2189 FUNC(pow) (0.0, x), 0.0, x);
2191 x = ((rand () % 1000000) + 1) * 2.0; /* Get random even integer > 1 */
2192 check_ext ("pow (-0, y) == +0 for y > 0 and not an odd integer",
2193 FUNC(pow) (minus_zero, x), 0.0, x);
2195 check_eps ("pow (0.7, 1.2) == 0.65180...", FUNC(pow) (0.7, 1.2),
2196 0.65180494056638638188L, CHOOSE(4e-17L, 0, 0));
2200 static void
2201 fdim_test (void)
2203 check ("fdim (+0, +0) = +0", FUNC(fdim) (0, 0), 0);
2204 check ("fdim (9, 0) = 9", FUNC(fdim) (9, 0), 9);
2205 check ("fdim (0, 9) = 0", FUNC(fdim) (0, 9), 0);
2206 check ("fdim (-9, 0) = 9", FUNC(fdim) (-9, 0), 0);
2207 check ("fdim (0, -9) = 9", FUNC(fdim) (0, -9), 9);
2209 check_isinfp ("fdim (+inf, 9) = +inf", FUNC(fdim) (plus_infty, 9));
2210 check_isinfp ("fdim (+inf, -9) = +inf", FUNC(fdim) (plus_infty, -9));
2211 check ("fdim (-inf, 9) = 0", FUNC(fdim) (minus_infty, 9), 0);
2212 check ("fdim (-inf, -9) = 0", FUNC(fdim) (minus_infty, -9), 0);
2213 check_isinfp ("fdim (+9, -inf) = +inf", FUNC(fdim) (9, minus_infty));
2214 check_isinfp ("fdim (-9, -inf) = +inf", FUNC(fdim) (-9, minus_infty));
2215 check ("fdim (9, inf) = 0", FUNC(fdim) (9, plus_infty), 0);
2216 check ("fdim (-9, inf) = 0", FUNC(fdim) (-9, plus_infty), 0);
2218 check_isnan ("fdim (0, NaN) = NaN", FUNC(fdim) (0, nan_value));
2219 check_isnan ("fdim (9, NaN) = NaN", FUNC(fdim) (9, nan_value));
2220 check_isnan ("fdim (-9, NaN) = NaN", FUNC(fdim) (-9, nan_value));
2221 check_isnan ("fdim (NaN, 9) = NaN", FUNC(fdim) (nan_value, 9));
2222 check_isnan ("fdim (NaN, -9) = NaN", FUNC(fdim) (nan_value, -9));
2223 check_isnan ("fdim (+inf, NaN) = NaN", FUNC(fdim) (plus_infty, nan_value));
2224 check_isnan ("fdim (-inf, NaN) = NaN", FUNC(fdim) (minus_infty, nan_value));
2225 check_isnan ("fdim (NaN, +inf) = NaN", FUNC(fdim) (nan_value, plus_infty));
2226 check_isnan ("fdim (NaN, -inf) = NaN", FUNC(fdim) (nan_value, minus_infty));
2227 check_isnan ("fdim (NaN, NaN) = NaN", FUNC(fdim) (nan_value, nan_value));
2231 static void
2232 fmin_test (void)
2234 check ("fmin (+0, +0) = +0", FUNC(fmin) (0, 0), 0);
2235 check ("fmin (9, 0) = 0", FUNC(fmin) (9, 0), 0);
2236 check ("fmin (0, 9) = 0", FUNC(fmin) (0, 9), 0);
2237 check ("fmin (-9, 0) = -9", FUNC(fmin) (-9, 0), -9);
2238 check ("fmin (0, -9) = -9", FUNC(fmin) (0, -9), -9);
2240 check ("fmin (+inf, 9) = 9", FUNC(fmin) (plus_infty, 9), 9);
2241 check ("fmin (9, +inf) = 9", FUNC(fmin) (9, plus_infty), 9);
2242 check ("fmin (+inf, -9) = -9", FUNC(fmin) (plus_infty, -9), -9);
2243 check ("fmin (-9, +inf) = -9", FUNC(fmin) (-9, plus_infty), -9);
2244 check_isinfn ("fmin (-inf, 9) = -inf", FUNC(fmin) (minus_infty, 9));
2245 check_isinfn ("fmin (-inf, -9) = -inf", FUNC(fmin) (minus_infty, -9));
2246 check_isinfn ("fmin (+9, -inf) = -inf", FUNC(fmin) (9, minus_infty));
2247 check_isinfn ("fmin (-9, -inf) = -inf", FUNC(fmin) (-9, minus_infty));
2249 check ("fmin (0, NaN) = 0", FUNC(fmin) (0, nan_value), 0);
2250 check ("fmin (9, NaN) = 9", FUNC(fmin) (9, nan_value), 9);
2251 check ("fmin (-9, NaN) = 9", FUNC(fmin) (-9, nan_value), -9);
2252 check ("fmin (NaN, 0) = 0", FUNC(fmin) (nan_value, 0), 0);
2253 check ("fmin (NaN, 9) = NaN", FUNC(fmin) (nan_value, 9), 9);
2254 check ("fmin (NaN, -9) = NaN", FUNC(fmin) (nan_value, -9), -9);
2255 check_isinfp ("fmin (+inf, NaN) = +inf", FUNC(fmin) (plus_infty, nan_value));
2256 check_isinfn ("fmin (-inf, NaN) = -inf", FUNC(fmin) (minus_infty, nan_value));
2257 check_isinfp ("fmin (NaN, +inf) = +inf", FUNC(fmin) (nan_value, plus_infty));
2258 check_isinfn ("fmin (NaN, -inf) = -inf", FUNC(fmin) (nan_value, minus_infty));
2259 check_isnan ("fmin (NaN, NaN) = NaN", FUNC(fmin) (nan_value, nan_value));
2263 static void
2264 fmax_test (void)
2266 check ("fmax (+0, +0) = +0", FUNC(fmax) (0, 0), 0);
2267 check ("fmax (9, 0) = 9", FUNC(fmax) (9, 0), 9);
2268 check ("fmax (0, 9) = 9", FUNC(fmax) (0, 9), 9);
2269 check ("fmax (-9, 0) = 0", FUNC(fmax) (-9, 0), 0);
2270 check ("fmax (0, -9) = 0", FUNC(fmax) (0, -9), 0);
2272 check_isinfp ("fmax (+inf, 9) = +inf", FUNC(fmax) (plus_infty, 9));
2273 check_isinfp ("fmax (9, +inf) = +inf", FUNC(fmax) (0, plus_infty));
2274 check_isinfp ("fmax (-9, +inf) = +inf", FUNC(fmax) (-9, plus_infty));
2275 check_isinfp ("fmax (+inf, -9) = +inf", FUNC(fmax) (plus_infty, -9));
2276 check ("fmax (-inf, 9) = 9", FUNC(fmax) (minus_infty, 9), 9);
2277 check ("fmax (-inf, -9) = -9", FUNC(fmax) (minus_infty, -9), -9);
2278 check ("fmax (+9, -inf) = 9", FUNC(fmax) (9, minus_infty), 9);
2279 check ("fmax (-9, -inf) = -9", FUNC(fmax) (-9, minus_infty), -9);
2281 check ("fmax (0, NaN) = 0", FUNC(fmax) (0, nan_value), 0);
2282 check ("fmax (9, NaN) = 9", FUNC(fmax) (9, nan_value), 9);
2283 check ("fmax (-9, NaN) = 9", FUNC(fmax) (-9, nan_value), -9);
2284 check ("fmax (NaN, 0) = 0", FUNC(fmax) (nan_value, 0), 0);
2285 check ("fmax (NaN, 9) = NaN", FUNC(fmax) (nan_value, 9), 9);
2286 check ("fmax (NaN, -9) = NaN", FUNC(fmax) (nan_value, -9), -9);
2287 check_isinfp ("fmax (+inf, NaN) = +inf", FUNC(fmax) (plus_infty, nan_value));
2288 check_isinfn ("fmax (-inf, NaN) = -inf", FUNC(fmax) (minus_infty, nan_value));
2289 check_isinfp ("fmax (NaN, +inf) = +inf", FUNC(fmax) (nan_value, plus_infty));
2290 check_isinfn ("fmax (NaN, -inf) = -inf", FUNC(fmax) (nan_value, minus_infty));
2291 check_isnan ("fmax (NaN, NaN) = NaN", FUNC(fmax) (nan_value, nan_value));
2295 static void
2296 fmod_test (void)
2298 MATHTYPE x;
2300 x = random_greater (0);
2301 check_ext ("fmod (+0, y) == +0 for y != 0", FUNC(fmod) (0, x), 0, x);
2303 x = random_greater (0);
2304 check_ext ("fmod (-0, y) == -0 for y != 0", FUNC(fmod) (minus_zero, x),
2305 minus_zero, x);
2307 check_isnan_exc_ext ("fmod (+inf, y) == NaN plus invalid exception",
2308 FUNC(fmod) (plus_infty, x), INVALID_EXCEPTION, x);
2309 check_isnan_exc_ext ("fmod (-inf, y) == NaN plus invalid exception",
2310 FUNC(fmod) (minus_infty, x), INVALID_EXCEPTION, x);
2311 check_isnan_exc_ext ("fmod (x, +0) == NaN plus invalid exception",
2312 FUNC(fmod) (x, 0), INVALID_EXCEPTION, x);
2313 check_isnan_exc_ext ("fmod (x, -0) == NaN plus invalid exception",
2314 FUNC(fmod) (x, minus_zero), INVALID_EXCEPTION, x);
2316 x = random_greater (0);
2317 check_ext ("fmod (x, +inf) == x for x not infinite",
2318 FUNC(fmod) (x, plus_infty), x, x);
2319 x = random_greater (0);
2320 check_ext ("fmod (x, -inf) == x for x not infinite",
2321 FUNC(fmod) (x, minus_infty), x, x);
2323 check_eps ("fmod (6.5, 2.3) == 1.9", FUNC(fmod) (6.5, 2.3), 1.9,
2324 CHOOSE(5e-16, 1e-15, 2e-7));
2325 check_eps ("fmod (-6.5, 2.3) == -1.9", FUNC(fmod) (-6.5, 2.3), -1.9,
2326 CHOOSE(5e-16, 1e-15, 2e-7));
2327 check_eps ("fmod (6.5, -2.3) == 1.9", FUNC(fmod) (6.5, -2.3), 1.9,
2328 CHOOSE(5e-16, 1e-15, 2e-7));
2329 check_eps ("fmod (-6.5, -2.3) == -1.9", FUNC(fmod) (-6.5, -2.3), -1.9,
2330 CHOOSE(5e-16, 1e-15, 2e-7));
2336 static void
2337 nextafter_test (void)
2339 MATHTYPE x;
2341 check ("nextafter (+0, +0) = +0", FUNC(nextafter) (0, 0), 0);
2342 check ("nextafter (-0, +0) = +0", FUNC(nextafter) (minus_zero, 0), 0);
2343 check ("nextafter (+0, -0) = -0", FUNC(nextafter) (0, minus_zero),
2344 minus_zero);
2345 check ("nextafter (-0, -0) = -0", FUNC(nextafter) (minus_zero, minus_zero),
2346 minus_zero);
2348 check ("nextafter (9, 9) = 9", FUNC(nextafter) (9, 9), 9);
2349 check ("nextafter (-9, -9) = -9", FUNC(nextafter) (-9, -9), -9);
2350 check_isinfp ("nextafter (+inf, +inf) = +inf",
2351 FUNC(nextafter) (plus_infty, plus_infty));
2352 check_isinfn ("nextafter (-inf, -inf) = -inf",
2353 FUNC(nextafter) (minus_infty, minus_infty));
2355 x = rand () * 1.1;
2356 check_isnan ("nextafter (NaN, x) = NaN", FUNC(nextafter) (nan_value, x));
2357 check_isnan ("nextafter (x, NaN) = NaN", FUNC(nextafter) (x, nan_value));
2358 check_isnan ("nextafter (NaN, NaN) = NaN", FUNC(nextafter) (nan_value,
2359 nan_value));
2361 /* XXX We need the hexadecimal FP number representation here for further
2362 tests. */
2366 static void
2367 copysign_test (void)
2369 check ("copysign (0, 4) = 0", FUNC(copysign) (0, 4), 0);
2370 check ("copysign (0, -4) = -0", FUNC(copysign) (0, -4), minus_zero);
2371 check ("copysign (-0, 4) = 0", FUNC(copysign) (minus_zero, 4), 0);
2372 check ("copysign (-0, -4) = -0", FUNC(copysign) (minus_zero, -4),
2373 minus_zero);
2375 check_isinfp ("copysign (+inf, 0) = +inf", FUNC(copysign) (plus_infty, 0));
2376 check_isinfn ("copysign (+inf, -0) = -inf", FUNC(copysign) (plus_infty,
2377 minus_zero));
2378 check_isinfp ("copysign (-inf, 0) = +inf", FUNC(copysign) (minus_infty, 0));
2379 check_isinfn ("copysign (-inf, -0) = -inf", FUNC(copysign) (minus_infty,
2380 minus_zero));
2382 check ("copysign (0, +inf) = 0", FUNC(copysign) (0, plus_infty), 0);
2383 check ("copysign (0, -inf) = -0", FUNC(copysign) (0, minus_zero),
2384 minus_zero);
2385 check ("copysign (-0, +inf) = 0", FUNC(copysign) (minus_zero, plus_infty),
2387 check ("copysign (-0, -inf) = -0", FUNC(copysign) (minus_zero, minus_zero),
2388 minus_zero);
2390 /* XXX More correctly we would have to check the sign of the NaN. */
2391 check_isnan ("copysign (+NaN, 0) = +NaN", FUNC(copysign) (nan_value, 0));
2392 check_isnan ("copysign (+NaN, -0) = -NaN", FUNC(copysign) (nan_value,
2393 minus_zero));
2394 check_isnan ("copysign (-NaN, 0) = +NaN", FUNC(copysign) (-nan_value, 0));
2395 check_isnan ("copysign (-NaN, -0) = -NaN", FUNC(copysign) (-nan_value,
2396 minus_zero));
2400 static void
2401 trunc_test (void)
2403 check ("trunc(0) = 0", FUNC(trunc) (0), 0);
2404 check ("trunc(-0) = -0", FUNC(trunc) (minus_zero), minus_zero);
2405 check ("trunc(0.625) = 0", FUNC(trunc) (0.625), 0);
2406 check ("trunc(-0.625) = -0", FUNC(trunc) (-0.625), minus_zero);
2407 check ("trunc(1) = 1", FUNC(trunc) (1), 1);
2408 check ("trunc(-1) = -1", FUNC(trunc) (-1), -1);
2409 check ("trunc(1.625) = 1", FUNC(trunc) (1.625), 1);
2410 check ("trunc(-1.625) = -1", FUNC(trunc) (-1.625), -1);
2412 check ("trunc(1048580.625) = 1048580", FUNC(trunc) (1048580.625L),
2413 1048580L);
2414 check ("trunc(-1048580.625) = -1048580", FUNC(trunc) (-1048580.625L),
2415 -1048580L);
2417 check ("trunc(8388610.125) = 8388610", FUNC(trunc) (8388610.125L),
2418 8388610.0L);
2419 check ("trunc(-8388610.125) = -8388610", FUNC(trunc) (-8388610.125L),
2420 -8388610.0L);
2422 check ("trunc(4294967296.625) = 4294967296", FUNC(trunc) (4294967296.625L),
2423 4294967296.0L);
2424 check ("trunc(-4294967296.625) = -4294967296",
2425 FUNC(trunc) (-4294967296.625L), -4294967296.0L);
2427 check_isinfp ("trunc(+inf) = +inf", FUNC(trunc) (plus_infty));
2428 check_isinfn ("trunc(-inf) = -inf", FUNC(trunc) (minus_infty));
2429 check_isnan ("trunc(NaN) = NaN", FUNC(trunc) (nan_value));
2433 static void
2434 sqrt_test (void)
2436 MATHTYPE x;
2439 /* XXX Tests fuer negative x are missing */
2440 check ("sqrt (0) == 0", FUNC(sqrt) (0), 0);
2441 check_isnan ("sqrt (NaN) == NaN", FUNC(sqrt) (nan_value));
2442 check_isinfp ("sqrt (+inf) == +inf", FUNC(sqrt) (plus_infty));
2444 check ("sqrt (-0) == -0", FUNC(sqrt) (0), 0);
2446 x = random_less (0.0);
2447 check_isnan_exc_ext ("sqrt (x) == NaN plus invalid exception for x < 0",
2448 FUNC(sqrt) (x), INVALID_EXCEPTION, x);
2450 x = random_value (0, 10000);
2451 check_ext ("sqrt (x*x) == x", FUNC(sqrt) (x*x), x, x);
2452 check ("sqrt (4) == 2", FUNC(sqrt) (4), 2);
2453 check ("sqrt (0.25) == 0.5", FUNC(sqrt) (0.25), 0.5);
2454 check ("sqrt (6642.25) == 81.5", FUNC(sqrt) (6642.25), 81.5);
2455 check_eps ("sqrt (15239.903) == 123.45", FUNC(sqrt) (15239.903), 123.45,
2456 CHOOSE (3e-6L, 3e-6, 8e-6));
2457 check_eps ("sqrt (0.7) == 0.8366600265", FUNC(sqrt) (0.7),
2458 0.83666002653407554798L, CHOOSE(3e-17L, 0, 0));
2461 static void
2462 remainder_test (void)
2464 MATHTYPE result;
2466 result = FUNC(remainder) (1, 0);
2467 check_isnan_exc ("remainder(1, +0) == NaN plus invalid exception",
2468 result, INVALID_EXCEPTION);
2470 result = FUNC(remainder) (1, minus_zero);
2471 check_isnan_exc ("remainder(1, -0) == NaN plus invalid exception",
2472 result, INVALID_EXCEPTION);
2474 result = FUNC(remainder) (plus_infty, 1);
2475 check_isnan_exc ("remainder(+inf, 1) == NaN plus invalid exception",
2476 result, INVALID_EXCEPTION);
2478 result = FUNC(remainder) (minus_infty, 1);
2479 check_isnan_exc ("remainder(-inf, 1) == NaN plus invalid exception",
2480 result, INVALID_EXCEPTION);
2482 result = FUNC(remainder) (1.625, 1.0);
2483 check ("remainder(1.625, 1.0) == -0.375", result, -0.375);
2485 result = FUNC(remainder) (-1.625, 1.0);
2486 check ("remainder(-1.625, 1.0) == 0.375", result, 0.375);
2488 result = FUNC(remainder) (1.625, -1.0);
2489 check ("remainder(1.625, -1.0) == -0.375", result, -0.375);
2491 result = FUNC(remainder) (-1.625, -1.0);
2492 check ("remainder(-1.625, -1.0) == 0.375", result, 0.375);
2494 result = FUNC(remainder) (5.0, 2.0);
2495 check ("remainder(5.0, 2.0) == 1.0", result, 1.0);
2497 result = FUNC(remainder) (3.0, 2.0);
2498 check ("remainder(3.0, 2.0) == -1.0", result, -1.0);
2502 static void
2503 remquo_test (void)
2505 int quo;
2506 MATHTYPE result;
2508 result = FUNC(remquo) (1, 0, &quo);
2509 check_isnan_exc ("remquo(1, +0, &x) == NaN plus invalid exception",
2510 result, INVALID_EXCEPTION);
2512 result = FUNC(remquo) (1, minus_zero, &quo);
2513 check_isnan_exc ("remquo(1, -0, &x) == NaN plus invalid exception",
2514 result, INVALID_EXCEPTION);
2516 result = FUNC(remquo) (plus_infty, 1, &quo);
2517 check_isnan_exc ("remquo(+inf, 1, &x) == NaN plus invalid exception",
2518 result, INVALID_EXCEPTION);
2520 result = FUNC(remquo) (minus_infty, 1, &quo);
2521 check_isnan_exc ("remquo(-inf, 1, &x) == NaN plus invalid exception",
2522 result, INVALID_EXCEPTION);
2524 result = FUNC(remquo) (1.625, 1.0, &quo);
2525 check ("remquo(1.625, 1.0, &x) == -0.375", result, -0.375);
2526 check_long ("remquo(1.625, 1.0, &x) puts 2 in x", quo, 2);
2528 result = FUNC(remquo) (-1.625, 1.0, &quo);
2529 check ("remquo(-1.625, 1.0, &x) == 0.375", result, 0.375);
2530 check_long ("remquo(-1.625, 1.0, &x) puts -2 in x", quo, -2);
2532 result = FUNC(remquo) (1.625, -1.0, &quo);
2533 check ("remquo(1.625, -1.0, &x) == -0.375", result, -0.375);
2534 check_long ("remquo(1.625, -1.0, &x) puts -2 in x", quo, -2);
2536 result = FUNC(remquo) (-1.625, -1.0, &quo);
2537 check ("remquo(-1.625, -1.0, &x) == 0.375", result, 0.375);
2538 check_long ("remquo(-1.625, -1.0, &x) puts 2 in x", quo, 2);
2540 result = FUNC(remquo) (5.0, 2.0, &quo);
2541 check ("remquo(5.0, 2.0, &x) == 1.0", result, 1.0);
2542 check_long ("remquo (5.0, 2.0, &x) puts 2 in x", quo, 2);
2544 result = FUNC(remquo) (3.0, 2.0, &quo);
2545 check ("remquo(3.0, 2.0, &x) == -1.0", result, -1.0);
2546 check_long ("remquo (3.0, 2.0, &x) puts 2 in x", quo, 2);
2550 static void
2551 cexp_test (void)
2553 __complex__ MATHTYPE result;
2555 result = FUNC(cexp) (BUILD_COMPLEX (plus_zero, plus_zero));
2556 check ("real(cexp(0 + 0i)) = 1", __real__ result, 1);
2557 check ("imag(cexp(0 + 0i)) = 0", __imag__ result, 0);
2558 result = FUNC(cexp) (BUILD_COMPLEX (minus_zero, plus_zero));
2559 check ("real(cexp(-0 + 0i)) = 1", __real__ result, 1);
2560 check ("imag(cexp(-0 + 0i)) = 0", __imag__ result, 0);
2561 result = FUNC(cexp) (BUILD_COMPLEX (plus_zero, minus_zero));
2562 check ("real(cexp(0 - 0i)) = 1", __real__ result, 1);
2563 check ("imag(cexp(0 - 0i)) = -0", __imag__ result, minus_zero);
2564 result = FUNC(cexp) (BUILD_COMPLEX (minus_zero, minus_zero));
2565 check ("real(cexp(-0 - 0i)) = 1", __real__ result, 1);
2566 check ("imag(cexp(-0 - 0i)) = -0", __imag__ result, minus_zero);
2568 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, plus_zero));
2569 check_isinfp ("real(cexp(+inf + 0i)) = +inf", __real__ result);
2570 check ("imag(cexp(+inf + 0i)) = 0", __imag__ result, 0);
2571 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, minus_zero));
2572 check_isinfp ("real(cexp(+inf - 0i)) = +inf", __real__ result);
2573 check ("imag(cexp(+inf - 0i)) = -0", __imag__ result, minus_zero);
2575 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, plus_zero));
2576 check ("real(cexp(-inf + 0i)) = 0", __real__ result, 0);
2577 check ("imag(cexp(-inf + 0i)) = 0", __imag__ result, 0);
2578 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, minus_zero));
2579 check ("real(cexp(-inf - 0i)) = 0", __real__ result, 0);
2580 check ("imag(cexp(-inf - 0i)) = -0", __imag__ result, minus_zero);
2583 result = FUNC(cexp) (BUILD_COMPLEX (0.0, plus_infty));
2584 check_isnan_exc ("real(cexp(0 + i inf)) = NaN plus invalid exception",
2585 __real__ result, INVALID_EXCEPTION);
2586 check_isnan ("imag(cexp(0 + i inf)) = NaN plus invalid exception",
2587 __imag__ result);
2589 #if defined __GNUC__ && __GNUC__ <= 2 && __GNUC_MINOR__ <= 7
2590 if (verbose)
2591 printf ("The following test for cexp might fail due to a gcc compiler error!\n");
2592 #endif
2594 result = FUNC(cexp) (BUILD_COMPLEX (minus_zero, plus_infty));
2595 check_isnan_exc ("real(cexp(-0 + i inf)) = NaN plus invalid exception",
2596 __real__ result, INVALID_EXCEPTION);
2597 check_isnan ("imag(cexp(-0 + i inf)) = NaN plus invalid exception",
2598 __imag__ result);
2599 result = FUNC(cexp) (BUILD_COMPLEX (0.0, minus_infty));
2600 check_isnan_exc ("real(cexp(0 - i inf)) = NaN plus invalid exception",
2601 __real__ result, INVALID_EXCEPTION);
2602 check_isnan ("imag(cexp(0 - i inf)) = NaN plus invalid exception",
2603 __imag__ result);
2604 result = FUNC(cexp) (BUILD_COMPLEX (minus_zero, minus_infty));
2605 check_isnan_exc ("real(cexp(-0 - i inf)) = NaN plus invalid exception",
2606 __real__ result, INVALID_EXCEPTION);
2607 check_isnan ("imag(cexp(-0 - i inf)) = NaN plus invalid exception",
2608 __imag__ result);
2610 result = FUNC(cexp) (BUILD_COMPLEX (100.0, plus_infty));
2611 check_isnan_exc ("real(cexp(100.0 + i inf)) = NaN plus invalid exception",
2612 __real__ result, INVALID_EXCEPTION);
2613 check_isnan ("imag(cexp(100.0 + i inf)) = NaN plus invalid exception",
2614 __imag__ result);
2615 result = FUNC(cexp) (BUILD_COMPLEX (-100.0, plus_infty));
2616 check_isnan_exc ("real(cexp(-100.0 + i inf)) = NaN plus invalid exception",
2617 __real__ result, INVALID_EXCEPTION);
2618 check_isnan ("imag(cexp(-100.0 + i inf)) = NaN plus invalid exception",
2619 __imag__ result);
2620 result = FUNC(cexp) (BUILD_COMPLEX (100.0, minus_infty));
2621 check_isnan_exc ("real(cexp(100.0 - i inf)) = NaN plus invalid exception",
2622 __real__ result, INVALID_EXCEPTION);
2623 check_isnan ("imag(cexp(100.0 - i inf)) = NaN plus invalid exception",
2624 __imag__ result);
2625 result = FUNC(cexp) (BUILD_COMPLEX (-100.0, minus_infty));
2626 check_isnan_exc ("real(cexp(-100.0 - i inf)) = NaN plus invalid exception",
2627 __real__ result, INVALID_EXCEPTION);
2628 check_isnan ("imag(cexp(-100.0 - i inf)) = NaN", __imag__ result);
2630 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, 2.0));
2631 check ("real(cexp(-inf + 2.0i)) = -0", __real__ result, minus_zero);
2632 check ("imag(cexp(-inf + 2.0i)) = 0", __imag__ result, 0);
2633 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, 4.0));
2634 check ("real(cexp(-inf + 4.0i)) = -0", __real__ result, minus_zero);
2635 check ("imag(cexp(-inf + 4.0i)) = -0", __imag__ result, minus_zero);
2637 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, 2.0));
2638 check_isinfn ("real(cexp(+inf + 2.0i)) = -inf", __real__ result);
2639 check_isinfp ("imag(cexp(+inf + 2.0i)) = +inf", __imag__ result);
2640 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, 4.0));
2641 check_isinfn ("real(cexp(+inf + 4.0i)) = -inf", __real__ result);
2642 check_isinfn ("imag(cexp(+inf + 4.0i)) = -inf", __imag__ result);
2644 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, plus_infty));
2645 check_isinfp_exc ("real(cexp(+inf + i inf)) = +inf plus invalid exception",
2646 __real__ result, INVALID_EXCEPTION);
2647 check_isnan ("imag(cexp(+inf + i inf)) = NaN plus invalid exception",
2648 __imag__ result);
2649 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, minus_infty));
2650 check_isinfp_exc ("real(cexp(+inf - i inf)) = +inf plus invalid exception",
2651 __real__ result, INVALID_EXCEPTION);
2652 check_isnan ("imag(cexp(+inf - i inf)) = NaN plus invalid exception",
2653 __imag__ result);
2655 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, plus_infty));
2656 check ("real(cexp(-inf + i inf)) = 0", __real__ result, 0);
2657 check ("imag(cexp(-inf + i inf)) = 0", __imag__ result, 0);
2658 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, minus_infty));
2659 check ("real(cexp(-inf - i inf)) = 0", __real__ result, 0);
2660 check ("imag(cexp(-inf - i inf)) = -0", __imag__ result, minus_zero);
2662 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, nan_value));
2663 check ("real(cexp(-inf + i NaN)) = 0", __real__ result, 0);
2664 check ("imag(cexp(-inf + i NaN)) = 0", fabs (__imag__ result), 0);
2666 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, nan_value));
2667 check_isinfp ("real(cexp(+inf + i NaN)) = +inf", __real__ result);
2668 check_isnan ("imag(cexp(+inf + i NaN)) = NaN", __imag__ result);
2670 result = FUNC(cexp) (BUILD_COMPLEX (nan_value, 0.0));
2671 check_isnan_maybe_exc ("real(cexp(NaN + i0)) = NaN plus maybe invalid exception",
2672 __real__ result, INVALID_EXCEPTION);
2673 check_isnan ("imag(cexp(NaN + i0)) = NaN plus maybe invalid exception",
2674 __imag__ result);
2675 result = FUNC(cexp) (BUILD_COMPLEX (nan_value, 1.0));
2676 check_isnan_maybe_exc ("real(cexp(NaN + 1i)) = NaN plus maybe invalid exception",
2677 __real__ result, INVALID_EXCEPTION);
2678 check_isnan ("imag(cexp(NaN + 1i)) = NaN plus maybe invalid exception",
2679 __imag__ result);
2680 result = FUNC(cexp) (BUILD_COMPLEX (nan_value, plus_infty));
2681 check_isnan_maybe_exc ("real(cexp(NaN + i inf)) = NaN plus maybe invalid exception",
2682 __real__ result, INVALID_EXCEPTION);
2683 check_isnan ("imag(cexp(NaN + i inf)) = NaN plus maybe invalid exception",
2684 __imag__ result);
2686 result = FUNC(cexp) (BUILD_COMPLEX (0, nan_value));
2687 check_isnan_maybe_exc ("real(cexp(0 + i NaN)) = NaN plus maybe invalid exception",
2688 __real__ result, INVALID_EXCEPTION);
2689 check_isnan ("imag(cexp(0 + i NaN)) = NaN plus maybe invalid exception",
2690 __imag__ result);
2691 result = FUNC(cexp) (BUILD_COMPLEX (1, nan_value));
2692 check_isnan_maybe_exc ("real(cexp(1 + i NaN)) = NaN plus maybe invalid exception",
2693 __real__ result, INVALID_EXCEPTION);
2694 check_isnan ("imag(cexp(1 + i NaN)) = NaN plus maybe invalid exception",
2695 __imag__ result);
2697 result = FUNC(cexp) (BUILD_COMPLEX (nan_value, nan_value));
2698 check_isnan ("real(cexp(NaN + i NaN)) = NaN", __real__ result);
2699 check_isnan ("imag(cexp(NaN + i NaN)) = NaN", __imag__ result);
2701 result = FUNC(cexp) (BUILD_COMPLEX (0.7, 1.2));
2702 check_eps ("real(cexp(0.7 + i 1.2)) == 0.72969...", __real__ result,
2703 0.7296989091503236012L, CHOOSE(6e-17L, 0, 2e-7));
2704 check_eps ("imag(cexp(0.7 + i 1.2)) == 1.87689...", __imag__ result,
2705 1.8768962328348102821L, CHOOSE(2e-16L, 0, 3e-7));
2707 result = FUNC(cexp) (BUILD_COMPLEX (-2, -3));
2708 check_eps ("real(cexp(-2 - i 3)) == -0.13398...", __real__ result,
2709 -0.1339809149295426134L, CHOOSE(6e-20L, 0, 2e-8));
2710 check_eps ("imag(cexp(-2 - i 3)) == -0.01909...", __imag__ result,
2711 -0.0190985162611351964L, CHOOSE(4e-20L, 0, 2e-9));
2715 static void
2716 csin_test (void)
2718 __complex__ MATHTYPE result;
2720 result = FUNC(csin) (BUILD_COMPLEX (0.0, 0.0));
2721 check ("real(csin(0 + 0i)) = 0", __real__ result, 0);
2722 check ("imag(csin(0 + 0i)) = 0", __imag__ result, 0);
2723 result = FUNC(csin) (BUILD_COMPLEX (minus_zero, 0.0));
2724 check ("real(csin(-0 + 0i)) = -0", __real__ result, minus_zero);
2725 check ("imag(csin(-0 + 0i)) = 0", __imag__ result, 0);
2726 result = FUNC(csin) (BUILD_COMPLEX (0.0, minus_zero));
2727 check ("real(csin(0 - 0i)) = 0", __real__ result, 0);
2728 check ("imag(csin(0 - 0i)) = -0", __imag__ result, minus_zero);
2729 result = FUNC(csin) (BUILD_COMPLEX (minus_zero, minus_zero));
2730 check ("real(csin(-0 - 0i)) = -0", __real__ result, minus_zero);
2731 check ("imag(csin(-0 - 0i)) = -0", __imag__ result, minus_zero);
2733 result = FUNC(csin) (BUILD_COMPLEX (0.0, plus_infty));
2734 check ("real(csin(0 + i Inf)) = 0", __real__ result, 0);
2735 check_isinfp ("imag(csin(0 + i Inf)) = +Inf", __imag__ result);
2736 result = FUNC(csin) (BUILD_COMPLEX (minus_zero, plus_infty));
2737 check ("real(csin(-0 + i Inf)) = -0", __real__ result, minus_zero);
2738 check_isinfp ("imag(csin(-0 + i Inf)) = +Inf", __imag__ result);
2739 result = FUNC(csin) (BUILD_COMPLEX (0.0, minus_infty));
2740 check ("real(csin(0 - i Inf)) = 0", __real__ result, 0);
2741 check_isinfn ("imag(csin(0 - i Inf)) = -Inf", __imag__ result);
2742 result = FUNC(csin) (BUILD_COMPLEX (minus_zero, minus_infty));
2743 check ("real(csin(-0 - i Inf)) = -0", __real__ result, minus_zero);
2744 check_isinfn("imag(csin(-0 - i Inf)) = -Inf", __imag__ result);
2746 result = FUNC(csin) (BUILD_COMPLEX (plus_infty, 0.0));
2747 check_isnan_exc ("real(csin(+Inf + 0i)) = NaN plus invalid exception",
2748 __real__ result, INVALID_EXCEPTION);
2749 check ("imag(csin(+Inf + 0i)) = +-0 plus invalid exception",
2750 FUNC(fabs) (__imag__ result), 0);
2751 result = FUNC(csin) (BUILD_COMPLEX (minus_infty, 0.0));
2752 check_isnan_exc ("real(csin(-Inf + 0i)) = NaN plus invalid exception",
2753 __real__ result, INVALID_EXCEPTION);
2754 check ("imag(csin(-Inf + 0i)) = +-0 plus invalid exception",
2755 FUNC(fabs) (__imag__ result), 0);
2756 result = FUNC(csin) (BUILD_COMPLEX (plus_infty, minus_zero));
2757 check_isnan_exc ("real(csin(+Inf - 0i)) = NaN plus invalid exception",
2758 __real__ result, INVALID_EXCEPTION);
2759 check ("imag(csin(+Inf - 0i)) = +-0 plus invalid exception",
2760 FUNC(fabs) (__imag__ result), 0.0);
2761 result = FUNC(csin) (BUILD_COMPLEX (minus_infty, minus_zero));
2762 check_isnan_exc ("real(csin(-Inf - 0i)) = NaN plus invalid exception",
2763 __real__ result, INVALID_EXCEPTION);
2764 check ("imag(csin(-Inf - 0i)) = +-0 plus invalid exception",
2765 FUNC(fabs) (__imag__ result), 0.0);
2767 result = FUNC(csin) (BUILD_COMPLEX (plus_infty, plus_infty));
2768 check_isnan_exc ("real(csin(+Inf + i Inf)) = NaN plus invalid exception",
2769 __real__ result, INVALID_EXCEPTION);
2770 check_isinfp ("imag(csin(+Inf + i Inf)) = +-Inf plus invalid exception",
2771 FUNC(fabs) (__imag__ result));
2772 result = FUNC(csin) (BUILD_COMPLEX (minus_infty, plus_infty));
2773 check_isnan_exc ("real(csin(-Inf + i Inf)) = NaN plus invalid exception",
2774 __real__ result, INVALID_EXCEPTION);
2775 check_isinfp ("imag(csin(-Inf + i Inf)) = +-Inf plus invalid exception",
2776 FUNC(fabs) (__imag__ result));
2777 result = FUNC(csin) (BUILD_COMPLEX (plus_infty, minus_infty));
2778 check_isnan_exc ("real(csin(Inf - i Inf)) = NaN plus invalid exception",
2779 __real__ result, INVALID_EXCEPTION);
2780 check_isinfp ("imag(csin(Inf - i Inf)) = +-Inf plus invalid exception",
2781 FUNC(fabs) (__imag__ result));
2782 result = FUNC(csin) (BUILD_COMPLEX (minus_infty, minus_infty));
2783 check_isnan_exc ("real(csin(-Inf - i Inf)) = NaN plus invalid exception",
2784 __real__ result, INVALID_EXCEPTION);
2785 check_isinfp ("imag(csin(-Inf - i Inf)) = +-Inf plus invalid exception",
2786 FUNC(fabs) (__imag__ result));
2788 result = FUNC(csin) (BUILD_COMPLEX (plus_infty, 6.75));
2789 check_isnan_exc ("real(csin(+Inf + i 6.75)) = NaN plus invalid exception",
2790 __real__ result, INVALID_EXCEPTION);
2791 check_isnan ("imag(csin(+Inf + i6.75)) = NaN plus invalid exception",
2792 __imag__ result);
2793 result = FUNC(csin) (BUILD_COMPLEX (plus_infty, -6.75));
2794 check_isnan_exc ("real(csin(+Inf - i 6.75)) = NaN plus invalid exception",
2795 __real__ result, INVALID_EXCEPTION);
2796 check_isnan ("imag(csin(+Inf - i6.75)) = NaN plus invalid exception",
2797 __imag__ result);
2798 result = FUNC(csin) (BUILD_COMPLEX (minus_infty, 6.75));
2799 check_isnan_exc ("real(csin(-Inf + i6.75)) = NaN plus invalid exception",
2800 __real__ result, INVALID_EXCEPTION);
2801 check_isnan ("imag(csin(-Inf + i6.75)) = NaN plus invalid exception",
2802 __imag__ result);
2803 result = FUNC(csin) (BUILD_COMPLEX (minus_infty, -6.75));
2804 check_isnan_exc ("real(csin(-Inf - i6.75)) = NaN plus invalid exception",
2805 __real__ result, INVALID_EXCEPTION);
2806 check_isnan ("imag(csin(-Inf - i6.75)) = NaN plus invalid exception",
2807 __imag__ result);
2809 result = FUNC(csin) (BUILD_COMPLEX (4.625, plus_infty));
2810 check_isinfn ("real(csin(4.625 + i Inf)) = -Inf", __real__ result);
2811 check_isinfn ("imag(csin(4.625 + i Inf)) = -Inf", __imag__ result);
2812 result = FUNC(csin) (BUILD_COMPLEX (4.625, minus_infty));
2813 check_isinfn ("real(csin(4.625 - i Inf)) = -Inf", __real__ result);
2814 check_isinfp ("imag(csin(4.625 - i Inf)) = +Inf", __imag__ result);
2815 result = FUNC(csin) (BUILD_COMPLEX (-4.625, plus_infty));
2816 check_isinfp ("real(csin(-4.625 + i Inf)) = +Inf", __real__ result);
2817 check_isinfn ("imag(csin(-4.625 + i Inf)) = -Inf", __imag__ result);
2818 result = FUNC(csin) (BUILD_COMPLEX (-4.625, minus_infty));
2819 check_isinfp ("real(csin(-4.625 - i Inf)) = +Inf", __real__ result);
2820 check_isinfp ("imag(csin(-4.625 - i Inf)) = +Inf", __imag__ result);
2822 result = FUNC(csin) (BUILD_COMPLEX (nan_value, 0.0));
2823 check_isnan ("real(csin(NaN + i0)) = NaN", __real__ result);
2824 check ("imag(csin(NaN + i0)) = +-0", FUNC(fabs) (__imag__ result), 0);
2825 result = FUNC(csin) (BUILD_COMPLEX (nan_value, minus_zero));
2826 check_isnan ("real(csin(NaN - i0)) = NaN", __real__ result);
2827 check ("imag(csin(NaN - i0)) = +-0", FUNC(fabs) (__imag__ result), 0);
2829 result = FUNC(csin) (BUILD_COMPLEX (nan_value, plus_infty));
2830 check_isnan ("real(csin(NaN + i Inf)) = NaN", __real__ result);
2831 check_isinfp ("imag(csin(NaN + i Inf)) = +-Inf",
2832 FUNC(fabs) (__imag__ result));
2833 result = FUNC(csin) (BUILD_COMPLEX (nan_value, minus_infty));
2834 check_isnan ("real(csin(NaN - i Inf)) = NaN", __real__ result);
2835 check_isinfp ("real(csin(NaN - i Inf)) = +-Inf",
2836 FUNC(fabs) (__imag__ result));
2838 result = FUNC(csin) (BUILD_COMPLEX (nan_value, 9.0));
2839 check_isnan_maybe_exc ("real(csin(NaN + i9.0)) = NaN plus maybe invalid exception",
2840 __real__ result, INVALID_EXCEPTION);
2841 check_isnan ("imag(csin(NaN + i9.0)) = NaN plus maybe invalid exception",
2842 __imag__ result);
2843 result = FUNC(csin) (BUILD_COMPLEX (nan_value, -9.0));
2844 check_isnan_maybe_exc ("real(csin(NaN - i9.0)) = NaN plus maybe invalid exception",
2845 __real__ result, INVALID_EXCEPTION);
2846 check_isnan ("imag(csin(NaN - i9.0)) = NaN plus maybe invalid exception",
2847 __imag__ result);
2849 result = FUNC(csin) (BUILD_COMPLEX (0.0, nan_value));
2850 check ("real(csin(0 + i NaN))", __real__ result, 0.0);
2851 check_isnan ("imag(csin(0 + i NaN)) = NaN", __imag__ result);
2852 result = FUNC(csin) (BUILD_COMPLEX (minus_zero, nan_value));
2853 check ("real(csin(-0 + i NaN)) = -0", __real__ result, minus_zero);
2854 check_isnan ("imag(csin(-0 + NaN)) = NaN", __imag__ result);
2856 result = FUNC(csin) (BUILD_COMPLEX (10.0, nan_value));
2857 check_isnan_maybe_exc ("real(csin(10 + i NaN)) = NaN plus maybe invalid exception",
2858 __real__ result, INVALID_EXCEPTION);
2859 check_isnan ("imag(csin(10 + i NaN)) = NaN plus maybe invalid exception",
2860 __imag__ result);
2861 result = FUNC(csin) (BUILD_COMPLEX (nan_value, -10.0));
2862 check_isnan_maybe_exc ("real(csin(-10 + i NaN)) = NaN plus maybe invalid exception",
2863 __real__ result, INVALID_EXCEPTION);
2864 check_isnan ("imag(csin(-10 + i NaN)) = NaN plus maybe invalid exception",
2865 __imag__ result);
2867 result = FUNC(csin) (BUILD_COMPLEX (plus_infty, nan_value));
2868 check_isnan_maybe_exc ("real(csin(+Inf + i NaN)) = NaN plus maybe invalid exception",
2869 __real__ result, INVALID_EXCEPTION);
2870 check_isnan ("imag(csin(+Inf + i NaN)) = NaN plus maybe invalid exception",
2871 __imag__ result);
2872 result = FUNC(csin) (BUILD_COMPLEX (minus_infty, nan_value));
2873 check_isnan_maybe_exc ("real(csin(-Inf + i NaN)) = NaN plus maybe invalid exception",
2874 __real__ result, INVALID_EXCEPTION);
2875 check_isnan ("imag(csin(-Inf + i NaN)) = NaN plus maybe invalid exception",
2876 __imag__ result);
2878 result = FUNC(csin) (BUILD_COMPLEX (nan_value, nan_value));
2879 check_isnan ("real(csin(NaN + i NaN)) = NaN", __real__ result);
2880 check_isnan ("imag(csin(NaN + i NaN)) = NaN", __imag__ result);
2882 result = FUNC(csin) (BUILD_COMPLEX (0.7, 1.2));
2883 check_eps ("real(csin(0.7 + i 1.2)) = 1.166456341...", __real__ result,
2884 1.1664563419657581376L, CHOOSE(2e-16L, 0, 0));
2885 check_eps ("imag(csin(0.7 + i 1.2)) = 1.154499724...", __imag__ result,
2886 1.1544997246948547371L, CHOOSE(2e-17L, 0, 2e-7));
2888 result = FUNC(csin) (BUILD_COMPLEX (-2, -3));
2889 check_eps ("real(csin(-2 - i 3)) == -9.15449...", __real__ result,
2890 -9.1544991469114295734L, CHOOSE(4e-18L, 0, 1e-6));
2891 check_eps ("imag(csin(-2 - i 3)) == -4.16890...", __imag__ result,
2892 4.1689069599665643507L, CHOOSE(2e-17L, 0, 5e-7));
2896 static void
2897 csinh_test (void)
2899 __complex__ MATHTYPE result;
2901 result = FUNC(csinh) (BUILD_COMPLEX (0.0, 0.0));
2902 check ("real(csinh(0 + 0i)) = 0", __real__ result, 0);
2903 check ("imag(csinh(0 + 0i)) = 0", __imag__ result, 0);
2904 result = FUNC(csinh) (BUILD_COMPLEX (minus_zero, 0.0));
2905 check ("real(csinh(-0 + 0i)) = -0", __real__ result, minus_zero);
2906 check ("imag(csinh(-0 + 0i)) = 0", __imag__ result, 0);
2907 result = FUNC(csinh) (BUILD_COMPLEX (0.0, minus_zero));
2908 check ("real(csinh(0 - 0i)) = 0", __real__ result, 0);
2909 check ("imag(csinh(0 - 0i)) = -0", __imag__ result, minus_zero);
2910 result = FUNC(csinh) (BUILD_COMPLEX (minus_zero, minus_zero));
2911 check ("real(csinh(-0 - 0i)) = -0", __real__ result, minus_zero);
2912 check ("imag(csinh(-0 - 0i)) = -0", __imag__ result, minus_zero);
2914 result = FUNC(csinh) (BUILD_COMPLEX (0.0, plus_infty));
2915 check_exc ("real(csinh(0 + i Inf)) = +-0 plus invalid exception",
2916 FUNC(fabs) (__real__ result), 0, INVALID_EXCEPTION);
2917 check_isnan ("imag(csinh(0 + i Inf)) = NaN plus invalid exception",
2918 __imag__ result);
2919 result = FUNC(csinh) (BUILD_COMPLEX (minus_zero, plus_infty));
2920 check_exc ("real(csinh(-0 + i Inf)) = +-0 plus invalid exception",
2921 FUNC(fabs) (__real__ result), 0, INVALID_EXCEPTION);
2922 check_isnan ("imag(csinh(-0 + i Inf)) = NaN plus invalid exception",
2923 __imag__ result);
2924 result = FUNC(csinh) (BUILD_COMPLEX (0.0, minus_infty));
2925 check_exc ("real(csinh(0 - i Inf)) = +-0 plus invalid exception",
2926 FUNC(fabs) (__real__ result), 0, INVALID_EXCEPTION);
2927 check_isnan ("imag(csinh(0 - i Inf)) = NaN plus invalid exception",
2928 __imag__ result);
2929 result = FUNC(csinh) (BUILD_COMPLEX (minus_zero, minus_infty));
2930 check_exc ("real(csinh(-0 - i Inf)) = +-0 plus invalid exception",
2931 FUNC(fabs) (__real__ result), 0, INVALID_EXCEPTION);
2932 check_isnan ("imag(csinh(-0 - i Inf)) = NaN plus invalid exception",
2933 __imag__ result);
2935 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, 0.0));
2936 check_isinfp ("real(csinh(+Inf + 0i)) = +Inf", __real__ result);
2937 check ("imag(csinh(+Inf + 0i)) = 0", __imag__ result, 0);
2938 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, 0.0));
2939 check_isinfn ("real(csinh(-Inf + 0i)) = -Inf", __real__ result);
2940 check ("imag(csinh(-Inf + 0i)) = 0", __imag__ result, 0);
2941 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, minus_zero));
2942 check_isinfp ("real(csinh(+Inf - 0i)) = +Inf", __real__ result);
2943 check ("imag(csinh(+Inf - 0i)) = -0", __imag__ result, minus_zero);
2944 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, minus_zero));
2945 check_isinfn ("real(csinh(-Inf - 0i)) = -Inf", __real__ result);
2946 check ("imag(csinh(-Inf - 0i)) = -0", __imag__ result, minus_zero);
2948 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, plus_infty));
2949 check_isinfp_exc ("real(csinh(+Inf + i Inf)) = +-Inf plus invalid exception",
2950 FUNC(fabs) (__real__ result), INVALID_EXCEPTION);
2951 check_isnan ("imag(csinh(+Inf + i Inf)) = NaN plus invalid exception",
2952 __imag__ result);
2953 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, plus_infty));
2954 check_isinfp_exc ("real(csinh(-Inf + i Inf)) = +-Inf plus invalid exception",
2955 FUNC(fabs) (__real__ result), INVALID_EXCEPTION);
2956 check_isnan ("imag(csinh(-Inf + i Inf)) = NaN plus invalid exception",
2957 __imag__ result);
2958 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, minus_infty));
2959 check_isinfp_exc ("real(csinh(Inf - i Inf)) = +-Inf plus invalid exception",
2960 FUNC(fabs) (__real__ result), INVALID_EXCEPTION);
2961 check_isnan ("imag(csinh(Inf - i Inf)) = NaN plus invalid exception",
2962 __imag__ result);
2963 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, minus_infty));
2964 check_isinfp_exc ("real(csinh(-Inf - i Inf)) = +-Inf plus invalid exception",
2965 FUNC(fabs) (__real__ result), INVALID_EXCEPTION);
2966 check_isnan ("imag(csinh(-Inf - i Inf)) = NaN plus invalid exception",
2967 __imag__ result);
2969 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, 4.625));
2970 check_isinfn ("real(csinh(+Inf + i4.625)) = -Inf", __real__ result);
2971 check_isinfn ("imag(csinh(+Inf + i4.625)) = -Inf", __imag__ result);
2972 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, 4.625));
2973 check_isinfp ("real(csinh(-Inf + i4.625)) = +Inf", __real__ result);
2974 check_isinfn ("imag(csinh(-Inf + i4.625)) = -Inf", __imag__ result);
2975 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, -4.625));
2976 check_isinfn ("real(csinh(+Inf - i4.625)) = -Inf", __real__ result);
2977 check_isinfp ("imag(csinh(+Inf - i4.625)) = +Inf", __imag__ result);
2978 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, -4.625));
2979 check_isinfp ("real(csinh(-Inf - i4.625)) = +Inf", __real__ result);
2980 check_isinfp ("imag(csinh(-Inf - i4.625)) = +Inf", __imag__ result);
2982 result = FUNC(csinh) (BUILD_COMPLEX (6.75, plus_infty));
2983 check_isnan_exc ("real(csinh(6.75 + i Inf)) = NaN plus invalid exception",
2984 __real__ result, INVALID_EXCEPTION);
2985 check_isnan ("imag(csinh(6.75 + i Inf)) = NaN plus invalid exception",
2986 __imag__ result);
2987 result = FUNC(csinh) (BUILD_COMPLEX (-6.75, plus_infty));
2988 check_isnan_exc ("real(csinh(-6.75 + i Inf)) = NaN plus invalid exception",
2989 __real__ result, INVALID_EXCEPTION);
2990 check_isnan ("imag(csinh(-6.75 + i Inf)) = NaN plus invalid exception",
2991 __imag__ result);
2992 result = FUNC(csinh) (BUILD_COMPLEX (6.75, minus_infty));
2993 check_isnan_exc ("real(csinh(6.75 - i Inf)) = NaN plus invalid exception",
2994 __real__ result, INVALID_EXCEPTION);
2995 check_isnan ("imag(csinh(6.75 - i Inf)) = NaN plus invalid exception",
2996 __imag__ result);
2997 result = FUNC(csinh) (BUILD_COMPLEX (-6.75, minus_infty));
2998 check_isnan_exc ("real(csinh(-6.75 - i Inf)) = NaN plus invalid exception",
2999 __real__ result, INVALID_EXCEPTION);
3000 check_isnan ("imag(csinh(-6.75 - i Inf)) = NaN plus invalid exception",
3001 __imag__ result);
3003 result = FUNC(csinh) (BUILD_COMPLEX (0.0, nan_value));
3004 check ("real(csinh(0 + i NaN)) = +-0", FUNC(fabs) (__real__ result), 0);
3005 check_isnan ("imag(csinh(0 + i NaN)) = NaN", __imag__ result);
3006 result = FUNC(csinh) (BUILD_COMPLEX (minus_zero, nan_value));
3007 check ("real(csinh(-0 + i NaN)) = +-0", FUNC(fabs) (__real__ result), 0);
3008 check_isnan ("imag(csinh(-0 + i NaN)) = NaN", __imag__ result);
3010 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, nan_value));
3011 check_isinfp ("real(csinh(+Inf + i NaN)) = +-Inf",
3012 FUNC(fabs) (__real__ result));
3013 check_isnan ("imag(csinh(+Inf + i NaN)) = NaN", __imag__ result);
3014 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, nan_value));
3015 check_isinfp ("real(csinh(-Inf + i NaN)) = +-Inf",
3016 FUNC(fabs) (__real__ result));
3017 check_isnan ("imag(csinh(-Inf + i NaN)) = NaN", __imag__ result);
3019 result = FUNC(csinh) (BUILD_COMPLEX (9.0, nan_value));
3020 check_isnan_maybe_exc ("real(csinh(9.0 + i NaN)) = NaN plus maybe invalid exception",
3021 __real__ result, INVALID_EXCEPTION);
3022 check_isnan ("imag(csinh(9.0 + i NaN)) = NaN plus maybe invalid exception",
3023 __imag__ result);
3024 result = FUNC(csinh) (BUILD_COMPLEX (-9.0, nan_value));
3025 check_isnan_maybe_exc ("real(csinh(-9.0 + i NaN)) = NaN plus maybe invalid exception",
3026 __real__ result, INVALID_EXCEPTION);
3027 check_isnan ("imag(csinh(-9.0 + i NaN)) = NaN plus maybe invalid exception",
3028 __imag__ result);
3030 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, 0.0));
3031 check_isnan ("real(csinh(NaN + i0)) = NaN", __real__ result);
3032 check ("imag(csinh(NaN + i0)) = 0", __imag__ result, 0.0);
3033 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, minus_zero));
3034 check_isnan ("real(csinh(NaN - i0)) = NaN", __real__ result);
3035 check ("imag(csinh(NaN - i0)) = -0", __imag__ result, minus_zero);
3037 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, 10.0));
3038 check_isnan_maybe_exc ("real(csinh(NaN + i10)) = NaN plus maybe invalid exception",
3039 __real__ result, INVALID_EXCEPTION);
3040 check_isnan ("imag(csinh(NaN + i10)) = NaN plus maybe invalid exception",
3041 __imag__ result);
3042 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, -10.0));
3043 check_isnan_maybe_exc ("real(csinh(NaN - i10)) = NaN plus maybe invalid exception",
3044 __real__ result, INVALID_EXCEPTION);
3045 check_isnan ("imag(csinh(NaN - i10)) = NaN plus maybe invalid exception",
3046 __imag__ result);
3048 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, plus_infty));
3049 check_isnan_maybe_exc ("real(csinh(NaN + i Inf)) = NaN plus maybe invalid exception",
3050 __real__ result, INVALID_EXCEPTION);
3051 check_isnan ("imag(csinh(NaN + i Inf)) = NaN plus maybe invalid exception",
3052 __imag__ result);
3053 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, minus_infty));
3054 check_isnan_maybe_exc ("real(csinh(NaN - i Inf)) = NaN plus maybe invalid exception",
3055 __real__ result, INVALID_EXCEPTION);
3056 check_isnan ("imag(csinh(NaN - i Inf)) = NaN plus maybe invalid exception",
3057 __imag__ result);
3059 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, nan_value));
3060 check_isnan ("real(csinh(NaN + i NaN)) = NaN", __real__ result);
3061 check_isnan ("imag(csinh(NaN + i NaN)) = NaN", __imag__ result);
3063 result = FUNC(csinh) (BUILD_COMPLEX (0.7, 1.2));
3064 check_eps ("real(csinh(0.7 + i 1.2)) = 0.274878686...", __real__ result,
3065 0.27487868678117583582L, CHOOSE(2e-17L, 6e-17, 3e-8));
3066 check_eps ("imag(csinh(0.7 + i 1.2)) = 1.169866572...", __imag__ result,
3067 1.1698665727426565139L, CHOOSE(6e-17L, 0, 2e-7));
3069 result = FUNC(csinh) (BUILD_COMPLEX (-2, -3));
3070 check_eps ("real(csinh(-2 - i 3)) == -3.59056...", __real__ result,
3071 3.5905645899857799520L, CHOOSE(7e-19L, 5e-16, 3e-7));
3072 check_eps ("imag(csinh(-2 - i 3)) == -0.53092...", __imag__ result,
3073 -0.5309210862485198052L, CHOOSE(3e-19L, 2e-16, 6e-8));
3077 static void
3078 ccos_test (void)
3080 __complex__ MATHTYPE result;
3082 result = FUNC(ccos) (BUILD_COMPLEX (0.0, 0.0));
3083 check ("real(ccos(0 + 0i)) = 1.0", __real__ result, 1.0);
3084 check ("imag(ccos(0 + 0i)) = -0", __imag__ result, minus_zero);
3085 result = FUNC(ccos) (BUILD_COMPLEX (minus_zero, 0.0));
3086 check ("real(ccos(-0 + 0i)) = 1.0", __real__ result, 1.0);
3087 check ("imag(ccos(-0 + 0i)) = 0", __imag__ result, 0.0);
3088 result = FUNC(ccos) (BUILD_COMPLEX (0.0, minus_zero));
3089 check ("real(ccos(0 - 0i)) = 1.0", __real__ result, 1.0);
3090 check ("imag(ccos(0 - 0i)) = 0", __imag__ result, 0.0);
3091 result = FUNC(ccos) (BUILD_COMPLEX (minus_zero, minus_zero));
3092 check ("real(ccos(-0 - 0i)) = 1.0", __real__ result, 1.0);
3093 check ("imag(ccos(-0 - 0i)) = -0", __imag__ result, minus_zero);
3095 result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, 0.0));
3096 check_isnan_exc ("real(ccos(+Inf + i0)) = NaN plus invalid exception",
3097 __real__ result, INVALID_EXCEPTION);
3098 check ("imag(ccos(Inf + i0)) = +-0 plus invalid exception",
3099 FUNC(fabs) (__imag__ result), 0);
3100 result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, minus_zero));
3101 check_isnan_exc ("real(ccos(Inf - i0)) = NaN plus invalid exception",
3102 __real__ result, INVALID_EXCEPTION);
3103 check ("imag(ccos(Inf - i0)) = +-0 plus invalid exception",
3104 FUNC(fabs) (__imag__ result), 0);
3105 result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, 0.0));
3106 check_isnan_exc ("real(ccos(-Inf + i0)) = NaN plus invalid exception",
3107 __real__ result, INVALID_EXCEPTION);
3108 check ("imag(ccos(-Inf + i0)) = +-0 plus invalid exception",
3109 FUNC(fabs) (__imag__ result), 0);
3110 result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, minus_zero));
3111 check_isnan_exc ("real(ccos(-Inf - i0)) = NaN plus invalid exception",
3112 __real__ result, INVALID_EXCEPTION);
3113 check ("imag(ccos(-Inf - i0)) = +-0 plus invalid exception",
3114 FUNC(fabs) (__imag__ result), 0);
3116 result = FUNC(ccos) (BUILD_COMPLEX (0.0, plus_infty));
3117 check_isinfp ("real(ccos(0 + i Inf)) = +Inf", __real__ result);
3118 check ("imag(ccos(0 + i Inf)) = -0", __imag__ result, minus_zero);
3119 result = FUNC(ccos) (BUILD_COMPLEX (0.0, minus_infty));
3120 check_isinfp ("real(ccos(0 - i Inf)) = +Inf", __real__ result);
3121 check ("imag(ccos(0 - i Inf)) = 0", __imag__ result, 0);
3122 result = FUNC(ccos) (BUILD_COMPLEX (minus_zero, plus_infty));
3123 check_isinfp ("real(ccos(-0 + i Inf)) = +Inf", __real__ result);
3124 check ("imag(ccos(-0 + i Inf)) = 0", __imag__ result, 0.0);
3125 result = FUNC(ccos) (BUILD_COMPLEX (minus_zero, minus_infty));
3126 check_isinfp ("real(ccos(-0 - i Inf)) = +Inf", __real__ result);
3127 check ("imag(ccos(-0 - i Inf)) = -0", __imag__ result, minus_zero);
3129 result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, plus_infty));
3130 check_isinfp_exc ("real(ccos(+Inf + i Inf)) = +Inf plus invalid exception",
3131 __real__ result, INVALID_EXCEPTION);
3132 check_isnan ("imag(ccos(+Inf + i Inf)) = NaN plus invalid exception",
3133 __imag__ result);
3134 result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, plus_infty));
3135 check_isinfp_exc ("real(ccos(-Inf + i Inf)) = +Inf plus invalid exception",
3136 __real__ result, INVALID_EXCEPTION);
3137 check_isnan ("imag(ccos(-Inf + i Inf)) = NaN plus invalid exception",
3138 __imag__ result);
3139 result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, minus_infty));
3140 check_isinfp_exc ("real(ccos(Inf - i Inf)) = +Inf plus invalid exception",
3141 __real__ result, INVALID_EXCEPTION);
3142 check_isnan ("imag(ccos(Inf - i Inf)) = NaN plus invalid exception",
3143 __imag__ result);
3144 result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, minus_infty));
3145 check_isinfp_exc ("real(ccos(-Inf - i Inf)) = +Inf plus invalid exception",
3146 __real__ result, INVALID_EXCEPTION);
3147 check_isnan ("imag(ccos(-Inf - i Inf)) = NaN plus invalid exception",
3148 __imag__ result);
3150 result = FUNC(ccos) (BUILD_COMPLEX (4.625, plus_infty));
3151 check_isinfn ("real(ccos(4.625 + i Inf)) = -Inf", __real__ result);
3152 check_isinfp ("imag(ccos(4.625 + i Inf)) = +Inf", __imag__ result);
3153 result = FUNC(ccos) (BUILD_COMPLEX (4.625, minus_infty));
3154 check_isinfn ("real(ccos(4.625 - i Inf)) = -Inf", __real__ result);
3155 check_isinfn ("imag(ccos(4.625 - i Inf)) = -Inf", __imag__ result);
3156 result = FUNC(ccos) (BUILD_COMPLEX (-4.625, plus_infty));
3157 check_isinfn ("real(ccos(-4.625 + i Inf)) = -Inf", __real__ result);
3158 check_isinfn ("imag(ccos(-4.625 + i Inf)) = -Inf", __imag__ result);
3159 result = FUNC(ccos) (BUILD_COMPLEX (-4.625, minus_infty));
3160 check_isinfn ("real(ccos(-4.625 - i Inf)) = -Inf", __real__ result);
3161 check_isinfp ("imag(ccos(-4.625 - i Inf)) = +Inf", __imag__ result);
3163 result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, 6.75));
3164 check_isnan_exc ("real(ccos(+Inf + i6.75)) = NaN plus invalid exception",
3165 __real__ result, INVALID_EXCEPTION);
3166 check_isnan ("imag(ccos(+Inf + i6.75)) = NaN plus invalid exception",
3167 __imag__ result);
3168 result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, -6.75));
3169 check_isnan_exc ("real(ccos(+Inf - i6.75)) = NaN plus invalid exception",
3170 __real__ result, INVALID_EXCEPTION);
3171 check_isnan ("imag(ccos(+Inf - i6.75)) = NaN plus invalid exception",
3172 __imag__ result);
3173 result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, 6.75));
3174 check_isnan_exc ("real(ccos(-Inf + i6.75)) = NaN plus invalid exception",
3175 __real__ result, INVALID_EXCEPTION);
3176 check_isnan ("imag(ccos(-Inf + i6.75)) = NaN plus invalid exception",
3177 __imag__ result);
3178 result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, -6.75));
3179 check_isnan_exc ("real(ccos(-Inf - i6.75)) = NaN plus invalid exception",
3180 __real__ result, INVALID_EXCEPTION);
3181 check_isnan ("imag(ccos(-Inf - i6.75)) = NaN plus invalid exception",
3182 __imag__ result);
3184 result = FUNC(ccos) (BUILD_COMPLEX (nan_value, 0.0));
3185 check_isnan ("real(ccos(NaN + i0)) = NaN", __real__ result);
3186 check ("imag(ccos(NaN + i0)) = +-0", FUNC(fabs) (__imag__ result), 0);
3187 result = FUNC(ccos) (BUILD_COMPLEX (nan_value, minus_zero));
3188 check_isnan ("real(ccos(NaN - i0)) = NaN", __real__ result);
3189 check ("imag(ccos(NaN - i0)) = +-0", FUNC(fabs) (__imag__ result), 0);
3191 result = FUNC(ccos) (BUILD_COMPLEX (nan_value, plus_infty));
3192 check_isinfp ("real(ccos(NaN + i Inf)) = +Inf", __real__ result);
3193 check_isnan ("imag(ccos(NaN + i Inf)) = NaN", __imag__ result);
3194 result = FUNC(ccos) (BUILD_COMPLEX (nan_value, minus_infty));
3195 check_isinfp ("real(ccos(NaN - i Inf)) = +Inf", __real__ result);
3196 check_isnan ("imag(ccos(NaN - i Inf)) = NaN", __imag__ result);
3198 result = FUNC(ccos) (BUILD_COMPLEX (nan_value, 9.0));
3199 check_isnan_maybe_exc ("real(ccos(NaN + i9.0)) = NaN plus maybe invalid exception",
3200 __real__ result, INVALID_EXCEPTION);
3201 check_isnan ("imag(ccos(NaN + i9.0)) = NaN plus maybe invalid exception",
3202 __imag__ result);
3203 result = FUNC(ccos) (BUILD_COMPLEX (nan_value, -9.0));
3204 check_isnan_maybe_exc ("real(ccos(NaN - i9.0)) = NaN plus maybe invalid exception",
3205 __real__ result, INVALID_EXCEPTION);
3206 check_isnan ("imag(ccos(NaN - i9.0)) = NaN plus maybe invalid exception",
3207 __imag__ result);
3209 result = FUNC(ccos) (BUILD_COMPLEX (0.0, nan_value));
3210 check_isnan ("real(ccos(0 + i NaN)) = NaN", __real__ result);
3211 check ("imag(ccos(0 + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0.0);
3212 result = FUNC(ccos) (BUILD_COMPLEX (minus_zero, nan_value));
3213 check_isnan ("real(ccos(-0 + i NaN)) = NaN", __real__ result);
3214 check ("imag(ccos(-0 + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0.0);
3216 result = FUNC(ccos) (BUILD_COMPLEX (10.0, nan_value));
3217 check_isnan_maybe_exc ("real(ccos(10 + i NaN)) = NaN plus maybe invalid exception",
3218 __real__ result, INVALID_EXCEPTION);
3219 check_isnan ("imag(ccos(10 + i NaN)) = NaN plus maybe invalid exception",
3220 __imag__ result);
3221 result = FUNC(ccos) (BUILD_COMPLEX (-10.0, nan_value));
3222 check_isnan_maybe_exc ("real(ccos(-10 + i NaN)) = NaN plus maybe invalid exception",
3223 __real__ result, INVALID_EXCEPTION);
3224 check_isnan ("imag(ccos(-10 + i NaN)) = NaN plus maybe invalid exception",
3225 __imag__ result);
3227 result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, nan_value));
3228 check_isnan_maybe_exc ("real(ccos(+Inf + i NaN)) = NaN plus maybe invalid exception",
3229 __real__ result, INVALID_EXCEPTION);
3230 check_isnan ("imag(ccos(+Inf + i NaN)) = NaN plus maybe invalid exception",
3231 __imag__ result);
3232 result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, nan_value));
3233 check_isnan_maybe_exc ("real(ccos(-Inf + i NaN)) = NaN plus maybe invalid exception",
3234 __real__ result, INVALID_EXCEPTION);
3235 check_isnan ("imag(ccos(-Inf + i NaN)) = NaN plus maybe invalid exception",
3236 __imag__ result);
3238 result = FUNC(ccos) (BUILD_COMPLEX (nan_value, nan_value));
3239 check_isnan ("real(ccos(NaN + i NaN)) = NaN", __real__ result);
3240 check_isnan ("imag(ccos(NaN + i NaN)) = NaN", __imag__ result);
3242 result = FUNC(ccos) (BUILD_COMPLEX (0.7, 1.2));
3243 check_eps ("real(ccos(0.7 + i 1.2)) = 1.384865764...", __real__ result,
3244 1.3848657645312111080L, CHOOSE(4e-18L, 3e-16, 2e-7));
3245 check_eps ("imag(ccos(0.7 + i 1.2)) = -0.972421703...", __imag__ result,
3246 -0.97242170335830028619L, CHOOSE(2e-16L, 2e-16, 0));
3248 result = FUNC(ccos) (BUILD_COMPLEX (-2, -3));
3249 check_eps ("real(ccos(-2 - i 3)) == -4.18962...", __real__ result,
3250 -4.1896256909688072301L, CHOOSE(2e-17L, 0, 5e-7));
3251 check_eps ("imag(ccos(-2 - i 3)) == -9.10922...", __imag__ result,
3252 -9.1092278937553365979L, CHOOSE(3e-18L, 0, 1e-6));
3256 static void
3257 ccosh_test (void)
3259 __complex__ MATHTYPE result;
3261 result = FUNC(ccosh) (BUILD_COMPLEX (0.0, 0.0));
3262 check ("real(ccosh(0 + 0i)) = 1.0", __real__ result, 1.0);
3263 check ("imag(ccosh(0 + 0i)) = 0", __imag__ result, 0);
3264 result = FUNC(ccosh) (BUILD_COMPLEX (minus_zero, 0.0));
3265 check ("real(ccosh(-0 + 0i)) = 1.0", __real__ result, 1.0);
3266 check ("imag(ccosh(-0 + 0i)) = -0", __imag__ result, minus_zero);
3267 result = FUNC(ccosh) (BUILD_COMPLEX (0.0, minus_zero));
3268 check ("real(ccosh(0 - 0i)) = 1.0", __real__ result, 1.0);
3269 check ("imag(ccosh(0 - 0i)) = -0", __imag__ result, minus_zero);
3270 result = FUNC(ccosh) (BUILD_COMPLEX (minus_zero, minus_zero));
3271 check ("real(ccosh(-0 - 0i)) = 1.0", __real__ result, 1.0);
3272 check ("imag(ccosh(-0 - 0i)) = 0", __imag__ result, 0.0);
3274 result = FUNC(ccosh) (BUILD_COMPLEX (0.0, plus_infty));
3275 check_isnan_exc ("real(ccosh(0 + i Inf)) = NaN plus invalid exception",
3276 __real__ result, INVALID_EXCEPTION);
3277 check ("imag(ccosh(0 + i Inf)) = +-0 plus invalid exception",
3278 FUNC(fabs) (__imag__ result), 0);
3279 result = FUNC(ccosh) (BUILD_COMPLEX (minus_zero, plus_infty));
3280 check_isnan_exc ("real(ccosh(-0 + i Inf)) = NaN plus invalid exception",
3281 __real__ result, INVALID_EXCEPTION);
3282 check ("imag(ccosh(-0 + i Inf)) = +-0 plus invalid exception",
3283 FUNC(fabs) (__imag__ result), 0);
3284 result = FUNC(ccosh) (BUILD_COMPLEX (0.0, minus_infty));
3285 check_isnan_exc ("real(ccosh(0 - i Inf)) = NaN plus invalid exception",
3286 __real__ result, INVALID_EXCEPTION);
3287 check ("imag(ccosh(0 - i Inf)) = +-0 plus invalid exception",
3288 FUNC(fabs) (__imag__ result), 0);
3289 result = FUNC(ccosh) (BUILD_COMPLEX (minus_zero, minus_infty));
3290 check_isnan_exc ("real(ccosh(-0 - i Inf)) = NaN plus invalid exception",
3291 __real__ result, INVALID_EXCEPTION);
3292 check ("imag(ccosh(-0 - i Inf)) = +-0 plus invalid exception",
3293 FUNC(fabs) (__imag__ result), 0);
3295 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, 0.0));
3296 check_isinfp ("real(ccosh(+Inf + 0i)) = +Inf", __real__ result);
3297 check ("imag(ccosh(+Inf + 0i)) = 0", __imag__ result, 0);
3298 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, 0.0));
3299 check_isinfp ("real(ccosh(-Inf + 0i)) = +Inf", __real__ result);
3300 check ("imag(ccosh(-Inf + 0i)) = -0", __imag__ result, minus_zero);
3301 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, minus_zero));
3302 check_isinfp ("real(ccosh(+Inf - 0i)) = +Inf", __real__ result);
3303 check ("imag(ccosh(+Inf - 0i)) = -0", __imag__ result, minus_zero);
3304 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, minus_zero));
3305 check_isinfp ("real(ccosh(-Inf - 0i)) = +Inf", __real__ result);
3306 check ("imag(ccosh(-Inf - 0i)) = 0", __imag__ result, 0.0);
3308 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, plus_infty));
3309 check_isinfp_exc ("real(ccosh(+Inf + i Inf)) = +Inf plus invalid exception",
3310 __real__ result, INVALID_EXCEPTION);
3311 check_isnan ("imag(ccosh(+Inf + i Inf)) = NaN plus invalid exception",
3312 __imag__ result);
3313 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, plus_infty));
3314 check_isinfp_exc ("real(ccosh(-Inf + i Inf)) = +Inf plus invalid exception",
3315 __real__ result, INVALID_EXCEPTION);
3316 check_isnan ("imag(ccosh(-Inf + i Inf)) = NaN plus invalid exception",
3317 __imag__ result);
3318 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, minus_infty));
3319 check_isinfp_exc ("real(ccosh(Inf - i Inf)) = +Inf plus invalid exception",
3320 __real__ result, INVALID_EXCEPTION);
3321 check_isnan ("imag(ccosh(Inf - i Inf)) = NaN plus invalid exception",
3322 __imag__ result);
3323 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, minus_infty));
3324 check_isinfp_exc ("real(ccosh(-Inf - i Inf)) = +Inf plus invalid exception",
3325 __real__ result, INVALID_EXCEPTION);
3326 check_isnan ("imag(ccosh(-Inf - i Inf)) = NaN plus invalid exception",
3327 __imag__ result);
3329 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, 4.625));
3330 check_isinfn ("real(ccosh(+Inf + i4.625)) = -Inf", __real__ result);
3331 check_isinfn ("imag(ccosh(+Inf + i4.625)) = -Inf", __imag__ result);
3332 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, 4.625));
3333 check_isinfn ("real(ccosh(-Inf + i4.625)) = -Inf", __real__ result);
3334 check_isinfp ("imag(ccosh(-Inf + i4.625)) = Inf", __imag__ result);
3335 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, -4.625));
3336 check_isinfn ("real(ccosh(+Inf - i4.625)) = -Inf", __real__ result);
3337 check_isinfp ("imag(ccosh(+Inf - i4.625)) = +Inf", __imag__ result);
3338 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, -4.625));
3339 check_isinfn ("real(ccosh(-Inf - i4.625)) = -Inf", __real__ result);
3340 check_isinfn ("imag(ccosh(-Inf - i4.625)) = -Inf", __imag__ result);
3342 result = FUNC(ccosh) (BUILD_COMPLEX (6.75, plus_infty));
3343 check_isnan_exc ("real(ccosh(6.75 + i Inf)) = NaN plus invalid exception",
3344 __real__ result, INVALID_EXCEPTION);
3345 check_isnan ("imag(ccosh(6.75 + i Inf)) = NaN plus invalid exception",
3346 __imag__ result);
3347 result = FUNC(ccosh) (BUILD_COMPLEX (-6.75, plus_infty));
3348 check_isnan_exc ("real(ccosh(-6.75 + i Inf)) = NaN plus invalid exception",
3349 __real__ result, INVALID_EXCEPTION);
3350 check_isnan ("imag(ccosh(-6.75 + i Inf)) = NaN plus invalid exception",
3351 __imag__ result);
3352 result = FUNC(ccosh) (BUILD_COMPLEX (6.75, minus_infty));
3353 check_isnan_exc ("real(ccosh(6.75 - i Inf)) = NaN plus invalid exception",
3354 __real__ result, INVALID_EXCEPTION);
3355 check_isnan ("imag(ccosh(6.75 - i Inf)) = NaN plus invalid exception",
3356 __imag__ result);
3357 result = FUNC(ccosh) (BUILD_COMPLEX (-6.75, minus_infty));
3358 check_isnan_exc ("real(ccosh(-6.75 - i Inf)) = NaN plus invalid exception",
3359 __real__ result, INVALID_EXCEPTION);
3360 check_isnan ("imag(ccosh(-6.75 - i Inf)) = NaN plus invalid exception",
3361 __imag__ result);
3363 result = FUNC(ccosh) (BUILD_COMPLEX (0.0, nan_value));
3364 check_isnan ("real(ccosh(0 + i NaN)) = NaN", __real__ result);
3365 check ("imag(ccosh(0 + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0);
3366 result = FUNC(ccosh) (BUILD_COMPLEX (minus_zero, nan_value));
3367 check_isnan ("real(ccosh(-0 + i NaN)) = NaN", __real__ result);
3368 check ("imag(ccosh(-0 + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0);
3370 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, nan_value));
3371 check_isinfp ("real(ccosh(+Inf + i NaN)) = +Inf", __real__ result);
3372 check_isnan ("imag(ccosh(+Inf + i NaN)) = NaN", __imag__ result);
3373 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, nan_value));
3374 check_isinfp ("real(ccosh(-Inf + i NaN)) = +Inf", __real__ result);
3375 check_isnan ("imag(ccosh(-Inf + i NaN)) = NaN", __imag__ result);
3377 result = FUNC(ccosh) (BUILD_COMPLEX (9.0, nan_value));
3378 check_isnan_maybe_exc ("real(ccosh(9.0 + i NaN)) = NaN plus maybe invalid exception",
3379 __real__ result, INVALID_EXCEPTION);
3380 check_isnan ("imag(ccosh(9.0 + i NaN)) = NaN plus maybe invalid exception",
3381 __imag__ result);
3382 result = FUNC(ccosh) (BUILD_COMPLEX (-9.0, nan_value));
3383 check_isnan_maybe_exc ("real(ccosh(-9.0 + i NaN)) = NaN plus maybe invalid exception",
3384 __real__ result, INVALID_EXCEPTION);
3385 check_isnan ("imag(ccosh(-9.0 + i NaN)) = NaN plus maybe invalid exception",
3386 __imag__ result);
3388 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, 0.0));
3389 check_isnan ("real(ccosh(NaN + i0)) = NaN", __real__ result);
3390 check ("imag(ccosh(NaN + i0)) = +-0", FUNC(fabs) (__imag__ result), 0.0);
3391 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, minus_zero));
3392 check_isnan ("real(ccosh(NaN - i0)) = NaN", __real__ result);
3393 check ("imag(ccosh(NaN - i0)) = +-0", FUNC(fabs) (__imag__ result), 0.0);
3395 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, 10.0));
3396 check_isnan_maybe_exc ("real(ccosh(NaN + i10)) = NaN plus maybe invalid exception",
3397 __real__ result, INVALID_EXCEPTION);
3398 check_isnan ("imag(ccosh(NaN + i10)) = NaN plus maybe invalid exception",
3399 __imag__ result);
3400 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, -10.0));
3401 check_isnan_maybe_exc ("real(ccosh(NaN - i10)) = NaN plus maybe invalid exception",
3402 __real__ result, INVALID_EXCEPTION);
3403 check_isnan ("imag(ccosh(NaN - i10)) = NaN plus maybe invalid exception",
3404 __imag__ result);
3406 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, plus_infty));
3407 check_isnan_maybe_exc ("real(ccosh(NaN + i Inf)) = NaN plus maybe invalid exception",
3408 __real__ result, INVALID_EXCEPTION);
3409 check_isnan ("imag(ccosh(NaN + i Inf)) = NaN plus maybe invalid exception",
3410 __imag__ result);
3411 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, minus_infty));
3412 check_isnan_maybe_exc ("real(ccosh(NaN - i Inf)) = NaN plus maybe invalid exception",
3413 __real__ result, INVALID_EXCEPTION);
3414 check_isnan ("imag(ccosh(NaN - i Inf)) = NaN plus maybe invalid exception",
3415 __imag__ result);
3417 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, nan_value));
3418 check_isnan ("real(ccosh(NaN + i NaN)) = NaN", __real__ result);
3419 check_isnan ("imag(ccosh(NaN + i NaN)) = NaN", __imag__ result);
3421 result = FUNC(ccosh) (BUILD_COMPLEX (0.7, 1.2));
3422 check_eps ("real(ccosh(0.7 + i 1.2)) == 0.45482...", __real__ result,
3423 0.4548202223691477654L, CHOOSE(5e-17L, 6e-17, 9e-8));
3424 check_eps ("imag(ccosh(0.7 + i 1.2)) == 0.70702...", __imag__ result,
3425 0.7070296600921537682L, CHOOSE(7e-17L, 0, 0));
3427 result = FUNC(ccosh) (BUILD_COMPLEX (-2, -3));
3428 check_eps ("real(ccosh(-2 - i 3)) == -3.72454...", __real__ result,
3429 -3.7245455049153225654L, CHOOSE(7e-19L, 0, 3e-7));
3430 check_eps ("imag(ccosh(-2 - i 3)) == -0.51182...", __imag__ result,
3431 0.5118225699873846088L, CHOOSE(3e-19L, 2e-16, 6e-8));
3435 static void
3436 cacos_test (void)
3438 __complex__ MATHTYPE result;
3440 result = FUNC(cacos) (BUILD_COMPLEX (0, 0));
3441 check ("real(cacos(0 + i0)) = pi/2", __real__ result, M_PI_2);
3442 check ("imag(cacos(0 + i0)) = -0", __imag__ result, minus_zero);
3443 result = FUNC(cacos) (BUILD_COMPLEX (minus_zero, 0));
3444 check ("real(cacos(-0 + i0)) = pi/2", __real__ result, M_PI_2);
3445 check ("imag(cacos(-0 + i0)) = -0", __imag__ result, minus_zero);
3446 result = FUNC(cacos) (BUILD_COMPLEX (0, minus_zero));
3447 check ("real(cacos(0 - i0)) = pi/2", __real__ result, M_PI_2);
3448 check ("imag(cacos(0 - i0)) = 0", __imag__ result, 0);
3449 result = FUNC(cacos) (BUILD_COMPLEX (minus_zero, minus_zero));
3450 check ("real(cacos(-0 - i0)) = pi/2", __real__ result, M_PI_2);
3451 check ("imag(cacos(-0 - i0)) = 0", __imag__ result, 0);
3453 result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, plus_infty));
3454 check ("real(cacos(-Inf + i Inf)) = 3*pi/4", __real__ result, M_PI - M_PI_4);
3455 check_isinfn ("imag(cacos(-Inf + i Inf)) = -Inf", __imag__ result);
3456 result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, minus_infty));
3457 check ("real(cacos(-Inf - i Inf)) = 3*pi/4", __real__ result, M_PI - M_PI_4);
3458 check_isinfp ("imag(cacos(-Inf - i Inf)) = +Inf", __imag__ result);
3460 result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, plus_infty));
3461 check ("real(cacos(+Inf + i Inf)) = pi/4", __real__ result, M_PI_4);
3462 check_isinfn ("imag(cacos(+Inf + i Inf)) = -Inf", __imag__ result);
3463 result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, minus_infty));
3464 check ("real(cacos(+Inf - i Inf)) = pi/4", __real__ result, M_PI_4);
3465 check_isinfp ("imag(cacos(+Inf - i Inf)) = +Inf", __imag__ result);
3467 result = FUNC(cacos) (BUILD_COMPLEX (-10.0, plus_infty));
3468 check ("real(cacos(-10.0 + i Inf)) = pi/2", __real__ result, M_PI_2);
3469 check_isinfn ("imag(cacos(-10.0 + i Inf)) = -Inf", __imag__ result);
3470 result = FUNC(cacos) (BUILD_COMPLEX (-10.0, minus_infty));
3471 check ("real(cacos(-10.0 - i Inf)) = pi/2", __real__ result, M_PI_2);
3472 check_isinfp ("imag(cacos(-10.0 - i Inf)) = +Inf", __imag__ result);
3473 result = FUNC(cacos) (BUILD_COMPLEX (0, plus_infty));
3474 check ("real(cacos(0 + i Inf)) = pi/2", __real__ result, M_PI_2);
3475 check_isinfn ("imag(cacos(0 + i Inf)) = -Inf", __imag__ result);
3476 result = FUNC(cacos) (BUILD_COMPLEX (0, minus_infty));
3477 check ("real(cacos(0 - i Inf)) = pi/2", __real__ result, M_PI_2);
3478 check_isinfp ("imag(cacos(0 - i Inf)) = +Inf", __imag__ result);
3479 result = FUNC(cacos) (BUILD_COMPLEX (0.1, plus_infty));
3480 check ("real(cacos(0.1 + i Inf)) = pi/2", __real__ result, M_PI_2);
3481 check_isinfn ("imag(cacos(0.1 + i Inf)) = -Inf", __imag__ result);
3482 result = FUNC(cacos) (BUILD_COMPLEX (0.1, minus_infty));
3483 check ("real(cacos(0.1 - i Inf)) = pi/2", __real__ result, M_PI_2);
3484 check_isinfp ("imag(cacos(0.1 - i Inf)) = +Inf", __imag__ result);
3486 result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, 0));
3487 check ("real(cacos(-Inf + i0)) = pi", __real__ result, M_PI);
3488 check_isinfn ("imag(cacos(-Inf + i0)) = -Inf", __imag__ result);
3489 result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, minus_zero));
3490 check ("real(cacos(-Inf - i0)) = pi", __real__ result, M_PI);
3491 check_isinfp ("imag(cacos(-Inf - i0)) = +Inf", __imag__ result);
3492 result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, 100));
3493 check ("real(cacos(-Inf + i100)) = pi", __real__ result, M_PI);
3494 check_isinfn ("imag(cacos(-Inf + i100)) = -Inf", __imag__ result);
3495 result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, -100));
3496 check ("real(cacos(-Inf - i100)) = pi", __real__ result, M_PI);
3497 check_isinfp ("imag(cacos(-Inf - i100)) = +Inf", __imag__ result);
3499 result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, 0));
3500 check ("real(cacos(+Inf + i0)) = 0", __real__ result, 0);
3501 check_isinfn ("imag(cacos(+Inf + i0)) = -Inf", __imag__ result);
3502 result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, minus_zero));
3503 check ("real(cacos(+Inf - i0)) = 0", __real__ result, 0);
3504 check_isinfp ("imag(cacos(+Inf - i0)) = +Inf", __imag__ result);
3505 result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, 0.5));
3506 check ("real(cacos(+Inf + i0.5)) = 0", __real__ result, 0);
3507 check_isinfn ("imag(cacos(+Inf + i0.5)) = -Inf", __imag__ result);
3508 result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, -0.5));
3509 check ("real(cacos(+Inf - i0.5)) = 0", __real__ result, 0);
3510 check_isinfp ("imag(cacos(+Inf - i0.5)) = +Inf", __imag__ result);
3512 result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, nan_value));
3513 check_isnan ("real(cacos(+Inf + i NaN)) = NaN", __real__ result);
3514 check_isinfp ("imag(cacos(+Inf + i NaN)) = +-Inf",
3515 FUNC(fabs) (__imag__ result));
3516 result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, nan_value));
3517 check_isnan ("real(cacos(-Inf + i NaN)) = NaN", __real__ result);
3518 check_isinfp ("imag(cacos(-Inf + i NaN)) = +-Inf",
3519 FUNC(fabs) (__imag__ result));
3521 result = FUNC(cacos) (BUILD_COMPLEX (0, nan_value));
3522 check ("real(cacos(0 + i NaN)) = pi/2", __real__ result, M_PI_2);
3523 check_isnan ("imag(cacos(0 + i NaN)) = NaN", __imag__ result);
3524 result = FUNC(cacos) (BUILD_COMPLEX (minus_zero, nan_value));
3525 check ("real(cacos(-0 + i NaN)) = pi/2", __real__ result, M_PI_2);
3526 check_isnan ("imag(cacos(-0 + i NaN)) = NaN", __imag__ result);
3528 result = FUNC(cacos) (BUILD_COMPLEX (nan_value, plus_infty));
3529 check_isnan ("real(cacos(NaN + i Inf)) = NaN", __real__ result);
3530 check_isinfn ("imag(cacos(NaN + i Inf)) = -Inf", __imag__ result);
3531 result = FUNC(cacos) (BUILD_COMPLEX (nan_value, minus_infty));
3532 check_isnan ("real(cacos(NaN - i Inf)) = NaN", __real__ result);
3533 check_isinfp ("imag(cacos(NaN - i Inf)) = +Inf", __imag__ result);
3535 result = FUNC(cacos) (BUILD_COMPLEX (10.5, nan_value));
3536 check_isnan_maybe_exc ("real(cacos(10.5 + i NaN)) = NaN plus maybe invalid exception",
3537 __real__ result, INVALID_EXCEPTION);
3538 check_isnan ("imag(cacos(10.5 + i NaN)) = NaN plus maybe invalid exception",
3539 __imag__ result);
3540 result = FUNC(cacos) (BUILD_COMPLEX (-10.5, nan_value));
3541 check_isnan_maybe_exc ("real(cacos(-10.5 + i NaN)) = NaN plus maybe invalid exception",
3542 __real__ result, INVALID_EXCEPTION);
3543 check_isnan ("imag(cacos(-10.5 + i NaN)) = NaN plus maybe invalid exception",
3544 __imag__ result);
3546 result = FUNC(cacos) (BUILD_COMPLEX (nan_value, 0.75));
3547 check_isnan_maybe_exc ("real(cacos(NaN + i0.75)) = NaN plus maybe invalid exception",
3548 __real__ result, INVALID_EXCEPTION);
3549 check_isnan ("imag(cacos(NaN + i0.75)) = NaN plus maybe invalid exception",
3550 __imag__ result);
3551 result = FUNC(cacos) (BUILD_COMPLEX (-10.5, nan_value));
3552 check_isnan_maybe_exc ("real(cacos(NaN - i0.75)) = NaN plus maybe invalid exception",
3553 __real__ result, INVALID_EXCEPTION);
3554 check_isnan ("imag(cacos(NaN - i0.75)) = NaN plus maybe invalid exception",
3555 __imag__ result);
3557 result = FUNC(cacos) (BUILD_COMPLEX (nan_value, nan_value));
3558 check_isnan ("real(cacos(NaN + i NaN)) = NaN", __real__ result);
3559 check_isnan ("imag(cacos(NaN + i NaN)) = NaN", __imag__ result);
3561 result = FUNC(cacos) (BUILD_COMPLEX (0.7, 1.2));
3562 check_eps ("real(cacos(0.7 + i 1.2)) == 1.13518...", __real__ result,
3563 1.1351827477151551089L, CHOOSE(2e-17L, 3e-16, 2e-7));
3564 check_eps ("imag(cacos(0.7 + i 1.2)) == -1.09276...", __imag__ result,
3565 -1.0927647857577371459L, CHOOSE(4e-17L, 0, 3e-7));
3567 result = FUNC(cacos) (BUILD_COMPLEX (-2, -3));
3568 check_eps ("real(cacos(-2 - i 3)) == 2.14144...", __real__ result,
3569 2.1414491111159960199L, CHOOSE(3e-19L, 0, 0));
3570 check_eps ("imag(cacos(-2 - i 3)) == -1.98338...", __imag__ result,
3571 1.9833870299165354323L, CHOOSE(3e-19L, 0, 0));
3575 static void
3576 cacosh_test (void)
3578 __complex__ MATHTYPE result;
3580 result = FUNC(cacosh) (BUILD_COMPLEX (0, 0));
3581 check ("real(cacosh(0 + i0)) = 0", __real__ result, 0);
3582 check ("imag(cacosh(0 + i0)) = pi/2", __imag__ result, M_PI_2);
3583 result = FUNC(cacosh) (BUILD_COMPLEX (minus_zero, 0));
3584 check ("real(cacosh(-0 + i0)) = 0", __real__ result, 0);
3585 check ("imag(cacosh(-0 + i0)) = pi/2", __imag__ result, M_PI_2);
3586 result = FUNC(cacosh) (BUILD_COMPLEX (0, minus_zero));
3587 check ("real(cacosh(0 - i0)) = 0", __real__ result, 0);
3588 check ("imag(cacosh(0 - i0)) = -pi/2", __imag__ result, -M_PI_2);
3589 result = FUNC(cacosh) (BUILD_COMPLEX (minus_zero, minus_zero));
3590 check ("real(cacosh(-0 - i0)) = 0", __real__ result, 0);
3591 check ("imag(cacosh(-0 - i0)) = -pi/2", __imag__ result, -M_PI_2);
3593 result = FUNC(cacosh) (BUILD_COMPLEX (minus_infty, plus_infty));
3594 check_isinfp ("real(cacosh(-Inf + i Inf)) = +Inf", __real__ result);
3595 check ("imag(cacosh(-Inf + i Inf)) = 3*pi/4", __imag__ result,
3596 M_PI - M_PI_4);
3597 result = FUNC(cacosh) (BUILD_COMPLEX (minus_infty, minus_infty));
3598 check_isinfp ("real(cacosh(-Inf - i Inf)) = +Inf", __real__ result);
3599 check ("imag(cacosh(-Inf - i Inf)) = -3*pi/4", __imag__ result,
3600 M_PI_4 - M_PI);
3602 result = FUNC(cacosh) (BUILD_COMPLEX (plus_infty, plus_infty));
3603 check_isinfp ("real(cacosh(+Inf + i Inf)) = +Inf", __real__ result);
3604 check ("imag(cacosh(+Inf + i Inf)) = pi/4", __imag__ result, M_PI_4);
3605 result = FUNC(cacosh) (BUILD_COMPLEX (plus_infty, minus_infty));
3606 check_isinfp ("real(cacosh(+Inf - i Inf)) = +Inf", __real__ result);
3607 check ("imag(cacosh(+Inf - i Inf)) = -pi/4", __imag__ result, -M_PI_4);
3609 result = FUNC(cacosh) (BUILD_COMPLEX (-10.0, plus_infty));
3610 check_isinfp ("real(cacosh(-10.0 + i Inf)) = +Inf", __real__ result);
3611 check ("imag(cacosh(-10.0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
3612 result = FUNC(cacosh) (BUILD_COMPLEX (-10.0, minus_infty));
3613 check_isinfp ("real(cacosh(-10.0 - i Inf)) = +Inf", __real__ result);
3614 check ("imag(cacosh(-10.0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3615 result = FUNC(cacosh) (BUILD_COMPLEX (0, plus_infty));
3616 check_isinfp ("real(cacosh(0 + i Inf)) = +Inf", __real__ result);
3617 check ("imag(cacosh(0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
3618 result = FUNC(cacosh) (BUILD_COMPLEX (0, minus_infty));
3619 check_isinfp ("real(cacosh(0 - i Inf)) = +Inf", __real__ result);
3620 check ("imag(cacosh(0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3621 result = FUNC(cacosh) (BUILD_COMPLEX (0.1, plus_infty));
3622 check_isinfp ("real(cacosh(0.1 + i Inf)) = +Inf", __real__ result);
3623 check ("imag(cacosh(0.1 + i Inf)) = pi/2", __imag__ result, M_PI_2);
3624 result = FUNC(cacosh) (BUILD_COMPLEX (0.1, minus_infty));
3625 check_isinfp ("real(cacosh(0.1 - i Inf)) = +Inf", __real__ result);
3626 check ("imag(cacosh(0.1 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3628 result = FUNC(cacosh) (BUILD_COMPLEX (minus_infty, 0));
3629 check_isinfp ("real(cacosh(-Inf + i0)) = +Inf", __real__ result);
3630 check ("imag(cacosh(-Inf + i0)) = pi", __imag__ result, M_PI);
3631 result = FUNC(cacosh) (BUILD_COMPLEX (minus_infty, minus_zero));
3632 check_isinfp ("real(cacosh(-Inf - i0)) = +Inf", __real__ result);
3633 check ("imag(cacosh(-Inf - i0)) = -pi", __imag__ result, -M_PI);
3634 result = FUNC(cacosh) (BUILD_COMPLEX (minus_infty, 100));
3635 check_isinfp ("real(cacosh(-Inf + i100)) = +Inf", __real__ result);
3636 check ("imag(cacosh(-Inf + i100)) = pi", __imag__ result, M_PI);
3637 result = FUNC(cacosh) (BUILD_COMPLEX (minus_infty, -100));
3638 check_isinfp ("real(cacosh(-Inf - i100)) = +Inf", __real__ result);
3639 check ("imag(cacosh(-Inf - i100)) = -pi", __imag__ result, -M_PI);
3641 result = FUNC(cacosh) (BUILD_COMPLEX (plus_infty, 0));
3642 check_isinfp ("real(cacosh(+Inf + i0)) = +Inf", __real__ result);
3643 check ("imag(cacosh(+Inf + i0)) = 0", __imag__ result, 0);
3644 result = FUNC(cacosh) (BUILD_COMPLEX (plus_infty, minus_zero));
3645 check_isinfp ("real(cacosh(+Inf - i0)) = +Inf", __real__ result);
3646 check ("imag(cacosh(+Inf - i0)) = -0", __imag__ result, minus_zero);
3647 result = FUNC(cacosh) (BUILD_COMPLEX (plus_infty, 0.5));
3648 check_isinfp ("real(cacosh(+Inf + i0.5)) = +Inf", __real__ result);
3649 check ("imag(cacosh(+Inf + i0.5)) = 0", __imag__ result, 0);
3650 result = FUNC(cacosh) (BUILD_COMPLEX (plus_infty, -0.5));
3651 check_isinfp ("real(cacosh(+Inf - i0.5)) = +Inf", __real__ result);
3652 check ("imag(cacosh(+Inf - i0.5)) = -0", __imag__ result, minus_zero);
3654 result = FUNC(cacosh) (BUILD_COMPLEX (plus_infty, nan_value));
3655 check_isinfp ("real(cacosh(+Inf + i NaN)) = +Inf", __real__ result);
3656 check_isnan ("imag(cacosh(+Inf + i NaN)) = NaN", __imag__ result);
3657 result = FUNC(cacosh) (BUILD_COMPLEX (minus_infty, nan_value));
3658 check_isinfp ("real(cacosh(-Inf + i NaN)) = +Inf", __real__ result);
3659 check_isnan ("imag(cacosh(-Inf + i NaN)) = NaN", __imag__ result);
3661 result = FUNC(cacosh) (BUILD_COMPLEX (0, nan_value));
3662 check_isnan ("real(cacosh(0 + i NaN)) = NaN", __real__ result);
3663 check_isnan ("imag(cacosh(0 + i NaN)) = NaN", __imag__ result);
3664 result = FUNC(cacosh) (BUILD_COMPLEX (minus_zero, nan_value));
3665 check_isnan ("real(cacosh(-0 + i NaN)) = NaN", __real__ result);
3666 check_isnan ("imag(cacosh(-0 + i NaN)) = NaN", __imag__ result);
3668 result = FUNC(cacosh) (BUILD_COMPLEX (nan_value, plus_infty));
3669 check_isinfp ("real(cacosh(NaN + i Inf)) = +Inf", __real__ result);
3670 check_isnan ("imag(cacosh(NaN + i Inf)) = NaN", __imag__ result);
3671 result = FUNC(cacosh) (BUILD_COMPLEX (nan_value, minus_infty));
3672 check_isinfp ("real(cacosh(NaN - i Inf)) = +Inf", __real__ result);
3673 check_isnan ("imag(cacosh(NaN - i Inf)) = NaN", __imag__ result);
3675 result = FUNC(cacosh) (BUILD_COMPLEX (10.5, nan_value));
3676 check_isnan_maybe_exc ("real(cacosh(10.5 + i NaN)) = NaN plus maybe invalid exception",
3677 __real__ result, INVALID_EXCEPTION);
3678 check_isnan ("imag(cacosh(10.5 + i NaN)) = NaN plus maybe invalid exception",
3679 __imag__ result);
3680 result = FUNC(cacosh) (BUILD_COMPLEX (-10.5, nan_value));
3681 check_isnan_maybe_exc ("real(cacosh(-10.5 + i NaN)) = NaN plus maybe invalid exception",
3682 __real__ result, INVALID_EXCEPTION);
3683 check_isnan ("imag(cacosh(-10.5 + i NaN)) = NaN plus maybe invalid exception",
3684 __imag__ result);
3686 result = FUNC(cacosh) (BUILD_COMPLEX (nan_value, 0.75));
3687 check_isnan_maybe_exc ("real(cacosh(NaN + i0.75)) = NaN plus maybe invalid exception",
3688 __real__ result, INVALID_EXCEPTION);
3689 check_isnan ("imag(cacosh(NaN + i0.75)) = NaN plus maybe invalid exception",
3690 __imag__ result);
3691 result = FUNC(cacosh) (BUILD_COMPLEX (-10.5, nan_value));
3692 check_isnan_maybe_exc ("real(cacosh(NaN - i0.75)) = NaN plus maybe invalid exception",
3693 __real__ result, INVALID_EXCEPTION);
3694 check_isnan ("imag(cacosh(NaN - i0.75)) = NaN plus maybe invalid exception",
3695 __imag__ result);
3697 result = FUNC(cacosh) (BUILD_COMPLEX (nan_value, nan_value));
3698 check_isnan ("real(cacosh(NaN + i NaN)) = NaN", __real__ result);
3699 check_isnan ("imag(cacosh(NaN + i NaN)) = NaN", __imag__ result);
3701 result = FUNC(cacosh) (BUILD_COMPLEX (0.7, 1.2));
3702 check_eps ("real(cacosh(0.7 + i 1.2)) == 1.09276...", __real__ result,
3703 1.0927647857577371459L, CHOOSE(4e-17L, 3e-16, 0));
3704 check_eps ("imag(cacosh(0.7 + i 1.2)) == 1.13518...", __imag__ result,
3705 1.1351827477151551089L, CHOOSE(2e-17L, 0, 0));
3707 result = FUNC(cacosh) (BUILD_COMPLEX (-2, -3));
3708 check_eps ("real(cacosh(-2 - i 3)) == -1.98338...", __real__ result,
3709 -1.9833870299165354323L, CHOOSE (2e-18L, 3e-16, 9e-7));
3710 check_eps ("imag(cacosh(-2 - i 3)) == 2.14144...", __imag__ result,
3711 2.1414491111159960199L, CHOOSE (3e-19, 5e-16, 1e-6));
3715 static void
3716 casin_test (void)
3718 __complex__ MATHTYPE result;
3720 result = FUNC(casin) (BUILD_COMPLEX (0, 0));
3721 check ("real(casin(0 + i0)) = 0", __real__ result, 0);
3722 check ("imag(casin(0 + i0)) = 0", __imag__ result, 0);
3723 result = FUNC(casin) (BUILD_COMPLEX (minus_zero, 0));
3724 check ("real(casin(-0 + i0)) = -0", __real__ result, minus_zero);
3725 check ("imag(casin(-0 + i0)) = 0", __imag__ result, 0);
3726 result = FUNC(casin) (BUILD_COMPLEX (0, minus_zero));
3727 check ("real(casin(0 - i0)) = 0", __real__ result, 0);
3728 check ("imag(casin(0 - i0)) = -0", __imag__ result, minus_zero);
3729 result = FUNC(casin) (BUILD_COMPLEX (minus_zero, minus_zero));
3730 check ("real(casin(-0 - i0)) = -0", __real__ result, minus_zero);
3731 check ("imag(casin(-0 - i0)) = -0", __imag__ result, minus_zero);
3733 result = FUNC(casin) (BUILD_COMPLEX (plus_infty, plus_infty));
3734 check ("real(casin(+Inf + i Inf)) = pi/4", __real__ result, M_PI_4);
3735 check_isinfp ("imag(casin(+Inf + i Inf)) = +Inf", __imag__ result);
3736 result = FUNC(casin) (BUILD_COMPLEX (plus_infty, minus_infty));
3737 check ("real(casin(+Inf - i Inf)) = pi/4", __real__ result, M_PI_4);
3738 check_isinfn ("imag(casin(+Inf - i Inf)) = -Inf", __imag__ result);
3739 result = FUNC(casin) (BUILD_COMPLEX (minus_infty, plus_infty));
3740 check ("real(casin(-Inf + i Inf)) = -pi/4", __real__ result, -M_PI_4);
3741 check_isinfp ("imag(casin(-Inf + i Inf)) = +Inf", __imag__ result);
3742 result = FUNC(casin) (BUILD_COMPLEX (minus_infty, minus_infty));
3743 check ("real(casin(-Inf - i Inf)) = -pi/4", __real__ result, -M_PI_4);
3744 check_isinfn ("imag(casin(-Inf - i Inf)) = -Inf", __imag__ result);
3746 result = FUNC(casin) (BUILD_COMPLEX (-10.0, plus_infty));
3747 check ("real(casin(-10.0 + i Inf)) = -0", __real__ result, minus_zero);
3748 check_isinfp ("imag(casin(-10.0 + i Inf)) = +Inf", __imag__ result);
3749 result = FUNC(casin) (BUILD_COMPLEX (-10.0, minus_infty));
3750 check ("real(casin(-10.0 - i Inf)) = -0", __real__ result, minus_zero);
3751 check_isinfn ("imag(casin(-10.0 - i Inf)) = -Inf", __imag__ result);
3752 result = FUNC(casin) (BUILD_COMPLEX (0, plus_infty));
3753 check ("real(casin(0 + i Inf)) = 0", __real__ result, 0.0);
3754 check_isinfp ("imag(casin(0 + i Inf)) = +Inf", __imag__ result);
3755 result = FUNC(casin) (BUILD_COMPLEX (0, minus_infty));
3756 check ("real(casin(0 - i Inf)) = 0", __real__ result, 0.0);
3757 check_isinfn ("imag(casin(0 - i Inf)) = -Inf", __imag__ result);
3758 result = FUNC(casin) (BUILD_COMPLEX (minus_zero, plus_infty));
3759 check ("real(casin(-0 + i Inf)) = -0", __real__ result, minus_zero);
3760 check_isinfp ("imag(casin(-0 + i Inf)) = +Inf", __imag__ result);
3761 result = FUNC(casin) (BUILD_COMPLEX (minus_zero, minus_infty));
3762 check ("real(casin(-0 - i Inf)) = -0", __real__ result, minus_zero);
3763 check_isinfn ("imag(casin(-0 - i Inf)) = -Inf", __imag__ result);
3764 result = FUNC(casin) (BUILD_COMPLEX (0.1, plus_infty));
3765 check ("real(casin(0.1 + i Inf)) = 0", __real__ result, 0);
3766 check_isinfp ("imag(casin(0.1 + i Inf)) = +Inf", __imag__ result);
3767 result = FUNC(casin) (BUILD_COMPLEX (0.1, minus_infty));
3768 check ("real(casin(0.1 - i Inf)) = 0", __real__ result, 0);
3769 check_isinfn ("imag(casin(0.1 - i Inf)) = -Inf", __imag__ result);
3771 result = FUNC(casin) (BUILD_COMPLEX (minus_infty, 0));
3772 check ("real(casin(-Inf + i0)) = -pi/2", __real__ result, -M_PI_2);
3773 check_isinfp ("imag(casin(-Inf + i0)) = +Inf", __imag__ result);
3774 result = FUNC(casin) (BUILD_COMPLEX (minus_infty, minus_zero));
3775 check ("real(casin(-Inf - i0)) = -pi/2", __real__ result, -M_PI_2);
3776 check_isinfn ("imag(casin(-Inf - i0)) = -Inf", __imag__ result);
3777 result = FUNC(casin) (BUILD_COMPLEX (minus_infty, 100));
3778 check ("real(casin(-Inf + i100)) = -pi/2", __real__ result, -M_PI_2);
3779 check_isinfp ("imag(casin(-Inf + i100)) = +Inf", __imag__ result);
3780 result = FUNC(casin) (BUILD_COMPLEX (minus_infty, -100));
3781 check ("real(casin(-Inf - i100)) = -pi/2", __real__ result, -M_PI_2);
3782 check_isinfn ("imag(casin(-Inf - i100)) = -Inf", __imag__ result);
3784 result = FUNC(casin) (BUILD_COMPLEX (plus_infty, 0));
3785 check ("real(casin(+Inf + i0)) = pi/2", __real__ result, M_PI_2);
3786 check_isinfp ("imag(casin(+Inf + i0)) = +Inf", __imag__ result);
3787 result = FUNC(casin) (BUILD_COMPLEX (plus_infty, minus_zero));
3788 check ("real(casin(+Inf - i0)) = pi/2", __real__ result, M_PI_2);
3789 check_isinfn ("imag(casin(+Inf - i0)) = -Inf", __imag__ result);
3790 result = FUNC(casin) (BUILD_COMPLEX (plus_infty, 0.5));
3791 check ("real(casin(+Inf + i0.5)) = pi/2", __real__ result, M_PI_2);
3792 check_isinfp ("imag(casin(+Inf + i0.5)) = +Inf", __imag__ result);
3793 result = FUNC(casin) (BUILD_COMPLEX (plus_infty, -0.5));
3794 check ("real(casin(+Inf - i0.5)) = pi/2", __real__ result, M_PI_2);
3795 check_isinfn ("imag(casin(+Inf - i0.5)) = -Inf", __imag__ result);
3797 result = FUNC(casin) (BUILD_COMPLEX (nan_value, plus_infty));
3798 check_isnan ("real(casin(NaN + i Inf)) = NaN", __real__ result);
3799 check_isinfp ("imag(casin(NaN + i Inf)) = +Inf", __imag__ result);
3800 result = FUNC(casin) (BUILD_COMPLEX (nan_value, minus_infty));
3801 check_isnan ("real(casin(NaN - i Inf)) = NaN", __real__ result);
3802 check_isinfn ("imag(casin(NaN - i Inf)) = -Inf", __imag__ result);
3804 result = FUNC(casin) (BUILD_COMPLEX (0.0, nan_value));
3805 check ("real(casin(0 + i NaN)) = 0", __real__ result, 0.0);
3806 check_isnan ("imag(casin(0 + i NaN)) = NaN", __imag__ result);
3807 result = FUNC(casin) (BUILD_COMPLEX (minus_zero, nan_value));
3808 check ("real(casin(-0 + i NaN)) = -0", __real__ result, minus_zero);
3809 check_isnan ("imag(casin(-0 + i NaN)) = NaN", __imag__ result);
3811 result = FUNC(casin) (BUILD_COMPLEX (plus_infty, nan_value));
3812 check_isnan ("real(casin(+Inf + i NaN)) = NaN", __real__ result);
3813 check_isinfp ("imag(casin(+Inf + i NaN)) = +-Inf",
3814 FUNC(fabs) (__imag__ result));
3815 result = FUNC(casin) (BUILD_COMPLEX (minus_infty, nan_value));
3816 check_isnan ("real(casin(-Inf + i NaN)) = NaN", __real__ result);
3817 check_isinfp ("imag(casin(-Inf + NaN)) = +-Inf",
3818 FUNC(fabs) (__imag__ result));
3820 result = FUNC(casin) (BUILD_COMPLEX (nan_value, 10.5));
3821 check_isnan_maybe_exc ("real(casin(NaN + i10.5)) = NaN plus maybe invalid exception",
3822 __real__ result, INVALID_EXCEPTION);
3823 check_isnan ("imag(casin(NaN + i10.5)) = NaN plus maybe invalid exception",
3824 __imag__ result);
3825 result = FUNC(casin) (BUILD_COMPLEX (nan_value, -10.5));
3826 check_isnan_maybe_exc ("real(casin(NaN - i10.5)) = NaN plus maybe invalid exception",
3827 __real__ result, INVALID_EXCEPTION);
3828 check_isnan ("imag(casin(NaN - i10.5)) = NaN plus maybe invalid exception",
3829 __imag__ result);
3831 result = FUNC(casin) (BUILD_COMPLEX (0.75, nan_value));
3832 check_isnan_maybe_exc ("real(casin(0.75 + i NaN)) = NaN plus maybe invalid exception",
3833 __real__ result, INVALID_EXCEPTION);
3834 check_isnan ("imag(casin(0.75 + i NaN)) = NaN plus maybe invalid exception",
3835 __imag__ result);
3836 result = FUNC(casin) (BUILD_COMPLEX (-0.75, nan_value));
3837 check_isnan_maybe_exc ("real(casin(-0.75 + i NaN)) = NaN plus maybe invalid exception",
3838 __real__ result, INVALID_EXCEPTION);
3839 check_isnan ("imag(casin(-0.75 + i NaN)) = NaN plus maybe invalid exception",
3840 __imag__ result);
3842 result = FUNC(casin) (BUILD_COMPLEX (nan_value, nan_value));
3843 check_isnan ("real(casin(NaN + i NaN)) = NaN", __real__ result);
3844 check_isnan ("imag(casin(NaN + i NaN)) = NaN", __imag__ result);
3846 result = FUNC(casin) (BUILD_COMPLEX (0.7, 1.2));
3847 check_eps ("real(casin(0.7 + i 1.2)) == 0.43561...", __real__ result,
3848 0.4356135790797415103L, CHOOSE(2e-17L, 2e-16, 2e-7));
3849 check_eps ("imag(casin(0.7 + i 1.2)) == 1.09276...", __imag__ result,
3850 1.0927647857577371459L, CHOOSE(4e-17L, 0, 3e-7));
3852 result = FUNC(casin) (BUILD_COMPLEX (-2, -3));
3853 check_eps ("real(casin(-2 - i 3)) == -0.57065...", __real__ result,
3854 -0.5706527843210994007L, CHOOSE(4e-19L, 0, 0));
3855 check_eps ("imag(casin(-2 - i 3)) == -1.98338...", __imag__ result,
3856 -1.9833870299165354323L, CHOOSE(3e-19L, 0, 0));
3860 static void
3861 casinh_test (void)
3863 __complex__ MATHTYPE result;
3865 result = FUNC(casinh) (BUILD_COMPLEX (0, 0));
3866 check ("real(casinh(0 + i0)) = 0", __real__ result, 0);
3867 check ("imag(casinh(0 + i0)) = 0", __imag__ result, 0);
3868 result = FUNC(casinh) (BUILD_COMPLEX (minus_zero, 0));
3869 check ("real(casinh(-0 + i0)) = -0", __real__ result, minus_zero);
3870 check ("imag(casinh(-0 + i0)) = 0", __imag__ result, 0);
3871 result = FUNC(casinh) (BUILD_COMPLEX (0, minus_zero));
3872 check ("real(casinh(0 - i0)) = 0", __real__ result, 0);
3873 check ("imag(casinh(0 - i0)) = -0", __imag__ result, minus_zero);
3874 result = FUNC(casinh) (BUILD_COMPLEX (minus_zero, minus_zero));
3875 check ("real(casinh(-0 - i0)) = -0", __real__ result, minus_zero);
3876 check ("imag(casinh(-0 - i0)) = -0", __imag__ result, minus_zero);
3878 result = FUNC(casinh) (BUILD_COMPLEX (plus_infty, plus_infty));
3879 check_isinfp ("real(casinh(+Inf + i Inf)) = +Inf", __real__ result);
3880 check ("imag(casinh(+Inf + i Inf)) = pi/4", __imag__ result, M_PI_4);
3881 result = FUNC(casinh) (BUILD_COMPLEX (plus_infty, minus_infty));
3882 check_isinfp ("real(casinh(+Inf - i Inf)) = +Inf", __real__ result);
3883 check ("imag(casinh(+Inf - i Inf)) = -pi/4", __imag__ result, -M_PI_4);
3884 result = FUNC(casinh) (BUILD_COMPLEX (minus_infty, plus_infty));
3885 check_isinfn ("real(casinh(-Inf + i Inf)) = -Inf", __real__ result);
3886 check ("imag(casinh(-Inf + i Inf)) = pi/4", __imag__ result, M_PI_4);
3887 result = FUNC(casinh) (BUILD_COMPLEX (minus_infty, minus_infty));
3888 check_isinfn ("real(casinh(-Inf - i Inf)) = -Inf", __real__ result);
3889 check ("imag(casinh(-Inf - i Inf)) = -pi/4", __imag__ result, -M_PI_4);
3891 result = FUNC(casinh) (BUILD_COMPLEX (-10.0, plus_infty));
3892 check_isinfn ("real(casinh(-10.0 + i Inf)) = -Inf", __real__ result);
3893 check ("imag(casinh(-10.0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
3894 result = FUNC(casinh) (BUILD_COMPLEX (-10.0, minus_infty));
3895 check_isinfn ("real(casinh(-10.0 - i Inf)) = -Inf", __real__ result);
3896 check ("imag(casinh(-10.0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3897 result = FUNC(casinh) (BUILD_COMPLEX (0, plus_infty));
3898 check_isinfp ("real(casinh(0 + i Inf)) = +Inf", __real__ result);
3899 check ("imag(casinh(0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
3900 result = FUNC(casinh) (BUILD_COMPLEX (0, minus_infty));
3901 check_isinfp ("real(casinh(0 - i Inf)) = +Inf", __real__ result);
3902 check ("imag(casinh(0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3903 result = FUNC(casinh) (BUILD_COMPLEX (minus_zero, plus_infty));
3904 check_isinfn ("real(casinh(-0 + i Inf)) = -Inf", __real__ result);
3905 check ("imag(casinh(-0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
3906 result = FUNC(casinh) (BUILD_COMPLEX (minus_zero, minus_infty));
3907 check_isinfn ("real(casinh(-0 - i Inf)) = -Inf", __real__ result);
3908 check ("imag(casinh(-0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3909 result = FUNC(casinh) (BUILD_COMPLEX (0.1, plus_infty));
3910 check_isinfp ("real(casinh(0.1 + i Inf)) = +Inf", __real__ result);
3911 check ("imag(casinh(0.1 + i Inf)) = pi/2", __imag__ result, M_PI_2);
3912 result = FUNC(casinh) (BUILD_COMPLEX (0.1, minus_infty));
3913 check_isinfp ("real(casinh(0.1 - i Inf)) = +Inf", __real__ result);
3914 check ("imag(casinh(0.1 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3916 result = FUNC(casinh) (BUILD_COMPLEX (minus_infty, 0));
3917 check_isinfn ("real(casinh(-Inf + i0)) = -Inf", __real__ result);
3918 check ("imag(casinh(-Inf + i0)) = 0", __imag__ result, 0);
3919 result = FUNC(casinh) (BUILD_COMPLEX (minus_infty, minus_zero));
3920 check_isinfn ("real(casinh(-Inf - i0)) = -Inf", __real__ result);
3921 check ("imag(casinh(-Inf - i0)) = -0", __imag__ result, minus_zero);
3922 result = FUNC(casinh) (BUILD_COMPLEX (minus_infty, 100));
3923 check_isinfn ("real(casinh(-Inf + i100)) = -Inf", __real__ result);
3924 check ("imag(casinh(-Inf + i100)) = 0", __imag__ result, 0);
3925 result = FUNC(casinh) (BUILD_COMPLEX (minus_infty, -100));
3926 check_isinfn ("real(casinh(-Inf - i100)) = -Inf", __real__ result);
3927 check ("imag(casinh(-Inf - i100)) = -0", __imag__ result, minus_zero);
3929 result = FUNC(casinh) (BUILD_COMPLEX (plus_infty, 0));
3930 check_isinfp ("real(casinh(+Inf + i0)) = +Inf", __real__ result);
3931 check ("imag(casinh(+Inf + i0)) = 0", __imag__ result, 0);
3932 result = FUNC(casinh) (BUILD_COMPLEX (plus_infty, minus_zero));
3933 check_isinfp ("real(casinh(+Inf - i0)) = +Inf", __real__ result);
3934 check ("imag(casinh(+Inf - i0)) = -0", __imag__ result, minus_zero);
3935 result = FUNC(casinh) (BUILD_COMPLEX (plus_infty, 0.5));
3936 check_isinfp ("real(casinh(+Inf + i0.5)) = +Inf", __real__ result);
3937 check ("imag(casinh(+Inf + i0.5)) = 0", __imag__ result, 0);
3938 result = FUNC(casinh) (BUILD_COMPLEX (plus_infty, -0.5));
3939 check_isinfp ("real(casinh(+Inf - i0.5)) = +Inf", __real__ result);
3940 check ("imag(casinh(+Inf - i0.5)) = -0", __imag__ result, minus_zero);
3942 result = FUNC(casinh) (BUILD_COMPLEX (plus_infty, nan_value));
3943 check_isinfp ("real(casinh(+Inf + i NaN)) = +Inf", __real__ result);
3944 check_isnan ("imag(casinh(+Inf + i NaN)) = NaN", __imag__ result);
3945 result = FUNC(casinh) (BUILD_COMPLEX (minus_infty, nan_value));
3946 check_isinfn ("real(casinh(-Inf + i NaN)) = -Inf", __real__ result);
3947 check_isnan ("imag(casinh(-Inf + i NaN)) = NaN", __imag__ result);
3949 result = FUNC(casinh) (BUILD_COMPLEX (nan_value, 0));
3950 check_isnan ("real(casinh(NaN + i0)) = NaN", __real__ result);
3951 check ("imag(casinh(NaN + i0)) = 0", __imag__ result, 0);
3952 result = FUNC(casinh) (BUILD_COMPLEX (nan_value, minus_zero));
3953 check_isnan ("real(casinh(NaN - i0)) = NaN", __real__ result);
3954 check ("imag(casinh(NaN - i0)) = -0", __imag__ result, minus_zero);
3956 result = FUNC(casinh) (BUILD_COMPLEX (nan_value, plus_infty));
3957 check_isinfp ("real(casinh(NaN + i Inf)) = +-Inf",
3958 FUNC(fabs) (__real__ result));
3959 check_isnan ("imag(casinh(NaN + i Inf)) = NaN", __imag__ result);
3960 result = FUNC(casinh) (BUILD_COMPLEX (nan_value, minus_infty));
3961 check_isinfp ("real(casinh(NaN - i Inf)) = +-Inf",
3962 FUNC(fabs) (__real__ result));
3963 check_isnan ("imag(casinh(NaN - i Inf)) = NaN", __imag__ result);
3965 result = FUNC(casinh) (BUILD_COMPLEX (10.5, nan_value));
3966 check_isnan_maybe_exc ("real(casinh(10.5 + i NaN)) = NaN plus maybe invalid exception",
3967 __real__ result, INVALID_EXCEPTION);
3968 check_isnan ("imag(casinh(10.5 + i NaN)) = NaN plus maybe invalid exception",
3969 __imag__ result);
3970 result = FUNC(casinh) (BUILD_COMPLEX (-10.5, nan_value));
3971 check_isnan_maybe_exc ("real(casinh(-10.5 + i NaN)) = NaN plus maybe invalid exception",
3972 __real__ result, INVALID_EXCEPTION);
3973 check_isnan ("imag(casinh(-10.5 + i NaN)) = NaN plus maybe invalid exception",
3974 __imag__ result);
3976 result = FUNC(casinh) (BUILD_COMPLEX (nan_value, 0.75));
3977 check_isnan_maybe_exc ("real(casinh(NaN + i0.75)) = NaN plus maybe invalid exception",
3978 __real__ result, INVALID_EXCEPTION);
3979 check_isnan ("imag(casinh(NaN + i0.75)) = NaN plus maybe invalid exception",
3980 __imag__ result);
3981 result = FUNC(casinh) (BUILD_COMPLEX (-0.75, nan_value));
3982 check_isnan_maybe_exc ("real(casinh(NaN - i0.75)) = NaN plus maybe invalid exception",
3983 __real__ result, INVALID_EXCEPTION);
3984 check_isnan ("imag(casinh(NaN - i0.75)) = NaN plus maybe invalid exception",
3985 __imag__ result);
3987 result = FUNC(casinh) (BUILD_COMPLEX (nan_value, nan_value));
3988 check_isnan ("real(casinh(NaN + i NaN)) = NaN", __real__ result);
3989 check_isnan ("imag(casinh(NaN + i NaN)) = NaN", __imag__ result);
3991 result = FUNC(casinh) (BUILD_COMPLEX (0.7, 1.2));
3992 check_eps ("real(casinh(0.7 + i 1.2)) == 0.97865...", __real__ result,
3993 0.9786545955936738768L, CHOOSE(5e-17L, 2e-16, 0));
3994 check_eps ("imag(casinh(0.7 + i 1.2)) == 0.91135...", __imag__ result,
3995 0.9113541895315601156L, CHOOSE(7e-19L, 2e-16, 6e-8));
3997 result = FUNC(casinh) (BUILD_COMPLEX (-2, -3));
3998 check_eps ("real(casinh(-2 - i 3)) == -1.96863...", __real__ result,
3999 -1.9686379257930962917L, CHOOSE(7e-19L, 2e-15, 2e-7));
4000 check_eps ("imag(casinh(-2 - i 3)) == -0.96465...", __imag__ result,
4001 -0.9646585044076027920L, CHOOSE(4e-19L, 2e-15, 4e-7));
4005 static void
4006 catan_test (void)
4008 __complex__ MATHTYPE result;
4010 result = FUNC(catan) (BUILD_COMPLEX (0, 0));
4011 check ("real(catan(0 + i0)) = 0", __real__ result, 0);
4012 check ("imag(catan(0 + i0)) = 0", __imag__ result, 0);
4013 result = FUNC(catan) (BUILD_COMPLEX (minus_zero, 0));
4014 check ("real(catan(-0 + i0)) = -0", __real__ result, minus_zero);
4015 check ("imag(catan(-0 + i0)) = 0", __imag__ result, 0);
4016 result = FUNC(catan) (BUILD_COMPLEX (0, minus_zero));
4017 check ("real(catan(0 - i0)) = 0", __real__ result, 0);
4018 check ("imag(catan(0 - i0)) = -0", __imag__ result, minus_zero);
4019 result = FUNC(catan) (BUILD_COMPLEX (minus_zero, minus_zero));
4020 check ("real(catan(-0 - i0)) = -0", __real__ result, minus_zero);
4021 check ("imag(catan(-0 - i0)) = -0", __imag__ result, minus_zero);
4023 result = FUNC(catan) (BUILD_COMPLEX (plus_infty, plus_infty));
4024 check ("real(catan(+Inf + i Inf)) = pi/2", __real__ result, M_PI_2);
4025 check ("imag(catan(+Inf + i Inf)) = 0", __imag__ result, 0);
4026 result = FUNC(catan) (BUILD_COMPLEX (plus_infty, minus_infty));
4027 check ("real(catan(+Inf - i Inf)) = pi/2", __real__ result, M_PI_2);
4028 check ("imag(catan(+Inf - i Inf)) = -0", __imag__ result, minus_zero);
4029 result = FUNC(catan) (BUILD_COMPLEX (minus_infty, plus_infty));
4030 check ("real(catan(-Inf + i Inf)) = -pi/2", __real__ result, -M_PI_2);
4031 check ("imag(catan(-Inf + i Inf)) = 0", __imag__ result, 0.0);
4032 result = FUNC(catan) (BUILD_COMPLEX (minus_infty, minus_infty));
4033 check ("real(catan(-Inf - i Inf)) = -pi/2", __real__ result, -M_PI_2);
4034 check ("imag(catan(-Inf - i Inf)) = -0", __imag__ result, minus_zero);
4036 result = FUNC(catan) (BUILD_COMPLEX (plus_infty, -10.0));
4037 check ("real(catan(+Inf - i10.0)) = pi/2", __real__ result, M_PI_2);
4038 check ("imag(catan(+Inf - i10.0)) = -0", __imag__ result, minus_zero);
4039 result = FUNC(catan) (BUILD_COMPLEX (minus_infty, -10.0));
4040 check ("real(catan(-Inf - i10.0)) = -pi/2", __real__ result, -M_PI_2);
4041 check ("imag(catan(-Inf - i10.0)) = -0", __imag__ result, minus_zero);
4042 result = FUNC(catan) (BUILD_COMPLEX (plus_infty, minus_zero));
4043 check ("real(catan(Inf - i0)) = pi/2", __real__ result, M_PI_2);
4044 check ("imag(catan(Inf - i0)) = -0", __imag__ result, minus_zero);
4045 result = FUNC(catan) (BUILD_COMPLEX (minus_infty, minus_zero));
4046 check ("real(catan(-Inf - i0)) = -pi/2", __real__ result, -M_PI_2);
4047 check ("imag(catan(-Inf - i0)) = -0", __imag__ result, minus_zero);
4048 result = FUNC(catan) (BUILD_COMPLEX (plus_infty, 0.0));
4049 check ("real(catan(Inf + i0)) = pi/2", __real__ result, M_PI_2);
4050 check ("imag(catan(Inf + i0)) = 0", __imag__ result, 0.0);
4051 result = FUNC(catan) (BUILD_COMPLEX (minus_infty, 0.0));
4052 check ("real(catan(-Inf + i0)) = -pi/2", __real__ result, -M_PI_2);
4053 check ("imag(catan(-Inf + i0)) = 0", __imag__ result, 0.0);
4054 result = FUNC(catan) (BUILD_COMPLEX (plus_infty, 0.1));
4055 check ("real(catan(+Inf + i0.1)) = pi/2", __real__ result, M_PI_2);
4056 check ("imag(catan(+Inf + i0.1)) = 0", __imag__ result, 0);
4057 result = FUNC(catan) (BUILD_COMPLEX (minus_infty, 0.1));
4058 check ("real(catan(-Inf + i0.1)) = -pi/2", __real__ result, -M_PI_2);
4059 check ("imag(catan(-Inf + i0.1)) = 0", __imag__ result, 0);
4061 result = FUNC(catan) (BUILD_COMPLEX (0.0, minus_infty));
4062 check ("real(catan(0 - i Inf)) = pi/2", __real__ result, M_PI_2);
4063 check ("imag(catan(0 - i Inf)) = -0", __imag__ result, minus_zero);
4064 result = FUNC(catan) (BUILD_COMPLEX (minus_zero, minus_infty));
4065 check ("real(catan(-0 - i Inf)) = -pi/2", __real__ result, -M_PI_2);
4066 check ("imag(catan(-0 - i Inf)) = -0", __imag__ result, minus_zero);
4067 result = FUNC(catan) (BUILD_COMPLEX (100.0, minus_infty));
4068 check ("real(catan(100 - i Inf)) = pi/2", __real__ result, M_PI_2);
4069 check ("imag(catan(100 - i Inf)) = -0", __imag__ result, minus_zero);
4070 result = FUNC(catan) (BUILD_COMPLEX (-100.0, minus_infty));
4071 check ("real(catan(-100 - i Inf)) = -pi/2", __real__ result, -M_PI_2);
4072 check ("imag(catan(-100 - i Inf)) = -0", __imag__ result, minus_zero);
4074 result = FUNC(catan) (BUILD_COMPLEX (0.0, plus_infty));
4075 check ("real(catan(0 + i Inf)) = pi/2", __real__ result, M_PI_2);
4076 check ("imag(catan(0 + i Inf)) = 0", __imag__ result, 0);
4077 result = FUNC(catan) (BUILD_COMPLEX (minus_zero, plus_infty));
4078 check ("real(catan(-0 + i Inf)) = -pi/2", __real__ result, -M_PI_2);
4079 check ("imag(catan(-0 + i Inf)) = 0", __imag__ result, 0);
4080 result = FUNC(catan) (BUILD_COMPLEX (0.5, plus_infty));
4081 check ("real(catan(0.5 + i Inf)) = pi/2", __real__ result, M_PI_2);
4082 check ("imag(catan(0.5 + i Inf)) = 0", __imag__ result, 0);
4083 result = FUNC(catan) (BUILD_COMPLEX (-0.5, plus_infty));
4084 check ("real(catan(-0.5 + i Inf)) = -pi/2", __real__ result, -M_PI_2);
4085 check ("imag(catan(-0.5 + i Inf)) = 0", __imag__ result, 0);
4087 result = FUNC(catan) (BUILD_COMPLEX (nan_value, 0.0));
4088 check_isnan ("real(catan(NaN + i0)) = NaN", __real__ result);
4089 check ("imag(catan(NaN + i0)) = 0", __imag__ result, 0.0);
4090 result = FUNC(catan) (BUILD_COMPLEX (nan_value, minus_zero));
4091 check_isnan ("real(catan(NaN - i0)) = NaN", __real__ result);
4092 check ("imag(catan(NaN - i0)) = -0", __imag__ result, minus_zero);
4094 result = FUNC(catan) (BUILD_COMPLEX (nan_value, plus_infty));
4095 check_isnan ("real(catan(NaN + i Inf)) = NaN", __real__ result);
4096 check ("imag(catan(NaN + i Inf)) = 0", __imag__ result, 0);
4097 result = FUNC(catan) (BUILD_COMPLEX (nan_value, minus_infty));
4098 check_isnan ("real(catan(NaN - i Inf)) = NaN", __real__ result);
4099 check ("imag(catan(NaN - i Inf)) = -0", __imag__ result, minus_zero);
4101 result = FUNC(catan) (BUILD_COMPLEX (0.0, nan_value));
4102 check_isnan ("real(catan(0 + i NaN)) = NaN", __real__ result);
4103 check_isnan ("imag(catan(0 + i NaN)) = NaN", __imag__ result);
4104 result = FUNC(catan) (BUILD_COMPLEX (minus_zero, nan_value));
4105 check_isnan ("real(catan(-0 + i NaN)) = NaN", __real__ result);
4106 check_isnan ("imag(catan(-0 + i NaN)) = NaN", __imag__ result);
4108 result = FUNC(catan) (BUILD_COMPLEX (plus_infty, nan_value));
4109 check ("real(catan(+Inf + i NaN)) = pi/2", __real__ result, M_PI_2);
4110 check ("imag(catan(+Inf + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0);
4111 result = FUNC(catan) (BUILD_COMPLEX (minus_infty, nan_value));
4112 check ("real(catan(-Inf + i NaN)) = -pi/2", __real__ result, -M_PI_2);
4113 check ("imag(catan(-Inf + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0);
4115 result = FUNC(catan) (BUILD_COMPLEX (nan_value, 10.5));
4116 check_isnan_maybe_exc ("real(catan(NaN + i10.5)) = NaN plus maybe invalid exception",
4117 __real__ result, INVALID_EXCEPTION);
4118 check_isnan ("imag(catan(NaN + i10.5)) = NaN plus maybe invalid exception",
4119 __imag__ result);
4120 result = FUNC(catan) (BUILD_COMPLEX (nan_value, -10.5));
4121 check_isnan_maybe_exc ("real(catan(NaN - i10.5)) = NaN plus maybe invalid exception",
4122 __real__ result, INVALID_EXCEPTION);
4123 check_isnan ("imag(catan(NaN - i10.5)) = NaN plus maybe invalid exception",
4124 __imag__ result);
4126 result = FUNC(catan) (BUILD_COMPLEX (0.75, nan_value));
4127 check_isnan_maybe_exc ("real(catan(0.75 + i NaN)) = NaN plus maybe invalid exception",
4128 __real__ result, INVALID_EXCEPTION);
4129 check_isnan ("imag(catan(0.75 + i NaN)) = NaN plus maybe invalid exception",
4130 __imag__ result);
4131 result = FUNC(catan) (BUILD_COMPLEX (-0.75, nan_value));
4132 check_isnan_maybe_exc ("real(catan(-0.75 + i NaN)) = NaN plus maybe invalid exception",
4133 __real__ result, INVALID_EXCEPTION);
4134 check_isnan ("imag(catan(-0.75 + i NaN)) = NaN plus maybe invalid exception",
4135 __imag__ result);
4137 result = FUNC(catan) (BUILD_COMPLEX (nan_value, nan_value));
4138 check_isnan ("real(catan(NaN + i NaN)) = NaN", __real__ result);
4139 check_isnan ("imag(catan(NaN + i NaN)) = NaN", __imag__ result);
4141 result = FUNC(catan) (BUILD_COMPLEX (0.7, 1.2));
4142 check_eps ("real(catan(0.7 + i 1.2)) == 1.07857...", __real__ result,
4143 1.0785743834118921877L, CHOOSE (3e-17, 0, 0));
4144 check_eps ("imag(catan(0.7 + i 1.2)) == 0.57705...", __imag__ result,
4145 0.5770573776534306764L, CHOOSE(3e-17L, 0, 6e-8));
4147 result = FUNC(catan) (BUILD_COMPLEX (-2, -3));
4148 check ("real(catan(-2 - i 3)) == -1.40992...", __real__ result,
4149 -1.4099210495965755225L);
4150 check_eps ("imag(catan(-2 - i 3)) == -0.22907...", __imag__ result,
4151 -0.2290726829685387662L, CHOOSE(1.1e-19L, 3e-17, 2e-8));
4155 static void
4156 catanh_test (void)
4158 __complex__ MATHTYPE result;
4160 result = FUNC(catanh) (BUILD_COMPLEX (0, 0));
4161 check ("real(catanh(0 + i0)) = 0", __real__ result, 0);
4162 check ("imag(catanh(0 + i0)) = 0", __imag__ result, 0);
4163 result = FUNC(catanh) (BUILD_COMPLEX (minus_zero, 0));
4164 check ("real(catanh(-0 + i0)) = -0", __real__ result, minus_zero);
4165 check ("imag(catanh(-0 + i0)) = 0", __imag__ result, 0);
4166 result = FUNC(catanh) (BUILD_COMPLEX (0, minus_zero));
4167 check ("real(catanh(0 - i0)) = 0", __real__ result, 0);
4168 check ("imag(catanh(0 - i0)) = -0", __imag__ result, minus_zero);
4169 result = FUNC(catanh) (BUILD_COMPLEX (minus_zero, minus_zero));
4170 check ("real(catanh(-0 - i0)) = -0", __real__ result, minus_zero);
4171 check ("imag(catanh(-0 - i0)) = -0", __imag__ result, minus_zero);
4173 result = FUNC(catanh) (BUILD_COMPLEX (plus_infty, plus_infty));
4174 check ("real(catanh(+Inf + i Inf)) = 0", __real__ result, 0);
4175 check ("imag(catanh(+Inf + i Inf)) = pi/2", __imag__ result, M_PI_2);
4176 result = FUNC(catanh) (BUILD_COMPLEX (plus_infty, minus_infty));
4177 check ("real(catanh(+Inf - i Inf)) = 0", __real__ result, 0);
4178 check ("imag(catanh(+Inf - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
4179 result = FUNC(catanh) (BUILD_COMPLEX (minus_infty, plus_infty));
4180 check ("real(catanh(-Inf + i Inf)) = -0", __real__ result, minus_zero);
4181 check ("imag(catanh(-Inf + i Inf)) = pi/2", __imag__ result, M_PI_2);
4182 result = FUNC(catanh) (BUILD_COMPLEX (minus_infty, minus_infty));
4183 check ("real(catanh(-Inf - i Inf)) = -0", __real__ result, minus_zero);
4184 check ("imag(catanh(-Inf - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
4186 result = FUNC(catanh) (BUILD_COMPLEX (-10.0, plus_infty));
4187 check ("real(catanh(-10.0 + i Inf)) = -0", __real__ result, minus_zero);
4188 check ("imag(catanh(-10.0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
4189 result = FUNC(catanh) (BUILD_COMPLEX (-10.0, minus_infty));
4190 check ("real(catanh(-10.0 - i Inf)) = -0", __real__ result, minus_zero);
4191 check ("imag(catanh(-10.0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
4192 result = FUNC(catanh) (BUILD_COMPLEX (minus_zero, plus_infty));
4193 check ("real(catanh(-0 + i Inf)) = -0", __real__ result, minus_zero);
4194 check ("imag(catanh(-0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
4195 result = FUNC(catanh) (BUILD_COMPLEX (minus_zero, minus_infty));
4196 check ("real(catanh(-0 - i Inf)) = -0", __real__ result, minus_zero);
4197 check ("imag(catanh(-0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
4198 result = FUNC(catanh) (BUILD_COMPLEX (0, plus_infty));
4199 check ("real(catanh(0 + i Inf)) = 0", __real__ result, 0);
4200 check ("imag(catanh(0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
4201 result = FUNC(catanh) (BUILD_COMPLEX (0, minus_infty));
4202 check ("real(catanh(0 - i Inf)) = 0", __real__ result, 0);
4203 check ("imag(catanh(0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
4204 result = FUNC(catanh) (BUILD_COMPLEX (0.1, plus_infty));
4205 check ("real(catanh(0.1 + i Inf)) = 0", __real__ result, 0);
4206 check ("imag(catanh(0.1 + i Inf)) = pi/2", __imag__ result, M_PI_2);
4207 result = FUNC(catanh) (BUILD_COMPLEX (0.1, minus_infty));
4208 check ("real(catanh(0.1 - i Inf)) = 0", __real__ result, 0);
4209 check ("imag(catanh(0.1 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
4211 result = FUNC(catanh) (BUILD_COMPLEX (minus_infty, 0));
4212 check ("real(catanh(-Inf + i0)) = -0", __real__ result, minus_zero);
4213 check ("imag(catanh(-Inf + i0)) = pi/2", __imag__ result, M_PI_2);
4214 result = FUNC(catanh) (BUILD_COMPLEX (minus_infty, minus_zero));
4215 check ("real(catanh(-Inf - i0)) = -0", __real__ result, minus_zero);
4216 check ("imag(catanh(-Inf - i0)) = -pi/2", __imag__ result, -M_PI_2);
4217 result = FUNC(catanh) (BUILD_COMPLEX (minus_infty, 100));
4218 check ("real(catanh(-Inf + i100)) = -0", __real__ result, minus_zero);
4219 check ("imag(catanh(-Inf + i100)) = pi/2", __imag__ result, M_PI_2);
4220 result = FUNC(catanh) (BUILD_COMPLEX (minus_infty, -100));
4221 check ("real(catanh(-Inf - i100)) = -0", __real__ result, minus_zero);
4222 check ("imag(catanh(-Inf - i100)) = -pi/2", __imag__ result, -M_PI_2);
4224 result = FUNC(catanh) (BUILD_COMPLEX (plus_infty, 0));
4225 check ("real(catanh(+Inf + i0)) = 0", __real__ result, 0);
4226 check ("imag(catanh(+Inf + i0)) = pi/2", __imag__ result, M_PI_2);
4227 result = FUNC(catanh) (BUILD_COMPLEX (plus_infty, minus_zero));
4228 check ("real(catanh(+Inf - i0)) = 0", __real__ result, 0);
4229 check ("imag(catanh(+Inf - i0)) = -pi/2", __imag__ result, -M_PI_2);
4230 result = FUNC(catanh) (BUILD_COMPLEX (plus_infty, 0.5));
4231 check ("real(catanh(+Inf + i0.5)) = 0", __real__ result, 0);
4232 check ("imag(catanh(+Inf + i0.5)) = pi/2", __imag__ result, M_PI_2);
4233 result = FUNC(catanh) (BUILD_COMPLEX (plus_infty, -0.5));
4234 check ("real(catanh(+Inf - i0.5)) = 0", __real__ result, 0);
4235 check ("imag(catanh(+Inf - i0.5)) = -pi/2", __imag__ result, -M_PI_2);
4237 result = FUNC(catanh) (BUILD_COMPLEX (0, nan_value));
4238 check ("real(catanh(0 + i NaN)) = 0", __real__ result, 0);
4239 check_isnan ("imag(catanh(0 + i NaN)) = NaN", __imag__ result);
4240 result = FUNC(catanh) (BUILD_COMPLEX (minus_zero, nan_value));
4241 check ("real(catanh(-0 + i NaN)) = -0", __real__ result, minus_zero);
4242 check_isnan ("imag(catanh(-0 + i NaN)) = NaN", __imag__ result);
4244 result = FUNC(catanh) (BUILD_COMPLEX (plus_infty, nan_value));
4245 check ("real(catanh(+Inf + i NaN)) = 0", __real__ result, 0);
4246 check_isnan ("imag(catanh(+Inf + i NaN)) = NaN", __imag__ result);
4247 result = FUNC(catanh) (BUILD_COMPLEX (minus_infty, nan_value));
4248 check ("real(catanh(-Inf + i NaN)) = -0", __real__ result, minus_zero);
4249 check_isnan ("imag(catanh(-Inf + i NaN)) = NaN", __imag__ result);
4251 result = FUNC(catanh) (BUILD_COMPLEX (nan_value, 0));
4252 check_isnan ("real(catanh(NaN + i0)) = NaN", __real__ result);
4253 check_isnan ("imag(catanh(NaN + i0)) = NaN", __imag__ result);
4254 result = FUNC(catanh) (BUILD_COMPLEX (nan_value, minus_zero));
4255 check_isnan ("real(catanh(NaN - i0)) = NaN", __real__ result);
4256 check_isnan ("imag(catanh(NaN - i0)) = NaN", __imag__ result);
4258 result = FUNC(catanh) (BUILD_COMPLEX (nan_value, plus_infty));
4259 check ("real(catanh(NaN + i Inf)) = +-0", FUNC(fabs) (__real__ result), 0);
4260 check ("imag(catanh(NaN + i Inf)) = pi/2", __imag__ result, M_PI_2);
4261 result = FUNC(catanh) (BUILD_COMPLEX (nan_value, minus_infty));
4262 check ("real(catanh(NaN - i Inf)) = +-0", FUNC(fabs) (__real__ result), 0);
4263 check ("imag(catanh(NaN - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
4265 result = FUNC(catanh) (BUILD_COMPLEX (10.5, nan_value));
4266 check_isnan_maybe_exc ("real(catanh(10.5 + i NaN)) = NaN plus maybe invalid exception",
4267 __real__ result, INVALID_EXCEPTION);
4268 check_isnan ("imag(catanh(10.5 + i NaN)) = NaN plus maybe invalid exception",
4269 __imag__ result);
4270 result = FUNC(catanh) (BUILD_COMPLEX (-10.5, nan_value));
4271 check_isnan_maybe_exc ("real(catanh(-10.5 + i NaN)) = NaN plus maybe invalid exception",
4272 __real__ result, INVALID_EXCEPTION);
4273 check_isnan ("imag(catanh(-10.5 + i NaN)) = NaN plus maybe invalid exception",
4274 __imag__ result);
4276 result = FUNC(catanh) (BUILD_COMPLEX (nan_value, 0.75));
4277 check_isnan_maybe_exc ("real(catanh(NaN + i0.75)) = NaN plus maybe invalid exception",
4278 __real__ result, INVALID_EXCEPTION);
4279 check_isnan ("imag(catanh(NaN + i0.75)) = NaN plus maybe invalid exception",
4280 __imag__ result);
4281 result = FUNC(catanh) (BUILD_COMPLEX (nan_value, -0.75));
4282 check_isnan_maybe_exc ("real(catanh(NaN - i0.75)) = NaN plus maybe invalid exception",
4283 __real__ result, INVALID_EXCEPTION);
4284 check_isnan ("imag(catanh(NaN - i0.75)) = NaN plus maybe invalid exception",
4285 __imag__ result);
4287 result = FUNC(catanh) (BUILD_COMPLEX (nan_value, nan_value));
4288 check_isnan ("real(catanh(NaN + i NaN)) = NaN", __real__ result);
4289 check_isnan ("imag(catanh(NaN + i NaN)) = NaN", __imag__ result);
4291 result = FUNC(catanh) (BUILD_COMPLEX (0.7, 1.2));
4292 check_eps ("real(catanh(0.7 + i 1.2)) == 0.26007...", __real__ result,
4293 0.2600749516525135959L, CHOOSE (2e-18, 0, 0));
4294 check_eps ("imag(catanh(0.7 + i 1.2)) == 0.97024...", __imag__ result,
4295 0.9702403077950989849L, CHOOSE (3e-17, 0, 0));
4297 result = FUNC(catanh) (BUILD_COMPLEX (-2, -3));
4298 check_eps ("real(catanh(-2 - i 3)) == -0.14694...", __real__ result,
4299 -0.1469466662255297520L, CHOOSE (9e-20L, 6e-17, 2e-8));
4300 check_eps ("imag(catanh(-2 - i 3)) == -1.33897...", __imag__ result,
4301 -1.3389725222944935611L, CHOOSE (7e-19L, 0, 0));
4305 static void
4306 ctan_test (void)
4308 __complex__ MATHTYPE result;
4310 result = FUNC(ctan) (BUILD_COMPLEX (0, 0));
4311 check ("real(ctan(0 + i0)) = 0", __real__ result, 0);
4312 check ("imag(ctan(0 + i0)) = 0", __imag__ result, 0);
4313 result = FUNC(ctan) (BUILD_COMPLEX (0, minus_zero));
4314 check ("real(ctan(0 - i0)) = 0", __real__ result, 0);
4315 check ("imag(ctan(0 - i0)) = -0", __imag__ result, minus_zero);
4316 result = FUNC(ctan) (BUILD_COMPLEX (minus_zero, 0));
4317 check ("real(ctan(-0 + i0)) = -0", __real__ result, minus_zero);
4318 check ("imag(ctan(-0 + i0)) = 0", __imag__ result, 0);
4319 result = FUNC(ctan) (BUILD_COMPLEX (minus_zero, minus_zero));
4320 check ("real(ctan(-0 - i0)) = -0", __real__ result, minus_zero);
4321 check ("imag(ctan(-0 - i0)) = -0", __imag__ result, minus_zero);
4324 result = FUNC(ctan) (BUILD_COMPLEX (0, plus_infty));
4325 check ("real(ctan(0 + i Inf)) = 0", __real__ result, 0);
4326 check ("imag(ctan(0 + i Inf)) = 1", __imag__ result, 1);
4327 result = FUNC(ctan) (BUILD_COMPLEX (1, plus_infty));
4328 check ("real(ctan(1 + i Inf)) = 0", __real__ result, 0);
4329 check ("imag(ctan(1 + i Inf)) = 1", __imag__ result, 1);
4330 result = FUNC(ctan) (BUILD_COMPLEX (minus_zero, plus_infty));
4331 check ("real(ctan(-0 + i Inf)) = -0", __real__ result, minus_zero);
4332 check ("imag(ctan(-0 + i Inf)) = 1", __imag__ result, 1);
4333 result = FUNC(ctan) (BUILD_COMPLEX (-1, plus_infty));
4334 check ("real(ctan(-1 + i Inf)) = -0", __real__ result, minus_zero);
4335 check ("imag(ctan(-1 + i Inf)) = 1", __imag__ result, 1);
4337 result = FUNC(ctan) (BUILD_COMPLEX (0, minus_infty));
4338 check ("real(ctan(0 - i Inf)) = 0", __real__ result, 0);
4339 check ("imag(ctan(0 - i Inf)) = -1", __imag__ result, -1);
4340 result = FUNC(ctan) (BUILD_COMPLEX (1, minus_infty));
4341 check ("real(ctan(1 - i Inf)) = 0", __real__ result, 0);
4342 check ("imag(ctan(1 - i Inf)) = -1", __imag__ result, -1);
4343 result = FUNC(ctan) (BUILD_COMPLEX (minus_zero, minus_infty));
4344 check ("real(ctan(-0 - i Inf)) = -0", __real__ result, minus_zero);
4345 check ("imag(ctan(-0 - i Inf)) = -1", __imag__ result, -1);
4346 result = FUNC(ctan) (BUILD_COMPLEX (-1, minus_infty));
4347 check ("real(ctan(-1 - i Inf)) = -0", __real__ result, minus_zero);
4348 check ("imag(ctan(-1 - i Inf)) = -1", __imag__ result, -1);
4350 result = FUNC(ctan) (BUILD_COMPLEX (plus_infty, 0));
4351 check_isnan_exc ("real(ctan(Inf + i 0)) = NaN plus invalid exception",
4352 __real__ result, INVALID_EXCEPTION);
4353 check_isnan ("imag(ctan(Inf + i 0)) = NaN plus invalid exception",
4354 __imag__ result);
4355 result = FUNC(ctan) (BUILD_COMPLEX (plus_infty, 2));
4356 check_isnan_exc ("real(ctan(Inf + i 2)) = NaN plus invalid exception",
4357 __real__ result, INVALID_EXCEPTION);
4358 check_isnan ("imag(ctan(Inf + i 2)) = NaN plus invalid exception",
4359 __imag__ result);
4360 result = FUNC(ctan) (BUILD_COMPLEX (minus_infty, 0));
4361 check_isnan_exc ("real(ctan(-Inf + i 0)) = NaN plus invalid exception",
4362 __real__ result, INVALID_EXCEPTION);
4363 check_isnan ("imag(ctan(-Inf + i 0)) = NaN plus invalid exception",
4364 __imag__ result);
4365 result = FUNC(ctan) (BUILD_COMPLEX (minus_infty, 2));
4366 check_isnan_exc ("real(ctan(- Inf + i 2)) = NaN plus invalid exception",
4367 __real__ result, INVALID_EXCEPTION);
4368 check_isnan ("imag(ctan(- Inf + i 2)) = NaN plus invalid exception",
4369 __imag__ result);
4370 result = FUNC(ctan) (BUILD_COMPLEX (plus_infty, minus_zero));
4371 check_isnan_exc ("real(ctan(Inf - i 0)) = NaN plus invalid exception",
4372 __real__ result, INVALID_EXCEPTION);
4373 check_isnan ("imag(ctan(Inf - i 0)) = NaN plus invalid exception",
4374 __imag__ result);
4375 result = FUNC(ctan) (BUILD_COMPLEX (plus_infty, -2));
4376 check_isnan_exc ("real(ctan(Inf - i 2)) = NaN plus invalid exception",
4377 __real__ result, INVALID_EXCEPTION);
4378 check_isnan ("imag(ctan(Inf - i 2)) = NaN plus invalid exception",
4379 __imag__ result);
4380 result = FUNC(ctan) (BUILD_COMPLEX (minus_infty, minus_zero));
4381 check_isnan_exc ("real(ctan(-Inf - i 0)) = NaN plus invalid exception",
4382 __real__ result, INVALID_EXCEPTION);
4383 check_isnan ("imag(ctan(-Inf - i 0)) = NaN plus invalid exception",
4384 __imag__ result);
4385 result = FUNC(ctan) (BUILD_COMPLEX (minus_infty, -2));
4386 check_isnan_exc ("real(ctan(-Inf - i 2)) = NaN plus invalid exception",
4387 __real__ result, INVALID_EXCEPTION);
4388 check_isnan ("imag(ctan(-Inf - i 2)) = NaN plus invalid exception",
4389 __imag__ result);
4391 result = FUNC(ctan) (BUILD_COMPLEX (nan_value, plus_infty));
4392 check ("real(ctan(NaN + i Inf)) = +-0", FUNC(fabs) (__real__ result), 0);
4393 check ("imag(ctan(NaN + i Inf)) = 1", __imag__ result, 1);
4394 result = FUNC(ctan) (BUILD_COMPLEX (nan_value, minus_infty));
4395 check ("real(ctan(NaN - i Inf)) = +-0", FUNC(fabs) (__real__ result), 0);
4396 check ("imag(ctan(NaN - i Inf)) = -1", __imag__ result, -1);
4398 result = FUNC(ctan) (BUILD_COMPLEX (0, nan_value));
4399 check ("real(ctan(0 + i NaN)) = 0", __real__ result, 0);
4400 check_isnan ("imag(ctan(0 + i NaN)) = NaN", __imag__ result);
4401 result = FUNC(ctan) (BUILD_COMPLEX (minus_zero, nan_value));
4402 check ("real(ctan(-0 + i NaN)) = -0", __real__ result, minus_zero);
4403 check_isnan ("imag(ctan(-0 + i NaN)) = NaN", __imag__ result);
4405 result = FUNC(ctan) (BUILD_COMPLEX (0.5, nan_value));
4406 check_isnan_maybe_exc ("real(ctan(0.5 + i NaN)) = NaN plus maybe invalid exception",
4407 __real__ result, INVALID_EXCEPTION);
4408 check_isnan ("imag(ctan(0.5 + i NaN)) = NaN plus maybe invalid exception",
4409 __imag__ result);
4410 result = FUNC(ctan) (BUILD_COMPLEX (-4.5, nan_value));
4411 check_isnan_maybe_exc ("real(ctan(-4.5 + i NaN)) = NaN plus maybe invalid exception",
4412 __real__ result, INVALID_EXCEPTION);
4413 check_isnan ("imag(ctan(-4.5 + i NaN)) = NaN plus maybe invalid exception",
4414 __imag__ result);
4416 result = FUNC(ctan) (BUILD_COMPLEX (nan_value, 0));
4417 check_isnan_maybe_exc ("real(ctan(NaN + i 0)) = NaN plus maybe invalid exception",
4418 __real__ result, INVALID_EXCEPTION);
4419 check_isnan ("imag(ctan(NaN + i 0)) = NaN plus maybe invalid exception",
4420 __imag__ result);
4421 result = FUNC(ctan) (BUILD_COMPLEX (nan_value, 5));
4422 check_isnan_maybe_exc ("real(ctan(NaN + i 5)) = NaN plus maybe invalid exception",
4423 __real__ result, INVALID_EXCEPTION);
4424 check_isnan ("imag(ctan(NaN + i 5)) = NaN plus maybe invalid exception",
4425 __imag__ result);
4426 result = FUNC(ctan) (BUILD_COMPLEX (nan_value, minus_zero));
4427 check_isnan_maybe_exc ("real(ctan(NaN - i 0)) = NaN plus maybe invalid exception",
4428 __real__ result, INVALID_EXCEPTION);
4429 check_isnan ("imag(ctan(NaN - i 0)) = NaN plus maybe invalid exception",
4430 __imag__ result);
4431 result = FUNC(ctan) (BUILD_COMPLEX (nan_value, -0.25));
4432 check_isnan_maybe_exc ("real(ctan(NaN -i 0.25)) = NaN plus maybe invalid exception",
4433 __real__ result, INVALID_EXCEPTION);
4434 check_isnan ("imag(ctan(NaN -i 0.25)) = NaN plus maybe invalid exception",
4435 __imag__ result);
4437 result = FUNC(ctan) (BUILD_COMPLEX (nan_value, nan_value));
4438 check_isnan ("real(ctan(NaN + i NaN)) = NaN", __real__ result);
4439 check_isnan ("imag(ctan(NaN + i NaN)) = NaN", __imag__ result);
4441 result = FUNC(ctan) (BUILD_COMPLEX (0.7, 1.2));
4442 check_eps ("real(ctan(0.7 + i 1.2)) == 0.17207...", __real__ result,
4443 0.1720734197630349001L, CHOOSE(1e-17L, 3e-17, 2e-8));
4444 check_eps ("imag(ctan(0.7 + i 1.2)) == 0.95448...", __imag__ result,
4445 0.9544807059989405538L, CHOOSE(2e-17L, 2e-16, 0));
4447 result = FUNC(ctan) (BUILD_COMPLEX (-2, -3));
4448 check_eps ("real(ctan(-2 - i 3)) == -0.00376...", __real__ result,
4449 0.0037640256415042482L, CHOOSE(1e-19L, 0, 0));
4450 check_eps ("imag(ctan(-2 - i 3)) == -1.00323...", __imag__ result,
4451 -1.0032386273536098014L, CHOOSE(2e-19L, 0, 2e-7));
4455 static void
4456 ctanh_test (void)
4458 __complex__ MATHTYPE result;
4460 result = FUNC(ctanh) (BUILD_COMPLEX (0, 0));
4461 check ("real(ctanh(0 + i0)) = 0", __real__ result, 0);
4462 check ("imag(ctanh(0 + i0)) = 0", __imag__ result, 0);
4463 result = FUNC(ctanh) (BUILD_COMPLEX (0, minus_zero));
4464 check ("real(ctanh(0 - i0)) = 0", __real__ result, 0);
4465 check ("imag(ctanh(0 - i0)) = -0", __imag__ result, minus_zero);
4466 result = FUNC(ctanh) (BUILD_COMPLEX (minus_zero, 0));
4467 check ("real(ctanh(-0 + i0)) = -0", __real__ result, minus_zero);
4468 check ("imag(ctanh(-0 + i0)) = 0", __imag__ result, 0);
4469 result = FUNC(ctanh) (BUILD_COMPLEX (minus_zero, minus_zero));
4470 check ("real(ctanh(-0 - i0)) = -0", __real__ result, minus_zero);
4471 check ("imag(ctanh(-0 - i0)) = -0", __imag__ result, minus_zero);
4473 result = FUNC(ctanh) (BUILD_COMPLEX (plus_infty, 0));
4474 check ("real(ctanh(+Inf + i0)) = 1", __real__ result, 1);
4475 check ("imag(ctanh(+Inf + i0)) = 0", __imag__ result, 0);
4476 result = FUNC(ctanh) (BUILD_COMPLEX (plus_infty, 1));
4477 check ("real(ctanh(+Inf + i1)) = 1", __real__ result, 1);
4478 check ("imag(ctanh(+Inf + i1)) = 0", __imag__ result, 0);
4479 result = FUNC(ctanh) (BUILD_COMPLEX (plus_infty, minus_zero));
4480 check ("real(ctanh(+Inf - i0)) = 1", __real__ result, 1);
4481 check ("imag(ctanh(+Inf - i0)) = -0", __imag__ result, minus_zero);
4482 result = FUNC(ctanh) (BUILD_COMPLEX (plus_infty, -1));
4483 check ("real(ctanh(+Inf - i1)) = 1", __real__ result, 1);
4484 check ("imag(ctanh(+Inf - i1)) = -0", __imag__ result, minus_zero);
4485 result = FUNC(ctanh) (BUILD_COMPLEX (minus_infty, 0));
4486 check ("real(ctanh(-Inf + i0)) = -1", __real__ result, -1);
4487 check ("imag(ctanh(-Inf + i0)) = 0", __imag__ result, 0);
4488 result = FUNC(ctanh) (BUILD_COMPLEX (minus_infty, 1));
4489 check ("real(ctanh(-Inf + i1)) = -1", __real__ result, -1);
4490 check ("imag(ctanh(-Inf + i1)) = 0", __imag__ result, 0);
4491 result = FUNC(ctanh) (BUILD_COMPLEX (minus_infty, minus_zero));
4492 check ("real(ctanh(-Inf - i0)) = -1", __real__ result, -1);
4493 check ("imag(ctanh(-Inf - i0)) = -0", __imag__ result, minus_zero);
4494 result = FUNC(ctanh) (BUILD_COMPLEX (minus_infty, -1));
4495 check ("real(ctanh(-Inf - i1)) = -1", __real__ result, -1);
4496 check ("imag(ctanh(-Inf - i1)) = -0", __imag__ result, minus_zero);
4498 result = FUNC(ctanh) (BUILD_COMPLEX (0, plus_infty));
4499 check_isnan_exc ("real(ctanh(0 + i Inf)) = NaN plus invalid exception",
4500 __real__ result, INVALID_EXCEPTION);
4501 check_isnan ("imag(ctanh(0 + i Inf)) = NaN plus invalid exception",
4502 __imag__ result);
4503 result = FUNC(ctanh) (BUILD_COMPLEX (2, plus_infty));
4504 check_isnan_exc ("real(ctanh(2 + i Inf)) = NaN plus invalid exception",
4505 __real__ result, INVALID_EXCEPTION);
4506 check_isnan ("imag(ctanh(2 + i Inf)) = NaN plus invalid exception",
4507 __imag__ result);
4508 result = FUNC(ctanh) (BUILD_COMPLEX (0, minus_infty));
4509 check_isnan_exc ("real(ctanh(0 - i Inf)) = NaN plus invalid exception",
4510 __real__ result, INVALID_EXCEPTION);
4511 check_isnan ("imag(ctanh(0 - i Inf)) = NaN plus invalid exception",
4512 __imag__ result);
4513 result = FUNC(ctanh) (BUILD_COMPLEX (2, minus_infty));
4514 check_isnan_exc ("real(ctanh(2 - i Inf)) = NaN plus invalid exception",
4515 __real__ result, INVALID_EXCEPTION);
4516 check_isnan ("imag(ctanh(2 - i Inf)) = NaN plus invalid exception",
4517 __imag__ result);
4518 result = FUNC(ctanh) (BUILD_COMPLEX (minus_zero, plus_infty));
4519 check_isnan_exc ("real(ctanh(-0 + i Inf)) = NaN plus invalid exception",
4520 __real__ result, INVALID_EXCEPTION);
4521 check_isnan ("imag(ctanh(-0 + i Inf)) = NaN plus invalid exception",
4522 __imag__ result);
4523 result = FUNC(ctanh) (BUILD_COMPLEX (-2, plus_infty));
4524 check_isnan_exc ("real(ctanh(-2 + i Inf)) = NaN plus invalid exception",
4525 __real__ result, INVALID_EXCEPTION);
4526 check_isnan ("imag(ctanh(-2 + i Inf)) = NaN plus invalid exception",
4527 __imag__ result);
4528 result = FUNC(ctanh) (BUILD_COMPLEX (minus_zero, minus_infty));
4529 check_isnan_exc ("real(ctanh(-0 - i Inf)) = NaN plus invalid exception",
4530 __real__ result, INVALID_EXCEPTION);
4531 check_isnan ("imag(ctanh(-0 - i Inf)) = NaN plus invalid exception",
4532 __imag__ result);
4533 result = FUNC(ctanh) (BUILD_COMPLEX (-2, minus_infty));
4534 check_isnan_exc ("real(ctanh(-2 - i Inf)) = NaN plus invalid exception",
4535 __real__ result, INVALID_EXCEPTION);
4536 check_isnan ("imag(ctanh(-2 - i Inf)) = NaN plus invalid exception",
4537 __imag__ result);
4539 result = FUNC(ctanh) (BUILD_COMPLEX (plus_infty, nan_value));
4540 check ("real(ctanh(+Inf + i NaN)) = 1", __real__ result, 1);
4541 check ("imag(ctanh(+Inf + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0);
4542 result = FUNC(ctanh) (BUILD_COMPLEX (minus_infty, nan_value));
4543 check ("real(ctanh(-Inf + i NaN)) = -1", __real__ result, -1);
4544 check ("imag(ctanh(-Inf + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0);
4546 result = FUNC(ctanh) (BUILD_COMPLEX (nan_value, 0));
4547 check_isnan ("real(ctanh(NaN + i0)) = NaN", __real__ result);
4548 check ("imag(ctanh(NaN + i0)) = 0", __imag__ result, 0);
4549 result = FUNC(ctanh) (BUILD_COMPLEX (nan_value, minus_zero));
4550 check_isnan ("real(ctanh(NaN - i0)) = NaN", __real__ result);
4551 check ("imag(ctanh(NaN - i0)) = -0", __imag__ result, minus_zero);
4553 result = FUNC(ctanh) (BUILD_COMPLEX (nan_value, 0.5));
4554 check_isnan_maybe_exc ("real(ctanh(NaN + i0.5)) = NaN plus maybe invalid exception",
4555 __real__ result, INVALID_EXCEPTION);
4556 check_isnan ("imag(ctanh(NaN + i0.5)) = NaN plus maybe invalid exception",
4557 __imag__ result);
4558 result = FUNC(ctanh) (BUILD_COMPLEX (nan_value, -4.5));
4559 check_isnan_maybe_exc ("real(ctanh(NaN - i4.5)) = NaN plus maybe invalid exception",
4560 __real__ result, INVALID_EXCEPTION);
4561 check_isnan ("imag(ctanh(NaN - i4.5)) = NaN plus maybe invalid exception",
4562 __imag__ result);
4564 result = FUNC(ctanh) (BUILD_COMPLEX (0, nan_value));
4565 check_isnan_maybe_exc ("real(ctanh(0 + i NaN)) = NaN plus maybe invalid exception",
4566 __real__ result, INVALID_EXCEPTION);
4567 check_isnan ("imag(ctanh(0 + i NaN)) = NaN plus maybe invalid exception",
4568 __imag__ result);
4569 result = FUNC(ctanh) (BUILD_COMPLEX (5, nan_value));
4570 check_isnan_maybe_exc ("real(ctanh(5 + i NaN)) = NaN plus maybe invalid exception",
4571 __real__ result, INVALID_EXCEPTION);
4572 check_isnan ("imag(ctanh(5 + i NaN)) = NaN plus maybe invalid exception",
4573 __imag__ result);
4574 result = FUNC(ctanh) (BUILD_COMPLEX (minus_zero, nan_value));
4575 check_isnan_maybe_exc ("real(ctanh(-0 + i NaN)) = NaN plus maybe invalid exception",
4576 __real__ result, INVALID_EXCEPTION);
4577 check_isnan ("imag(ctanh(-0 + i NaN)) = NaN plus maybe invalid exception",
4578 __imag__ result);
4579 result = FUNC(ctanh) (BUILD_COMPLEX (-0.25, nan_value));
4580 check_isnan_maybe_exc ("real(ctanh(-0.25 + i NaN)) = NaN plus maybe invalid exception",
4581 __real__ result, INVALID_EXCEPTION);
4582 check_isnan ("imag(ctanh(-0.25 + i NaN)) = NaN plus maybe invalid exception",
4583 __imag__ result);
4585 result = FUNC(ctanh) (BUILD_COMPLEX (nan_value, nan_value));
4586 check_isnan ("real(ctanh(NaN + i NaN)) = NaN", __real__ result);
4587 check_isnan ("imag(ctanh(NaN + i NaN)) = NaN", __imag__ result);
4589 result = FUNC(ctanh) (BUILD_COMPLEX (0, M_PI_4));
4590 check ("real(ctanh (0 + i pi/4)) == 0", __real__ result, 0);
4591 check_eps ("imag(ctanh (0 + i pi/4)) == 1", __imag__ result, 1,
4592 CHOOSE (0, 2e-16, 2e-7));
4594 result = FUNC(ctanh) (BUILD_COMPLEX (0.7, 1.2));
4595 check_eps ("real(ctanh(0.7 + i 1.2)) == 1.34721...", __real__ result,
4596 1.3472197399061191630L, CHOOSE(4e-17L, 6e-17, 2e-7));
4597 check_eps ("imag(ctanh(0.7 + i 1.2)) == -0.47786...", __imag__ result,
4598 0.4778641038326365540L, CHOOSE(9e-17L, 6e-17, 0));
4600 result = FUNC(ctanh) (BUILD_COMPLEX (-2, -3));
4601 check_eps ("real(ctanh(-2 - i 3)) == -0.96538...", __real__ result,
4602 -0.9653858790221331242L, CHOOSE(2e-19L, 0, 0));
4603 check_eps ("imag(ctanh(-2 - i 3)) == 0.00988...", __imag__ result,
4604 0.0098843750383224937L, CHOOSE(7e-20L, 0, 1e-9));
4608 static void
4609 clog_test (void)
4611 __complex__ MATHTYPE result;
4613 result = FUNC(clog) (BUILD_COMPLEX (minus_zero, 0));
4614 check_isinfn_exc ("real(clog(-0 + i0)) = -Inf plus divide-by-zero exception",
4615 __real__ result, DIVIDE_BY_ZERO_EXCEPTION);
4616 check ("imag(clog(-0 + i0)) = pi plus divide-by-zero exception",
4617 __imag__ result, M_PI);
4618 result = FUNC(clog) (BUILD_COMPLEX (minus_zero, minus_zero));
4619 check_isinfn_exc ("real(clog(-0 - i0)) = -Inf plus divide-by-zero exception",
4620 __real__ result, DIVIDE_BY_ZERO_EXCEPTION);
4621 check ("imag(clog(-0 - i0)) = -pi plus divide-by-zero exception",
4622 __imag__ result, -M_PI);
4624 result = FUNC(clog) (BUILD_COMPLEX (0, 0));
4625 check_isinfn_exc ("real(clog(0 + i0)) = -Inf plus divide-by-zero exception",
4626 __real__ result, DIVIDE_BY_ZERO_EXCEPTION);
4627 check ("imag(clog(0 + i0)) = 0 plus divide-by-zero exception",
4628 __imag__ result, 0);
4629 result = FUNC(clog) (BUILD_COMPLEX (0, minus_zero));
4630 check_isinfn_exc ("real(clog(0 - i0)) = -Inf plus divide-by-zero exception",
4631 __real__ result, DIVIDE_BY_ZERO_EXCEPTION);
4632 check ("imag(clog(0 - i0)) = -0 plus divide-by-zero exception",
4633 __imag__ result, minus_zero);
4635 result = FUNC(clog) (BUILD_COMPLEX (minus_infty, plus_infty));
4636 check_isinfp ("real(clog(-Inf + i Inf)) = +Inf", __real__ result);
4637 check ("imag(clog(-Inf + i Inf)) = 3*pi/4", __imag__ result, M_PI - M_PI_4);
4638 result = FUNC(clog) (BUILD_COMPLEX (minus_infty, minus_infty));
4639 check_isinfp ("real(clog(-Inf - i Inf)) = +Inf", __real__ result);
4640 check ("imag(clog(-Inf - i Inf)) = -3*pi/4", __imag__ result, M_PI_4 - M_PI);
4642 result = FUNC(clog) (BUILD_COMPLEX (plus_infty, plus_infty));
4643 check_isinfp ("real(clog(+Inf + i Inf)) = +Inf", __real__ result);
4644 check ("imag(clog(+Inf + i Inf)) = pi/4", __imag__ result, M_PI_4);
4645 result = FUNC(clog) (BUILD_COMPLEX (plus_infty, minus_infty));
4646 check_isinfp ("real(clog(+Inf - i Inf)) = +Inf", __real__ result);
4647 check ("imag(clog(+Inf - i Inf)) = -pi/4", __imag__ result, -M_PI_4);
4649 result = FUNC(clog) (BUILD_COMPLEX (0, plus_infty));
4650 check_isinfp ("real(clog(0 + i Inf)) = +Inf", __real__ result);
4651 check ("imag(clog(0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
4652 result = FUNC(clog) (BUILD_COMPLEX (3, plus_infty));
4653 check_isinfp ("real(clog(3 + i Inf)) = +Inf", __real__ result);
4654 check ("imag(clog(3 + i Inf)) = pi/2", __imag__ result, M_PI_2);
4655 result = FUNC(clog) (BUILD_COMPLEX (minus_zero, plus_infty));
4656 check_isinfp ("real(clog(-0 + i Inf)) = +Inf", __real__ result);
4657 check ("imag(clog(-0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
4658 result = FUNC(clog) (BUILD_COMPLEX (-3, plus_infty));
4659 check_isinfp ("real(clog(-3 + i Inf)) = +Inf", __real__ result);
4660 check ("imag(clog(-3 + i Inf)) = pi/2", __imag__ result, M_PI_2);
4661 result = FUNC(clog) (BUILD_COMPLEX (0, minus_infty));
4662 check_isinfp ("real(clog(0 - i Inf)) = +Inf", __real__ result);
4663 check ("imag(clog(0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
4664 result = FUNC(clog) (BUILD_COMPLEX (3, minus_infty));
4665 check_isinfp ("real(clog(3 - i Inf)) = +Inf", __real__ result);
4666 check ("imag(clog(3 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
4667 result = FUNC(clog) (BUILD_COMPLEX (minus_zero, minus_infty));
4668 check_isinfp ("real(clog(-0 - i Inf)) = +Inf", __real__ result);
4669 check ("imag(clog(-0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
4670 result = FUNC(clog) (BUILD_COMPLEX (-3, minus_infty));
4671 check_isinfp ("real(clog(-3 - i Inf)) = +Inf", __real__ result);
4672 check ("imag(clog(-3 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
4674 result = FUNC(clog) (BUILD_COMPLEX (minus_infty, 0));
4675 check_isinfp ("real(clog(-Inf + i0)) = +Inf", __real__ result);
4676 check ("imag(clog(-Inf + i0)) = pi", __imag__ result, M_PI);
4677 result = FUNC(clog) (BUILD_COMPLEX (minus_infty, 1));
4678 check_isinfp ("real(clog(-Inf + i1)) = +Inf", __real__ result);
4679 check ("imag(clog(-Inf + i1)) = pi", __imag__ result, M_PI);
4680 result = FUNC(clog) (BUILD_COMPLEX (minus_infty, minus_zero));
4681 check_isinfp ("real(clog(-Inf - i0)) = +Inf", __real__ result);
4682 check ("imag(clog(-Inf - i0)) = -pi", __imag__ result, -M_PI);
4683 result = FUNC(clog) (BUILD_COMPLEX (minus_infty, -1));
4684 check_isinfp ("real(clog(-Inf - i1)) = +Inf", __real__ result);
4685 check ("imag(clog(-Inf - i1)) = -pi", __imag__ result, -M_PI);
4687 result = FUNC(clog) (BUILD_COMPLEX (plus_infty, 0));
4688 check_isinfp ("real(clog(+Inf + i0)) = +Inf", __real__ result);
4689 check ("imag(clog(+Inf + i0)) = 0", __imag__ result, 0);
4690 result = FUNC(clog) (BUILD_COMPLEX (plus_infty, 1));
4691 check_isinfp ("real(clog(+Inf + i1)) = +Inf", __real__ result);
4692 check ("imag(clog(+Inf + i1)) = 0", __imag__ result, 0);
4693 result = FUNC(clog) (BUILD_COMPLEX (plus_infty, minus_zero));
4694 check_isinfp ("real(clog(+Inf - i0)) = +Inf", __real__ result);
4695 check ("imag(clog(+Inf - i0)) = -0", __imag__ result, minus_zero);
4696 result = FUNC(clog) (BUILD_COMPLEX (plus_infty, -1));
4697 check_isinfp ("real(clog(+Inf - i1)) = +Inf", __real__ result);
4698 check ("imag(clog(+Inf - i1)) = -0", __imag__ result, minus_zero);
4700 result = FUNC(clog) (BUILD_COMPLEX (plus_infty, nan_value));
4701 check_isinfp ("real(clog(+Inf + i NaN)) = +Inf", __real__ result);
4702 check_isnan ("imag(clog(+Inf + i NaN)) = NaN", __imag__ result);
4703 result = FUNC(clog) (BUILD_COMPLEX (minus_infty, nan_value));
4704 check_isinfp ("real(clog(-Inf + i NaN)) = +Inf", __real__ result);
4705 check_isnan ("imag(clog(-Inf + i NaN)) = NaN", __imag__ result);
4707 result = FUNC(clog) (BUILD_COMPLEX (nan_value, plus_infty));
4708 check_isinfp ("real(clog(NaN + i Inf)) = +Inf", __real__ result);
4709 check_isnan ("imag(clog(NaN + i Inf)) = NaN", __imag__ result);
4710 result = FUNC(clog) (BUILD_COMPLEX (nan_value, minus_infty));
4711 check_isinfp ("real(clog(NaN - i Inf)) = +Inf", __real__ result);
4712 check_isnan ("imag(clog(NaN - i Inf)) = NaN", __imag__ result);
4714 result = FUNC(clog) (BUILD_COMPLEX (0, nan_value));
4715 check_isnan_maybe_exc ("real(clog(0 + i NaN)) = NaN plus maybe invalid exception",
4716 __real__ result, INVALID_EXCEPTION);
4717 check_isnan ("imag(clog(0 + i NaN)) = NaN plus maybe invalid exception",
4718 __imag__ result);
4719 result = FUNC(clog) (BUILD_COMPLEX (3, nan_value));
4720 check_isnan_maybe_exc ("real(clog(3 + i NaN)) = NaN plus maybe invalid exception",
4721 __real__ result, INVALID_EXCEPTION);
4722 check_isnan ("imag(clog(3 + i NaN)) = NaN plus maybe invalid exception",
4723 __imag__ result);
4724 result = FUNC(clog) (BUILD_COMPLEX (minus_zero, nan_value));
4725 check_isnan_maybe_exc ("real(clog(-0 + i NaN)) = NaN plus maybe invalid exception",
4726 __real__ result, INVALID_EXCEPTION);
4727 check_isnan ("imag(clog(-0 + i NaN)) = NaN plus maybe invalid exception",
4728 __imag__ result);
4729 result = FUNC(clog) (BUILD_COMPLEX (-3, nan_value));
4730 check_isnan_maybe_exc ("real(clog(-3 + i NaN)) = NaN plus maybe invalid exception",
4731 __real__ result, INVALID_EXCEPTION);
4732 check_isnan ("imag(clog(-3 + i NaN)) = NaN plus maybe invalid exception",
4733 __imag__ result);
4735 result = FUNC(clog) (BUILD_COMPLEX (nan_value, 0));
4736 check_isnan_maybe_exc ("real(clog(NaN + i0)) = NaN plus maybe invalid exception",
4737 __real__ result, INVALID_EXCEPTION);
4738 check_isnan ("imag(clog(NaN + i0)) = NaN plus maybe invalid exception",
4739 __imag__ result);
4740 result = FUNC(clog) (BUILD_COMPLEX (nan_value, 5));
4741 check_isnan_maybe_exc ("real(clog(NaN + i5)) = NaN plus maybe invalid exception",
4742 __real__ result, INVALID_EXCEPTION);
4743 check_isnan ("imag(clog(NaN + i5)) = NaN plus maybe invalid exception",
4744 __imag__ result);
4745 result = FUNC(clog) (BUILD_COMPLEX (nan_value, minus_zero));
4746 check_isnan_maybe_exc ("real(clog(NaN - i0)) = NaN plus maybe invalid exception",
4747 __real__ result, INVALID_EXCEPTION);
4748 check_isnan ("imag(clog(NaN - i0)) = NaN plus maybe invalid exception",
4749 __imag__ result);
4750 result = FUNC(clog) (BUILD_COMPLEX (nan_value, -5));
4751 check_isnan_maybe_exc ("real(clog(NaN - i5)) = NaN plus maybe invalid exception",
4752 __real__ result, INVALID_EXCEPTION);
4753 check_isnan ("imag(clog(NaN - i5)) = NaN plus maybe invalid exception",
4754 __imag__ result);
4756 result = FUNC(clog) (BUILD_COMPLEX (nan_value, nan_value));
4757 check_isnan ("real(clog(NaN + i NaN)) = NaN", __real__ result);
4758 check_isnan ("imag(clog(NaN + i NaN)) = NaN", __imag__ result);
4760 result = FUNC(clog) (BUILD_COMPLEX (0.7, 1.2));
4761 check_eps ("real(clog(0.7 + i 1.2)) == 0.32876...", __real__ result,
4762 0.3287600014583970919L, CHOOSE(5e-17L, 6e-17, 3e-8));
4763 check_eps ("imag(clog(0.7 + i 1.2)) == 1.04272...", __imag__ result,
4764 1.0427218783685369524L, CHOOSE(2e-17L, 0, 0));
4766 result = FUNC(clog) (BUILD_COMPLEX (-2, -3));
4767 check_eps ("real(clog(-2 - i 3)) == 1.28247...", __real__ result,
4768 1.2824746787307683680L, CHOOSE(3e-19L, 0, 0));
4769 check_eps ("imag(clog(-2 - i 3)) == -2.15879...", __imag__ result,
4770 -2.1587989303424641704L, CHOOSE(2e-18L, 0, 0));
4774 static void
4775 clog10_test (void)
4777 __complex__ MATHTYPE result;
4779 result = FUNC(clog10) (BUILD_COMPLEX (minus_zero, 0));
4780 check_isinfn_exc ("real(clog10(-0 + i0)) = -Inf plus divide-by-zero exception",
4781 __real__ result, DIVIDE_BY_ZERO_EXCEPTION);
4782 check ("imag(clog10(-0 + i0)) = pi plus divide-by-zero exception",
4783 __imag__ result, M_PI);
4784 result = FUNC(clog10) (BUILD_COMPLEX (minus_zero, minus_zero));
4785 check_isinfn_exc ("real(clog10(-0 - i0)) = -Inf plus divide-by-zero exception",
4786 __real__ result, DIVIDE_BY_ZERO_EXCEPTION);
4787 check ("imag(clog10(-0 - i0)) = -pi plus divide-by-zero exception",
4788 __imag__ result, -M_PI);
4790 result = FUNC(clog10) (BUILD_COMPLEX (0, 0));
4791 check_isinfn_exc ("real(clog10(0 + i0)) = -Inf plus divide-by-zero exception",
4792 __real__ result, DIVIDE_BY_ZERO_EXCEPTION);
4793 check ("imag(clog10(0 + i0)) = 0 plus divide-by-zero exception",
4794 __imag__ result, 0);
4795 result = FUNC(clog10) (BUILD_COMPLEX (0, minus_zero));
4796 check_isinfn_exc ("real(clog10(0 - i0)) = -Inf plus divide-by-zero exception",
4797 __real__ result, DIVIDE_BY_ZERO_EXCEPTION);
4798 check ("imag(clog10(0 - i0)) = -0 plus divide-by-zero exception",
4799 __imag__ result, minus_zero);
4801 result = FUNC(clog10) (BUILD_COMPLEX (minus_infty, plus_infty));
4802 check_isinfp ("real(clog10(-Inf + i Inf)) = +Inf", __real__ result);
4803 check_eps ("imag(clog10(-Inf + i Inf)) = 3*pi/4*M_LOG10E", __imag__ result,
4804 (M_PI - M_PI_4) * M_LOG10E, CHOOSE (0, 3e-16, 0));
4805 result = FUNC(clog10) (BUILD_COMPLEX (minus_infty, minus_infty));
4806 check_isinfp ("real(clog10(-Inf - i Inf)) = +Inf", __real__ result);
4807 check_eps ("imag(clog10(-Inf - i Inf)) = -3*pi/4*M_LOG10E", __imag__ result,
4808 (M_PI_4 - M_PI) * M_LOG10E, CHOOSE (0, 3e-16, 0));
4810 result = FUNC(clog10) (BUILD_COMPLEX (plus_infty, plus_infty));
4811 check_isinfp ("real(clog10(+Inf + i Inf)) = +Inf", __real__ result);
4812 check_eps ("imag(clog10(+Inf + i Inf)) = pi/4*M_LOG10E", __imag__ result,
4813 M_PI_4 * M_LOG10E, CHOOSE (0, 6e-17, 3e-8));
4814 result = FUNC(clog10) (BUILD_COMPLEX (plus_infty, minus_infty));
4815 check_isinfp ("real(clog10(+Inf - i Inf)) = +Inf", __real__ result);
4816 check_eps ("imag(clog10(+Inf - i Inf)) = -pi/4*M_LOG10E", __imag__ result,
4817 -M_PI_4 * M_LOG10E, CHOOSE (0, 6e-17, 3e-8));
4819 result = FUNC(clog10) (BUILD_COMPLEX (0, plus_infty));
4820 check_isinfp ("real(clog10(0 + i Inf)) = +Inf", __real__ result);
4821 check_eps ("imag(clog10(0 + i Inf)) = pi/2*M_LOG10E", __imag__ result,
4822 M_PI_2 * M_LOG10E, CHOOSE (0, 2e-16, 6e-8));
4823 result = FUNC(clog10) (BUILD_COMPLEX (3, plus_infty));
4824 check_isinfp ("real(clog10(3 + i Inf)) = +Inf", __real__ result);
4825 check_eps ("imag(clog10(3 + i Inf)) = pi/2*M_LOG10E", __imag__ result,
4826 M_PI_2 * M_LOG10E, CHOOSE (0, 2e-16, 6e-8));
4827 result = FUNC(clog10) (BUILD_COMPLEX (minus_zero, plus_infty));
4828 check_isinfp ("real(clog10(-0 + i Inf)) = +Inf", __real__ result);
4829 check_eps ("imag(clog10(-0 + i Inf)) = pi/2*M_LOG10E", __imag__ result,
4830 M_PI_2 * M_LOG10E, CHOOSE (0, 2e-16, 6e-8));
4831 result = FUNC(clog10) (BUILD_COMPLEX (-3, plus_infty));
4832 check_isinfp ("real(clog10(-3 + i Inf)) = +Inf", __real__ result);
4833 check_eps ("imag(clog10(-3 + i Inf)) = pi/2*M_LOG10E", __imag__ result,
4834 M_PI_2 * M_LOG10E, CHOOSE (0, 2e-16, 6e-8));
4835 result = FUNC(clog10) (BUILD_COMPLEX (0, minus_infty));
4836 check_isinfp ("real(clog10(0 - i Inf)) = +Inf", __real__ result);
4837 check_eps ("imag(clog10(0 - i Inf)) = -pi/2*M_LOG10E", __imag__ result,
4838 -M_PI_2*M_LOG10E, CHOOSE (0, 2e-16, 6e-8));
4839 result = FUNC(clog10) (BUILD_COMPLEX (3, minus_infty));
4840 check_isinfp ("real(clog10(3 - i Inf)) = +Inf", __real__ result);
4841 check_eps ("imag(clog10(3 - i Inf)) = -pi/2*M_LOG10E", __imag__ result,
4842 -M_PI_2*M_LOG10E, CHOOSE (0, 2e-16, 6e-8));
4843 result = FUNC(clog10) (BUILD_COMPLEX (minus_zero, minus_infty));
4844 check_isinfp ("real(clog10(-0 - i Inf)) = +Inf", __real__ result);
4845 check_eps ("imag(clog10(-0 - i Inf)) = -pi/2*M_LOG10E", __imag__ result,
4846 -M_PI_2 * M_LOG10E, CHOOSE (0, 2e-16, 6e-8));
4847 result = FUNC(clog10) (BUILD_COMPLEX (-3, minus_infty));
4848 check_isinfp ("real(clog10(-3 - i Inf)) = +Inf", __real__ result);
4849 check_eps ("imag(clog10(-3 - i Inf)) = -pi/2*M_LOG10E", __imag__ result,
4850 -M_PI_2 * M_LOG10E, CHOOSE (0, 2e-16, 6e-8));
4852 result = FUNC(clog10) (BUILD_COMPLEX (minus_infty, 0));
4853 check_isinfp ("real(clog10(-Inf + i0)) = +Inf", __real__ result);
4854 check_eps ("imag(clog10(-Inf + i0)) = pi*M_LOG10E", __imag__ result,
4855 M_PI * M_LOG10E, CHOOSE (0, 3e-16, 2e-7));
4856 result = FUNC(clog10) (BUILD_COMPLEX (minus_infty, 1));
4857 check_isinfp ("real(clog10(-Inf + i1)) = +Inf", __real__ result);
4858 check_eps ("imag(clog10(-Inf + i1)) = pi*M_LOG10E", __imag__ result,
4859 M_PI * M_LOG10E, CHOOSE (0, 3e-16, 2e-7));
4860 result = FUNC(clog10) (BUILD_COMPLEX (minus_infty, minus_zero));
4861 check_isinfp ("real(clog10(-Inf - i0)) = +Inf", __real__ result);
4862 check_eps ("imag(clog10(-Inf - i0)) = -pi*M_LOG10E", __imag__ result,
4863 -M_PI * M_LOG10E, CHOOSE (0, 3e-16, 2e-7));
4864 result = FUNC(clog10) (BUILD_COMPLEX (minus_infty, -1));
4865 check_isinfp ("real(clog10(-Inf - i1)) = +Inf", __real__ result);
4866 check_eps ("imag(clog10(-Inf - i1)) = -pi*M_LOG10E", __imag__ result,
4867 -M_PI * M_LOG10E, CHOOSE (0, 3e-16, 2e-7));
4869 result = FUNC(clog10) (BUILD_COMPLEX (plus_infty, 0));
4870 check_isinfp ("real(clog10(+Inf + i0)) = +Inf", __real__ result);
4871 check ("imag(clog10(+Inf + i0)) = 0", __imag__ result, 0);
4872 result = FUNC(clog10) (BUILD_COMPLEX (plus_infty, 1));
4873 check_isinfp ("real(clog10(+Inf + i1)) = +Inf", __real__ result);
4874 check ("imag(clog10(+Inf + i1)) = 0", __imag__ result, 0);
4875 result = FUNC(clog10) (BUILD_COMPLEX (plus_infty, minus_zero));
4876 check_isinfp ("real(clog10(+Inf - i0)) = +Inf", __real__ result);
4877 check ("imag(clog10(+Inf - i0)) = -0", __imag__ result, minus_zero);
4878 result = FUNC(clog10) (BUILD_COMPLEX (plus_infty, -1));
4879 check_isinfp ("real(clog10(+Inf - i1)) = +Inf", __real__ result);
4880 check ("imag(clog10(+Inf - i1)) = -0", __imag__ result, minus_zero);
4882 result = FUNC(clog10) (BUILD_COMPLEX (plus_infty, nan_value));
4883 check_isinfp ("real(clog10(+Inf + i NaN)) = +Inf", __real__ result);
4884 check_isnan ("imag(clog10(+Inf + i NaN)) = NaN", __imag__ result);
4885 result = FUNC(clog10) (BUILD_COMPLEX (minus_infty, nan_value));
4886 check_isinfp ("real(clog10(-Inf + i NaN)) = +Inf", __real__ result);
4887 check_isnan ("imag(clog10(-Inf + i NaN)) = NaN", __imag__ result);
4889 result = FUNC(clog10) (BUILD_COMPLEX (nan_value, plus_infty));
4890 check_isinfp ("real(clog10(NaN + i Inf)) = +Inf", __real__ result);
4891 check_isnan ("imag(clog10(NaN + i Inf)) = NaN", __imag__ result);
4892 result = FUNC(clog10) (BUILD_COMPLEX (nan_value, minus_infty));
4893 check_isinfp ("real(clog10(NaN - i Inf)) = +Inf", __real__ result);
4894 check_isnan ("imag(clog10(NaN - i Inf)) = NaN", __imag__ result);
4896 result = FUNC(clog10) (BUILD_COMPLEX (0, nan_value));
4897 check_isnan_maybe_exc ("real(clog10(0 + i NaN)) = NaN plus maybe invalid exception",
4898 __real__ result, INVALID_EXCEPTION);
4899 check_isnan ("imag(clog10(0 + i NaN)) = NaN plus maybe invalid exception",
4900 __imag__ result);
4901 result = FUNC(clog10) (BUILD_COMPLEX (3, nan_value));
4902 check_isnan_maybe_exc ("real(clog10(3 + i NaN)) = NaN plus maybe invalid exception",
4903 __real__ result, INVALID_EXCEPTION);
4904 check_isnan ("imag(clog10(3 + i NaN)) = NaN plus maybe invalid exception",
4905 __imag__ result);
4906 result = FUNC(clog10) (BUILD_COMPLEX (minus_zero, nan_value));
4907 check_isnan_maybe_exc ("real(clog10(-0 + i NaN)) = NaN plus maybe invalid exception",
4908 __real__ result, INVALID_EXCEPTION);
4909 check_isnan ("imag(clog10(-0 + i NaN)) = NaN plus maybe invalid exception",
4910 __imag__ result);
4911 result = FUNC(clog10) (BUILD_COMPLEX (-3, nan_value));
4912 check_isnan_maybe_exc ("real(clog10(-3 + i NaN)) = NaN plus maybe invalid exception",
4913 __real__ result, INVALID_EXCEPTION);
4914 check_isnan ("imag(clog10(-3 + i NaN)) = NaN plus maybe invalid exception",
4915 __imag__ result);
4917 result = FUNC(clog10) (BUILD_COMPLEX (nan_value, 0));
4918 check_isnan_maybe_exc ("real(clog10(NaN + i0)) = NaN plus maybe invalid exception",
4919 __real__ result, INVALID_EXCEPTION);
4920 check_isnan ("imag(clog10(NaN + i0)) = NaN plus maybe invalid exception",
4921 __imag__ result);
4922 result = FUNC(clog10) (BUILD_COMPLEX (nan_value, 5));
4923 check_isnan_maybe_exc ("real(clog10(NaN + i5)) = NaN plus maybe invalid exception",
4924 __real__ result, INVALID_EXCEPTION);
4925 check_isnan ("imag(clog10(NaN + i5)) = NaN plus maybe invalid exception",
4926 __imag__ result);
4927 result = FUNC(clog10) (BUILD_COMPLEX (nan_value, minus_zero));
4928 check_isnan_maybe_exc ("real(clog10(NaN - i0)) = NaN plus maybe invalid exception",
4929 __real__ result, INVALID_EXCEPTION);
4930 check_isnan ("imag(clog10(NaN - i0)) = NaN plus maybe invalid exception",
4931 __imag__ result);
4932 result = FUNC(clog10) (BUILD_COMPLEX (nan_value, -5));
4933 check_isnan_maybe_exc ("real(clog10(NaN - i5)) = NaN plus maybe invalid exception",
4934 __real__ result, INVALID_EXCEPTION);
4935 check_isnan ("imag(clog10(NaN - i5)) = NaN plus maybe invalid exception",
4936 __imag__ result);
4938 result = FUNC(clog10) (BUILD_COMPLEX (nan_value, nan_value));
4939 check_isnan ("real(clog10(NaN + i NaN)) = NaN", __real__ result);
4940 check_isnan ("imag(clog10(NaN + i NaN)) = NaN", __imag__ result);
4942 result = FUNC(clog10) (BUILD_COMPLEX (0.7, 1.2));
4943 check_eps ("real(clog10(0.7 + i 1.2)) == 0.14277...", __real__ result,
4944 0.1427786545038868803L, CHOOSE(2e-17L, 6e-17, 2e-8));
4945 check_eps ("imag(clog10(0.7 + i 1.2)) == 0.45284...", __imag__ result,
4946 0.4528483579352493248L, CHOOSE(6e-18, 6e-17, 3e-8));
4948 result = FUNC(clog10) (BUILD_COMPLEX (-2, -3));
4949 check_eps ("real(clog10(-2 - i 3)) == 0.55697...", __real__ result,
4950 0.5569716761534183846L, CHOOSE(6e-20L, 0, 0));
4951 check_eps ("imag(clog10(-2 - i 3)) == -0.93755...", __imag__ result,
4952 -0.9375544629863747085L, CHOOSE (7e-19L, 2e-16, 0));
4956 static void
4957 csqrt_test (void)
4959 __complex__ MATHTYPE result;
4961 result = FUNC(csqrt) (BUILD_COMPLEX (0, 0));
4962 check ("real(csqrt(0 + i0)) = 0", __real__ result, 0);
4963 check ("imag(csqrt(0 + i0)) = 0", __imag__ result, 0);
4964 result = FUNC(csqrt) (BUILD_COMPLEX (0, minus_zero));
4965 check ("real(csqrt(0 - i0)) = 0", __real__ result, 0);
4966 check ("imag(csqrt(0 - i0)) = -0", __imag__ result, minus_zero);
4967 result = FUNC(csqrt) (BUILD_COMPLEX (minus_zero, 0));
4968 check ("real(csqrt(-0 + i0)) = 0", __real__ result, 0);
4969 check ("imag(csqrt(-0 + i0)) = 0", __imag__ result, 0);
4970 result = FUNC(csqrt) (BUILD_COMPLEX (minus_zero, minus_zero));
4971 check ("real(csqrt(-0 - i0)) = 0", __real__ result, 0);
4972 check ("imag(csqrt(-0 - i0)) = -0", __imag__ result, minus_zero);
4974 result = FUNC(csqrt) (BUILD_COMPLEX (minus_infty, 0));
4975 check ("real(csqrt(-Inf + i0)) = 0", __real__ result, 0);
4976 check_isinfp ("imag(csqrt(-Inf + i0)) = +Inf", __imag__ result);
4977 result = FUNC(csqrt) (BUILD_COMPLEX (minus_infty, 6));
4978 check ("real(csqrt(-Inf + i6)) = 0", __real__ result, 0);
4979 check_isinfp ("imag(csqrt(-Inf + i6)) = +Inf", __imag__ result);
4980 result = FUNC(csqrt) (BUILD_COMPLEX (minus_infty, minus_zero));
4981 check ("real(csqrt(-Inf - i0)) = 0", __real__ result, 0);
4982 check_isinfn ("imag(csqrt(-Inf - i0)) = -Inf", __imag__ result);
4983 result = FUNC(csqrt) (BUILD_COMPLEX (minus_infty, -6));
4984 check ("real(csqrt(-Inf - i6)) = 0", __real__ result, 0);
4985 check_isinfn ("imag(csqrt(-Inf - i6)) = -Inf", __imag__ result);
4987 result = FUNC(csqrt) (BUILD_COMPLEX (plus_infty, 0));
4988 check_isinfp ("real(csqrt(+Inf + i0)) = +Inf", __real__ result);
4989 check ("imag(csqrt(+Inf + i0)) = 0", __imag__ result, 0);
4990 result = FUNC(csqrt) (BUILD_COMPLEX (plus_infty, 6));
4991 check_isinfp ("real(csqrt(+Inf + i6)) = +Inf", __real__ result);
4992 check ("imag(csqrt(+Inf + i6)) = 0", __imag__ result, 0);
4993 result = FUNC(csqrt) (BUILD_COMPLEX (plus_infty, minus_zero));
4994 check_isinfp ("real(csqrt(+Inf - i0)) = +Inf", __real__ result);
4995 check ("imag(csqrt(+Inf - i0)) = -0", __imag__ result, minus_zero);
4996 result = FUNC(csqrt) (BUILD_COMPLEX (plus_infty, -6));
4997 check_isinfp ("real(csqrt(+Inf - i6)) = +Inf", __real__ result);
4998 check ("imag(csqrt(+Inf - i6)) = -0", __imag__ result, minus_zero);
5000 result = FUNC(csqrt) (BUILD_COMPLEX (0, plus_infty));
5001 check_isinfp ("real(csqrt(0 + i Inf)) = +Inf", __real__ result);
5002 check_isinfp ("imag(csqrt(0 + i Inf)) = +Inf", __imag__ result);
5003 result = FUNC(csqrt) (BUILD_COMPLEX (4, plus_infty));
5004 check_isinfp ("real(csqrt(4 + i Inf)) = +Inf", __real__ result);
5005 check_isinfp ("imag(csqrt(4 + i Inf)) = +Inf", __imag__ result);
5006 result = FUNC(csqrt) (BUILD_COMPLEX (plus_infty, plus_infty));
5007 check_isinfp ("real(csqrt(+Inf + i Inf)) = +Inf", __real__ result);
5008 check_isinfp ("imag(csqrt(+Inf + i Inf)) = +Inf", __imag__ result);
5009 result = FUNC(csqrt) (BUILD_COMPLEX (minus_zero, plus_infty));
5010 check_isinfp ("real(csqrt(-0 + i Inf)) = +Inf", __real__ result);
5011 check_isinfp ("imag(csqrt(-0 + i Inf)) = +Inf", __imag__ result);
5012 result = FUNC(csqrt) (BUILD_COMPLEX (-4, plus_infty));
5013 check_isinfp ("real(csqrt(-4 + i Inf)) = +Inf", __real__ result);
5014 check_isinfp ("imag(csqrt(-4 + i Inf)) = +Inf", __imag__ result);
5015 result = FUNC(csqrt) (BUILD_COMPLEX (minus_infty, plus_infty));
5016 check_isinfp ("real(csqrt(-Inf + i Inf)) = +Inf", __real__ result);
5017 check_isinfp ("imag(csqrt(-Inf + i Inf)) = +Inf", __imag__ result);
5018 result = FUNC(csqrt) (BUILD_COMPLEX (0, minus_infty));
5019 check_isinfp ("real(csqrt(0 - i Inf)) = +Inf", __real__ result);
5020 check_isinfn ("imag(csqrt(0 - i Inf)) = -Inf", __imag__ result);
5021 result = FUNC(csqrt) (BUILD_COMPLEX (4, minus_infty));
5022 check_isinfp ("real(csqrt(4 - i Inf)) = +Inf", __real__ result);
5023 check_isinfn ("imag(csqrt(4 - i Inf)) = -Inf", __imag__ result);
5024 result = FUNC(csqrt) (BUILD_COMPLEX (plus_infty, minus_infty));
5025 check_isinfp ("real(csqrt(+Inf - i Inf)) = +Inf", __real__ result);
5026 check_isinfn ("imag(csqrt(+Inf - i Inf)) = -Inf", __imag__ result);
5027 result = FUNC(csqrt) (BUILD_COMPLEX (minus_zero, minus_infty));
5028 check_isinfp ("real(csqrt(-0 - i Inf)) = +Inf", __real__ result);
5029 check_isinfn ("imag(csqrt(-0 - i Inf)) = -Inf", __imag__ result);
5030 result = FUNC(csqrt) (BUILD_COMPLEX (-4, minus_infty));
5031 check_isinfp ("real(csqrt(-4 - i Inf)) = +Inf", __real__ result);
5032 check_isinfn ("imag(csqrt(-4 - i Inf)) = -Inf", __imag__ result);
5033 result = FUNC(csqrt) (BUILD_COMPLEX (minus_infty, minus_infty));
5034 check_isinfp ("real(csqrt(-Inf - i Inf)) = +Inf", __real__ result);
5035 check_isinfn ("imag(csqrt(-Inf - i Inf)) = -Inf", __imag__ result);
5037 result = FUNC(csqrt) (BUILD_COMPLEX (minus_infty, nan_value));
5038 check_isnan ("real(csqrt(-Inf + i NaN)) = NaN", __real__ result);
5039 check_isinfp ("imag(csqrt(-Inf + i NaN)) = +-Inf",
5040 FUNC(fabs) (__imag__ result));
5042 result = FUNC(csqrt) (BUILD_COMPLEX (plus_infty, nan_value));
5043 check_isinfp ("real(csqrt(+Inf + i NaN)) = +Inf", __real__ result);
5044 check_isnan ("imag(csqrt(+Inf + i NaN)) = NaN", __imag__ result);
5046 result = FUNC(csqrt) (BUILD_COMPLEX (0, nan_value));
5047 check_isnan_maybe_exc ("real(csqrt(0 + i NaN)) = NaN plus maybe invalid exception",
5048 __real__ result, INVALID_EXCEPTION);
5049 check_isnan ("imag(csqrt(0 + i NaN)) = NaN plus maybe invalid exception",
5050 __imag__ result);
5051 result = FUNC(csqrt) (BUILD_COMPLEX (1, nan_value));
5052 check_isnan_maybe_exc ("real(csqrt(1 + i NaN)) = NaN plus maybe invalid exception",
5053 __real__ result, INVALID_EXCEPTION);
5054 check_isnan ("imag(csqrt(1 + i NaN)) = NaN plus maybe invalid exception",
5055 __imag__ result);
5056 result = FUNC(csqrt) (BUILD_COMPLEX (minus_zero, nan_value));
5057 check_isnan_maybe_exc ("real(csqrt(-0 + i NaN)) = NaN plus maybe invalid exception",
5058 __real__ result, INVALID_EXCEPTION);
5059 check_isnan ("imag(csqrt(-0 + i NaN)) = NaN plus maybe invalid exception",
5060 __imag__ result);
5061 result = FUNC(csqrt) (BUILD_COMPLEX (-1, nan_value));
5062 check_isnan_maybe_exc ("real(csqrt(-1 + i NaN)) = NaN plus maybe invalid exception",
5063 __real__ result, INVALID_EXCEPTION);
5064 check_isnan ("imag(csqrt(-1 + i NaN)) = NaN plus maybe invalid exception",
5065 __imag__ result);
5067 result = FUNC(csqrt) (BUILD_COMPLEX (nan_value, 0));
5068 check_isnan_maybe_exc ("real(csqrt(NaN + i0)) = NaN plus maybe invalid exception",
5069 __real__ result, INVALID_EXCEPTION);
5070 check_isnan ("imag(csqrt(NaN + i0)) = NaN plus maybe invalid exception",
5071 __imag__ result);
5072 result = FUNC(csqrt) (BUILD_COMPLEX (nan_value, 8));
5073 check_isnan_maybe_exc ("real(csqrt(NaN + i8)) = NaN plus maybe invalid exception",
5074 __real__ result, INVALID_EXCEPTION);
5075 check_isnan ("imag(csqrt(NaN + i8)) = NaN plus maybe invalid exception",
5076 __imag__ result);
5077 result = FUNC(csqrt) (BUILD_COMPLEX (nan_value, minus_zero));
5078 check_isnan_maybe_exc ("real(csqrt(NaN - i0)) = NaN plus maybe invalid exception",
5079 __real__ result, INVALID_EXCEPTION);
5080 check_isnan ("imag(csqrt(NaN - i0)) = NaN plus maybe invalid exception",
5081 __imag__ result);
5082 result = FUNC(csqrt) (BUILD_COMPLEX (nan_value, -8));
5083 check_isnan_maybe_exc ("real(csqrt(NaN - i8)) = NaN plus maybe invalid exception",
5084 __real__ result, INVALID_EXCEPTION);
5085 check_isnan ("imag(csqrt(NaN - i8)) = NaN plus maybe invalid exception",
5086 __imag__ result);
5088 result = FUNC(csqrt) (BUILD_COMPLEX (nan_value, nan_value));
5089 check_isnan ("real(csqrt(NaN + i NaN)) = NaN", __real__ result);
5090 check_isnan ("imag(csqrt(NaN + i NaN)) = NaN", __imag__ result);
5092 result = FUNC(csqrt) (BUILD_COMPLEX (16.0, -30.0));
5093 check ("real(csqrt(16 - 30i)) = 5", __real__ result, 5.0);
5094 check ("imag(csqrt(16 - 30i)) = -3", __imag__ result, -3.0);
5096 result = FUNC(csqrt) (BUILD_COMPLEX (-1, 0));
5097 check ("real(csqrt(1 + i0) = 0", __real__ result, 0);
5098 check ("imag(csqrt(1 + i0) = 1", __imag__ result, 1);
5100 result = FUNC(csqrt) (BUILD_COMPLEX (0, 2));
5101 check ("real(csqrt(0 + i 2) = 1", __real__ result, 1);
5102 check ("imag(csqrt(0 + i 2) = 1", __imag__ result, 1);
5104 result = FUNC(csqrt) (BUILD_COMPLEX (119, 120));
5105 check ("real(csqrt(119 + i 120) = 12", __real__ result, 12);
5106 check ("imag(csqrt(119 + i 120) = 5", __imag__ result, 5);
5108 result = FUNC(csqrt) (BUILD_COMPLEX (0.7, 1.2));
5109 check_eps ("real(csqrt(0.7 + i 1.2)) == 1.02206...", __real__ result,
5110 1.0220676100300264507L, CHOOSE(3e-17L, 3e-16, 2e-7));
5111 check_eps ("imag(csqrt(0.7 + i 1.2)) == 0.58704...", __imag__ result,
5112 0.5870453129635652115L, CHOOSE(7e-18L, 0, 0));
5114 result = FUNC(csqrt) (BUILD_COMPLEX (-2, -3));
5115 check_eps ("real(csqrt(-2 - i 3)) == -0.89597...", __real__ result,
5116 0.8959774761298381247L, CHOOSE(6e-20L, 2e-16, 6e-8));
5117 check_eps ("imag(csqrt(-2 - i 3)) == -1.67414...", __imag__ result,
5118 -1.6741492280355400404L, CHOOSE(0, 5e-16, 0));
5122 static void
5123 cpow_test (void)
5125 __complex__ MATHTYPE result;
5127 result = FUNC (cpow) (BUILD_COMPLEX (1, 0), BUILD_COMPLEX (0, 0));
5128 check ("real(cpow (1 + i0), (0 + i0)) == 0", __real__ result, 1);
5129 check ("imag(cpow (1 + i0), (0 + i0)) == 0", __imag__ result, 0);
5131 result = FUNC (cpow) (BUILD_COMPLEX (2, 0), BUILD_COMPLEX (10, 0));
5132 check_eps ("real(cpow (2 + i0), (10 + i0)) == 1024", __real__ result, 1024,
5133 CHOOSE (2e-16L, 0, 0));
5134 check ("imag(cpow (2 + i0), (10 + i0)) == 0", __imag__ result, 0);
5136 result = FUNC (cpow) (BUILD_COMPLEX (M_E, 0), BUILD_COMPLEX (0, 2*M_PI));
5137 check_eps ("real(cpow (e + i0), (0 + i 2*PI)) == 1", __real__ result, 1,
5138 CHOOSE (0, 0, 6e-8));
5139 check_eps ("imag(cpow (e + i0), (0 + i 2*PI)) == 0", __imag__ result, 0,
5140 CHOOSE (3e-18L, 3e-16, 4e-7));
5142 result = FUNC (cpow) (BUILD_COMPLEX (2, 3), BUILD_COMPLEX (4, 0));
5143 check_eps ("real(cpow (2 + i3), (4 + i0)) == -119", __real__ result, -119,
5144 CHOOSE (9e-16L, 2e-14, 4e-5));
5145 check_eps ("imag(cpow (2 + i3), (4 + i0)) == -120", __imag__ result, -120,
5146 CHOOSE (1e-15L, 0, 5e-5));
5150 static void
5151 cabs_test (void)
5153 /* cabs (x + iy) is specified as hypot (x,y) */
5154 MATHTYPE a;
5155 a = random_greater (0);
5156 check_isinfp_ext ("cabs (+inf + i x) == +inf",
5157 FUNC(cabs) (BUILD_COMPLEX (plus_infty, a)), a);
5158 check_isinfp_ext ("cabs (-inf + i x) == +inf",
5159 FUNC(cabs) (BUILD_COMPLEX (minus_infty, a)), a);
5161 check_isinfp ("cabs (+inf+ iNaN) == +inf",
5162 FUNC(cabs) (BUILD_COMPLEX(minus_infty, nan_value)));
5163 check_isinfp ("cabs (-inf+ iNaN) == +inf",
5164 FUNC(cabs) (BUILD_COMPLEX(minus_infty, nan_value)));
5166 check_isnan ("cabs (NaN+ iNaN) == NaN",
5167 FUNC(cabs) (BUILD_COMPLEX(nan_value, nan_value)));
5169 a = FUNC(cabs) (BUILD_COMPLEX (12.4L, 0.7L));
5170 check ("cabs (x,y) == cabs (y,x)",
5171 FUNC(cabs) (BUILD_COMPLEX(0.7L, 12.4L)), a);
5172 check ("cabs (x,y) == cabs (-x,y)",
5173 FUNC(cabs) (BUILD_COMPLEX(-12.4L, 0.7L)), a);
5174 check ("cabs (x,y) == cabs (-y,x)",
5175 FUNC(cabs) (BUILD_COMPLEX(-0.7L, 12.4L)), a);
5176 check ("cabs (x,y) == cabs (-x,-y)",
5177 FUNC(cabs) (BUILD_COMPLEX(-12.4L, -0.7L)), a);
5178 check ("cabs (x,y) == cabs (-y,-x)",
5179 FUNC(cabs) (BUILD_COMPLEX(-0.7L, -12.4L)), a);
5180 check ("cabs (x,0) == fabs (x)", FUNC(cabs) (BUILD_COMPLEX(-0.7L, 0)), 0.7L);
5181 check ("cabs (x,0) == fabs (x)", FUNC(cabs) (BUILD_COMPLEX(0.7L, 0)), 0.7L);
5182 check ("cabs (x,0) == fabs (x)", FUNC(cabs) (BUILD_COMPLEX(-1.0L, 0)), 1.0L);
5183 check ("cabs (x,0) == fabs (x)", FUNC(cabs) (BUILD_COMPLEX(1.0L, 0)), 1.0L);
5184 check ("cabs (x,0) == fabs (x)", FUNC(cabs) (BUILD_COMPLEX(-5.7e7L, 0)),
5185 5.7e7L);
5186 check ("cabs (x,0) == fabs (x)", FUNC(cabs) (BUILD_COMPLEX(5.7e7L, 0)),
5187 5.7e7L);
5189 check_eps ("cabs (0.7 + i 1.2) == 1.38924...", FUNC(cabs) (BUILD_COMPLEX(0.7, 1.2)),
5190 1.3892443989449804508L, CHOOSE(7e-17L, 3e-16, 0));
5194 static void
5195 carg_test (void)
5197 /* carg (x + iy) is specified as atan2 (y, x) */
5198 MATHTYPE x;
5200 x = random_greater (0);
5201 check ("carg (x + i 0) == 0 for x > 0",
5202 FUNC(carg) (BUILD_COMPLEX(x, 0)), 0);
5203 x = random_greater (0);
5204 check ("carg (x - i 0) == -0 for x > 0",
5205 FUNC(carg) (BUILD_COMPLEX(x, minus_zero)), minus_zero);
5207 check ("carg (+0 + i 0) == +0", FUNC(carg) (BUILD_COMPLEX(0, 0)), 0);
5208 check ("carg (+0 - i 0) == -0", FUNC(carg) (BUILD_COMPLEX(0, minus_zero)),
5209 minus_zero);
5211 x = -random_greater (0);
5212 check ("carg (x + i 0) == +pi for x < 0", FUNC(carg) (BUILD_COMPLEX(x, 0)),
5213 M_PI);
5215 x = -random_greater (0);
5216 check ("carg (x - i 0) == -pi for x < 0",
5217 FUNC(carg) (BUILD_COMPLEX(x, minus_zero)), -M_PI);
5219 check ("carg (-0 + i 0) == +pi", FUNC(carg) (BUILD_COMPLEX(minus_zero, 0)),
5220 M_PI);
5221 check ("carg (-0 - i 0) == -pi",
5222 FUNC(carg) (BUILD_COMPLEX(minus_zero, minus_zero)), -M_PI);
5224 x = random_greater (0);
5225 check ("carg (+0 + i y) == pi/2 for y > 0", FUNC(carg) (BUILD_COMPLEX(0, x)),
5226 M_PI_2);
5228 x = random_greater (0);
5229 check ("carg (-0 + i y) == pi/2 for y > 0",
5230 FUNC(carg) (BUILD_COMPLEX(minus_zero, x)), M_PI_2);
5232 x = random_less (0);
5233 check ("carg (+0 + i y) == -pi/2 for y < 0", FUNC(carg) (BUILD_COMPLEX(0, x)),
5234 -M_PI_2);
5236 x = random_less (0);
5237 check ("carg (-0 + i y) == -pi/2 for y < 0",
5238 FUNC(carg) (BUILD_COMPLEX(minus_zero, x)), -M_PI_2);
5240 x = random_greater (0);
5241 check ("carg (inf + i y) == +0 for finite y > 0",
5242 FUNC(carg) (BUILD_COMPLEX(plus_infty, x)), 0);
5244 x = -random_greater (0);
5245 check ("carg (inf + i y) == -0 for finite y < 0",
5246 FUNC(carg) (BUILD_COMPLEX(plus_infty, x)), minus_zero);
5248 x = random_value (-1e4, 1e4);
5249 check ("carg(x + i inf) == pi/2 for finite x",
5250 FUNC(carg) (BUILD_COMPLEX(x, plus_infty)), M_PI_2);
5252 x = random_value (-1e4, 1e4);
5253 check ("carg(x - i inf) == -pi/2 for finite x",
5254 FUNC(carg) (BUILD_COMPLEX(x, minus_infty)), -M_PI_2);
5256 x = random_greater (0);
5257 check ("carg (-inf + i y) == +pi for finite y > 0",
5258 FUNC(carg) (BUILD_COMPLEX(minus_infty, x)), M_PI);
5260 x = -random_greater (0);
5261 check ("carg (-inf + i y) == -pi for finite y < 0",
5262 FUNC(carg) (BUILD_COMPLEX(minus_infty, x)), -M_PI);
5264 check ("carg (+inf + i inf) == +pi/4",
5265 FUNC(carg) (BUILD_COMPLEX(plus_infty, plus_infty)), M_PI_4);
5267 check ("carg (+inf -i inf) == -pi/4",
5268 FUNC(carg) (BUILD_COMPLEX(plus_infty, minus_infty)), -M_PI_4);
5270 check ("carg (-inf +i inf) == +3*pi/4",
5271 FUNC(carg) (BUILD_COMPLEX(minus_infty, plus_infty)), 3 * M_PI_4);
5273 check ("carg (-inf -i inf) == -3*pi/4",
5274 FUNC(carg) (BUILD_COMPLEX(minus_infty, minus_infty)), -3 * M_PI_4);
5279 static void
5280 nearbyint_test (void)
5282 check ("nearbyint(+0) = 0", FUNC(nearbyint) (0.0), 0.0);
5283 check ("nearbyint(-0) = -0", FUNC(nearbyint) (minus_zero), minus_zero);
5284 check_isinfp ("nearbyint(+Inf) = +Inf", FUNC(nearbyint) (plus_infty));
5285 check_isinfn ("nearbyint(-Inf) = -Inf", FUNC(nearbyint) (minus_infty));
5289 static void
5290 rint_test (void)
5292 check ("rint(0) = 0", FUNC(rint) (0.0), 0.0);
5293 check ("rint(-0) = -0", FUNC(rint) (minus_zero), minus_zero);
5294 check_isinfp ("rint(+Inf) = +Inf", FUNC(rint) (plus_infty));
5295 check_isinfn ("rint(-Inf) = -Inf", FUNC(rint) (minus_infty));
5299 static void
5300 lrint_test (void)
5302 /* XXX this test is incomplete. We need to have a way to specifiy
5303 the rounding method and test the critical cases. So far, only
5304 unproblematic numbers are tested. */
5306 check_long ("lrint(0) = 0", FUNC(lrint) (0.0), 0);
5307 check_long ("lrint(-0) = 0", FUNC(lrint) (minus_zero), 0);
5308 check_long ("lrint(0.2) = 0", FUNC(lrint) (0.2), 0);
5309 check_long ("lrint(-0.2) = 0", FUNC(lrint) (-0.2), 0);
5311 check_long ("lrint(1.4) = 1", FUNC(lrint) (1.4), 1);
5312 check_long ("lrint(-1.4) = -1", FUNC(lrint) (-1.4), -1);
5314 check_long ("lrint(8388600.3) = 8388600", FUNC(lrint) (8388600.3), 8388600);
5315 check_long ("lrint(-8388600.3) = -8388600", FUNC(lrint) (-8388600.3),
5316 -8388600);
5320 static void
5321 llrint_test (void)
5323 /* XXX this test is incomplete. We need to have a way to specifiy
5324 the rounding method and test the critical cases. So far, only
5325 unproblematic numbers are tested. */
5327 check_longlong ("llrint(0) = 0", FUNC(llrint) (0.0), 0);
5328 check_longlong ("llrint(-0) = 0", FUNC(llrint) (minus_zero), 0);
5329 check_longlong ("llrint(0.2) = 0", FUNC(llrint) (0.2), 0);
5330 check_longlong ("llrint(-0.2) = 0", FUNC(llrint) (-0.2), 0);
5332 check_longlong ("llrint(1.4) = 1", FUNC(llrint) (1.4), 1);
5333 check_longlong ("llrint(-1.4) = -1", FUNC(llrint) (-1.4), -1);
5335 check_longlong ("llrint(8388600.3) = 8388600", FUNC(llrint) (8388600.3),
5336 8388600);
5337 check_longlong ("llrint(-8388600.3) = -8388600", FUNC(llrint) (-8388600.3),
5338 -8388600);
5340 /* Test boundary conditions. */
5341 /* 0x1FFFFF */
5342 check_longlong ("llrint(2097151.0) = 2097151", FUNC(llrint) (2097151.0),
5343 2097151LL);
5344 /* 0x800000 */
5345 check_longlong ("llrint(8388608.0) = 8388608", FUNC(llrint) (8388608.0),
5346 8388608LL);
5347 /* 0x1000000 */
5348 check_longlong ("llrint(16777216.0) = 16777216",
5349 FUNC(llrint) (16777216.0), 16777216LL);
5350 /* 0x20000000000 */
5351 check_longlong ("llrint(2199023255552.0) = 2199023255552",
5352 FUNC(llrint) (2199023255552.0), 2199023255552LL);
5353 /* 0x40000000000 */
5354 check_longlong ("llrint(4398046511104.0) = 4398046511104",
5355 FUNC(llrint) (4398046511104.0), 4398046511104LL);
5356 /* 0x10000000000000 */
5357 check_longlong ("llrint(4503599627370496.0) = 4503599627370496",
5358 FUNC(llrint) (4503599627370496.0), 4503599627370496LL);
5359 /* 0x10000080000000 */
5360 check_longlong ("llrint(4503601774854144.0) = 4503601774854144",
5361 FUNC(llrint) (4503601774854144.0), 4503601774854144LL);
5362 /* 0x20000000000000 */
5363 check_longlong ("llrint(9007199254740992.0) = 9007199254740992",
5364 FUNC(llrint) (9007199254740992.0), 9007199254740992LL);
5365 /* 0x80000000000000 */
5366 check_longlong ("llrint(36028797018963968.0) = 36028797018963968",
5367 FUNC(llrint) (36028797018963968.0), 36028797018963968LL);
5368 /* 0x100000000000000 */
5369 check_longlong ("llrint(72057594037927936.0) = 72057594037927936",
5370 FUNC(llrint) (72057594037927936.0), 72057594037927936LL);
5374 static void
5375 round_test (void)
5377 check ("round(0) = 0", FUNC(round) (0), 0);
5378 check ("round(-0) = -0", FUNC(round) (minus_zero), minus_zero);
5379 check ("round(0.2) = 0", FUNC(round) (0.2), 0.0);
5380 check ("round(-0.2) = -0", FUNC(round) (-0.2), minus_zero);
5381 check ("round(0.5) = 1", FUNC(round) (0.5), 1.0);
5382 check ("round(-0.5) = -1", FUNC(round) (-0.5), -1.0);
5383 check ("round(0.8) = 1", FUNC(round) (0.8), 1.0);
5384 check ("round(-0.8) = -1", FUNC(round) (-0.8), -1.0);
5385 check ("round(1.5) = 2", FUNC(round) (1.5), 2.0);
5386 check ("round(-1.5) = -2", FUNC(round) (-1.5), -2.0);
5387 check ("round(2097152.5) = 2097153", FUNC(round) (2097152.5), 2097153);
5388 check ("round(-2097152.5) = -2097153", FUNC(round) (-2097152.5), -2097153);
5392 static void
5393 lround_test (void)
5395 check_long ("lround(0) = 0", FUNC(lround) (0), 0);
5396 check_long ("lround(-0) = 0", FUNC(lround) (minus_zero), 0);
5397 check_long ("lround(0.2) = 0", FUNC(lround) (0.2), 0.0);
5398 check_long ("lround(-0.2) = 0", FUNC(lround) (-0.2), 0);
5399 check_long ("lround(0.5) = 1", FUNC(lround) (0.5), 1);
5400 check_long ("lround(-0.5) = -1", FUNC(lround) (-0.5), -1);
5401 check_long ("lround(0.8) = 1", FUNC(lround) (0.8), 1);
5402 check_long ("lround(-0.8) = -1", FUNC(lround) (-0.8), -1);
5403 check_long ("lround(1.5) = 2", FUNC(lround) (1.5), 2);
5404 check_long ("lround(-1.5) = -2", FUNC(lround) (-1.5), -2);
5405 check_long ("lround(22514.5) = 22515", FUNC(lround) (22514.5), 22515);
5406 check_long ("lround(-22514.5) = -22515", FUNC(lround) (-22514.5), -22515);
5407 #ifndef TEST_FLOAT
5408 check_long ("lround(2097152.5) = 2097153", FUNC(lround) (2097152.5),
5409 2097153);
5410 check_long ("lround(-2097152.5) = -2097153", FUNC(lround) (-2097152.5),
5411 -2097153);
5412 #endif
5416 static void
5417 llround_test (void)
5419 check_longlong ("llround(0) = 0", FUNC(llround) (0), 0);
5420 check_longlong ("llround(-0) = 0", FUNC(llround) (minus_zero), 0);
5421 check_longlong ("llround(0.2) = 0", FUNC(llround) (0.2), 0.0);
5422 check_longlong ("llround(-0.2) = 0", FUNC(llround) (-0.2), 0);
5423 check_longlong ("llround(0.5) = 1", FUNC(llround) (0.5), 1);
5424 check_longlong ("llround(-0.5) = -1", FUNC(llround) (-0.5), -1);
5425 check_longlong ("llround(0.8) = 1", FUNC(llround) (0.8), 1);
5426 check_longlong ("llround(-0.8) = -1", FUNC(llround) (-0.8), -1);
5427 check_longlong ("llround(1.5) = 2", FUNC(llround) (1.5), 2);
5428 check_longlong ("llround(-1.5) = -2", FUNC(llround) (-1.5), -2);
5429 check_longlong ("llround(22514.5) = 22515", FUNC(llround) (22514.5), 22515);
5430 check_longlong ("llround(-22514.5) = -22515", FUNC(llround) (-22514.5),
5431 -22515);
5432 #ifndef TEST_FLOAT
5433 check_longlong ("llround(2097152.5) = 2097153",
5434 FUNC(llround) (2097152.5), 2097153);
5435 check_longlong ("llround(-2097152.5) = -2097153",
5436 FUNC(llround) (-2097152.5), -2097153);
5437 check_longlong ("llround(34359738368.5) = 34359738369",
5438 FUNC(llround) (34359738368.5), 34359738369ll);
5439 check_longlong ("llround(-34359738368.5) = -34359738369",
5440 FUNC(llround) (-34359738368.5), -34359738369ll);
5441 #endif
5443 /* Test boundary conditions. */
5444 /* 0x1FFFFF */
5445 check_longlong ("llround(2097151.0) = 2097151", FUNC(llround) (2097151.0),
5446 2097151LL);
5447 /* 0x800000 */
5448 check_longlong ("llround(8388608.0) = 8388608", FUNC(llround) (8388608.0),
5449 8388608LL);
5450 /* 0x1000000 */
5451 check_longlong ("llround(16777216.0) = 16777216",
5452 FUNC(llround) (16777216.0), 16777216LL);
5453 /* 0x20000000000 */
5454 check_longlong ("llround(2199023255552.0) = 2199023255552",
5455 FUNC(llround) (2199023255552.0), 2199023255552LL);
5456 /* 0x40000000000 */
5457 check_longlong ("llround(4398046511104.0) = 4398046511104",
5458 FUNC(llround) (4398046511104.0), 4398046511104LL);
5459 /* 0x10000000000000 */
5460 check_longlong ("llround(4503599627370496.0) = 4503599627370496",
5461 FUNC(llround) (4503599627370496.0), 4503599627370496LL);
5462 /* 0x10000080000000 */
5463 check_longlong ("llrint(4503601774854144.0) = 4503601774854144",
5464 FUNC(llrint) (4503601774854144.0), 4503601774854144LL);
5465 /* 0x20000000000000 */
5466 check_longlong ("llround(9007199254740992.0) = 9007199254740992",
5467 FUNC(llround) (9007199254740992.0), 9007199254740992LL);
5468 /* 0x80000000000000 */
5469 check_longlong ("llround(36028797018963968.0) = 36028797018963968",
5470 FUNC(llround) (36028797018963968.0), 36028797018963968LL);
5471 /* 0x100000000000000 */
5472 check_longlong ("llround(72057594037927936.0) = 72057594037927936",
5473 FUNC(llround) (72057594037927936.0), 72057594037927936LL);
5477 static void
5478 fma_test (void)
5480 check ("fma(1.0, 2.0, 3.0) = 5.0", FUNC(fma) (1.0, 2.0, 3.0), 5.0);
5481 check_isnan ("fma(NaN, 2.0, 3.0) = NaN", FUNC(fma) (nan_value, 2.0, 3.0));
5482 check_isnan ("fma(1.0, NaN, 3.0) = NaN", FUNC(fma) (1.0, nan_value, 3.0));
5483 check_isnan_maybe_exc ("fma(1.0, 2.0, NaN) = NaN",
5484 FUNC(fma) (1.0, 2.0, nan_value), INVALID_EXCEPTION);
5485 check_isnan_maybe_exc ("fma(+Inf, 0.0, NaN) = NaN",
5486 FUNC(fma) (plus_infty, 0.0, nan_value),
5487 INVALID_EXCEPTION);
5488 check_isnan_maybe_exc ("fma(-Inf, 0.0, NaN) = NaN",
5489 FUNC(fma) (minus_infty, 0.0, nan_value),
5490 INVALID_EXCEPTION);
5491 check_isnan_maybe_exc ("fma(0.0, +Inf, NaN) = NaN",
5492 FUNC(fma) (0.0, plus_infty, nan_value),
5493 INVALID_EXCEPTION);
5494 check_isnan_maybe_exc ("fma(0.0, -Inf, NaN) = NaN",
5495 FUNC(fma) (0.0, minus_infty, nan_value),
5496 INVALID_EXCEPTION);
5497 check_isnan_exc ("fma(+Inf, 0.0, 1.0) = NaN",
5498 FUNC(fma) (plus_infty, 0.0, 1.0), INVALID_EXCEPTION);
5499 check_isnan_exc ("fma(-Inf, 0.0, 1.0) = NaN",
5500 FUNC(fma) (minus_infty, 0.0, 1.0), INVALID_EXCEPTION);
5501 check_isnan_exc ("fma(0.0, +Inf, 1.0) = NaN",
5502 FUNC(fma) (0.0, plus_infty, 1.0), INVALID_EXCEPTION);
5503 check_isnan_exc ("fma(0.0, -Inf, 1.0) = NaN",
5504 FUNC(fma) (0.0, minus_infty, 1.0), INVALID_EXCEPTION);
5506 check_isnan_exc ("fma(+Inf, +Inf, -Inf) = NaN",
5507 FUNC(fma) (plus_infty, plus_infty, minus_infty),
5508 INVALID_EXCEPTION);
5509 check_isnan_exc ("fma(-Inf, +Inf, +Inf) = NaN",
5510 FUNC(fma) (minus_infty, plus_infty, plus_infty),
5511 INVALID_EXCEPTION);
5512 check_isnan_exc ("fma(+Inf, -Inf, +Inf) = NaN",
5513 FUNC(fma) (plus_infty, minus_infty, plus_infty),
5514 INVALID_EXCEPTION);
5515 check_isnan_exc ("fma(-Inf, -Inf, -Inf) = NaN",
5516 FUNC(fma) (minus_infty, minus_infty, minus_infty),
5517 INVALID_EXCEPTION);
5521 static void
5522 inverse_func_pair_test (const char *test_name,
5523 mathfunc f1, mathfunc inverse,
5524 MATHTYPE x, MATHTYPE epsilon)
5526 MATHTYPE a, b, difference;
5527 int result;
5529 a = f1 (x);
5530 (void) &a;
5531 b = inverse (a);
5532 (void) &b;
5534 output_new_test (test_name);
5535 result = check_equal (b, x, epsilon, &difference);
5536 output_result (test_name, result,
5537 b, x, difference, PRINT, PRINT);
5541 static void
5542 inverse_functions (void)
5544 inverse_func_pair_test ("asin(sin(x)) == x",
5545 FUNC(sin), FUNC(asin), 1.0,
5546 CHOOSE (2e-18L, 0, 3e-7L));
5547 inverse_func_pair_test ("sin(asin(x)) == x",
5548 FUNC(asin), FUNC(sin), 1.0, 0.0);
5550 inverse_func_pair_test ("acos(cos(x)) == x",
5551 FUNC(cos), FUNC(acos), 1.0,
5552 CHOOSE (4e-18L, 1e-15L, 0));
5553 inverse_func_pair_test ("cos(acos(x)) == x",
5554 FUNC(acos), FUNC(cos), 1.0, 0.0);
5555 inverse_func_pair_test ("atan(tan(x)) == x",
5556 FUNC(tan), FUNC(atan), 1.0, CHOOSE (2e-18L, 0, 0));
5557 inverse_func_pair_test ("tan(atan(x)) == x",
5558 FUNC(atan), FUNC(tan), 1.0,
5559 CHOOSE (2e-18L, 1e-15L, 2e-7));
5561 inverse_func_pair_test ("asinh(sinh(x)) == x",
5562 FUNC(sinh), FUNC(asinh), 1.0, CHOOSE (1e-18L, 0, 1e-7));
5563 inverse_func_pair_test ("sinh(asinh(x)) == x",
5564 FUNC(asinh), FUNC(sinh), 1.0,
5565 CHOOSE (2e-18L, 2e-16L, 2e-7));
5567 inverse_func_pair_test ("acosh(cosh(x)) == x",
5568 FUNC(cosh), FUNC(acosh), 1.0,
5569 CHOOSE (1e-18L, 1e-15L, 6e-8));
5570 inverse_func_pair_test ("cosh(acosh(x)) == x",
5571 FUNC(acosh), FUNC(cosh), 1.0, 0.0);
5573 inverse_func_pair_test ("atanh(tanh(x)) == x",
5574 FUNC(tanh), FUNC(atanh), 1.0, CHOOSE (1e-18L, 1e-15L, 0));
5575 inverse_func_pair_test ("tanh(atanh(x)) == x",
5576 FUNC(atanh), FUNC(tanh), 1.0, 0.0);
5580 /* Test sin and cos with the identity: sin(x)^2 + cos(x)^2 = 1. */
5581 static void
5582 identities1_test (MATHTYPE x, MATHTYPE epsilon)
5584 MATHTYPE res1, res2, res3, diff;
5585 int result;
5587 res1 = FUNC(sin) (x);
5588 (void) &res1;
5589 res2 = FUNC(cos) (x);
5590 (void) &res2;
5591 res3 = res1 * res1 + res2 * res2;
5592 (void) &res3;
5594 output_new_test ("sin^2 + cos^2 == 1");
5595 result = check_equal (res3, 1.0, epsilon, &diff);
5596 output_result_ext ("sin^2 + cos^2 == 1", result,
5597 res3, 1.0, diff, x, PRINT, PRINT);
5601 /* Test sin, cos, tan with the following relation: tan = sin/cos. */
5602 static void
5603 identities2_test (MATHTYPE x, MATHTYPE epsilon)
5605 #ifndef TEST_INLINE
5606 MATHTYPE res1, res2, res3, res4, diff;
5607 int result;
5609 res1 = FUNC(sin) (x);
5610 (void) &res1;
5611 res2 = FUNC(cos) (x);
5612 (void) &res2;
5613 res3 = FUNC(tan) (x);
5614 (void) &res3;
5615 res4 = res1 / res2;
5616 (void) &res4;
5618 output_new_test ("sin/cos == tan");
5619 result = check_equal (res4, res3, epsilon, &diff);
5620 output_result_ext ("sin/cos == tan", result,
5621 res4, res3, diff, x, PRINT, PRINT);
5622 #endif
5626 /* Test cosh and sinh with the identity cosh^2 - sinh^2 = 1. */
5627 static void
5628 identities3_test (MATHTYPE x, MATHTYPE epsilon)
5630 MATHTYPE res1, res2, res3, diff;
5631 int result;
5633 res1 = FUNC(sinh) (x);
5634 (void) &res1;
5635 res2 = FUNC(cosh) (x);
5636 (void) &res2;
5637 res3 = res2 * res2 - res1 * res1;
5638 (void) &res3;
5640 output_new_test ("cosh^2 - sinh^2 == 1");
5641 result = check_equal (res3, 1.0, epsilon, &diff);
5642 output_result_ext ("cosh^2 - sinh^2 == 1", result,
5643 res3, 1.0, diff, x, PRINT, PRINT);
5647 static void
5648 identities (void)
5650 identities1_test (0.2L, CHOOSE (1e-18L, 0, 2e-7));
5651 identities1_test (0.9L, CHOOSE (1e-18L, 0, 1e-7));
5652 identities1_test (0, 0);
5653 identities1_test (-1, CHOOSE (1e-18L, 0, 1e-7));
5655 identities2_test (0.2L, CHOOSE (1e-19L, 1e-16, 0));
5656 identities2_test (0.9L, CHOOSE (3e-19L, 1e-15, 2e-7));
5657 identities2_test (0, 0);
5658 identities2_test (-1, CHOOSE (1e-18L, 1e-15, 2e-7));
5660 identities3_test (0.2L, CHOOSE (1e-18L, 0, 1e-7));
5661 identities3_test (0.9L, CHOOSE (1e-18L, 1e-15, 1e-6));
5662 identities3_test (0, CHOOSE (0, 0, 1e-6));
5663 identities3_test (-1, CHOOSE (1e-18L, 7e-16, 1e-6));
5668 Let's test that basic arithmetic is working
5669 tests: Infinity and NaN
5671 static void
5672 basic_tests (void)
5674 /* variables are declared volatile to forbid some compiler
5675 optimizations */
5676 volatile MATHTYPE Inf_var, NaN_var, zero_var, one_var;
5677 MATHTYPE x1, x2;
5679 zero_var = 0.0;
5680 one_var = 1.0;
5681 NaN_var = nan_value;
5682 Inf_var = one_var / zero_var;
5684 (void) &zero_var;
5685 (void) &one_var;
5686 (void) &NaN_var;
5687 (void) &Inf_var;
5689 /* Clear all exceptions. The previous computations raised exceptions. */
5690 feclearexcept (FE_ALL_EXCEPT);
5692 check_isinfp ("isinf (inf) == +1", Inf_var);
5693 check_isinfn ("isinf (-inf) == -1", -Inf_var);
5694 check_bool ("!isinf (1)", !(FUNC(isinf) (one_var)));
5695 check_bool ("!isinf (NaN)", !(FUNC(isinf) (NaN_var)));
5697 check_isnan ("isnan (NaN)", NaN_var);
5698 check_isnan ("isnan (-NaN)", -NaN_var);
5699 check_bool ("!isnan (1)", !(FUNC(isnan) (one_var)));
5700 check_bool ("!isnan (inf)", !(FUNC(isnan) (Inf_var)));
5702 check_bool ("inf == inf", Inf_var == Inf_var);
5703 check_bool ("-inf == -inf", -Inf_var == -Inf_var);
5704 check_bool ("inf != -inf", Inf_var != -Inf_var);
5705 check_bool ("NaN != NaN", NaN_var != NaN_var);
5708 the same tests but this time with NAN from <bits/nan.h>
5709 NAN is a double const
5711 check_bool ("isnan (NAN)", isnan (NAN));
5712 check_bool ("isnan (-NAN)", isnan (-NAN));
5713 check_bool ("!isinf (NAN)", !(isinf (NAN)));
5714 check_bool ("!isinf (-NAN)", !(isinf (-NAN)));
5715 check_bool ("NAN != NAN", NAN != NAN);
5718 And again with the value returned by the `nan' function.
5720 check_bool ("isnan (NAN)", FUNC(isnan) (FUNC(nan) ("")));
5721 check_bool ("isnan (-NAN)", FUNC(isnan) (-FUNC(nan) ("")));
5722 check_bool ("!isinf (NAN)", !(FUNC(isinf) (FUNC(nan) (""))));
5723 check_bool ("!isinf (-NAN)", !(FUNC(isinf) (-FUNC(nan) (""))));
5724 check_bool ("NAN != NAN", FUNC(nan) ("") != FUNC(nan) (""));
5726 /* test if EPSILON is ok */
5727 x1 = MATHCONST (1.0);
5728 x2 = x1 + CHOOSE (LDBL_EPSILON, DBL_EPSILON, FLT_EPSILON);
5729 check_bool ("1 != 1+EPSILON", x1 != x2);
5731 x1 = MATHCONST (1.0);
5732 x2 = x1 - CHOOSE (LDBL_EPSILON, DBL_EPSILON, FLT_EPSILON);
5733 check_bool ("1 != 1-EPSILON", x1 != x2);
5735 /* test if HUGE_VALx is ok */
5736 x1 = CHOOSE (HUGE_VALL, HUGE_VAL, HUGE_VALF);
5737 check_bool ("isinf (HUGE_VALx) == +1", ISINF (x1) == +1);
5738 x1 = -CHOOSE (HUGE_VALL, HUGE_VAL, HUGE_VALF);
5739 check_bool ("isinf (-HUGE_VALx) == -1", ISINF (x1) == -1);
5744 static void
5745 initialize (void)
5747 fpstack_test ("start *init*");
5748 plus_zero = 0.0;
5749 nan_value = plus_zero / plus_zero; /* Suppress GCC warning */
5751 minus_zero = FUNC (copysign) (0.0, -1.0);
5752 plus_infty = CHOOSE (HUGE_VALL, HUGE_VAL, HUGE_VALF);
5753 minus_infty = -CHOOSE (HUGE_VALL, HUGE_VAL, HUGE_VALF);
5755 (void) &plus_zero;
5756 (void) &nan_value;
5757 (void) &minus_zero;
5758 (void) &plus_infty;
5759 (void) &minus_infty;
5761 /* Clear all exceptions. From now on we must not get random exceptions. */
5762 feclearexcept (FE_ALL_EXCEPT);
5764 /* Test to make sure we start correctly. */
5765 fpstack_test ("end *init*");
5769 static struct option long_options[] =
5771 {"verbose", optional_argument, NULL, 'v'},
5772 {"silent", no_argument, NULL, 's'},
5773 {0, 0, 0, 0}
5777 static void
5778 parse_options (int argc, char *argv[])
5780 int c;
5781 int option_index;
5783 verbose = 1;
5785 while (1)
5787 c = getopt_long (argc, argv, "v::s",
5788 long_options, &option_index);
5790 /* Detect the end of the options. */
5791 if (c == -1)
5792 break;
5794 switch (c)
5796 case 'v':
5797 if (optarg)
5798 verbose = (unsigned int) strtoul (optarg, NULL, 0);
5799 else
5800 verbose = 4;
5801 break;
5802 case 's':
5803 verbose = 0;
5804 default:
5805 break;
5812 main (int argc, char *argv[])
5815 parse_options (argc, argv);
5817 initialize ();
5818 printf (TEST_MSG);
5820 basic_tests ();
5822 /* keep the tests a wee bit ordered (according to ISO 9X) */
5823 /* classification functions */
5824 fpclassify_test ();
5825 isfinite_test ();
5826 isnormal_test ();
5827 signbit_test ();
5829 /* trigonometric functions */
5830 acos_test ();
5831 asin_test ();
5832 atan_test ();
5833 atan2_test ();
5834 cos_test ();
5835 sin_test ();
5836 sincos_test ();
5837 tan_test ();
5839 /* hyperbolic functions */
5840 acosh_test ();
5841 asinh_test ();
5842 atanh_test ();
5843 cosh_test ();
5844 sinh_test ();
5845 tanh_test ();
5847 /* exponential and logarithmic functions */
5848 exp_test ();
5849 exp2_test ();
5850 expm1_test ();
5851 frexp_test ();
5852 ldexp_test ();
5853 log_test ();
5854 log10_test ();
5855 log1p_test ();
5856 log2_test ();
5857 logb_test ();
5858 modf_test ();
5859 ilogb_test ();
5860 scalb_test ();
5861 scalbn_test ();
5863 /* power and absolute value functions */
5864 cbrt_test ();
5865 fabs_test ();
5866 hypot_test ();
5867 pow_test ();
5868 sqrt_test ();
5870 /* error and gamma functions */
5871 erf_test ();
5872 erfc_test ();
5873 gamma_test ();
5874 lgamma_test ();
5876 /* nearest integer functions */
5877 ceil_test ();
5878 floor_test ();
5879 nearbyint_test ();
5880 rint_test ();
5881 lrint_test ();
5882 llrint_test ();
5883 round_test ();
5884 lround_test ();
5885 llround_test ();
5886 trunc_test ();
5888 /* remainder functions */
5889 fmod_test ();
5890 remainder_test ();
5891 remquo_test ();
5893 /* manipulation functions */
5894 copysign_test ();
5895 nextafter_test ();
5897 /* maximum, minimum and positive difference functions */
5898 fdim_test ();
5899 fmin_test ();
5900 fmax_test ();
5902 /* complex functions */
5903 cabs_test ();
5904 carg_test ();
5905 cexp_test ();
5906 csin_test ();
5907 csinh_test ();
5908 ccos_test ();
5909 ccosh_test ();
5910 clog_test ();
5911 clog10_test ();
5912 cacos_test ();
5913 cacosh_test ();
5914 casin_test ();
5915 casinh_test ();
5916 catan_test ();
5917 catanh_test ();
5918 ctan_test ();
5919 ctanh_test ();
5920 csqrt_test ();
5921 cpow_test ();
5923 /* multiply and add */
5924 fma_test ();
5926 /* special tests */
5927 identities ();
5928 inverse_functions ();
5930 printf ("\nTest suite completed:\n");
5931 printf (" %d test cases plus %d tests for exception flags executed.\n",
5932 noTests, noExcTests);
5933 if (noErrors)
5935 printf (" %d errors occured.\n", noErrors);
5936 exit (1);
5938 printf (" All tests passed successfully.\n");
5939 exit (0);