(connect): Change to __connect, add alias.
[glibc/history.git] / math / libm-test.c
blob5b773d6bd84188d8b2a1c8a64bae1c21b5c2f20a
1 /* Copyright (C) 1997 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Andreas Jaeger <aj@arthur.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"
41 /* This program isn't finished yet.
42 It has tests for:
43 acos, acosh, asin, asinh, atan, atan2, atanh,
44 cbrt, ceil, copysign, cos, cosh, erf, erfc, exp, exp2, expm1,
45 fabs, fdim, floor, fmin, fmax, fmod, fpclassify,
46 frexp, gamma, hypot,
47 ilogb, isfinite, isinf, isnan, isnormal,
48 ldexp, lgamma, log, log10, log1p, log2, logb,
49 modf, nearbyint, nextafter,
50 pow, remainder, remquo, rint, lrint, llrint,
51 round, lround, llround,
52 scalb, scalbn, signbit, sin, sincos, sinh, sqrt, tan, tanh, trunc
54 and for the following complex math functions:
55 cacos, cacosh, casin, casinh, catan, catanh,
56 ccos, ccosh, cexp, clog, cpow, csin, csinh, csqrt, ctanh.
58 At the moment the following functions aren't tested:
59 cabs, carg, conj, cproj, cimag, creal, ctan, drem,
60 j0, j1, jn, y0, y1, yn,
61 significand,
62 nan, comparison macros (isless,isgreater,...).
64 The routines using random variables are still under construction. I don't
65 like it the way it's working now and will change it.
67 Parameter handling is primitive in the moment:
68 --verbose=[0..4] for different levels of output:
69 0: only error count
70 1: basic report on failed tests (default)
71 2: full report on failed tests
72 3: full report on failed and passed tests
73 4: additional report on exceptions
74 -v for full output (equals --verbose=4)
75 -s,--silent outputs only the error count (equals --verbose=0)
78 /* "Philosophy":
80 This suite tests the correct implementation of mathematical
81 functions in libm. Some simple, specific parameters are tested for
82 correctness. Handling of specific inputs (e.g. infinity,
83 not-a-number) is also tested. Correct handling of exceptions is
84 checked against. These implemented tests should check all cases
85 that are specified in ISO C 9X.
87 Exception testing: At the moment only divide-by-zero and invalid
88 exceptions are tested. Overflow/underflow and inexact exceptions
89 aren't checked at the moment.
91 NaN values: There exist signalling and quiet NaNs. This implementation
92 only uses signalling NaN as parameter but does not differenciate
93 between the two kinds of NaNs as result.
95 Inline functions: Inlining functions should give an improvement in
96 speed - but not in precission. The inlined functions return
97 reasonable values for a reasonable range of input values. The
98 result is not necessarily correct for all values and exceptions are
99 not correctly raised in all cases. Problematic input and return
100 values are infinity, not-a-number and minus zero. This suite
101 therefore does not check these specific inputs and the exception
102 handling for inlined mathematical functions - just the "reasonable"
103 values are checked.
105 Beware: The tests might fail for any of the following reasons:
106 - Tests are wrong
107 - Functions are wrong
108 - Floating Point Unit not working properly
109 - Compiler has errors
111 With e.g. gcc 2.7.2.2 the test for cexp fails because of a compiler error.
115 #ifndef _GNU_SOURCE
116 # define _GNU_SOURCE
117 #endif
119 #include <complex.h>
120 #include <math.h>
121 #include <float.h>
122 #include <fenv.h>
124 #include <errno.h>
125 #include <stdlib.h>
126 #include <stdio.h>
127 #include <getopt.h>
129 /* Possible exceptions */
130 #define NO_EXCEPTION 0x0
131 #define INVALID_EXCEPTION 0x1
132 #define DIVIDE_BY_ZERO_EXCEPTION 0x2
134 #define PRINT 1
135 #define NO_PRINT 0
137 /* Various constants (we must supply them precalculated for accuracy). */
138 #define M_PI_6 .52359877559829887308L
140 static int noErrors;
142 static int verbose = 3;
143 static MATHTYPE minus_zero, plus_zero;
144 static MATHTYPE plus_infty, minus_infty, nan_value;
146 typedef MATHTYPE (*mathfunc) (MATHTYPE);
148 #define BUILD_COMPLEX(real, imag) \
149 ({ __complex__ MATHTYPE __retval; \
150 __real__ __retval = (real); \
151 __imag__ __retval = (imag); \
152 __retval; })
155 #define ISINF(x) \
156 (sizeof (x) == sizeof (float) ? \
157 isinff (x) \
158 : sizeof (x) == sizeof (double) ? \
159 isinf (x) : isinfl (x))
163 Test if Floating-Point stack hasn't changed
165 static void
166 fpstack_test (const char *test_name)
168 #ifdef i386
169 static int old_stack;
170 int sw;
171 asm ("fnstsw":"=a" (sw));
172 sw >>= 11;
173 sw &= 7;
174 if (sw != old_stack)
176 printf ("FP-Stack wrong after test %s\n", test_name);
177 if (verbose > 2)
178 printf ("=======> stack = %d\n", sw);
179 ++noErrors;
180 old_stack = sw;
182 #endif
187 Get a random value x with min_value < x < max_value
188 and min_value, max_value finite,
189 max_value and min_value shouldn't be too close together
191 static MATHTYPE
192 random_value (MATHTYPE min_value, MATHTYPE max_value)
194 int r;
195 MATHTYPE x;
197 r = rand ();
199 x = (max_value - min_value) / RAND_MAX * (MATHTYPE) r + min_value;
201 if ((x <= min_value) || (x >= max_value) || !isfinite (x))
202 x = (max_value - min_value) / 2 + min_value;
204 /* Make sure the RNG has no influence on the exceptions. */
205 feclearexcept (FE_ALL_EXCEPT);
207 return x;
210 /* Get a random value x with x > min_value. */
211 static MATHTYPE
212 random_greater (MATHTYPE min_value)
214 return random_value (min_value, 1e6); /* CHOOSE (LDBL_MAX, DBL_MAX, FLT_MAX) */
217 /* Get a random value x with x < max_value. */
218 static MATHTYPE
219 random_less (MATHTYPE max_value)
221 return random_value (-1e6, max_value);
225 static void
226 output_new_test (const char *test_name)
228 if (verbose > 2)
229 printf ("\nTesting: %s\n", test_name);
233 static void
234 output_pass_value (void)
236 if (verbose > 2)
237 printf ("Pass: Value Ok.\n");
241 static void
242 output_fail_value (const char * test_name)
244 if (verbose > 0 && verbose < 3)
245 printf ("Fail: %s\n", test_name);
246 if (verbose >= 3)
247 printf ("Fail:\n");
251 /* Test whether a given exception was raised. */
252 static void
253 test_single_exception (const char *test_name,
254 short int exception,
255 short int exc_flag,
256 int fe_flag,
257 const char *flag_name)
259 #ifndef TEST_INLINE
260 if (exception & exc_flag)
262 if (fetestexcept (fe_flag))
264 if (verbose > 3)
265 printf ("Pass: Exception \"%s\" set\n", flag_name);
267 else
269 if (verbose && verbose < 3)
270 printf ("Fail: %s: Exception \"%s\" not set\n",
271 test_name, flag_name);
272 if (verbose >= 3)
273 printf ("Fail: Exception \"%s\" not set\n",
274 flag_name);
275 ++noErrors;
278 else
280 if (fetestexcept (fe_flag))
282 if (verbose && verbose < 3)
283 printf ("Fail: %s: Exception \"%s\" set\n",
284 test_name, flag_name);
285 if (verbose >= 3)
286 printf ("Fail: Exception \"%s\" set\n",
287 flag_name);
288 ++noErrors;
290 else
292 if (verbose > 3)
293 printf ("Pass: Exception \"%s\" not set\n",
294 flag_name);
297 #endif
301 /* Test whether exception given by EXCEPTION are raised. */
302 static void
303 test_not_exception (const char *test_name, short int exception)
305 #ifdef FE_DIVBYZERO
306 if ((exception & DIVIDE_BY_ZERO_EXCEPTION) == 0)
307 test_single_exception (test_name, exception,
308 DIVIDE_BY_ZERO_EXCEPTION, FE_DIVBYZERO,
309 "Divide by zero");
310 #endif
311 #ifdef FE_INVALID
312 if ((exception & INVALID_EXCEPTION) == 0)
313 test_single_exception (test_name, exception, INVALID_EXCEPTION, FE_INVALID,
314 "Invalid operation");
315 #endif
316 feclearexcept (FE_ALL_EXCEPT);
320 /* Test whether exceptions given by EXCEPTION are raised. */
321 static void
322 test_exceptions (const char *test_name, short int exception)
324 #ifdef FE_DIVBYZERO
325 test_single_exception (test_name, exception,
326 DIVIDE_BY_ZERO_EXCEPTION, FE_DIVBYZERO,
327 "Divide by zero");
328 #endif
329 #ifdef FE_INVALID
330 test_single_exception (test_name, exception, INVALID_EXCEPTION, FE_INVALID,
331 "Invalid operation");
332 #endif
333 feclearexcept (FE_ALL_EXCEPT);
337 /* Test if two floating point numbers are equal. */
338 static int
339 check_equal (MATHTYPE computed, MATHTYPE supplied, MATHTYPE eps, MATHTYPE * diff)
341 int ret_value;
343 /* Both plus Infinity or both minus infinity. */
344 if (ISINF (computed) && (ISINF (computed) == ISINF (supplied)))
345 return 1;
347 if (isnan (computed) && isnan (supplied)) /* isnan works for all types */
348 return 1;
350 *diff = FUNC(fabs) (computed - supplied);
353 ret_value = (*diff <= eps &&
354 (signbit (computed) == signbit (supplied) || eps != 0.0));
356 /* Make sure the subtraction/comparsion have no influence on the exceptions. */
357 feclearexcept (FE_ALL_EXCEPT);
359 return ret_value;
364 static void
365 output_result_bool (const char *test_name, int result)
367 if (result)
369 output_pass_value ();
371 else
373 output_fail_value (test_name);
374 if (verbose > 1)
375 printf (" Value: %d\n", result);
376 ++noErrors;
379 fpstack_test (test_name);
383 static void
384 output_isvalue (const char *test_name, int result,
385 MATHTYPE value)
387 if (result)
389 output_pass_value ();
391 else
393 output_fail_value (test_name);
394 if (verbose > 1)
395 printf (" Value: %.20" PRINTF_EXPR "\n", value);
396 noErrors++;
399 fpstack_test (test_name);
403 static void
404 output_isvalue_ext (const char *test_name, int result,
405 MATHTYPE value, MATHTYPE parameter)
407 if (result)
409 output_pass_value ();
411 else
413 output_fail_value (test_name);
414 if (verbose > 1)
416 printf (" Value: %.20" PRINTF_EXPR "\n", value);
417 printf (" Parameter: %.20" PRINTF_EXPR "\n", parameter);
419 noErrors++;
422 fpstack_test (test_name);
426 static void
427 output_result (const char *test_name, int result,
428 MATHTYPE computed, MATHTYPE expected,
429 MATHTYPE difference,
430 int print_values, int print_diff)
432 if (result)
434 output_pass_value ();
436 else
438 output_fail_value (test_name);
439 if (verbose > 1 && print_values)
441 printf ("Result:\n");
442 printf (" is: %.20" PRINTF_EXPR "\n", computed);
443 printf (" should be: %.20" PRINTF_EXPR "\n", expected);
444 if (print_diff)
445 printf (" difference: %.20" PRINTF_EXPR "\n", difference);
447 noErrors++;
450 fpstack_test (test_name);
454 static void
455 output_result_ext (const char *test_name, int result,
456 MATHTYPE computed, MATHTYPE expected,
457 MATHTYPE difference,
458 MATHTYPE parameter,
459 int print_values, int print_diff)
461 if (result)
463 output_pass_value ();
465 else
467 output_fail_value (test_name);
468 if (verbose > 1 && print_values)
470 printf ("Result:\n");
471 printf (" is: %.20" PRINTF_EXPR "\n", computed);
472 printf (" should be: %.20" PRINTF_EXPR "\n", expected);
473 if (print_diff)
474 printf (" difference: %.20" PRINTF_EXPR "\n", difference);
475 printf ("Parameter: %.20" PRINTF_EXPR "\n", parameter);
477 noErrors++;
480 fpstack_test (test_name);
484 check that computed and expected values are the same
486 static void
487 check (const char *test_name, MATHTYPE computed, MATHTYPE expected)
489 MATHTYPE diff;
490 int result;
492 output_new_test (test_name);
493 test_exceptions (test_name, NO_EXCEPTION);
494 result = check_equal (computed, expected, 0, &diff);
495 output_result (test_name, result,
496 computed, expected, diff, PRINT, PRINT);
501 check that computed and expected values are the same,
502 outputs the parameter to the function
504 static void
505 check_ext (const char *test_name, MATHTYPE computed, MATHTYPE expected,
506 MATHTYPE parameter)
508 MATHTYPE diff;
509 int result;
511 output_new_test (test_name);
512 test_exceptions (test_name, NO_EXCEPTION);
513 result = check_equal (computed, expected, 0, &diff);
514 output_result_ext (test_name, result,
515 computed, expected, diff, parameter, PRINT, PRINT);
520 check that computed and expected values are the same and
521 checks also for exception flags
523 static void
524 check_exc (const char *test_name, MATHTYPE computed, MATHTYPE expected,
525 short exception)
527 MATHTYPE diff;
528 int result;
530 output_new_test (test_name);
531 test_exceptions (test_name, exception);
532 result = check_equal (computed, expected, 0, &diff);
533 output_result (test_name, result,
534 computed, expected, diff, PRINT, PRINT);
538 check that computed and expected values are close enough
540 static void
541 check_eps (const char *test_name, MATHTYPE computed, MATHTYPE expected,
542 MATHTYPE epsilon)
544 MATHTYPE diff;
545 int result;
547 output_new_test (test_name);
548 test_exceptions (test_name, NO_EXCEPTION);
549 result = check_equal (computed, expected, epsilon, &diff);
550 output_result (test_name, result,
551 computed, expected, diff, PRINT, PRINT);
555 check a boolean condition
557 static void
558 check_bool (const char *test_name, int computed)
560 output_new_test (test_name);
561 test_exceptions (test_name, NO_EXCEPTION);
562 output_result_bool (test_name, computed);
568 check that computed and expected values are equal (int values)
570 static void
571 check_int (const char *test_name, int computed, int expected)
573 int diff = computed - expected;
574 int result = diff == 0;
576 output_new_test (test_name);
577 test_exceptions (test_name, NO_EXCEPTION);
579 if (result)
581 output_pass_value ();
583 else
585 output_fail_value (test_name);
586 if (verbose > 1)
588 printf ("Result:\n");
589 printf (" is: %d\n", computed);
590 printf (" should be: %d\n", expected);
592 noErrors++;
595 fpstack_test (test_name);
600 check that computed and expected values are equal (long int values)
602 static void
603 check_long (const char *test_name, long int computed, long int expected)
605 long int diff = computed - expected;
606 int result = diff == 0;
608 output_new_test (test_name);
609 test_exceptions (test_name, NO_EXCEPTION);
611 if (result)
613 output_pass_value ();
615 else
617 output_fail_value (test_name);
618 if (verbose > 1)
620 printf ("Result:\n");
621 printf (" is: %ld\n", computed);
622 printf (" should be: %ld\n", expected);
624 noErrors++;
627 fpstack_test (test_name);
631 check that computed and expected values are equal (long long int values)
633 static void
634 check_longlong (const char *test_name, long long int computed,
635 long long int expected)
637 long long int diff = computed - expected;
638 int result = diff == 0;
640 output_new_test (test_name);
641 test_exceptions (test_name, NO_EXCEPTION);
643 if (result)
645 output_pass_value ();
647 else
649 output_fail_value (test_name);
650 if (verbose > 1)
652 printf ("Result:\n");
653 printf (" is: %lld\n", computed);
654 printf (" should be: %lld\n", expected);
656 noErrors++;
659 fpstack_test (test_name);
663 check that computed value is not-a-number
665 static void
666 check_isnan (const char *test_name, MATHTYPE computed)
668 output_new_test (test_name);
669 test_exceptions (test_name, NO_EXCEPTION);
670 output_isvalue (test_name, isnan (computed), computed);
675 check that computed value is not-a-number and test for exceptions
677 static void
678 check_isnan_exc (const char *test_name, MATHTYPE computed,
679 short exception)
681 output_new_test (test_name);
682 test_exceptions (test_name, exception);
683 output_isvalue (test_name, isnan (computed), computed);
688 check that computed value is not-a-number and test for exceptions
690 static void
691 check_isnan_maybe_exc (const char *test_name, MATHTYPE computed,
692 short exception)
694 output_new_test (test_name);
695 test_not_exception (test_name, exception);
696 output_isvalue (test_name, isnan (computed), computed);
700 check that computed value is not-a-number and supply parameter
702 #ifndef TEST_INLINE
703 static void
704 check_isnan_ext (const char *test_name, MATHTYPE computed,
705 MATHTYPE parameter)
707 output_new_test (test_name);
708 test_exceptions (test_name, NO_EXCEPTION);
709 output_isvalue_ext (test_name, isnan (computed), computed, parameter);
711 #endif
714 check that computed value is not-a-number, test for exceptions
715 and supply parameter
717 static void
718 check_isnan_exc_ext (const char *test_name, MATHTYPE computed,
719 short exception, MATHTYPE parameter)
721 output_new_test (test_name);
722 test_exceptions (test_name,exception);
723 output_isvalue_ext (test_name, isnan (computed), computed, parameter);
727 /* Tests if computed is +Inf */
728 static void
729 check_isinfp (const char *test_name, MATHTYPE computed)
731 output_new_test (test_name);
732 test_exceptions (test_name, NO_EXCEPTION);
733 output_isvalue (test_name, (ISINF (computed) == +1), computed);
737 static void
738 check_isinfp_ext (const char *test_name, MATHTYPE computed,
739 MATHTYPE parameter)
741 output_new_test (test_name);
742 test_exceptions (test_name, NO_EXCEPTION);
743 output_isvalue_ext (test_name, (ISINF (computed) == +1), computed, parameter);
747 /* Tests if computed is +Inf */
748 static void
749 check_isinfp_exc (const char *test_name, MATHTYPE computed,
750 int exception)
752 output_new_test (test_name);
753 test_exceptions (test_name, exception);
754 output_isvalue (test_name, (ISINF (computed) == +1), computed);
757 /* Tests if computed is -Inf */
758 static void
759 check_isinfn (const char *test_name, MATHTYPE computed)
761 output_new_test (test_name);
762 test_exceptions (test_name, NO_EXCEPTION);
763 output_isvalue (test_name, (ISINF (computed) == -1), computed);
767 #ifndef TEST_INLINE
768 static void
769 check_isinfn_ext (const char *test_name, MATHTYPE computed,
770 MATHTYPE parameter)
772 output_new_test (test_name);
773 test_exceptions (test_name, NO_EXCEPTION);
774 output_isvalue_ext (test_name, (ISINF (computed) == -1), computed, parameter);
776 #endif
779 /* Tests if computed is -Inf */
780 static void
781 check_isinfn_exc (const char *test_name, MATHTYPE computed,
782 int exception)
784 output_new_test (test_name);
785 test_exceptions (test_name, exception);
786 output_isvalue (test_name, (ISINF (computed) == -1), computed);
790 /* This is to prevent messages from the SVID libm emulation. */
792 matherr (struct exception *x __attribute__ ((unused)))
794 return 1;
798 /****************************************************************************
799 Test for single functions of libm
800 ****************************************************************************/
802 static void
803 acos_test (void)
805 #ifndef TEST_INLINE
806 MATHTYPE x;
808 x = random_greater (1);
809 check_isnan_exc ("acos (x) == NaN plus invalid exception for |x| > 1",
810 FUNC(acos) (x),
811 INVALID_EXCEPTION);
813 x = random_less (1);
814 check_isnan_exc ("acos (x) == NaN plus invalid exception for |x| > 1",
815 FUNC(acos) (x),
816 INVALID_EXCEPTION);
817 #endif
819 check ("acos (1) == 0", FUNC(acos) (1), 0);
820 check ("acos (-1) == pi", FUNC(acos) (-1), M_PI);
824 static void
825 acosh_test (void)
827 #ifndef TEST_INLINE
828 MATHTYPE x;
830 check_isinfp ("acosh(+inf) == +inf", FUNC(acosh) (plus_infty));
832 x = random_less (1);
833 check_isnan_exc ("acosh(x) == NaN plus invalid exception if x < 1",
834 FUNC(acosh) (x), INVALID_EXCEPTION);
835 #endif
837 check ("acosh(1) == 0", FUNC(acosh) (1), 0);
841 static void
842 asin_test (void)
844 #ifndef TEST_INLINE
845 MATHTYPE x;
847 x = random_greater (1);
848 check_isnan_exc ("asin x == NaN plus invalid exception for |x| > 1",
849 FUNC(asin) (x),
850 INVALID_EXCEPTION);
852 x = random_less (1);
853 check_isnan_exc ("asin x == NaN plus invalid exception for |x| > 1",
854 FUNC(asin) (x),
855 INVALID_EXCEPTION);
856 #endif
858 check ("asin (0) == 0", FUNC(asin) (0), 0);
862 static void
863 asinh_test (void)
866 check ("asinh(+0) == +0", FUNC(asinh) (0), 0);
867 #ifndef TEST_INLINE
868 check ("asinh(-0) == -0", FUNC(asinh) (minus_zero), minus_zero);
869 check_isinfp ("asinh(+inf) == +inf", FUNC(asinh) (plus_infty));
870 check_isinfn ("asinh(-inf) == -inf", FUNC(asinh) (minus_infty));
871 #endif
876 static void
877 atan_test (void)
879 check ("atan (0) == 0", FUNC(atan) (0), 0);
880 check ("atan (-0) == -0", FUNC(atan) (minus_zero), minus_zero);
882 check ("atan (+inf) == pi/2", FUNC(atan) (plus_infty), M_PI_2);
883 check ("atan (-inf) == -pi/2", FUNC(atan) (minus_infty), -M_PI_2);
887 static void
888 atan2_test (void)
890 MATHTYPE x;
892 x = random_greater (0);
893 check ("atan2 (0,x) == 0 for x > 0",
894 FUNC(atan2) (0, x), 0);
895 x = random_greater (0);
896 check ("atan2 (-0,x) == -0 for x > 0",
897 FUNC(atan2) (minus_zero, x), minus_zero);
899 check ("atan2 (+0,+0) == +0", FUNC(atan2) (0, 0), 0);
900 check ("atan2 (-0,+0) == -0", FUNC(atan2) (minus_zero, 0), minus_zero);
902 x = -random_greater (0);
903 check ("atan2 (+0,x) == +pi for x < 0", FUNC(atan2) (0, x), M_PI);
905 x = -random_greater (0);
906 check ("atan2 (-0,x) == -pi for x < 0", FUNC(atan2) (minus_zero, x), -M_PI);
908 check ("atan2 (+0,-0) == +pi", FUNC(atan2) (0, minus_zero), M_PI);
909 check ("atan2 (-0,-0) == -pi", FUNC(atan2) (minus_zero, minus_zero), -M_PI);
911 x = random_greater (0);
912 check ("atan2 (y,+0) == pi/2 for y > 0", FUNC(atan2) (x, 0), M_PI_2);
914 x = random_greater (0);
915 check ("atan2 (y,-0) == pi/2 for y > 0", FUNC(atan2) (x, minus_zero), M_PI_2);
917 x = random_less (0);
918 check ("atan2 (y,+0) == -pi/2 for y < 0", FUNC(atan2) (x, 0), -M_PI_2);
920 x = random_less (0);
921 check ("atan2 (y,-0) == -pi/2 for y < 0", FUNC(atan2) (x, minus_zero), -M_PI_2);
923 x = random_greater (0);
924 check ("atan2 (y,inf) == +0 for finite y > 0",
925 FUNC(atan2) (x, plus_infty), 0);
927 x = -random_greater (0);
928 check ("atan2 (y,inf) == -0 for finite y < 0",
929 FUNC(atan2) (x, plus_infty), minus_zero);
931 x = random_value (-1e4, 1e4);
932 check ("atan2(+inf, x) == pi/2 for finite x",
933 FUNC(atan2) (plus_infty, x), M_PI_2);
935 x = random_value (-1e4, 1e4);
936 check ("atan2(-inf, x) == -pi/2 for finite x",
937 FUNC(atan2) (minus_infty, x), -M_PI_2);
939 x = random_greater (0);
940 check ("atan2 (y,-inf) == +pi for finite y > 0",
941 FUNC(atan2) (x, minus_infty), M_PI);
943 x = -random_greater (0);
944 check ("atan2 (y,-inf) == -pi for finite y < 0",
945 FUNC(atan2) (x, minus_infty), -M_PI);
947 check ("atan2 (+inf,+inf) == +pi/4",
948 FUNC(atan2) (plus_infty, plus_infty), M_PI_4);
950 check ("atan2 (-inf,+inf) == -pi/4",
951 FUNC(atan2) (minus_infty, plus_infty), -M_PI_4);
953 check ("atan2 (+inf,-inf) == +3*pi/4",
954 FUNC(atan2) (plus_infty, minus_infty), 3 * M_PI_4);
956 check ("atan2 (-inf,-inf) == -3*pi/4",
957 FUNC(atan2) (minus_infty, minus_infty), -3 * M_PI_4);
959 /* FIXME: Add some specific tests */
963 static void
964 atanh_test (void)
966 #ifndef TEST_INLINE
967 MATHTYPE x;
968 #endif
970 check ("atanh(+0) == +0", FUNC(atanh) (0), 0);
971 #ifndef TEST_INLINE
972 check ("atanh(-0) == -0", FUNC(atanh) (minus_zero), minus_zero);
974 check_isinfp_exc ("atanh(+1) == +inf plus divide-by-zero exception",
975 FUNC(atanh) (1), DIVIDE_BY_ZERO_EXCEPTION);
976 check_isinfn_exc ("atanh(-1) == -inf plus divide-by-zero exception",
977 FUNC(atanh) (-1), DIVIDE_BY_ZERO_EXCEPTION);
979 x = random_greater (1.0);
980 check_isnan_exc_ext ("atanh (x) == NaN plus invalid exception if |x| > 1",
981 FUNC(atanh) (x), INVALID_EXCEPTION, x);
983 x = random_less (1.0);
984 check_isnan_exc_ext ("atanh (x) == NaN plus invalid exception if |x| > 1",
985 FUNC(atanh) (x), INVALID_EXCEPTION, x);
987 #endif
991 static void
992 cbrt_test (void)
994 check ("cbrt (+0) == +0", FUNC(cbrt) (0.0), 0.0);
995 check ("cbrt (-0) == -0", FUNC(cbrt) (minus_zero), minus_zero);
997 #ifndef TEST_INLINE
998 check_isinfp ("cbrt (+inf) == +inf", FUNC(cbrt) (plus_infty));
999 check_isinfn ("cbrt (-inf) == -inf", FUNC(cbrt) (minus_infty));
1000 check_isnan ("cbrt (NaN) == NaN", FUNC(cbrt) (nan_value));
1001 #endif
1002 check ("cbrt (-0.001) == -0.1", FUNC(cbrt) (-0.001), -0.1);
1003 check_eps ("cbrt (8) == 2", FUNC(cbrt) (8), 2, CHOOSE (5e-17L, 0, 0));
1004 check_eps ("cbrt (-27) == -3", FUNC(cbrt) (-27.0), -3.0,
1005 CHOOSE (3e-16L, 0, 0));
1009 static void
1010 ceil_test (void)
1012 check ("ceil (+0) == +0", FUNC(ceil) (0.0), 0.0);
1013 check ("ceil (-0) == -0", FUNC(ceil) (minus_zero), minus_zero);
1014 check_isinfp ("ceil (+inf) == +inf", FUNC(ceil) (plus_infty));
1015 check_isinfn ("ceil (-inf) == -inf", FUNC(ceil) (minus_infty));
1017 check ("ceil (pi) == 4", FUNC(ceil) (M_PI), 4.0);
1018 check ("ceil (-pi) == -3", FUNC(ceil) (-M_PI), -3.0);
1022 static void
1023 cos_test (void)
1026 check ("cos (+0) == 1", FUNC(cos) (0), 1);
1027 check ("cos (-0) == 1", FUNC(cos) (minus_zero), 1);
1028 check_isnan_exc ("cos (+inf) == NaN plus invalid exception",
1029 FUNC(cos) (plus_infty),
1030 INVALID_EXCEPTION);
1031 check_isnan_exc ("cos (-inf) == NaN plus invalid exception",
1032 FUNC(cos) (minus_infty),
1033 INVALID_EXCEPTION);
1035 check_eps ("cos (pi/3) == 0.5", FUNC(cos) (M_PI_6 * 2.0),
1036 0.5, CHOOSE (4e-18L, 1e-15L, 1e-7L));
1037 check_eps ("cos (pi/2) == 0", FUNC(cos) (M_PI_2),
1038 0, CHOOSE (1e-19L, 1e-16L, 1e-7L));
1042 static void
1043 cosh_test (void)
1045 check ("cosh (+0) == 1", FUNC(cosh) (0), 1);
1046 check ("cosh (-0) == 1", FUNC(cosh) (minus_zero), 1);
1048 #ifndef TEST_INLINE
1049 check_isinfp ("cosh (+inf) == +inf", FUNC(cosh) (plus_infty));
1050 check_isinfp ("cosh (-inf) == +inf", FUNC(cosh) (minus_infty));
1051 #endif
1055 static void
1056 erf_test (void)
1058 errno = 0;
1059 FUNC(erf) (0);
1060 if (errno == ENOSYS)
1061 /* Function not implemented. */
1062 return;
1064 check ("erf (+0) == +0", FUNC(erf) (0), 0);
1065 check ("erf (-0) == -0", FUNC(erf) (minus_zero), minus_zero);
1066 check ("erf (+inf) == +1", FUNC(erf) (plus_infty), 1);
1067 check ("erf (-inf) == -1", FUNC(erf) (minus_infty), -1);
1071 static void
1072 erfc_test (void)
1074 errno = 0;
1075 FUNC(erfc) (0);
1076 if (errno == ENOSYS)
1077 /* Function not implemented. */
1078 return;
1080 check ("erfc (+inf) == 0", FUNC(erfc) (plus_infty), 0.0);
1081 check ("erfc (-inf) == 2", FUNC(erfc) (minus_infty), 2.0);
1082 check ("erfc (+0) == 1", FUNC(erfc) (0.0), 1.0);
1083 check ("erfc (-0) == 1", FUNC(erfc) (minus_zero), 1.0);
1087 static void
1088 exp_test (void)
1090 check ("exp (+0) == 1", FUNC(exp) (0), 1);
1091 check ("exp (-0) == 1", FUNC(exp) (minus_zero), 1);
1093 #ifndef TEST_INLINE
1094 check_isinfp ("exp (+inf) == +inf", FUNC(exp) (plus_infty));
1095 check ("exp (-inf) == 0", FUNC(exp) (minus_infty), 0);
1096 #endif
1097 check_eps ("exp (1) == e", FUNC(exp) (1), M_E, CHOOSE (4e-18L, 0, 0));
1101 static void
1102 exp2_test (void)
1104 errno = 0;
1105 FUNC(exp2) (0);
1106 if (errno == ENOSYS)
1107 /* Function not implemented. */
1108 return;
1110 check ("exp2 (+0) == 1", FUNC(exp2) (0), 1);
1111 check ("exp2 (-0) == 1", FUNC(exp2) (minus_zero), 1);
1113 check_isinfp ("exp2 (+inf) == +inf", FUNC(exp2) (plus_infty));
1114 check ("exp2 (-inf) == 0", FUNC(exp2) (minus_infty), 0);
1115 check ("exp2 (10) == 1024", FUNC(exp2) (10), 1024);
1119 static void
1120 expm1_test (void)
1122 check ("expm1 (+0) == 0", FUNC(expm1) (0), 0);
1123 check ("expm1 (-0) == -0", FUNC(expm1) (minus_zero), minus_zero);
1125 check_isinfp ("expm1 (+inf) == +inf", FUNC(expm1) (plus_infty));
1126 check ("expm1 (-inf) == -1", FUNC(expm1) (minus_infty), -1);
1128 check_eps ("expm1 (1) == e-1", FUNC(expm1) (1), M_E - 1.0,
1129 CHOOSE (4e-18L, 0, 0));
1135 static void
1136 check_frexp (const char *test_name, MATHTYPE computed, MATHTYPE expected,
1137 int comp_int, int exp_int)
1139 MATHTYPE diff;
1140 int result;
1142 result = (check_equal (computed, expected, 0, &diff)
1143 && (comp_int == exp_int));
1145 if (result)
1147 if (verbose > 2)
1148 printf ("Pass: %s\n", test_name);
1150 else
1152 if (verbose)
1153 printf ("Fail: %s\n", test_name);
1154 if (verbose > 1)
1156 printf ("Result:\n");
1157 printf (" is: %.20" PRINTF_EXPR " *2^%d\n", computed, comp_int);
1158 printf (" should be: %.20" PRINTF_EXPR " *2^%d\n", expected, exp_int);
1159 printf (" difference: %.20" PRINTF_EXPR "\n", diff);
1161 noErrors++;
1163 fpstack_test (test_name);
1164 output_result (test_name, result,
1165 computed, expected, diff, PRINT, PRINT);
1169 static void
1170 frexp_test (void)
1172 int x_int;
1173 MATHTYPE result;
1175 result = FUNC(frexp) (plus_infty, &x_int);
1176 check_isinfp ("frexp (+inf, expr) == +inf", result);
1178 result = FUNC(frexp) (minus_infty, &x_int);
1179 check_isinfn ("frexp (-inf, expr) == -inf", result);
1181 result = FUNC(frexp) (nan_value, &x_int);
1182 check_isnan ("frexp (Nan, expr) == NaN", result);
1184 result = FUNC(frexp) (0, &x_int);
1185 check_frexp ("frexp: +0 == 0 * 2^0", result, 0, x_int, 0);
1187 result = FUNC(frexp) (minus_zero, &x_int);
1188 check_frexp ("frexp: -0 == -0 * 2^0", result, minus_zero, x_int, 0);
1190 result = FUNC(frexp) (12.8L, &x_int);
1191 check_frexp ("frexp: 12.8 == 0.8 * 2^4", result, 0.8L, x_int, 4);
1193 result = FUNC(frexp) (-27.34L, &x_int);
1194 check_frexp ("frexp: -27.34 == -0.854375 * 2^5", result, -0.854375L, x_int, 5);
1199 #if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 1)
1200 /* All floating-point numbers can be put in one of these categories. */
1201 enum
1203 FP_NAN,
1204 #define FP_NAN FP_NAN
1205 FP_INFINITE,
1206 #define FP_INFINITE FP_INFINITE
1207 FP_ZERO,
1208 #define FP_ZERO FP_ZERO
1209 FP_SUBNORMAL,
1210 #define FP_SUBNORMAL FP_SUBNORMAL
1211 FP_NORMAL
1212 #define FP_NORMAL FP_NORMAL
1214 #endif
1217 static void
1218 fpclassify_test (void)
1220 MATHTYPE x;
1222 /* fpclassify is a macro, don't give it constants as parameter */
1223 check_bool ("fpclassify (NaN) == FP_NAN", fpclassify (nan_value) == FP_NAN);
1224 check_bool ("fpclassify (+inf) == FP_INFINITE",
1225 fpclassify (plus_infty) == FP_INFINITE);
1226 check_bool ("fpclassify (-inf) == FP_INFINITE",
1227 fpclassify (minus_infty) == FP_INFINITE);
1228 check_bool ("fpclassify (+0) == FP_ZERO",
1229 fpclassify (plus_zero) == FP_ZERO);
1230 check_bool ("fpclassify (-0) == FP_ZERO",
1231 fpclassify (minus_zero) == FP_ZERO);
1233 x = 1000.0;
1234 check_bool ("fpclassify (1000) == FP_NORMAL",
1235 fpclassify (x) == FP_NORMAL);
1239 static void
1240 isfinite_test (void)
1242 check_bool ("isfinite (0) != 0", isfinite (0));
1243 check_bool ("isfinite (-0) != 0", isfinite (minus_zero));
1244 check_bool ("isfinite (10) != 0", isfinite (10));
1245 check_bool ("isfinite (+inf) == 0", isfinite (plus_infty) == 0);
1246 check_bool ("isfinite (-inf) == 0", isfinite (minus_infty) == 0);
1247 check_bool ("isfinite (NaN) == 0", isfinite (nan_value) == 0);
1251 static void
1252 isnormal_test (void)
1254 check_bool ("isnormal (0) == 0", isnormal (0) == 0);
1255 check_bool ("isnormal (-0) == 0", isnormal (minus_zero) == 0);
1256 check_bool ("isnormal (10) != 0", isnormal (10));
1257 check_bool ("isnormal (+inf) == 0", isnormal (plus_infty) == 0);
1258 check_bool ("isnormal (-inf) == 0", isnormal (minus_infty) == 0);
1259 check_bool ("isnormal (NaN) == 0", isnormal (nan_value) == 0);
1264 static void
1265 signbit_test (void)
1267 MATHTYPE x;
1269 check_bool ("signbit (+0) == 0", signbit (0) == 0);
1270 check_bool ("signbit (-0) != 0", signbit (minus_zero));
1271 check_bool ("signbit (+inf) == 0", signbit (plus_infty) == 0);
1272 check_bool ("signbit (-inf) != 0", signbit (minus_infty));
1274 x = random_less (0);
1275 check_bool ("signbit (x) != 0 for x < 0", signbit (x));
1277 x = random_greater (0);
1278 check_bool ("signbit (x) == 0 for x > 0", signbit (x) == 0);
1284 gamma has different semantics depending on _LIB_VERSION:
1285 if _LIB_VERSION is _SVID, gamma is just an alias for lgamma,
1286 otherwise gamma is the real gamma function as definied in ISO C 9X.
1288 static void
1289 gamma_test (void)
1291 int save_lib_version = _LIB_VERSION;
1292 errno = 0;
1293 FUNC(gamma) (1);
1294 if (errno == ENOSYS)
1295 /* Function not implemented. */
1296 return;
1297 feclearexcept (FE_ALL_EXCEPT);
1300 _LIB_VERSION = _SVID_;
1302 check_isinfp ("gamma (+inf) == +inf", FUNC(gamma) (plus_infty));
1303 check_isinfp_exc ("gamma (0) == +inf plus divide by zero exception",
1304 FUNC(gamma) (0), DIVIDE_BY_ZERO_EXCEPTION);
1306 check_isinfp_exc ("gamma (x) == +inf plus divide by zero exception for integer x <= 0",
1307 FUNC(gamma) (-3), DIVIDE_BY_ZERO_EXCEPTION);
1308 check_isnan_exc ("gamma (-inf) == NaN plus invalid exception",
1309 FUNC(gamma) (minus_infty), INVALID_EXCEPTION);
1311 signgam = 0;
1312 check ("gamma (1) == 0", FUNC(gamma) (1), 0);
1313 check_int ("gamma (0) sets signgam to 1", signgam, 1);
1315 signgam = 0;
1316 check ("gamma (3) == M_LN2", FUNC(gamma) (3), M_LN2);
1317 check_int ("gamma (3) sets signgam to 1", signgam, 1);
1319 signgam = 0;
1320 check_eps ("gamma (0.5) == log(sqrt(pi))", FUNC(gamma) (0.5),
1321 FUNC(log) (FUNC(sqrt) (M_PI)), CHOOSE (0, 1e-15, 1e-7));
1322 check_int ("gamma (0.5) sets signgam to 1", signgam, 1);
1324 signgam = 0;
1325 check_eps ("gamma (-0.5) == log(2*sqrt(pi))", FUNC(gamma) (-0.5),
1326 FUNC(log) (2*FUNC(sqrt) (M_PI)), CHOOSE (0, 1e-15, 0));
1328 check_int ("gamma (-0.5) sets signgam to -1", signgam, -1);
1331 _LIB_VERSION = _IEEE_;
1333 check_isinfp ("gamma (+inf) == +inf", FUNC(gamma) (plus_infty));
1334 check_isnan_exc ("gamma (0) == NaN plus invalid exception",
1335 FUNC(gamma) (0), INVALID_EXCEPTION);
1337 check_isnan_exc_ext ("gamma (x) == NaN plus invalid exception for integer x <= 0",
1338 FUNC(gamma) (-2), INVALID_EXCEPTION, -2);
1339 check_isnan_exc ("gamma (-inf) == NaN plus invalid exception",
1340 FUNC(gamma) (minus_infty), INVALID_EXCEPTION);
1342 check_eps ("gamma (0.5) == sqrt(pi)", FUNC(gamma) (0.5), FUNC(sqrt) (M_PI),
1343 CHOOSE (0, 5e-16, 2e-7));
1344 check_eps ("gamma (-0.5) == -2*sqrt(pi)", FUNC(gamma) (-0.5),
1345 -2*FUNC(sqrt) (M_PI), CHOOSE (0, 5e-16, 3e-7));
1347 check ("gamma (1) == 1", FUNC(gamma) (1), 1);
1348 check ("gamma (4) == 6", FUNC(gamma) (4), 6);
1350 _LIB_VERSION = save_lib_version;
1354 static void
1355 lgamma_test (void)
1357 errno = 0;
1358 FUNC(lgamma) (0);
1359 if (errno == ENOSYS)
1360 /* Function not implemented. */
1361 return;
1362 feclearexcept (FE_ALL_EXCEPT);
1364 check_isinfp ("lgamma (+inf) == +inf", FUNC(lgamma) (plus_infty));
1365 check_isinfp_exc ("lgamma (0) == +inf plus divide by zero exception",
1366 FUNC(lgamma) (0), DIVIDE_BY_ZERO_EXCEPTION);
1368 check_isinfp_exc ("lgamma (x) == +inf plus divide by zero exception for integer x <= 0",
1369 FUNC(lgamma) (-3), DIVIDE_BY_ZERO_EXCEPTION);
1370 check_isnan_exc ("lgamma (-inf) == NaN plus invalid exception",
1371 FUNC(lgamma) (minus_infty), INVALID_EXCEPTION);
1373 signgam = 0;
1374 check ("lgamma (1) == 0", FUNC(lgamma) (1), 0);
1375 check_int ("lgamma (0) sets signgam to 1", signgam, 1);
1377 signgam = 0;
1378 check ("lgamma (3) == M_LN2", FUNC(lgamma) (3), M_LN2);
1379 check_int ("lgamma (3) sets signgam to 1", signgam, 1);
1381 signgam = 0;
1382 check_eps ("lgamma (0.5) == log(sqrt(pi))", FUNC(lgamma) (0.5),
1383 FUNC(log) (FUNC(sqrt) (M_PI)), CHOOSE (0, 1e-15, 1e-7));
1384 check_int ("lgamma (0.5) sets signgam to 1", signgam, 1);
1386 signgam = 0;
1387 check_eps ("lgamma (-0.5) == log(2*sqrt(pi))", FUNC(lgamma) (-0.5),
1388 FUNC(log) (2*FUNC(sqrt) (M_PI)), CHOOSE (0, 1e-15, 0));
1390 check_int ("lgamma (-0.5) sets signgam to -1", signgam, -1);
1395 static void
1396 ilogb_test (void)
1398 int i;
1400 check_int ("ilogb (1) == 0", FUNC(ilogb) (1), 0);
1401 check_int ("ilogb (e) == 1", FUNC(ilogb) (M_E), 1);
1402 check_int ("ilogb (1024) == 10", FUNC(ilogb) (1024), 10);
1403 check_int ("ilogb (-2000) == 10", FUNC(ilogb) (-2000), 10);
1405 /* XXX We have a problem here: the standard does not tell us whether
1406 exceptions are allowed/required. ignore them for now. */
1407 i = FUNC (ilogb) (0.0);
1408 feclearexcept (FE_ALL_EXCEPT);
1409 check_int ("ilogb (0) == FP_ILOGB0", i, FP_ILOGB0);
1410 i = FUNC(ilogb) (nan_value);
1411 feclearexcept (FE_ALL_EXCEPT);
1412 check_int ("ilogb (NaN) == FP_ILOGBNAN", i, FP_ILOGBNAN);
1417 static void
1418 ldexp_test (void)
1420 MATHTYPE x;
1422 check ("ldexp (0, 0) == 0", FUNC(ldexp) (0, 0), 0);
1424 check_isinfp ("ldexp (+inf, 1) == +inf", FUNC(ldexp) (plus_infty, 1));
1425 check_isinfn ("ldexp (-inf, 1) == -inf", FUNC(ldexp) (minus_infty, 1));
1426 check_isnan ("ldexp (NaN, 1) == NaN", FUNC(ldexp) (nan_value, 1));
1428 check ("ldexp (0.8, 4) == 12.8", FUNC(ldexp) (0.8L, 4), 12.8L);
1429 check ("ldexp (-0.854375, 5) == -27.34", FUNC(ldexp) (-0.854375L, 5), -27.34L);
1431 x = random_greater (0.0);
1432 check_ext ("ldexp (x, 0) == x", FUNC(ldexp) (x, 0L), x, x);
1437 static void
1438 log_test (void)
1440 check_isinfn_exc ("log (+0) == -inf plus divide-by-zero exception",
1441 FUNC(log) (0), DIVIDE_BY_ZERO_EXCEPTION);
1442 check_isinfn_exc ("log (-0) == -inf plus divide-by-zero exception",
1443 FUNC(log) (minus_zero), DIVIDE_BY_ZERO_EXCEPTION);
1445 check ("log (1) == 0", FUNC(log) (1), 0);
1447 check_isnan_exc ("log (x) == NaN plus invalid exception if x < 0",
1448 FUNC(log) (-1), INVALID_EXCEPTION);
1449 check_isinfp ("log (+inf) == +inf", FUNC(log) (plus_infty));
1451 check_eps ("log (e) == 1", FUNC(log) (M_E), 1, CHOOSE (1e-18L, 0, 9e-8L));
1452 check_eps ("log (1/e) == -1", FUNC(log) (1.0 / M_E), -1,
1453 CHOOSE (2e-18L, 0, 0));
1454 check ("log (2) == M_LN2", FUNC(log) (2), M_LN2);
1455 check_eps ("log (10) == M_LN10", FUNC(log) (10), M_LN10,
1456 CHOOSE (1e-18L, 0, 0));
1460 static void
1461 log10_test (void)
1463 check_isinfn_exc ("log10 (+0) == -inf plus divide-by-zero exception",
1464 FUNC(log10) (0), DIVIDE_BY_ZERO_EXCEPTION);
1465 check_isinfn_exc ("log10 (-0) == -inf plus divide-by-zero exception",
1466 FUNC(log10) (minus_zero), DIVIDE_BY_ZERO_EXCEPTION);
1468 check ("log10 (1) == +0", FUNC(log10) (1), 0);
1470 check_isnan_exc ("log10 (x) == NaN plus invalid exception if x < 0",
1471 FUNC(log10) (-1), INVALID_EXCEPTION);
1473 check_isinfp ("log10 (+inf) == +inf", FUNC(log10) (plus_infty));
1475 check_eps ("log10 (0.1) == -1", FUNC(log10) (0.1L), -1,
1476 CHOOSE (1e-18L, 0, 0));
1477 check_eps ("log10 (10) == 1", FUNC(log10) (10.0), 1,
1478 CHOOSE (1e-18L, 0, 0));
1479 check_eps ("log10 (100) == 2", FUNC(log10) (100.0), 2,
1480 CHOOSE (1e-18L, 0, 0));
1481 check ("log10 (10000) == 4", FUNC(log10) (10000.0), 4);
1482 check_eps ("log10 (e) == M_LOG10E", FUNC(log10) (M_E), M_LOG10E,
1483 CHOOSE (1e-18, 0, 9e-8));
1487 static void
1488 log1p_test (void)
1490 check ("log1p (+0) == +0", FUNC(log1p) (0), 0);
1491 check ("log1p (-0) == -0", FUNC(log1p) (minus_zero), minus_zero);
1493 check_isinfn_exc ("log1p (-1) == -inf plus divide-by-zero exception",
1494 FUNC(log1p) (-1), DIVIDE_BY_ZERO_EXCEPTION);
1495 check_isnan_exc ("log1p (x) == NaN plus invalid exception if x < -1",
1496 FUNC(log1p) (-2), INVALID_EXCEPTION);
1498 check_isinfp ("log1p (+inf) == +inf", FUNC(log1p) (plus_infty));
1500 check_eps ("log1p (e-1) == 1", FUNC(log1p) (M_E - 1.0), 1,
1501 CHOOSE (1e-18L, 0, 0));
1506 static void
1507 log2_test (void)
1509 check_isinfn_exc ("log2 (+0) == -inf plus divide-by-zero exception",
1510 FUNC(log2) (0), DIVIDE_BY_ZERO_EXCEPTION);
1511 check_isinfn_exc ("log2 (-0) == -inf plus divide-by-zero exception",
1512 FUNC(log2) (minus_zero), DIVIDE_BY_ZERO_EXCEPTION);
1514 check ("log2 (1) == +0", FUNC(log2) (1), 0);
1516 check_isnan_exc ("log2 (x) == NaN plus invalid exception if x < 0",
1517 FUNC(log2) (-1), INVALID_EXCEPTION);
1519 check_isinfp ("log2 (+inf) == +inf", FUNC(log2) (plus_infty));
1521 check_eps ("log2 (e) == M_LOG2E", FUNC(log2) (M_E), M_LOG2E,
1522 CHOOSE (1e-18L, 0, 0));
1523 check ("log2 (2) == 1", FUNC(log2) (2.0), 1);
1524 check_eps ("log2 (16) == 4", FUNC(log2) (16.0), 4, CHOOSE (1e-18L, 0, 0));
1525 check ("log2 (256) == 8", FUNC(log2) (256.0), 8);
1530 static void
1531 logb_test (void)
1533 check_isinfp ("logb (+inf) == +inf", FUNC(logb) (plus_infty));
1534 check_isinfp ("logb (-inf) == +inf", FUNC(logb) (minus_infty));
1536 check_isinfn_exc ("logb (+0) == -inf plus divide-by-zero exception",
1537 FUNC(logb) (0), DIVIDE_BY_ZERO_EXCEPTION);
1539 check_isinfn_exc ("logb (-0) == -inf plus divide-by-zero exception",
1540 FUNC(logb) (minus_zero), DIVIDE_BY_ZERO_EXCEPTION);
1542 check ("logb (1) == 0", FUNC(logb) (1), 0);
1543 check ("logb (e) == 1", FUNC(logb) (M_E), 1);
1544 check ("logb (1024) == 10", FUNC(logb) (1024), 10);
1545 check ("logb (-2000) == 10", FUNC(logb) (-2000), 10);
1550 static void
1551 modf_test (void)
1553 MATHTYPE result, intpart;
1555 result = FUNC(modf) (plus_infty, &intpart);
1556 check ("modf (+inf, &x) returns +0", result, 0);
1557 check_isinfp ("modf (+inf, &x) set x to +inf", intpart);
1559 result = FUNC(modf) (minus_infty, &intpart);
1560 check ("modf (-inf, &x) returns -0", result, minus_zero);
1561 check_isinfn ("modf (-inf, &x) sets x to -inf", intpart);
1563 result = FUNC(modf) (nan_value, &intpart);
1564 check_isnan ("modf (NaN, &x) returns NaN", result);
1565 check_isnan ("modf (NaN, &x) sets x to NaN", intpart);
1567 result = FUNC(modf) (0, &intpart);
1568 check ("modf (0, &x) returns 0", result, 0);
1569 check ("modf (0, &x) sets x to 0", intpart, 0);
1571 result = FUNC(modf) (minus_zero, &intpart);
1572 check ("modf (-0, &x) returns -0", result, minus_zero);
1573 check ("modf (-0, &x) sets x to -0", intpart, minus_zero);
1575 result = FUNC(modf) (2.5, &intpart);
1576 check ("modf (2.5, &x) returns 0.5", result, 0.5);
1577 check ("modf (2.5, &x) sets x to 2", intpart, 2);
1579 result = FUNC(modf) (-2.5, &intpart);
1580 check ("modf (-2.5, &x) returns -0.5", result, -0.5);
1581 check ("modf (-2.5, &x) sets x to -2", intpart, -2);
1586 static void
1587 scalb_test (void)
1589 MATHTYPE x;
1591 check_isnan ("scalb (2, 0.5) == NaN", FUNC(scalb) (2, 0.5));
1592 check_isnan ("scalb (3, -2.5) == NaN", FUNC(scalb) (3, -2.5));
1594 check_isnan ("scalb (0, NaN) == NaN", FUNC(scalb) (0, nan_value));
1595 check_isnan ("scalb (1, NaN) == NaN", FUNC(scalb) (1, nan_value));
1597 x = random_greater (0.0);
1598 check ("scalb (x, 0) == 0", FUNC(scalb) (x, 0), x);
1599 x = random_greater (0.0);
1600 check ("scalb (-x, 0) == 0", FUNC(scalb) (-x, 0), -x);
1602 check_isnan_exc ("scalb (+0, +inf) == NaN plus invalid exception",
1603 FUNC(scalb) (0, plus_infty), INVALID_EXCEPTION);
1604 check_isnan_exc ("scalb (-0, +inf) == NaN plus invalid exception",
1605 FUNC(scalb) (minus_zero, plus_infty), INVALID_EXCEPTION);
1607 check ("scalb (+0, 2) == +0", FUNC(scalb) (0, 2), 0);
1608 check ("scalb (-0, 4) == -0", FUNC(scalb) (minus_zero, -4), minus_zero);
1609 check ("scalb (+0, 0) == +0", FUNC(scalb) (0, 0), 0);
1610 check ("scalb (-0, 0) == -0", FUNC(scalb) (minus_zero, 0), minus_zero);
1611 check ("scalb (+0, -1) == +0", FUNC(scalb) (0, -1), 0);
1612 check ("scalb (-0, -10) == -0", FUNC(scalb) (minus_zero, -10), minus_zero);
1613 check ("scalb (+0, -inf) == +0", FUNC(scalb) (0, minus_infty), 0);
1614 check ("scalb (-0, -inf) == -0", FUNC(scalb) (minus_zero, minus_infty),
1615 minus_zero);
1617 check_isinfp ("scalb (+inf, -1) == +inf", FUNC(scalb) (plus_infty, -1));
1618 check_isinfn ("scalb (-inf, -10) == -inf", FUNC(scalb) (minus_infty, -10));
1619 check_isinfp ("scalb (+inf, 0) == +inf", FUNC(scalb) (plus_infty, 0));
1620 check_isinfn ("scalb (-inf, 0) == -inf", FUNC(scalb) (minus_infty, 0));
1621 check_isinfp ("scalb (+inf, 2) == +inf", FUNC(scalb) (plus_infty, 2));
1622 check_isinfn ("scalb (-inf, 100) == -inf", FUNC(scalb) (minus_infty, 100));
1624 x = random_greater (0.0);
1625 check ("scalb (x, -inf) == 0", FUNC(scalb) (x, minus_infty), 0.0);
1626 check ("scalb (-x, -inf) == -0", FUNC(scalb) (-x, minus_infty), minus_zero);
1628 x = random_greater (0.0);
1629 check_isinfp ("scalb (x, +inf) == +inf", FUNC(scalb) (x, plus_infty));
1630 x = random_greater (0.0);
1631 check_isinfn ("scalb (-x, +inf) == -inf", FUNC(scalb) (-x, plus_infty));
1632 check_isinfp ("scalb (+inf, +inf) == +inf",
1633 FUNC(scalb) (plus_infty, plus_infty));
1634 check_isinfn ("scalb (-inf, +inf) == -inf",
1635 FUNC(scalb) (minus_infty, plus_infty));
1637 check_isnan ("scalb (+inf, -inf) == NaN",
1638 FUNC(scalb) (plus_infty, minus_infty));
1639 check_isnan ("scalb (-inf, -inf) == NaN",
1640 FUNC(scalb) (minus_infty, minus_infty));
1642 check_isnan ("scalb (NaN, 1) == NaN", FUNC(scalb) (nan_value, 1));
1643 check_isnan ("scalb (1, NaN) == NaN", FUNC(scalb) (1, nan_value));
1644 check_isnan ("scalb (NaN, 0) == NaN", FUNC(scalb) (nan_value, 0));
1645 check_isnan ("scalb (0, NaN) == NaN", FUNC(scalb) (0, nan_value));
1646 check_isnan ("scalb (NaN, +inf) == NaN",
1647 FUNC(scalb) (nan_value, plus_infty));
1648 check_isnan ("scalb (+inf, NaN) == NaN",
1649 FUNC(scalb) (plus_infty, nan_value));
1650 check_isnan ("scalb (NaN, NaN) == NaN", FUNC(scalb) (nan_value, nan_value));
1652 check ("scalb (0.8, 4) == 12.8", FUNC(scalb) (0.8L, 4), 12.8L);
1653 check ("scalb (-0.854375, 5) == -27.34", FUNC(scalb) (-0.854375L, 5), -27.34L);
1657 static void
1658 scalbn_test (void)
1660 MATHTYPE x;
1662 check ("scalbn (0, 0) == 0", FUNC(scalbn) (0, 0), 0);
1664 check_isinfp ("scalbn (+inf, 1) == +inf", FUNC(scalbn) (plus_infty, 1));
1665 check_isinfn ("scalbn (-inf, 1) == -inf", FUNC(scalbn) (minus_infty, 1));
1666 check_isnan ("scalbn (NaN, 1) == NaN", FUNC(scalbn) (nan_value, 1));
1668 check ("scalbn (0.8, 4) == 12.8", FUNC(scalbn) (0.8L, 4), 12.8L);
1669 check ("scalbn (-0.854375, 5) == -27.34", FUNC(scalbn) (-0.854375L, 5), -27.34L);
1671 x = random_greater (0.0);
1672 check_ext ("scalbn (x, 0) == x", FUNC(scalbn) (x, 0L), x, x);
1676 static void
1677 sin_test (void)
1679 check ("sin (+0) == +0", FUNC(sin) (0), 0);
1680 check ("sin (-0) == -0", FUNC(sin) (minus_zero), minus_zero);
1681 check_isnan_exc ("sin (+inf) == NaN plus invalid exception",
1682 FUNC(sin) (plus_infty),
1683 INVALID_EXCEPTION);
1684 check_isnan_exc ("sin (-inf) == NaN plus invalid exception",
1685 FUNC(sin) (minus_infty),
1686 INVALID_EXCEPTION);
1688 check_eps ("sin (pi/6) == 0.5", FUNC(sin) (M_PI_6),
1689 0.5,CHOOSE (4e-18L, 0, 0));
1690 check ("sin (pi/2) == 1", FUNC(sin) (M_PI_2), 1);
1694 static void
1695 sinh_test (void)
1697 check ("sinh (+0) == +0", FUNC(sinh) (0), 0);
1699 #ifndef TEST_INLINE
1700 check ("sinh (-0) == -0", FUNC(sinh) (minus_zero), minus_zero);
1702 check_isinfp ("sinh (+inf) == +inf", FUNC(sinh) (plus_infty));
1703 check_isinfn ("sinh (-inf) == -inf", FUNC(sinh) (minus_infty));
1704 #endif
1708 static void
1709 sincos_test (void)
1711 MATHTYPE sin_res, cos_res;
1712 fenv_t fenv;
1714 FUNC(sincos) (0, &sin_res, &cos_res);
1715 fegetenv (&fenv);
1716 check ("sincos (+0, &sin, &cos) puts +0 in sin", sin_res, 0);
1717 fesetenv (&fenv);
1718 check ("sincos (+0, &sin, &cos) puts 1 in cos", cos_res, 1);
1720 FUNC(sincos) (minus_zero, &sin_res, &cos_res);
1721 fegetenv (&fenv);
1722 check ("sincos (-0, &sin, &cos) puts -0 in sin", sin_res, minus_zero);
1723 fesetenv (&fenv);
1724 check ("sincos (-0, &sin, &cos) puts 1 in cos", cos_res, 1);
1726 FUNC(sincos) (plus_infty, &sin_res, &cos_res);
1727 fegetenv (&fenv);
1728 check_isnan_exc ("sincos (+inf, &sin, &cos) puts NaN in sin plus invalid exception",
1729 sin_res, INVALID_EXCEPTION);
1730 fesetenv (&fenv);
1731 check_isnan_exc ("sincos (+inf, &sin, &cos) puts NaN in cos plus invalid exception",
1732 cos_res, INVALID_EXCEPTION);
1734 FUNC(sincos) (minus_infty, &sin_res, &cos_res);
1735 fegetenv (&fenv);
1736 check_isnan_exc ("sincos (-inf,&sin, &cos) puts NaN in sin plus invalid exception",
1737 sin_res, INVALID_EXCEPTION);
1738 fesetenv (&fenv);
1739 check_isnan_exc ("sincos (-inf,&sin, &cos) puts NaN in cos plus invalid exception",
1740 cos_res, INVALID_EXCEPTION);
1742 FUNC(sincos) (M_PI_2, &sin_res, &cos_res);
1743 fegetenv (&fenv);
1744 check ("sincos (pi/2, &sin, &cos) puts 1 in sin", sin_res, 1);
1745 fesetenv (&fenv);
1746 check_eps ("sincos (pi/2, &sin, &cos) puts 0 in cos", cos_res, 0,
1747 CHOOSE (1e-18L, 1e-16, 1e-7));
1749 FUNC(sincos) (M_PI_6, &sin_res, &cos_res);
1750 check_eps ("sincos (pi/6, &sin, &cos) puts 0.5 in sin", sin_res, 0.5,
1751 CHOOSE (5e-18L, 0, 0));
1753 FUNC(sincos) (M_PI_6*2.0, &sin_res, &cos_res);
1754 check_eps ("sincos (pi/3, &sin, &cos) puts 0.5 in cos", cos_res, 0.5,
1755 CHOOSE (5e-18L, 1e-15, 1e-7));
1761 static void
1762 tan_test (void)
1764 check ("tan (+0) == +0", FUNC(tan) (0), 0);
1765 check ("tan (-0) == -0", FUNC(tan) (minus_zero), minus_zero);
1766 check_isnan_exc ("tan (+inf) == NaN plus invalid exception",
1767 FUNC(tan) (plus_infty), INVALID_EXCEPTION);
1768 check_isnan_exc ("tan (-inf) == NaN plus invalid exception",
1769 FUNC(tan) (minus_infty), INVALID_EXCEPTION);
1771 check_eps ("tan (pi/4) == 1", FUNC(tan) (M_PI_4), 1,
1772 CHOOSE (2e-18L, 1e-15L, 0));
1776 static void
1777 tanh_test (void)
1779 check ("tanh (+0) == +0", FUNC(tanh) (0), 0);
1780 #ifndef TEST_INLINE
1781 check ("tanh (-0) == -0", FUNC(tanh) (minus_zero), minus_zero);
1783 check ("tanh (+inf) == +1", FUNC(tanh) (plus_infty), 1);
1784 check ("tanh (-inf) == -1", FUNC(tanh) (minus_infty), -1);
1785 #endif
1789 static void
1790 fabs_test (void)
1792 check ("fabs (+0) == +0", FUNC(fabs) (0), 0);
1793 check ("fabs (-0) == +0", FUNC(fabs) (minus_zero), 0);
1795 check_isinfp ("fabs (+inf) == +inf", FUNC(fabs) (plus_infty));
1796 check_isinfp ("fabs (-inf) == +inf", FUNC(fabs) (minus_infty));
1798 check ("fabs (+38) == 38", FUNC(fabs) (38.0), 38.0);
1799 check ("fabs (-e) == e", FUNC(fabs) (-M_E), M_E);
1803 static void
1804 floor_test (void)
1806 check ("floor (+0) == +0", FUNC(floor) (0.0), 0.0);
1807 check ("floor (-0) == -0", FUNC(floor) (minus_zero), minus_zero);
1808 check_isinfp ("floor (+inf) == +inf", FUNC(floor) (plus_infty));
1809 check_isinfn ("floor (-inf) == -inf", FUNC(floor) (minus_infty));
1811 check ("floor (pi) == 3", FUNC(floor) (M_PI), 3.0);
1812 check ("floor (-pi) == -4", FUNC(floor) (-M_PI), -4.0);
1816 static void
1817 hypot_test (void)
1819 MATHTYPE a;
1821 a = random_greater (0);
1822 check_isinfp_ext ("hypot (+inf, x) == +inf", FUNC(hypot) (plus_infty, a), a);
1823 check_isinfp_ext ("hypot (-inf, x) == +inf", FUNC(hypot) (minus_infty, a), a);
1825 #ifndef TEST_INLINE
1826 check_isinfp ("hypot (+inf, NaN) == +inf", FUNC(hypot) (minus_infty, nan_value));
1827 check_isinfp ("hypot (-inf, NaN) == +inf", FUNC(hypot) (minus_infty, nan_value));
1828 #endif
1830 check_isnan ("hypot (NaN, NaN) == NaN", FUNC(hypot) (nan_value, nan_value));
1832 a = FUNC(hypot) (12.4L, 0.7L);
1833 check ("hypot (x,y) == hypot (y,x)", FUNC(hypot) (0.7L, 12.4L), a);
1834 check ("hypot (x,y) == hypot (-x,y)", FUNC(hypot) (-12.4L, 0.7L), a);
1835 check ("hypot (x,y) == hypot (-y,x)", FUNC(hypot) (-0.7L, 12.4L), a);
1836 check ("hypot (x,y) == hypot (-x,-y)", FUNC(hypot) (-12.4L, -0.7L), a);
1837 check ("hypot (x,y) == hypot (-y,-x)", FUNC(hypot) (-0.7L, -12.4L), a);
1838 check ("hypot (x,0) == fabs (x)", FUNC(hypot) (-0.7L, 0), 0.7L);
1839 check ("hypot (x,0) == fabs (x)", FUNC(hypot) (0.7L, 0), 0.7L);
1840 check ("hypot (x,0) == fabs (x)", FUNC(hypot) (-1.0L, 0), 1.0L);
1841 check ("hypot (x,0) == fabs (x)", FUNC(hypot) (1.0L, 0), 1.0L);
1842 check ("hypot (x,0) == fabs (x)", FUNC(hypot) (-5.7e7L, 0), 5.7e7L);
1843 check ("hypot (x,0) == fabs (x)", FUNC(hypot) (5.7e7L, 0), 5.7e7L);
1847 static void
1848 pow_test (void)
1850 MATHTYPE x;
1852 check ("pow (+0, +0) == 1", FUNC(pow) (0, 0), 1);
1853 check ("pow (+0, -0) == 1", FUNC(pow) (0, minus_zero), 1);
1854 check ("pow (-0, +0) == 1", FUNC(pow) (minus_zero, 0), 1);
1855 check ("pow (-0, -0) == 1", FUNC(pow) (minus_zero, minus_zero), 1);
1857 check ("pow (+10, +0) == 1", FUNC(pow) (10, 0), 1);
1858 check ("pow (+10, -0) == 1", FUNC(pow) (10, minus_zero), 1);
1859 check ("pow (-10, +0) == 1", FUNC(pow) (-10, 0), 1);
1860 check ("pow (-10, -0) == 1", FUNC(pow) (-10, minus_zero), 1);
1862 check ("pow (NaN, +0) == 1", FUNC(pow) (nan_value, 0), 1);
1863 check ("pow (NaN, -0) == 1", FUNC(pow) (nan_value, minus_zero), 1);
1865 #ifndef TEST_INLINE
1866 check_isinfp ("pow (+1.1, +inf) == +inf", FUNC(pow) (1.1, plus_infty));
1867 check_isinfp ("pow (+inf, +inf) == +inf", FUNC(pow) (plus_infty, plus_infty));
1868 check_isinfp ("pow (-1.1, +inf) == +inf", FUNC(pow) (-1.1, plus_infty));
1869 check_isinfp ("pow (-inf, +inf) == +inf", FUNC(pow) (minus_infty, plus_infty));
1871 check ("pow (0.9, +inf) == +0", FUNC(pow) (0.9L, plus_infty), 0);
1872 check ("pow (1e-7, +inf) == +0", FUNC(pow) (1e-7L, plus_infty), 0);
1873 check ("pow (-0.9, +inf) == +0", FUNC(pow) (-0.9L, plus_infty), 0);
1874 check ("pow (-1e-7, +inf) == +0", FUNC(pow) (-1e-7L, plus_infty), 0);
1876 check ("pow (+1.1, -inf) == 0", FUNC(pow) (1.1, minus_infty), 0);
1877 check ("pow (+inf, -inf) == 0", FUNC(pow) (plus_infty, minus_infty), 0);
1878 check ("pow (-1.1, -inf) == 0", FUNC(pow) (-1.1, minus_infty), 0);
1879 check ("pow (-inf, -inf) == 0", FUNC(pow) (minus_infty, minus_infty), 0);
1881 check_isinfp ("pow (0.9, -inf) == +inf", FUNC(pow) (0.9L, minus_infty));
1882 check_isinfp ("pow (1e-7, -inf) == +inf", FUNC(pow) (1e-7L, minus_infty));
1883 check_isinfp ("pow (-0.9, -inf) == +inf", FUNC(pow) (-0.9L, minus_infty));
1884 check_isinfp ("pow (-1e-7, -inf) == +inf", FUNC(pow) (-1e-7L, minus_infty));
1886 check_isinfp ("pow (+inf, 1e-7) == +inf", FUNC(pow) (plus_infty, 1e-7L));
1887 check_isinfp ("pow (+inf, 1) == +inf", FUNC(pow) (plus_infty, 1));
1888 check_isinfp ("pow (+inf, 1e7) == +inf", FUNC(pow) (plus_infty, 1e7L));
1890 check ("pow (+inf, -1e-7) == 0", FUNC(pow) (plus_infty, -1e-7L), 0);
1891 check ("pow (+inf, -1) == 0", FUNC(pow) (plus_infty, -1), 0);
1892 check ("pow (+inf, -1e7) == 0", FUNC(pow) (plus_infty, -1e7L), 0);
1894 check_isinfn ("pow (-inf, 1) == -inf", FUNC(pow) (minus_infty, 1));
1895 check_isinfn ("pow (-inf, 11) == -inf", FUNC(pow) (minus_infty, 11));
1896 check_isinfn ("pow (-inf, 1001) == -inf", FUNC(pow) (minus_infty, 1001));
1898 check_isinfp ("pow (-inf, 2) == +inf", FUNC(pow) (minus_infty, 2));
1899 check_isinfp ("pow (-inf, 12) == +inf", FUNC(pow) (minus_infty, 12));
1900 check_isinfp ("pow (-inf, 1002) == +inf", FUNC(pow) (minus_infty, 1002));
1901 check_isinfp ("pow (-inf, 0.1) == +inf", FUNC(pow) (minus_infty, 0.1));
1902 check_isinfp ("pow (-inf, 1.1) == +inf", FUNC(pow) (minus_infty, 1.1));
1903 check_isinfp ("pow (-inf, 11.1) == +inf", FUNC(pow) (minus_infty, 11.1));
1904 check_isinfp ("pow (-inf, 1001.1) == +inf", FUNC(pow) (minus_infty, 1001.1));
1906 check ("pow (-inf, -1) == -0", FUNC(pow) (minus_infty, -1), minus_zero);
1907 check ("pow (-inf, -11) == -0", FUNC(pow) (minus_infty, -11), minus_zero);
1908 check ("pow (-inf, -1001) == -0", FUNC(pow) (minus_infty, -1001), minus_zero);
1910 check ("pow (-inf, -2) == +0", FUNC(pow) (minus_infty, -2), 0);
1911 check ("pow (-inf, -12) == +0", FUNC(pow) (minus_infty, -12), 0);
1912 check ("pow (-inf, -1002) == +0", FUNC(pow) (minus_infty, -1002), 0);
1913 check ("pow (-inf, -0.1) == +0", FUNC(pow) (minus_infty, -0.1), 0);
1914 check ("pow (-inf, -1.1) == +0", FUNC(pow) (minus_infty, -1.1), 0);
1915 check ("pow (-inf, -11.1) == +0", FUNC(pow) (minus_infty, -11.1), 0);
1916 check ("pow (-inf, -1001.1) == +0", FUNC(pow) (minus_infty, -1001.1), 0);
1918 check_isnan ("pow (NaN, NaN) == NaN", FUNC(pow) (nan_value, nan_value));
1919 check_isnan ("pow (0, NaN) == NaN", FUNC(pow) (0, nan_value));
1920 check_isnan ("pow (1, NaN) == NaN", FUNC(pow) (1, nan_value));
1921 check_isnan ("pow (-1, NaN) == NaN", FUNC(pow) (-1, nan_value));
1922 check_isnan ("pow (NaN, 1) == NaN", FUNC(pow) (nan_value, 1));
1923 check_isnan ("pow (NaN, -1) == NaN", FUNC(pow) (nan_value, -1));
1925 x = random_greater (0.0);
1926 check_isnan_ext ("pow (x, NaN) == NaN", FUNC(pow) (x, nan_value), x);
1928 check_isnan_exc ("pow (+1, +inf) == NaN plus invalid exception",
1929 FUNC(pow) (1, plus_infty), INVALID_EXCEPTION);
1930 check_isnan_exc ("pow (-1, +inf) == NaN plus invalid exception",
1931 FUNC(pow) (-1, plus_infty), INVALID_EXCEPTION);
1932 check_isnan_exc ("pow (+1, -inf) == NaN plus invalid exception",
1933 FUNC(pow) (1, minus_infty), INVALID_EXCEPTION);
1934 check_isnan_exc ("pow (-1, -inf) == NaN plus invalid exception",
1935 FUNC(pow) (-1, minus_infty), INVALID_EXCEPTION);
1937 check_isnan_exc ("pow (-0.1, 1.1) == NaN plus invalid exception",
1938 FUNC(pow) (-0.1, 1.1), INVALID_EXCEPTION);
1939 check_isnan_exc ("pow (-0.1, -1.1) == NaN plus invalid exception",
1940 FUNC(pow) (-0.1, -1.1), INVALID_EXCEPTION);
1941 check_isnan_exc ("pow (-10.1, 1.1) == NaN plus invalid exception",
1942 FUNC(pow) (-10.1, 1.1), INVALID_EXCEPTION);
1943 check_isnan_exc ("pow (-10.1, -1.1) == NaN plus invalid exception",
1944 FUNC(pow) (-10.1, -1.1), INVALID_EXCEPTION);
1946 check_isinfp_exc ("pow (+0, -1) == +inf plus divide-by-zero exception",
1947 FUNC(pow) (0, -1), DIVIDE_BY_ZERO_EXCEPTION);
1948 check_isinfp_exc ("pow (+0, -11) == +inf plus divide-by-zero exception",
1949 FUNC(pow) (0, -11), DIVIDE_BY_ZERO_EXCEPTION);
1950 check_isinfn_exc ("pow (-0, -1) == -inf plus divide-by-zero exception",
1951 FUNC(pow) (minus_zero, -1), DIVIDE_BY_ZERO_EXCEPTION);
1952 check_isinfn_exc ("pow (-0, -11) == -inf plus divide-by-zero exception",
1953 FUNC(pow) (minus_zero, -11), DIVIDE_BY_ZERO_EXCEPTION);
1955 check_isinfp_exc ("pow (+0, -2) == +inf plus divide-by-zero exception",
1956 FUNC(pow) (0, -2), DIVIDE_BY_ZERO_EXCEPTION);
1957 check_isinfp_exc ("pow (+0, -11.1) == +inf plus divide-by-zero exception",
1958 FUNC(pow) (0, -11.1), DIVIDE_BY_ZERO_EXCEPTION);
1959 check_isinfp_exc ("pow (-0, -2) == +inf plus divide-by-zero exception",
1960 FUNC(pow) (minus_zero, -2), DIVIDE_BY_ZERO_EXCEPTION);
1961 check_isinfp_exc ("pow (-0, -11.1) == +inf plus divide-by-zero exception",
1962 FUNC(pow) (minus_zero, -11.1), DIVIDE_BY_ZERO_EXCEPTION);
1963 #endif
1965 check ("pow (+0, 1) == +0", FUNC(pow) (0, 1), 0);
1966 check ("pow (+0, 11) == +0", FUNC(pow) (0, 11), 0);
1967 #ifndef TEST_INLINE
1968 check ("pow (-0, 1) == -0", FUNC(pow) (minus_zero, 1), minus_zero);
1969 check ("pow (-0, 11) == -0", FUNC(pow) (minus_zero, 11), minus_zero);
1970 #endif
1972 check ("pow (+0, 2) == +0", FUNC(pow) (0, 2), 0);
1973 check ("pow (+0, 11.1) == +0", FUNC(pow) (0, 11.1), 0);
1975 #ifndef TEST_INLINE
1976 check ("pow (-0, 2) == +0", FUNC(pow) (minus_zero, 2), 0);
1977 check ("pow (-0, 11.1) == +0", FUNC(pow) (minus_zero, 11.1), 0);
1979 x = random_greater (1.0);
1980 check_isinfp_ext ("pow (x, +inf) == +inf for |x| > 1",
1981 FUNC(pow) (x, plus_infty), x);
1983 x = random_value (-1.0, 1.0);
1984 check_ext ("pow (x, +inf) == +0 for |x| < 1",
1985 FUNC(pow) (x, plus_infty), 0.0, x);
1987 x = random_greater (1.0);
1988 check_ext ("pow (x, -inf) == +0 for |x| > 1",
1989 FUNC(pow) (x, minus_infty), 0.0, x);
1991 x = random_value (-1.0, 1.0);
1992 check_isinfp_ext ("pow (x, -inf) == +inf for |x| < 1",
1993 FUNC(pow) (x, minus_infty), x);
1995 x = random_greater (0.0);
1996 check_isinfp_ext ("pow (+inf, y) == +inf for y > 0",
1997 FUNC(pow) (plus_infty, x), x);
1999 x = random_less (0.0);
2000 check_ext ("pow (+inf, y) == +0 for y < 0",
2001 FUNC(pow) (plus_infty, x), 0.0, x);
2003 x = (rand () % 1000000) * 2.0 + 1; /* Get random odd integer > 0 */
2004 check_isinfn_ext ("pow (-inf, y) == -inf for y an odd integer > 0",
2005 FUNC(pow) (minus_infty, x), x);
2007 x = ((rand () % 1000000) + 1) * 2.0; /* Get random even integer > 1 */
2008 check_isinfp_ext ("pow (-inf, y) == +inf for y > 0 and not an odd integer",
2009 FUNC(pow) (minus_infty, x), x);
2011 x = -((rand () % 1000000) * 2.0 + 1); /* Get random odd integer < 0 */
2012 check_ext ("pow (-inf, y) == -0 for y an odd integer < 0",
2013 FUNC(pow) (minus_infty, x), minus_zero, x);
2015 x = ((rand () % 1000000) + 1) * -2.0; /* Get random even integer < 0 */
2016 check_ext ("pow (-inf, y) == +0 for y < 0 and not an odd integer",
2017 FUNC(pow) (minus_infty, x), 0.0, x);
2018 #endif
2020 x = (rand () % 1000000) * 2.0 + 1; /* Get random odd integer > 0 */
2021 check_ext ("pow (+0, y) == +0 for y an odd integer > 0",
2022 FUNC(pow) (0.0, x), 0.0, x);
2023 #ifndef TEST_INLINE
2024 x = (rand () % 1000000) * 2.0 + 1; /* Get random odd integer > 0 */
2025 check_ext ("pow (-0, y) == -0 for y an odd integer > 0",
2026 FUNC(pow) (minus_zero, x), minus_zero, x);
2027 #endif
2029 x = ((rand () % 1000000) + 1) * 2.0; /* Get random even integer > 1 */
2030 check_ext ("pow (+0, y) == +0 for y > 0 and not an odd integer",
2031 FUNC(pow) (0.0, x), 0.0, x);
2033 x = ((rand () % 1000000) + 1) * 2.0; /* Get random even integer > 1 */
2034 check_ext ("pow (-0, y) == +0 for y > 0 and not an odd integer",
2035 FUNC(pow) (minus_zero, x), 0.0, x);
2039 static void
2040 fdim_test (void)
2042 check ("fdim (+0, +0) = +0", FUNC(fdim) (0, 0), 0);
2043 check ("fdim (9, 0) = 9", FUNC(fdim) (9, 0), 9);
2044 check ("fdim (0, 9) = 0", FUNC(fdim) (0, 9), 0);
2045 check ("fdim (-9, 0) = 9", FUNC(fdim) (-9, 0), 0);
2046 check ("fdim (0, -9) = 9", FUNC(fdim) (0, -9), 9);
2048 check_isinfp ("fdim (+inf, 9) = +inf", FUNC(fdim) (plus_infty, 9));
2049 check_isinfp ("fdim (+inf, -9) = +inf", FUNC(fdim) (plus_infty, -9));
2050 check ("fdim (-inf, 9) = 0", FUNC(fdim) (minus_infty, 9), 0);
2051 check ("fdim (-inf, -9) = 0", FUNC(fdim) (minus_infty, -9), 0);
2052 check_isinfp ("fdim (+9, -inf) = +inf", FUNC(fdim) (9, minus_infty));
2053 check_isinfp ("fdim (-9, -inf) = +inf", FUNC(fdim) (-9, minus_infty));
2054 check ("fdim (9, inf) = 0", FUNC(fdim) (9, plus_infty), 0);
2055 check ("fdim (-9, inf) = 0", FUNC(fdim) (-9, plus_infty), 0);
2057 check_isnan ("fdim (0, NaN) = NaN", FUNC(fdim) (0, nan_value));
2058 check_isnan ("fdim (9, NaN) = NaN", FUNC(fdim) (9, nan_value));
2059 check_isnan ("fdim (-9, NaN) = NaN", FUNC(fdim) (-9, nan_value));
2060 check_isnan ("fdim (NaN, 9) = NaN", FUNC(fdim) (nan_value, 9));
2061 check_isnan ("fdim (NaN, -9) = NaN", FUNC(fdim) (nan_value, -9));
2062 check_isnan ("fdim (+inf, NaN) = NaN", FUNC(fdim) (plus_infty, nan_value));
2063 check_isnan ("fdim (-inf, NaN) = NaN", FUNC(fdim) (minus_infty, nan_value));
2064 check_isnan ("fdim (NaN, +inf) = NaN", FUNC(fdim) (nan_value, plus_infty));
2065 check_isnan ("fdim (NaN, -inf) = NaN", FUNC(fdim) (nan_value, minus_infty));
2066 check_isnan ("fdim (NaN, NaN) = NaN", FUNC(fdim) (nan_value, nan_value));
2070 static void
2071 fmin_test (void)
2073 check ("fmin (+0, +0) = +0", FUNC(fmin) (0, 0), 0);
2074 check ("fmin (9, 0) = 0", FUNC(fmin) (9, 0), 0);
2075 check ("fmin (0, 9) = 0", FUNC(fmin) (0, 9), 0);
2076 check ("fmin (-9, 0) = -9", FUNC(fmin) (-9, 0), -9);
2077 check ("fmin (0, -9) = -9", FUNC(fmin) (0, -9), -9);
2079 check ("fmin (+inf, 9) = 9", FUNC(fmin) (plus_infty, 9), 9);
2080 check ("fmin (9, +inf) = 9", FUNC(fmin) (9, plus_infty), 9);
2081 check ("fmin (+inf, -9) = -9", FUNC(fmin) (plus_infty, -9), -9);
2082 check ("fmin (-9, +inf) = -9", FUNC(fmin) (-9, plus_infty), -9);
2083 check_isinfn ("fmin (-inf, 9) = -inf", FUNC(fmin) (minus_infty, 9));
2084 check_isinfn ("fmin (-inf, -9) = -inf", FUNC(fmin) (minus_infty, -9));
2085 check_isinfn ("fmin (+9, -inf) = -inf", FUNC(fmin) (9, minus_infty));
2086 check_isinfn ("fmin (-9, -inf) = -inf", FUNC(fmin) (-9, minus_infty));
2088 check ("fmin (0, NaN) = 0", FUNC(fmin) (0, nan_value), 0);
2089 check ("fmin (9, NaN) = 9", FUNC(fmin) (9, nan_value), 9);
2090 check ("fmin (-9, NaN) = 9", FUNC(fmin) (-9, nan_value), -9);
2091 check ("fmin (NaN, 0) = 0", FUNC(fmin) (nan_value, 0), 0);
2092 check ("fmin (NaN, 9) = NaN", FUNC(fmin) (nan_value, 9), 9);
2093 check ("fmin (NaN, -9) = NaN", FUNC(fmin) (nan_value, -9), -9);
2094 check_isinfp ("fmin (+inf, NaN) = +inf", FUNC(fmin) (plus_infty, nan_value));
2095 check_isinfn ("fmin (-inf, NaN) = -inf", FUNC(fmin) (minus_infty, nan_value));
2096 check_isinfp ("fmin (NaN, +inf) = +inf", FUNC(fmin) (nan_value, plus_infty));
2097 check_isinfn ("fmin (NaN, -inf) = -inf", FUNC(fmin) (nan_value, minus_infty));
2098 check_isnan ("fmin (NaN, NaN) = NaN", FUNC(fmin) (nan_value, nan_value));
2102 static void
2103 fmax_test (void)
2105 check ("fmax (+0, +0) = +0", FUNC(fmax) (0, 0), 0);
2106 check ("fmax (9, 0) = 9", FUNC(fmax) (9, 0), 9);
2107 check ("fmax (0, 9) = 9", FUNC(fmax) (0, 9), 9);
2108 check ("fmax (-9, 0) = 0", FUNC(fmax) (-9, 0), 0);
2109 check ("fmax (0, -9) = 0", FUNC(fmax) (0, -9), 0);
2111 check_isinfp ("fmax (+inf, 9) = +inf", FUNC(fmax) (plus_infty, 9));
2112 check_isinfp ("fmax (9, +inf) = +inf", FUNC(fmax) (0, plus_infty));
2113 check_isinfp ("fmax (-9, +inf) = +inf", FUNC(fmax) (-9, plus_infty));
2114 check_isinfp ("fmax (+inf, -9) = +inf", FUNC(fmax) (plus_infty, -9));
2115 check ("fmax (-inf, 9) = 9", FUNC(fmax) (minus_infty, 9), 9);
2116 check ("fmax (-inf, -9) = -9", FUNC(fmax) (minus_infty, -9), -9);
2117 check ("fmax (+9, -inf) = 9", FUNC(fmax) (9, minus_infty), 9);
2118 check ("fmax (-9, -inf) = -9", FUNC(fmax) (-9, minus_infty), -9);
2120 check ("fmax (0, NaN) = 0", FUNC(fmax) (0, nan_value), 0);
2121 check ("fmax (9, NaN) = 9", FUNC(fmax) (9, nan_value), 9);
2122 check ("fmax (-9, NaN) = 9", FUNC(fmax) (-9, nan_value), -9);
2123 check ("fmax (NaN, 0) = 0", FUNC(fmax) (nan_value, 0), 0);
2124 check ("fmax (NaN, 9) = NaN", FUNC(fmax) (nan_value, 9), 9);
2125 check ("fmax (NaN, -9) = NaN", FUNC(fmax) (nan_value, -9), -9);
2126 check_isinfp ("fmax (+inf, NaN) = +inf", FUNC(fmax) (plus_infty, nan_value));
2127 check_isinfn ("fmax (-inf, NaN) = -inf", FUNC(fmax) (minus_infty, nan_value));
2128 check_isinfp ("fmax (NaN, +inf) = +inf", FUNC(fmax) (nan_value, plus_infty));
2129 check_isinfn ("fmax (NaN, -inf) = -inf", FUNC(fmax) (nan_value, minus_infty));
2130 check_isnan ("fmax (NaN, NaN) = NaN", FUNC(fmax) (nan_value, nan_value));
2134 static void
2135 fmod_test (void)
2137 MATHTYPE x;
2139 x = random_greater (0);
2140 check_ext ("fmod (+0, y) == +0 for y != 0", FUNC(fmod) (0, x), 0, x);
2142 x = random_greater (0);
2143 check_ext ("fmod (-0, y) == -0 for y != 0", FUNC(fmod) (minus_zero, x),
2144 minus_zero, x);
2146 check_isnan_exc_ext ("fmod (+inf, y) == NaN plus invalid exception",
2147 FUNC(fmod) (plus_infty, x), INVALID_EXCEPTION, x);
2148 check_isnan_exc_ext ("fmod (-inf, y) == NaN plus invalid exception",
2149 FUNC(fmod) (minus_infty, x), INVALID_EXCEPTION, x);
2150 check_isnan_exc_ext ("fmod (x, +0) == NaN plus invalid exception",
2151 FUNC(fmod) (x, 0), INVALID_EXCEPTION, x);
2152 check_isnan_exc_ext ("fmod (x, -0) == NaN plus invalid exception",
2153 FUNC(fmod) (x, minus_zero), INVALID_EXCEPTION, x);
2155 x = random_greater (0);
2156 check_ext ("fmod (x, +inf) == x for x not infinite",
2157 FUNC(fmod) (x, plus_infty), x, x);
2158 x = random_greater (0);
2159 check_ext ("fmod (x, -inf) == x for x not infinite",
2160 FUNC(fmod) (x, minus_infty), x, x);
2162 check_eps ("fmod (6.5, 2.3) == 1.9", FUNC(fmod) (6.5, 2.3), 1.9,
2163 CHOOSE(5e-16, 1e-15, 2e-7));
2164 check_eps ("fmod (-6.5, 2.3) == -1.9", FUNC(fmod) (-6.5, 2.3), -1.9,
2165 CHOOSE(5e-16, 1e-15, 2e-7));
2166 check_eps ("fmod (6.5, -2.3) == 1.9", FUNC(fmod) (6.5, -2.3), 1.9,
2167 CHOOSE(5e-16, 1e-15, 2e-7));
2168 check_eps ("fmod (-6.5, -2.3) == -1.9", FUNC(fmod) (-6.5, -2.3), -1.9,
2169 CHOOSE(5e-16, 1e-15, 2e-7));
2175 static void
2176 nextafter_test (void)
2178 MATHTYPE x;
2180 check ("nextafter (+0, +0) = +0", FUNC(nextafter) (0, 0), 0);
2181 check ("nextafter (-0, +0) = +0", FUNC(nextafter) (minus_zero, 0), 0);
2182 check ("nextafter (+0, -0) = -0", FUNC(nextafter) (0, minus_zero),
2183 minus_zero);
2184 check ("nextafter (-0, -0) = -0", FUNC(nextafter) (minus_zero, minus_zero),
2185 minus_zero);
2187 check ("nextafter (9, 9) = 9", FUNC(nextafter) (9, 9), 9);
2188 check ("nextafter (-9, -9) = -9", FUNC(nextafter) (-9, -9), -9);
2189 check_isinfp ("nextafter (+inf, +inf) = +inf",
2190 FUNC(nextafter) (plus_infty, plus_infty));
2191 check_isinfn ("nextafter (-inf, -inf) = -inf",
2192 FUNC(nextafter) (minus_infty, minus_infty));
2194 x = rand () * 1.1;
2195 check_isnan ("nextafter (NaN, x) = NaN", FUNC(nextafter) (nan_value, x));
2196 check_isnan ("nextafter (x, NaN) = NaN", FUNC(nextafter) (x, nan_value));
2197 check_isnan ("nextafter (NaN, NaN) = NaN", FUNC(nextafter) (nan_value,
2198 nan_value));
2200 /* XXX We need the hexadecimal FP number representation here for further
2201 tests. */
2205 static void
2206 copysign_test (void)
2208 check ("copysign (0, 4) = 0", FUNC(copysign) (0, 4), 0);
2209 check ("copysign (0, -4) = -0", FUNC(copysign) (0, -4), minus_zero);
2210 check ("copysign (-0, 4) = 0", FUNC(copysign) (minus_zero, 4), 0);
2211 check ("copysign (-0, -4) = -0", FUNC(copysign) (minus_zero, -4),
2212 minus_zero);
2214 check_isinfp ("copysign (+inf, 0) = +inf", FUNC(copysign) (plus_infty, 0));
2215 check_isinfn ("copysign (+inf, -0) = -inf", FUNC(copysign) (plus_infty,
2216 minus_zero));
2217 check_isinfp ("copysign (-inf, 0) = +inf", FUNC(copysign) (minus_infty, 0));
2218 check_isinfn ("copysign (-inf, -0) = -inf", FUNC(copysign) (minus_infty,
2219 minus_zero));
2221 check ("copysign (0, +inf) = 0", FUNC(copysign) (0, plus_infty), 0);
2222 check ("copysign (0, -inf) = -0", FUNC(copysign) (0, minus_zero),
2223 minus_zero);
2224 check ("copysign (-0, +inf) = 0", FUNC(copysign) (minus_zero, plus_infty),
2226 check ("copysign (-0, -inf) = -0", FUNC(copysign) (minus_zero, minus_zero),
2227 minus_zero);
2229 /* XXX More correctly we would have to check the sign of the NaN. */
2230 check_isnan ("copysign (+NaN, 0) = +NaN", FUNC(copysign) (nan_value, 0));
2231 check_isnan ("copysign (+NaN, -0) = -NaN", FUNC(copysign) (nan_value,
2232 minus_zero));
2233 check_isnan ("copysign (-NaN, 0) = +NaN", FUNC(copysign) (-nan_value, 0));
2234 check_isnan ("copysign (-NaN, -0) = -NaN", FUNC(copysign) (-nan_value,
2235 minus_zero));
2239 static void
2240 trunc_test (void)
2242 check ("trunc(0) = 0", FUNC(trunc) (0), 0);
2243 check ("trunc(-0) = -0", FUNC(trunc) (minus_zero), minus_zero);
2244 check ("trunc(0.625) = 0", FUNC(trunc) (0.625), 0);
2245 check ("trunc(-0.625) = -0", FUNC(trunc) (-0.625), minus_zero);
2246 check ("trunc(1) = 1", FUNC(trunc) (1), 1);
2247 check ("trunc(-1) = -1", FUNC(trunc) (-1), -1);
2248 check ("trunc(1.625) = 1", FUNC(trunc) (1.625), 1);
2249 check ("trunc(-1.625) = -1", FUNC(trunc) (-1.625), -1);
2251 check ("trunc(1048580.625) = 1048580", FUNC(trunc) (1048580.625L),
2252 1048580L);
2253 check ("trunc(-1048580.625) = -1048580", FUNC(trunc) (-1048580.625L),
2254 -1048580L);
2256 check ("trunc(8388610.125) = 8388610", FUNC(trunc) (8388610.125L),
2257 8388610.0L);
2258 check ("trunc(-8388610.125) = -8388610", FUNC(trunc) (-8388610.125L),
2259 -8388610.0L);
2261 check ("trunc(4294967296.625) = 4294967296", FUNC(trunc) (4294967296.625L),
2262 4294967296.0L);
2263 check ("trunc(-4294967296.625) = -4294967296",
2264 FUNC(trunc) (-4294967296.625L), -4294967296.0L);
2266 check_isinfp ("trunc(+inf) = +inf", FUNC(trunc) (plus_infty));
2267 check_isinfn ("trunc(-inf) = -inf", FUNC(trunc) (minus_infty));
2268 check_isnan ("trunc(NaN) = NaN", FUNC(trunc) (nan_value));
2272 static void
2273 sqrt_test (void)
2275 MATHTYPE x;
2278 /* XXX Tests fuer negative x are missing */
2279 check ("sqrt (0) == 0", FUNC(sqrt) (0), 0);
2280 check_isnan ("sqrt (NaN) == NaN", FUNC(sqrt) (nan_value));
2281 check_isinfp ("sqrt (+inf) == +inf", FUNC(sqrt) (plus_infty));
2283 check ("sqrt (-0) == -0", FUNC(sqrt) (0), 0);
2285 x = random_less (0.0);
2286 check_isnan_exc_ext ("sqrt (x) == NaN plus invalid exception for x < 0",
2287 FUNC(sqrt) (x), INVALID_EXCEPTION, x);
2289 x = random_value (0, 10000);
2290 check_ext ("sqrt (x*x) == x", FUNC(sqrt) (x*x), x, x);
2291 check ("sqrt (4) == 2", FUNC(sqrt) (4), 2);
2295 static void
2296 remainder_test (void)
2298 MATHTYPE result;
2300 result = FUNC(remainder) (1, 0);
2301 check_isnan_exc ("remainder(1, +0) == NaN plus invalid exception",
2302 result, INVALID_EXCEPTION);
2304 result = FUNC(remainder) (1, minus_zero);
2305 check_isnan_exc ("remainder(1, -0) == NaN plus invalid exception",
2306 result, INVALID_EXCEPTION);
2308 result = FUNC(remainder) (plus_infty, 1);
2309 check_isnan_exc ("remainder(+inf, 1) == NaN plus invalid exception",
2310 result, INVALID_EXCEPTION);
2312 result = FUNC(remainder) (minus_infty, 1);
2313 check_isnan_exc ("remainder(-inf, 1) == NaN plus invalid exception",
2314 result, INVALID_EXCEPTION);
2316 result = FUNC(remainder) (1.625, 1.0);
2317 check ("remainder(1.625, 1.0) == -0.375", result, -0.375);
2319 result = FUNC(remainder) (-1.625, 1.0);
2320 check ("remainder(-1.625, 1.0) == 0.375", result, 0.375);
2322 result = FUNC(remainder) (1.625, -1.0);
2323 check ("remainder(1.625, -1.0) == -0.375", result, -0.375);
2325 result = FUNC(remainder) (-1.625, -1.0);
2326 check ("remainder(-1.625, -1.0) == 0.375", result, 0.375);
2328 result = FUNC(remainder) (5.0, 2.0);
2329 check ("remainder(5.0, 2.0) == 1.0", result, 1.0);
2331 result = FUNC(remainder) (3.0, 2.0);
2332 check ("remainder(3.0, 2.0) == -1.0", result, -1.0);
2336 static void
2337 remquo_test (void)
2339 int quo;
2340 MATHTYPE result;
2342 result = FUNC(remquo) (1, 0, &quo);
2343 check_isnan_exc ("remquo(1, +0, &x) == NaN plus invalid exception",
2344 result, INVALID_EXCEPTION);
2346 result = FUNC(remquo) (1, minus_zero, &quo);
2347 check_isnan_exc ("remquo(1, -0, &x) == NaN plus invalid exception",
2348 result, INVALID_EXCEPTION);
2350 result = FUNC(remquo) (plus_infty, 1, &quo);
2351 check_isnan_exc ("remquo(+inf, 1, &x) == NaN plus invalid exception",
2352 result, INVALID_EXCEPTION);
2354 result = FUNC(remquo) (minus_infty, 1, &quo);
2355 check_isnan_exc ("remquo(-inf, 1, &x) == NaN plus invalid exception",
2356 result, INVALID_EXCEPTION);
2358 result = FUNC(remquo) (1.625, 1.0, &quo);
2359 check ("remquo(1.625, 1.0, &x) == -0.375", result, -0.375);
2360 check_long ("remquo(1.625, 1.0, &x) puts 2 in x", quo, 2);
2362 result = FUNC(remquo) (-1.625, 1.0, &quo);
2363 check ("remquo(-1.625, 1.0, &x) == 0.375", result, 0.375);
2364 check_long ("remquo(-1.625, 1.0, &x) puts -2 in x", quo, -2);
2366 result = FUNC(remquo) (1.625, -1.0, &quo);
2367 check ("remquo(1.625, -1.0, &x) == -0.375", result, -0.375);
2368 check_long ("remquo(1.625, -1.0, &x) puts -2 in x", quo, -2);
2370 result = FUNC(remquo) (-1.625, -1.0, &quo);
2371 check ("remquo(-1.625, -1.0, &x) == 0.375", result, 0.375);
2372 check_long ("remquo(-1.625, -1.0, &x) puts 2 in x", quo, 2);
2374 result = FUNC(remquo) (5.0, 2.0, &quo);
2375 check ("remquo(5.0, 2.0, &x) == 1.0", result, 1.0);
2376 check_long ("remquo (5.0, 2.0, &x) puts 2 in x", quo, 2);
2378 result = FUNC(remquo) (3.0, 2.0, &quo);
2379 check ("remquo(3.0, 2.0, &x) == -1.0", result, -1.0);
2380 check_long ("remquo (3.0, 2.0, &x) puts 2 in x", quo, 2);
2384 static void
2385 cexp_test (void)
2387 __complex__ MATHTYPE result;
2389 result = FUNC(cexp) (BUILD_COMPLEX (plus_zero, plus_zero));
2390 check ("real(cexp(0 + 0i)) = 1", __real__ result, 1);
2391 check ("imag(cexp(0 + 0i)) = 0", __imag__ result, 0);
2392 result = FUNC(cexp) (BUILD_COMPLEX (minus_zero, plus_zero));
2393 check ("real(cexp(-0 + 0i)) = 1", __real__ result, 1);
2394 check ("imag(cexp(-0 + 0i)) = 0", __imag__ result, 0);
2395 result = FUNC(cexp) (BUILD_COMPLEX (plus_zero, minus_zero));
2396 check ("real(cexp(0 - 0i)) = 1", __real__ result, 1);
2397 check ("imag(cexp(0 - 0i)) = -0", __imag__ result, minus_zero);
2398 result = FUNC(cexp) (BUILD_COMPLEX (minus_zero, minus_zero));
2399 check ("real(cexp(-0 - 0i)) = 1", __real__ result, 1);
2400 check ("imag(cexp(-0 - 0i)) = -0", __imag__ result, minus_zero);
2402 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, plus_zero));
2403 check_isinfp ("real(cexp(+inf + 0i)) = +inf", __real__ result);
2404 check ("imag(cexp(+inf + 0i)) = 0", __imag__ result, 0);
2405 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, minus_zero));
2406 check_isinfp ("real(cexp(+inf - 0i)) = +inf", __real__ result);
2407 check ("imag(cexp(+inf - 0i)) = -0", __imag__ result, minus_zero);
2409 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, plus_zero));
2410 check ("real(cexp(-inf + 0i)) = 0", __real__ result, 0);
2411 check ("imag(cexp(-inf + 0i)) = 0", __imag__ result, 0);
2412 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, minus_zero));
2413 check ("real(cexp(-inf - 0i)) = 0", __real__ result, 0);
2414 check ("imag(cexp(-inf - 0i)) = -0", __imag__ result, minus_zero);
2417 result = FUNC(cexp) (BUILD_COMPLEX (0.0, plus_infty));
2418 check_isnan_exc ("real(cexp(0 + i inf)) = NaN plus invalid exception",
2419 __real__ result, INVALID_EXCEPTION);
2420 check_isnan ("imag(cexp(0 + i inf)) = NaN plus invalid exception",
2421 __imag__ result);
2423 #if defined __GNUC__ && __GNUC__ <= 2 && __GNUC_MINOR <= 7
2424 if (verbose)
2425 printf ("The following test for cexp might fail due to a gcc compiler error!\n");
2426 #endif
2428 result = FUNC(cexp) (BUILD_COMPLEX (minus_zero, plus_infty));
2429 check_isnan_exc ("real(cexp(-0 + i inf)) = NaN plus invalid exception",
2430 __real__ result, INVALID_EXCEPTION);
2431 check_isnan ("imag(cexp(-0 + i inf)) = NaN plus invalid exception",
2432 __imag__ result);
2433 result = FUNC(cexp) (BUILD_COMPLEX (0.0, minus_infty));
2434 check_isnan_exc ("real(cexp(0 - i inf)) = NaN plus invalid exception",
2435 __real__ result, INVALID_EXCEPTION);
2436 check_isnan ("imag(cexp(0 - i inf)) = NaN plus invalid exception",
2437 __imag__ result);
2438 result = FUNC(cexp) (BUILD_COMPLEX (minus_zero, minus_infty));
2439 check_isnan_exc ("real(cexp(-0 - i inf)) = NaN plus invalid exception",
2440 __real__ result, INVALID_EXCEPTION);
2441 check_isnan ("imag(cexp(-0 - i inf)) = NaN plus invalid exception",
2442 __imag__ result);
2444 result = FUNC(cexp) (BUILD_COMPLEX (100.0, plus_infty));
2445 check_isnan_exc ("real(cexp(100.0 + i inf)) = NaN plus invalid exception",
2446 __real__ result, INVALID_EXCEPTION);
2447 check_isnan ("imag(cexp(100.0 + i inf)) = NaN plus invalid exception",
2448 __imag__ result);
2449 result = FUNC(cexp) (BUILD_COMPLEX (-100.0, plus_infty));
2450 check_isnan_exc ("real(cexp(-100.0 + i inf)) = NaN plus invalid exception",
2451 __real__ result, INVALID_EXCEPTION);
2452 check_isnan ("imag(cexp(-100.0 + i inf)) = NaN plus invalid exception",
2453 __imag__ result);
2454 result = FUNC(cexp) (BUILD_COMPLEX (100.0, minus_infty));
2455 check_isnan_exc ("real(cexp(100.0 - i inf)) = NaN plus invalid exception",
2456 __real__ result, INVALID_EXCEPTION);
2457 check_isnan ("imag(cexp(100.0 - i inf)) = NaN plus invalid exception",
2458 __imag__ result);
2459 result = FUNC(cexp) (BUILD_COMPLEX (-100.0, minus_infty));
2460 check_isnan_exc ("real(cexp(-100.0 - i inf)) = NaN plus invalid exception",
2461 __real__ result, INVALID_EXCEPTION);
2462 check_isnan ("imag(cexp(-100.0 - i inf)) = NaN", __imag__ result);
2464 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, 2.0));
2465 check ("real(cexp(-inf + 2.0i)) = -0", __real__ result, minus_zero);
2466 check ("imag(cexp(-inf + 2.0i)) = 0", __imag__ result, 0);
2467 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, 4.0));
2468 check ("real(cexp(-inf + 4.0i)) = -0", __real__ result, minus_zero);
2469 check ("imag(cexp(-inf + 4.0i)) = -0", __imag__ result, minus_zero);
2471 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, 2.0));
2472 check_isinfn ("real(cexp(+inf + 2.0i)) = -inf", __real__ result);
2473 check_isinfp ("imag(cexp(+inf + 2.0i)) = +inf", __imag__ result);
2474 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, 4.0));
2475 check_isinfn ("real(cexp(+inf + 4.0i)) = -inf", __real__ result);
2476 check_isinfn ("imag(cexp(+inf + 4.0i)) = -inf", __imag__ result);
2478 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, plus_infty));
2479 check_isinfp_exc ("real(cexp(+inf + i inf)) = +inf plus invalid exception",
2480 __real__ result, INVALID_EXCEPTION);
2481 check_isnan ("imag(cexp(+inf + i inf)) = NaN plus invalid exception",
2482 __imag__ result);
2483 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, minus_infty));
2484 check_isinfp_exc ("real(cexp(+inf - i inf)) = +inf plus invalid exception",
2485 __real__ result, INVALID_EXCEPTION);
2486 check_isnan ("imag(cexp(+inf - i inf)) = NaN plus invalid exception",
2487 __imag__ result);
2489 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, plus_infty));
2490 check ("real(cexp(-inf + i inf)) = 0", __real__ result, 0);
2491 check ("imag(cexp(-inf + i inf)) = 0", __imag__ result, 0);
2492 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, minus_infty));
2493 check ("real(cexp(-inf - i inf)) = 0", __real__ result, 0);
2494 check ("imag(cexp(-inf - i inf)) = -0", __imag__ result, minus_zero);
2496 result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, nan_value));
2497 check ("real(cexp(-inf + i NaN)) = 0", __real__ result, 0);
2498 check ("imag(cexp(-inf + i NaN)) = 0", fabs (__imag__ result), 0);
2500 result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, nan_value));
2501 check_isinfp ("real(cexp(+inf + i NaN)) = +inf", __real__ result);
2502 check_isnan ("imag(cexp(+inf + i NaN)) = NaN", __imag__ result);
2504 result = FUNC(cexp) (BUILD_COMPLEX (nan_value, 0.0));
2505 check_isnan_maybe_exc ("real(cexp(NaN + i0)) = NaN plus maybe invalid exception",
2506 __real__ result, INVALID_EXCEPTION);
2507 check_isnan ("imag(cexp(NaN + i0)) = NaN plus maybe invalid exception",
2508 __imag__ result);
2509 result = FUNC(cexp) (BUILD_COMPLEX (nan_value, 1.0));
2510 check_isnan_maybe_exc ("real(cexp(NaN + 1i)) = NaN plus maybe invalid exception",
2511 __real__ result, INVALID_EXCEPTION);
2512 check_isnan ("imag(cexp(NaN + 1i)) = NaN plus maybe invalid exception",
2513 __imag__ result);
2514 result = FUNC(cexp) (BUILD_COMPLEX (nan_value, plus_infty));
2515 check_isnan_maybe_exc ("real(cexp(NaN + i inf)) = NaN plus maybe invalid exception",
2516 __real__ result, INVALID_EXCEPTION);
2517 check_isnan ("imag(cexp(NaN + i inf)) = NaN plus maybe invalid exception",
2518 __imag__ result);
2520 result = FUNC(cexp) (BUILD_COMPLEX (0, nan_value));
2521 check_isnan_maybe_exc ("real(cexp(0 + i NaN)) = NaN plus maybe invalid exception",
2522 __real__ result, INVALID_EXCEPTION);
2523 check_isnan ("imag(cexp(0 + i NaN)) = NaN plus maybe invalid exception",
2524 __imag__ result);
2525 result = FUNC(cexp) (BUILD_COMPLEX (1, nan_value));
2526 check_isnan_maybe_exc ("real(cexp(1 + i NaN)) = NaN plus maybe invalid exception",
2527 __real__ result, INVALID_EXCEPTION);
2528 check_isnan ("imag(cexp(1 + i NaN)) = NaN plus maybe invalid exception",
2529 __imag__ result);
2531 result = FUNC(cexp) (BUILD_COMPLEX (nan_value, nan_value));
2532 check_isnan ("real(cexp(NaN + i NaN)) = NaN", __real__ result);
2533 check_isnan ("imag(cexp(NaN + i NaN)) = NaN", __imag__ result);
2537 static void
2538 csin_test (void)
2540 __complex__ MATHTYPE result;
2542 result = FUNC(csin) (BUILD_COMPLEX (0.0, 0.0));
2543 check ("real(csin(0 + 0i)) = 0", __real__ result, 0);
2544 check ("imag(csin(0 + 0i)) = 0", __imag__ result, 0);
2545 result = FUNC(csin) (BUILD_COMPLEX (minus_zero, 0.0));
2546 check ("real(csin(-0 + 0i)) = -0", __real__ result, minus_zero);
2547 check ("imag(csin(-0 + 0i)) = 0", __imag__ result, 0);
2548 result = FUNC(csin) (BUILD_COMPLEX (0.0, minus_zero));
2549 check ("real(csin(0 - 0i)) = 0", __real__ result, 0);
2550 check ("imag(csin(0 - 0i)) = -0", __imag__ result, minus_zero);
2551 result = FUNC(csin) (BUILD_COMPLEX (minus_zero, minus_zero));
2552 check ("real(csin(-0 - 0i)) = -0", __real__ result, minus_zero);
2553 check ("imag(csin(-0 - 0i)) = -0", __imag__ result, minus_zero);
2555 result = FUNC(csin) (BUILD_COMPLEX (0.0, plus_infty));
2556 check ("real(csin(0 + i Inf)) = 0", __real__ result, 0);
2557 check_isinfp ("imag(csin(0 + i Inf)) = +Inf", __imag__ result);
2558 result = FUNC(csin) (BUILD_COMPLEX (minus_zero, plus_infty));
2559 check ("real(csin(-0 + i Inf)) = -0", __real__ result, minus_zero);
2560 check_isinfp ("imag(csin(-0 + i Inf)) = +Inf", __imag__ result);
2561 result = FUNC(csin) (BUILD_COMPLEX (0.0, minus_infty));
2562 check ("real(csin(0 - i Inf)) = 0", __real__ result, 0);
2563 check_isinfn ("imag(csin(0 - i Inf)) = -Inf", __imag__ result);
2564 result = FUNC(csin) (BUILD_COMPLEX (minus_zero, minus_infty));
2565 check ("real(csin(-0 - i Inf)) = -0", __real__ result, minus_zero);
2566 check_isinfn("imag(csin(-0 - i Inf)) = -Inf", __imag__ result);
2568 result = FUNC(csin) (BUILD_COMPLEX (plus_infty, 0.0));
2569 check_isnan_exc ("real(csin(+Inf + 0i)) = NaN plus invalid exception",
2570 __real__ result, INVALID_EXCEPTION);
2571 check ("imag(csin(+Inf + 0i)) = +-0 plus invalid exception",
2572 FUNC(fabs) (__imag__ result), 0);
2573 result = FUNC(csin) (BUILD_COMPLEX (minus_infty, 0.0));
2574 check_isnan_exc ("real(csin(-Inf + 0i)) = NaN plus invalid exception",
2575 __real__ result, INVALID_EXCEPTION);
2576 check ("imag(csin(-Inf + 0i)) = +-0 plus invalid exception",
2577 FUNC(fabs) (__imag__ result), 0);
2578 result = FUNC(csin) (BUILD_COMPLEX (plus_infty, minus_zero));
2579 check_isnan_exc ("real(csin(+Inf - 0i)) = NaN plus invalid exception",
2580 __real__ result, INVALID_EXCEPTION);
2581 check ("imag(csin(+Inf - 0i)) = +-0 plus invalid exception",
2582 FUNC(fabs) (__imag__ result), 0.0);
2583 result = FUNC(csin) (BUILD_COMPLEX (minus_infty, minus_zero));
2584 check_isnan_exc ("real(csin(-Inf - 0i)) = NaN plus invalid exception",
2585 __real__ result, INVALID_EXCEPTION);
2586 check ("imag(csin(-Inf - 0i)) = +-0 plus invalid exception",
2587 FUNC(fabs) (__imag__ result), 0.0);
2589 result = FUNC(csin) (BUILD_COMPLEX (plus_infty, plus_infty));
2590 check_isnan_exc ("real(csin(+Inf + i Inf)) = NaN plus invalid exception",
2591 __real__ result, INVALID_EXCEPTION);
2592 check_isinfp ("imag(csin(+Inf + i Inf)) = +-Inf plus invalid exception",
2593 FUNC(fabs) (__imag__ result));
2594 result = FUNC(csin) (BUILD_COMPLEX (minus_infty, plus_infty));
2595 check_isnan_exc ("real(csin(-Inf + i Inf)) = NaN plus invalid exception",
2596 __real__ result, INVALID_EXCEPTION);
2597 check_isinfp ("imag(csin(-Inf + i Inf)) = +-Inf plus invalid exception",
2598 FUNC(fabs) (__imag__ result));
2599 result = FUNC(csin) (BUILD_COMPLEX (plus_infty, minus_infty));
2600 check_isnan_exc ("real(csin(Inf - i Inf)) = NaN plus invalid exception",
2601 __real__ result, INVALID_EXCEPTION);
2602 check_isinfp ("imag(csin(Inf - i Inf)) = +-Inf plus invalid exception",
2603 FUNC(fabs) (__imag__ result));
2604 result = FUNC(csin) (BUILD_COMPLEX (minus_infty, minus_infty));
2605 check_isnan_exc ("real(csin(-Inf - i Inf)) = NaN plus invalid exception",
2606 __real__ result, INVALID_EXCEPTION);
2607 check_isinfp ("imag(csin(-Inf - i Inf)) = +-Inf plus invalid exception",
2608 FUNC(fabs) (__imag__ result));
2610 result = FUNC(csin) (BUILD_COMPLEX (plus_infty, 6.75));
2611 check_isnan_exc ("real(csin(+Inf + i 6.75)) = NaN plus invalid exception",
2612 __real__ result, INVALID_EXCEPTION);
2613 check_isnan ("imag(csin(+Inf + i6.75)) = NaN plus invalid exception",
2614 __imag__ result);
2615 result = FUNC(csin) (BUILD_COMPLEX (plus_infty, -6.75));
2616 check_isnan_exc ("real(csin(+Inf - i 6.75)) = NaN plus invalid exception",
2617 __real__ result, INVALID_EXCEPTION);
2618 check_isnan ("imag(csin(+Inf - i6.75)) = NaN plus invalid exception",
2619 __imag__ result);
2620 result = FUNC(csin) (BUILD_COMPLEX (minus_infty, 6.75));
2621 check_isnan_exc ("real(csin(-Inf + i6.75)) = NaN plus invalid exception",
2622 __real__ result, INVALID_EXCEPTION);
2623 check_isnan ("imag(csin(-Inf + i6.75)) = NaN plus invalid exception",
2624 __imag__ result);
2625 result = FUNC(csin) (BUILD_COMPLEX (minus_infty, -6.75));
2626 check_isnan_exc ("real(csin(-Inf - i6.75)) = NaN plus invalid exception",
2627 __real__ result, INVALID_EXCEPTION);
2628 check_isnan ("imag(csin(-Inf - i6.75)) = NaN plus invalid exception",
2629 __imag__ result);
2631 result = FUNC(csin) (BUILD_COMPLEX (4.625, plus_infty));
2632 check_isinfn ("real(csin(4.625 + i Inf)) = -Inf", __real__ result);
2633 check_isinfn ("imag(csin(4.625 + i Inf)) = -Inf", __imag__ result);
2634 result = FUNC(csin) (BUILD_COMPLEX (4.625, minus_infty));
2635 check_isinfn ("real(csin(4.625 - i Inf)) = -Inf", __real__ result);
2636 check_isinfp ("imag(csin(4.625 - i Inf)) = +Inf", __imag__ result);
2637 result = FUNC(csin) (BUILD_COMPLEX (-4.625, plus_infty));
2638 check_isinfp ("real(csin(-4.625 + i Inf)) = +Inf", __real__ result);
2639 check_isinfn ("imag(csin(-4.625 + i Inf)) = -Inf", __imag__ result);
2640 result = FUNC(csin) (BUILD_COMPLEX (-4.625, minus_infty));
2641 check_isinfp ("real(csin(-4.625 - i Inf)) = +Inf", __real__ result);
2642 check_isinfp ("imag(csin(-4.625 - i Inf)) = +Inf", __imag__ result);
2644 result = FUNC(csin) (BUILD_COMPLEX (nan_value, 0.0));
2645 check_isnan ("real(csin(NaN + i0)) = NaN", __real__ result);
2646 check ("imag(csin(NaN + i0)) = +-0", FUNC(fabs) (__imag__ result), 0);
2647 result = FUNC(csin) (BUILD_COMPLEX (nan_value, minus_zero));
2648 check_isnan ("real(csin(NaN - i0)) = NaN", __real__ result);
2649 check ("imag(csin(NaN - i0)) = +-0", FUNC(fabs) (__imag__ result), 0);
2651 result = FUNC(csin) (BUILD_COMPLEX (nan_value, plus_infty));
2652 check_isnan ("real(csin(NaN + i Inf)) = NaN", __real__ result);
2653 check_isinfp ("imag(csin(NaN + i Inf)) = +-Inf",
2654 FUNC(fabs) (__imag__ result));
2655 result = FUNC(csin) (BUILD_COMPLEX (nan_value, minus_infty));
2656 check_isnan ("real(csin(NaN - i Inf)) = NaN", __real__ result);
2657 check_isinfp ("real(csin(NaN - i Inf)) = +-Inf",
2658 FUNC(fabs) (__imag__ result));
2660 result = FUNC(csin) (BUILD_COMPLEX (nan_value, 9.0));
2661 check_isnan_maybe_exc ("real(csin(NaN + i9.0)) = NaN plus maybe invalid exception",
2662 __real__ result, INVALID_EXCEPTION);
2663 check_isnan ("imag(csin(NaN + i9.0)) = NaN plus maybe invalid exception",
2664 __imag__ result);
2665 result = FUNC(csin) (BUILD_COMPLEX (nan_value, -9.0));
2666 check_isnan_maybe_exc ("real(csin(NaN - i9.0)) = NaN plus maybe invalid exception",
2667 __real__ result, INVALID_EXCEPTION);
2668 check_isnan ("imag(csin(NaN - i9.0)) = NaN plus maybe invalid exception",
2669 __imag__ result);
2671 result = FUNC(csin) (BUILD_COMPLEX (0.0, nan_value));
2672 check ("real(csin(0 + i NaN))", __real__ result, 0.0);
2673 check_isnan ("imag(csin(0 + i NaN)) = NaN", __imag__ result);
2674 result = FUNC(csin) (BUILD_COMPLEX (minus_zero, nan_value));
2675 check ("real(csin(-0 + i NaN)) = -0", __real__ result, minus_zero);
2676 check_isnan ("imag(csin(-0 + NaN)) = NaN", __imag__ result);
2678 result = FUNC(csin) (BUILD_COMPLEX (10.0, nan_value));
2679 check_isnan_maybe_exc ("real(csin(10 + i NaN)) = NaN plus maybe invalid exception",
2680 __real__ result, INVALID_EXCEPTION);
2681 check_isnan ("imag(csin(10 + i NaN)) = NaN plus maybe invalid exception",
2682 __imag__ result);
2683 result = FUNC(csin) (BUILD_COMPLEX (nan_value, -10.0));
2684 check_isnan_maybe_exc ("real(csin(-10 + i NaN)) = NaN plus maybe invalid exception",
2685 __real__ result, INVALID_EXCEPTION);
2686 check_isnan ("imag(csin(-10 + i NaN)) = NaN plus maybe invalid exception",
2687 __imag__ result);
2689 result = FUNC(csin) (BUILD_COMPLEX (plus_infty, nan_value));
2690 check_isnan_maybe_exc ("real(csin(+Inf + i NaN)) = NaN plus maybe invalid exception",
2691 __real__ result, INVALID_EXCEPTION);
2692 check_isnan ("imag(csin(+Inf + i NaN)) = NaN plus maybe invalid exception",
2693 __imag__ result);
2694 result = FUNC(csin) (BUILD_COMPLEX (minus_infty, nan_value));
2695 check_isnan_maybe_exc ("real(csin(-Inf + i NaN)) = NaN plus maybe invalid exception",
2696 __real__ result, INVALID_EXCEPTION);
2697 check_isnan ("imag(csin(-Inf + i NaN)) = NaN plus maybe invalid exception",
2698 __imag__ result);
2700 result = FUNC(csin) (BUILD_COMPLEX (nan_value, nan_value));
2701 check_isnan ("real(csin(NaN + i NaN)) = NaN", __real__ result);
2702 check_isnan ("imag(csin(NaN + i NaN)) = NaN", __imag__ result);
2706 static void
2707 csinh_test (void)
2709 __complex__ MATHTYPE result;
2711 result = FUNC(csinh) (BUILD_COMPLEX (0.0, 0.0));
2712 check ("real(csinh(0 + 0i)) = 0", __real__ result, 0);
2713 check ("imag(csinh(0 + 0i)) = 0", __imag__ result, 0);
2714 result = FUNC(csinh) (BUILD_COMPLEX (minus_zero, 0.0));
2715 check ("real(csinh(-0 + 0i)) = -0", __real__ result, minus_zero);
2716 check ("imag(csinh(-0 + 0i)) = 0", __imag__ result, 0);
2717 result = FUNC(csinh) (BUILD_COMPLEX (0.0, minus_zero));
2718 check ("real(csinh(0 - 0i)) = 0", __real__ result, 0);
2719 check ("imag(csinh(0 - 0i)) = -0", __imag__ result, minus_zero);
2720 result = FUNC(csinh) (BUILD_COMPLEX (minus_zero, minus_zero));
2721 check ("real(csinh(-0 - 0i)) = -0", __real__ result, minus_zero);
2722 check ("imag(csinh(-0 - 0i)) = -0", __imag__ result, minus_zero);
2724 result = FUNC(csinh) (BUILD_COMPLEX (0.0, plus_infty));
2725 check_exc ("real(csinh(0 + i Inf)) = +-0 plus invalid exception",
2726 FUNC(fabs) (__real__ result), 0, INVALID_EXCEPTION);
2727 check_isnan ("imag(csinh(0 + i Inf)) = NaN plus invalid exception",
2728 __imag__ result);
2729 result = FUNC(csinh) (BUILD_COMPLEX (minus_zero, plus_infty));
2730 check_exc ("real(csinh(-0 + i Inf)) = +-0 plus invalid exception",
2731 FUNC(fabs) (__real__ result), 0, INVALID_EXCEPTION);
2732 check_isnan ("imag(csinh(-0 + i Inf)) = NaN plus invalid exception",
2733 __imag__ result);
2734 result = FUNC(csinh) (BUILD_COMPLEX (0.0, minus_infty));
2735 check_exc ("real(csinh(0 - i Inf)) = +-0 plus invalid exception",
2736 FUNC(fabs) (__real__ result), 0, INVALID_EXCEPTION);
2737 check_isnan ("imag(csinh(0 - i Inf)) = NaN plus invalid exception",
2738 __imag__ result);
2739 result = FUNC(csinh) (BUILD_COMPLEX (minus_zero, minus_infty));
2740 check_exc ("real(csinh(-0 - i Inf)) = +-0 plus invalid exception",
2741 FUNC(fabs) (__real__ result), 0, INVALID_EXCEPTION);
2742 check_isnan ("imag(csinh(-0 - i Inf)) = NaN plus invalid exception",
2743 __imag__ result);
2745 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, 0.0));
2746 check_isinfp ("real(csinh(+Inf + 0i)) = +Inf", __real__ result);
2747 check ("imag(csinh(+Inf + 0i)) = 0", __imag__ result, 0);
2748 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, 0.0));
2749 check_isinfn ("real(csinh(-Inf + 0i)) = -Inf", __real__ result);
2750 check ("imag(csinh(-Inf + 0i)) = 0", __imag__ result, 0);
2751 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, minus_zero));
2752 check_isinfp ("real(csinh(+Inf - 0i)) = +Inf", __real__ result);
2753 check ("imag(csinh(+Inf - 0i)) = -0", __imag__ result, minus_zero);
2754 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, minus_zero));
2755 check_isinfn ("real(csinh(-Inf - 0i)) = -Inf", __real__ result);
2756 check ("imag(csinh(-Inf - 0i)) = -0", __imag__ result, minus_zero);
2758 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, plus_infty));
2759 check_isinfp_exc ("real(csinh(+Inf + i Inf)) = +-Inf plus invalid exception",
2760 FUNC(fabs) (__real__ result), INVALID_EXCEPTION);
2761 check_isnan ("imag(csinh(+Inf + i Inf)) = NaN plus invalid exception",
2762 __imag__ result);
2763 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, plus_infty));
2764 check_isinfp_exc ("real(csinh(-Inf + i Inf)) = +-Inf plus invalid exception",
2765 FUNC(fabs) (__real__ result), INVALID_EXCEPTION);
2766 check_isnan ("imag(csinh(-Inf + i Inf)) = NaN plus invalid exception",
2767 __imag__ result);
2768 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, minus_infty));
2769 check_isinfp_exc ("real(csinh(Inf - i Inf)) = +-Inf plus invalid exception",
2770 FUNC(fabs) (__real__ result), INVALID_EXCEPTION);
2771 check_isnan ("imag(csinh(Inf - i Inf)) = NaN plus invalid exception",
2772 __imag__ result);
2773 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, minus_infty));
2774 check_isinfp_exc ("real(csinh(-Inf - i Inf)) = +-Inf plus invalid exception",
2775 FUNC(fabs) (__real__ result), INVALID_EXCEPTION);
2776 check_isnan ("imag(csinh(-Inf - i Inf)) = NaN plus invalid exception",
2777 __imag__ result);
2779 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, 4.625));
2780 check_isinfn ("real(csinh(+Inf + i4.625)) = -Inf", __real__ result);
2781 check_isinfn ("imag(csinh(+Inf + i4.625)) = -Inf", __imag__ result);
2782 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, 4.625));
2783 check_isinfp ("real(csinh(-Inf + i4.625)) = +Inf", __real__ result);
2784 check_isinfn ("imag(csinh(-Inf + i4.625)) = -Inf", __imag__ result);
2785 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, -4.625));
2786 check_isinfn ("real(csinh(+Inf - i4.625)) = -Inf", __real__ result);
2787 check_isinfp ("imag(csinh(+Inf - i4.625)) = +Inf", __imag__ result);
2788 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, -4.625));
2789 check_isinfp ("real(csinh(-Inf - i4.625)) = +Inf", __real__ result);
2790 check_isinfp ("imag(csinh(-Inf - i4.625)) = +Inf", __imag__ result);
2792 result = FUNC(csinh) (BUILD_COMPLEX (6.75, plus_infty));
2793 check_isnan_exc ("real(csinh(6.75 + i Inf)) = NaN plus invalid exception",
2794 __real__ result, INVALID_EXCEPTION);
2795 check_isnan ("imag(csinh(6.75 + i Inf)) = NaN plus invalid exception",
2796 __imag__ result);
2797 result = FUNC(csinh) (BUILD_COMPLEX (-6.75, plus_infty));
2798 check_isnan_exc ("real(csinh(-6.75 + i Inf)) = NaN plus invalid exception",
2799 __real__ result, INVALID_EXCEPTION);
2800 check_isnan ("imag(csinh(-6.75 + i Inf)) = NaN plus invalid exception",
2801 __imag__ result);
2802 result = FUNC(csinh) (BUILD_COMPLEX (6.75, minus_infty));
2803 check_isnan_exc ("real(csinh(6.75 - i Inf)) = NaN plus invalid exception",
2804 __real__ result, INVALID_EXCEPTION);
2805 check_isnan ("imag(csinh(6.75 - i Inf)) = NaN plus invalid exception",
2806 __imag__ result);
2807 result = FUNC(csinh) (BUILD_COMPLEX (-6.75, minus_infty));
2808 check_isnan_exc ("real(csinh(-6.75 - i Inf)) = NaN plus invalid exception",
2809 __real__ result, INVALID_EXCEPTION);
2810 check_isnan ("imag(csinh(-6.75 - i Inf)) = NaN plus invalid exception",
2811 __imag__ result);
2813 result = FUNC(csinh) (BUILD_COMPLEX (0.0, nan_value));
2814 check ("real(csinh(0 + i NaN)) = +-0", FUNC(fabs) (__real__ result), 0);
2815 check_isnan ("imag(csinh(0 + i NaN)) = NaN", __imag__ result);
2816 result = FUNC(csinh) (BUILD_COMPLEX (minus_zero, nan_value));
2817 check ("real(csinh(-0 + i NaN)) = +-0", FUNC(fabs) (__real__ result), 0);
2818 check_isnan ("imag(csinh(-0 + i NaN)) = NaN", __imag__ result);
2820 result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, nan_value));
2821 check_isinfp ("real(csinh(+Inf + i NaN)) = +-Inf",
2822 FUNC(fabs) (__real__ result));
2823 check_isnan ("imag(csinh(+Inf + i NaN)) = NaN", __imag__ result);
2824 result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, nan_value));
2825 check_isinfp ("real(csinh(-Inf + i NaN)) = +-Inf",
2826 FUNC(fabs) (__real__ result));
2827 check_isnan ("imag(csinh(-Inf + i NaN)) = NaN", __imag__ result);
2829 result = FUNC(csinh) (BUILD_COMPLEX (9.0, nan_value));
2830 check_isnan_maybe_exc ("real(csinh(9.0 + i NaN)) = NaN plus maybe invalid exception",
2831 __real__ result, INVALID_EXCEPTION);
2832 check_isnan ("imag(csinh(9.0 + i NaN)) = NaN plus maybe invalid exception",
2833 __imag__ result);
2834 result = FUNC(csinh) (BUILD_COMPLEX (-9.0, nan_value));
2835 check_isnan_maybe_exc ("real(csinh(-9.0 + i NaN)) = NaN plus maybe invalid exception",
2836 __real__ result, INVALID_EXCEPTION);
2837 check_isnan ("imag(csinh(-9.0 + i NaN)) = NaN plus maybe invalid exception",
2838 __imag__ result);
2840 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, 0.0));
2841 check_isnan ("real(csinh(NaN + i0)) = NaN", __real__ result);
2842 check ("imag(csinh(NaN + i0)) = 0", __imag__ result, 0.0);
2843 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, minus_zero));
2844 check_isnan ("real(csinh(NaN - i0)) = NaN", __real__ result);
2845 check ("imag(csinh(NaN - i0)) = -0", __imag__ result, minus_zero);
2847 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, 10.0));
2848 check_isnan_maybe_exc ("real(csinh(NaN + i10)) = NaN plus maybe invalid exception",
2849 __real__ result, INVALID_EXCEPTION);
2850 check_isnan ("imag(csinh(NaN + i10)) = NaN plus maybe invalid exception",
2851 __imag__ result);
2852 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, -10.0));
2853 check_isnan_maybe_exc ("real(csinh(NaN - i10)) = NaN plus maybe invalid exception",
2854 __real__ result, INVALID_EXCEPTION);
2855 check_isnan ("imag(csinh(NaN - i10)) = NaN plus maybe invalid exception",
2856 __imag__ result);
2858 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, plus_infty));
2859 check_isnan_maybe_exc ("real(csinh(NaN + i Inf)) = NaN plus maybe invalid exception",
2860 __real__ result, INVALID_EXCEPTION);
2861 check_isnan ("imag(csinh(NaN + i Inf)) = NaN plus maybe invalid exception",
2862 __imag__ result);
2863 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, minus_infty));
2864 check_isnan_maybe_exc ("real(csinh(NaN - i Inf)) = NaN plus maybe invalid exception",
2865 __real__ result, INVALID_EXCEPTION);
2866 check_isnan ("imag(csinh(NaN - i Inf)) = NaN plus maybe invalid exception",
2867 __imag__ result);
2869 result = FUNC(csinh) (BUILD_COMPLEX (nan_value, nan_value));
2870 check_isnan ("real(csinh(NaN + i NaN)) = NaN", __real__ result);
2871 check_isnan ("imag(csinh(NaN + i NaN)) = NaN", __imag__ result);
2875 static void
2876 ccos_test (void)
2878 __complex__ MATHTYPE result;
2880 result = FUNC(ccos) (BUILD_COMPLEX (0.0, 0.0));
2881 check ("real(ccos(0 + 0i)) = 1.0", __real__ result, 1.0);
2882 check ("imag(ccos(0 + 0i)) = -0", __imag__ result, minus_zero);
2883 result = FUNC(ccos) (BUILD_COMPLEX (minus_zero, 0.0));
2884 check ("real(ccos(-0 + 0i)) = 1.0", __real__ result, 1.0);
2885 check ("imag(ccos(-0 + 0i)) = 0", __imag__ result, 0.0);
2886 result = FUNC(ccos) (BUILD_COMPLEX (0.0, minus_zero));
2887 check ("real(ccos(0 - 0i)) = 1.0", __real__ result, 1.0);
2888 check ("imag(ccos(0 - 0i)) = 0", __imag__ result, 0.0);
2889 result = FUNC(ccos) (BUILD_COMPLEX (minus_zero, minus_zero));
2890 check ("real(ccos(-0 - 0i)) = 1.0", __real__ result, 1.0);
2891 check ("imag(ccos(-0 - 0i)) = -0", __imag__ result, minus_zero);
2893 result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, 0.0));
2894 check_isnan_exc ("real(ccos(+Inf + i0)) = NaN plus invalid exception",
2895 __real__ result, INVALID_EXCEPTION);
2896 check ("imag(ccos(Inf + i0)) = +-0 plus invalid exception",
2897 FUNC(fabs) (__imag__ result), 0);
2898 result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, minus_zero));
2899 check_isnan_exc ("real(ccos(Inf - i0)) = NaN plus invalid exception",
2900 __real__ result, INVALID_EXCEPTION);
2901 check ("imag(ccos(Inf - i0)) = +-0 plus invalid exception",
2902 FUNC(fabs) (__imag__ result), 0);
2903 result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, 0.0));
2904 check_isnan_exc ("real(ccos(-Inf + i0)) = NaN plus invalid exception",
2905 __real__ result, INVALID_EXCEPTION);
2906 check ("imag(ccos(-Inf + i0)) = +-0 plus invalid exception",
2907 FUNC(fabs) (__imag__ result), 0);
2908 result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, minus_zero));
2909 check_isnan_exc ("real(ccos(-Inf - i0)) = NaN plus invalid exception",
2910 __real__ result, INVALID_EXCEPTION);
2911 check ("imag(ccos(-Inf - i0)) = +-0 plus invalid exception",
2912 FUNC(fabs) (__imag__ result), 0);
2914 result = FUNC(ccos) (BUILD_COMPLEX (0.0, plus_infty));
2915 check_isinfp ("real(ccos(0 + i Inf)) = +Inf", __real__ result);
2916 check ("imag(ccos(0 + i Inf)) = -0", __imag__ result, minus_zero);
2917 result = FUNC(ccos) (BUILD_COMPLEX (0.0, minus_infty));
2918 check_isinfp ("real(ccos(0 - i Inf)) = +Inf", __real__ result);
2919 check ("imag(ccos(0 - i Inf)) = 0", __imag__ result, 0);
2920 result = FUNC(ccos) (BUILD_COMPLEX (minus_zero, plus_infty));
2921 check_isinfp ("real(ccos(-0 + i Inf)) = +Inf", __real__ result);
2922 check ("imag(ccos(-0 + i Inf)) = 0", __imag__ result, 0.0);
2923 result = FUNC(ccos) (BUILD_COMPLEX (minus_zero, minus_infty));
2924 check_isinfp ("real(ccos(-0 - i Inf)) = +Inf", __real__ result);
2925 check ("imag(ccos(-0 - i Inf)) = -0", __imag__ result, minus_zero);
2927 result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, plus_infty));
2928 check_isinfp_exc ("real(ccos(+Inf + i Inf)) = +Inf plus invalid exception",
2929 __real__ result, INVALID_EXCEPTION);
2930 check_isnan ("imag(ccos(+Inf + i Inf)) = NaN plus invalid exception",
2931 __imag__ result);
2932 result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, plus_infty));
2933 check_isinfp_exc ("real(ccos(-Inf + i Inf)) = +Inf plus invalid exception",
2934 __real__ result, INVALID_EXCEPTION);
2935 check_isnan ("imag(ccos(-Inf + i Inf)) = NaN plus invalid exception",
2936 __imag__ result);
2937 result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, minus_infty));
2938 check_isinfp_exc ("real(ccos(Inf - i Inf)) = +Inf plus invalid exception",
2939 __real__ result, INVALID_EXCEPTION);
2940 check_isnan ("imag(ccos(Inf - i Inf)) = NaN plus invalid exception",
2941 __imag__ result);
2942 result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, minus_infty));
2943 check_isinfp_exc ("real(ccos(-Inf - i Inf)) = +Inf plus invalid exception",
2944 __real__ result, INVALID_EXCEPTION);
2945 check_isnan ("imag(ccos(-Inf - i Inf)) = NaN plus invalid exception",
2946 __imag__ result);
2948 result = FUNC(ccos) (BUILD_COMPLEX (4.625, plus_infty));
2949 check_isinfn ("real(ccos(4.625 + i Inf)) = -Inf", __real__ result);
2950 check_isinfp ("imag(ccos(4.625 + i Inf)) = +Inf", __imag__ result);
2951 result = FUNC(ccos) (BUILD_COMPLEX (4.625, minus_infty));
2952 check_isinfn ("real(ccos(4.625 - i Inf)) = -Inf", __real__ result);
2953 check_isinfn ("imag(ccos(4.625 - i Inf)) = -Inf", __imag__ result);
2954 result = FUNC(ccos) (BUILD_COMPLEX (-4.625, plus_infty));
2955 check_isinfn ("real(ccos(-4.625 + i Inf)) = -Inf", __real__ result);
2956 check_isinfn ("imag(ccos(-4.625 + i Inf)) = -Inf", __imag__ result);
2957 result = FUNC(ccos) (BUILD_COMPLEX (-4.625, minus_infty));
2958 check_isinfn ("real(ccos(-4.625 - i Inf)) = -Inf", __real__ result);
2959 check_isinfp ("imag(ccos(-4.625 - i Inf)) = +Inf", __imag__ result);
2961 result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, 6.75));
2962 check_isnan_exc ("real(ccos(+Inf + i6.75)) = NaN plus invalid exception",
2963 __real__ result, INVALID_EXCEPTION);
2964 check_isnan ("imag(ccos(+Inf + i6.75)) = NaN plus invalid exception",
2965 __imag__ result);
2966 result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, -6.75));
2967 check_isnan_exc ("real(ccos(+Inf - i6.75)) = NaN plus invalid exception",
2968 __real__ result, INVALID_EXCEPTION);
2969 check_isnan ("imag(ccos(+Inf - i6.75)) = NaN plus invalid exception",
2970 __imag__ result);
2971 result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, 6.75));
2972 check_isnan_exc ("real(ccos(-Inf + i6.75)) = NaN plus invalid exception",
2973 __real__ result, INVALID_EXCEPTION);
2974 check_isnan ("imag(ccos(-Inf + i6.75)) = NaN plus invalid exception",
2975 __imag__ result);
2976 result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, -6.75));
2977 check_isnan_exc ("real(ccos(-Inf - i6.75)) = NaN plus invalid exception",
2978 __real__ result, INVALID_EXCEPTION);
2979 check_isnan ("imag(ccos(-Inf - i6.75)) = NaN plus invalid exception",
2980 __imag__ result);
2982 result = FUNC(ccos) (BUILD_COMPLEX (nan_value, 0.0));
2983 check_isnan ("real(ccos(NaN + i0)) = NaN", __real__ result);
2984 check ("imag(ccos(NaN + i0)) = +-0", FUNC(fabs) (__imag__ result), 0);
2985 result = FUNC(ccos) (BUILD_COMPLEX (nan_value, minus_zero));
2986 check_isnan ("real(ccos(NaN - i0)) = NaN", __real__ result);
2987 check ("imag(ccos(NaN - i0)) = +-0", FUNC(fabs) (__imag__ result), 0);
2989 result = FUNC(ccos) (BUILD_COMPLEX (nan_value, plus_infty));
2990 check_isinfp ("real(ccos(NaN + i Inf)) = +Inf", __real__ result);
2991 check_isnan ("imag(ccos(NaN + i Inf)) = NaN", __imag__ result);
2992 result = FUNC(ccos) (BUILD_COMPLEX (nan_value, minus_infty));
2993 check_isinfp ("real(ccos(NaN - i Inf)) = +Inf", __real__ result);
2994 check_isnan ("imag(ccos(NaN - i Inf)) = NaN", __imag__ result);
2996 result = FUNC(ccos) (BUILD_COMPLEX (nan_value, 9.0));
2997 check_isnan_maybe_exc ("real(ccos(NaN + i9.0)) = NaN plus maybe invalid exception",
2998 __real__ result, INVALID_EXCEPTION);
2999 check_isnan ("imag(ccos(NaN + i9.0)) = NaN plus maybe invalid exception",
3000 __imag__ result);
3001 result = FUNC(ccos) (BUILD_COMPLEX (nan_value, -9.0));
3002 check_isnan_maybe_exc ("real(ccos(NaN - i9.0)) = NaN plus maybe invalid exception",
3003 __real__ result, INVALID_EXCEPTION);
3004 check_isnan ("imag(ccos(NaN - i9.0)) = NaN plus maybe invalid exception",
3005 __imag__ result);
3007 result = FUNC(ccos) (BUILD_COMPLEX (0.0, nan_value));
3008 check_isnan ("real(ccos(0 + i NaN)) = NaN", __real__ result);
3009 check ("imag(ccos(0 + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0.0);
3010 result = FUNC(ccos) (BUILD_COMPLEX (minus_zero, nan_value));
3011 check_isnan ("real(ccos(-0 + i NaN)) = NaN", __real__ result);
3012 check ("imag(ccos(-0 + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0.0);
3014 result = FUNC(ccos) (BUILD_COMPLEX (10.0, nan_value));
3015 check_isnan_maybe_exc ("real(ccos(10 + i NaN)) = NaN plus maybe invalid exception",
3016 __real__ result, INVALID_EXCEPTION);
3017 check_isnan ("imag(ccos(10 + i NaN)) = NaN plus maybe invalid exception",
3018 __imag__ result);
3019 result = FUNC(ccos) (BUILD_COMPLEX (-10.0, nan_value));
3020 check_isnan_maybe_exc ("real(ccos(-10 + i NaN)) = NaN plus maybe invalid exception",
3021 __real__ result, INVALID_EXCEPTION);
3022 check_isnan ("imag(ccos(-10 + i NaN)) = NaN plus maybe invalid exception",
3023 __imag__ result);
3025 result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, nan_value));
3026 check_isnan_maybe_exc ("real(ccos(+Inf + i NaN)) = NaN plus maybe invalid exception",
3027 __real__ result, INVALID_EXCEPTION);
3028 check_isnan ("imag(ccos(+Inf + i NaN)) = NaN plus maybe invalid exception",
3029 __imag__ result);
3030 result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, nan_value));
3031 check_isnan_maybe_exc ("real(ccos(-Inf + i NaN)) = NaN plus maybe invalid exception",
3032 __real__ result, INVALID_EXCEPTION);
3033 check_isnan ("imag(ccos(-Inf + i NaN)) = NaN plus maybe invalid exception",
3034 __imag__ result);
3036 result = FUNC(ccos) (BUILD_COMPLEX (nan_value, nan_value));
3037 check_isnan ("real(ccos(NaN + i NaN)) = NaN", __real__ result);
3038 check_isnan ("imag(ccos(NaN + i NaN)) = NaN", __imag__ result);
3042 static void
3043 ccosh_test (void)
3045 __complex__ MATHTYPE result;
3047 result = FUNC(ccosh) (BUILD_COMPLEX (0.0, 0.0));
3048 check ("real(ccosh(0 + 0i)) = 1.0", __real__ result, 1.0);
3049 check ("imag(ccosh(0 + 0i)) = 0", __imag__ result, 0);
3050 result = FUNC(ccosh) (BUILD_COMPLEX (minus_zero, 0.0));
3051 check ("real(ccosh(-0 + 0i)) = 1.0", __real__ result, 1.0);
3052 check ("imag(ccosh(-0 + 0i)) = -0", __imag__ result, minus_zero);
3053 result = FUNC(ccosh) (BUILD_COMPLEX (0.0, minus_zero));
3054 check ("real(ccosh(0 - 0i)) = 1.0", __real__ result, 1.0);
3055 check ("imag(ccosh(0 - 0i)) = -0", __imag__ result, minus_zero);
3056 result = FUNC(ccosh) (BUILD_COMPLEX (minus_zero, minus_zero));
3057 check ("real(ccosh(-0 - 0i)) = 1.0", __real__ result, 1.0);
3058 check ("imag(ccosh(-0 - 0i)) = 0", __imag__ result, 0.0);
3060 result = FUNC(ccosh) (BUILD_COMPLEX (0.0, plus_infty));
3061 check_isnan_exc ("real(ccosh(0 + i Inf)) = NaN plus invalid exception",
3062 __real__ result, INVALID_EXCEPTION);
3063 check ("imag(ccosh(0 + i Inf)) = +-0 plus invalid exception",
3064 FUNC(fabs) (__imag__ result), 0);
3065 result = FUNC(ccosh) (BUILD_COMPLEX (minus_zero, plus_infty));
3066 check_isnan_exc ("real(ccosh(-0 + i Inf)) = NaN plus invalid exception",
3067 __real__ result, INVALID_EXCEPTION);
3068 check ("imag(ccosh(-0 + i Inf)) = +-0 plus invalid exception",
3069 FUNC(fabs) (__imag__ result), 0);
3070 result = FUNC(ccosh) (BUILD_COMPLEX (0.0, minus_infty));
3071 check_isnan_exc ("real(ccosh(0 - i Inf)) = NaN plus invalid exception",
3072 __real__ result, INVALID_EXCEPTION);
3073 check ("imag(ccosh(0 - i Inf)) = +-0 plus invalid exception",
3074 FUNC(fabs) (__imag__ result), 0);
3075 result = FUNC(ccosh) (BUILD_COMPLEX (minus_zero, minus_infty));
3076 check_isnan_exc ("real(ccosh(-0 - i Inf)) = NaN plus invalid exception",
3077 __real__ result, INVALID_EXCEPTION);
3078 check ("imag(ccosh(-0 - i Inf)) = +-0 plus invalid exception",
3079 FUNC(fabs) (__imag__ result), 0);
3081 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, 0.0));
3082 check_isinfp ("real(ccosh(+Inf + 0i)) = +Inf", __real__ result);
3083 check ("imag(ccosh(+Inf + 0i)) = 0", __imag__ result, 0);
3084 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, 0.0));
3085 check_isinfp ("real(ccosh(-Inf + 0i)) = +Inf", __real__ result);
3086 check ("imag(ccosh(-Inf + 0i)) = -0", __imag__ result, minus_zero);
3087 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, minus_zero));
3088 check_isinfp ("real(ccosh(+Inf - 0i)) = +Inf", __real__ result);
3089 check ("imag(ccosh(+Inf - 0i)) = -0", __imag__ result, minus_zero);
3090 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, minus_zero));
3091 check_isinfp ("real(ccosh(-Inf - 0i)) = +Inf", __real__ result);
3092 check ("imag(ccosh(-Inf - 0i)) = 0", __imag__ result, 0.0);
3094 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, plus_infty));
3095 check_isinfp_exc ("real(ccosh(+Inf + i Inf)) = +Inf plus invalid exception",
3096 __real__ result, INVALID_EXCEPTION);
3097 check_isnan ("imag(ccosh(+Inf + i Inf)) = NaN plus invalid exception",
3098 __imag__ result);
3099 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, plus_infty));
3100 check_isinfp_exc ("real(ccosh(-Inf + i Inf)) = +Inf plus invalid exception",
3101 __real__ result, INVALID_EXCEPTION);
3102 check_isnan ("imag(ccosh(-Inf + i Inf)) = NaN plus invalid exception",
3103 __imag__ result);
3104 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, minus_infty));
3105 check_isinfp_exc ("real(ccosh(Inf - i Inf)) = +Inf plus invalid exception",
3106 __real__ result, INVALID_EXCEPTION);
3107 check_isnan ("imag(ccosh(Inf - i Inf)) = NaN plus invalid exception",
3108 __imag__ result);
3109 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, minus_infty));
3110 check_isinfp_exc ("real(ccosh(-Inf - i Inf)) = +Inf plus invalid exception",
3111 __real__ result, INVALID_EXCEPTION);
3112 check_isnan ("imag(ccosh(-Inf - i Inf)) = NaN plus invalid exception",
3113 __imag__ result);
3115 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, 4.625));
3116 check_isinfn ("real(ccosh(+Inf + i4.625)) = -Inf", __real__ result);
3117 check_isinfn ("imag(ccosh(+Inf + i4.625)) = -Inf", __imag__ result);
3118 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, 4.625));
3119 check_isinfn ("real(ccosh(-Inf + i4.625)) = -Inf", __real__ result);
3120 check_isinfp ("imag(ccosh(-Inf + i4.625)) = Inf", __imag__ result);
3121 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, -4.625));
3122 check_isinfn ("real(ccosh(+Inf - i4.625)) = -Inf", __real__ result);
3123 check_isinfp ("imag(ccosh(+Inf - i4.625)) = +Inf", __imag__ result);
3124 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, -4.625));
3125 check_isinfn ("real(ccosh(-Inf - i4.625)) = -Inf", __real__ result);
3126 check_isinfn ("imag(ccosh(-Inf - i4.625)) = -Inf", __imag__ result);
3128 result = FUNC(ccosh) (BUILD_COMPLEX (6.75, plus_infty));
3129 check_isnan_exc ("real(ccosh(6.75 + i Inf)) = NaN plus invalid exception",
3130 __real__ result, INVALID_EXCEPTION);
3131 check_isnan ("imag(ccosh(6.75 + i Inf)) = NaN plus invalid exception",
3132 __imag__ result);
3133 result = FUNC(ccosh) (BUILD_COMPLEX (-6.75, plus_infty));
3134 check_isnan_exc ("real(ccosh(-6.75 + i Inf)) = NaN plus invalid exception",
3135 __real__ result, INVALID_EXCEPTION);
3136 check_isnan ("imag(ccosh(-6.75 + i Inf)) = NaN plus invalid exception",
3137 __imag__ result);
3138 result = FUNC(ccosh) (BUILD_COMPLEX (6.75, minus_infty));
3139 check_isnan_exc ("real(ccosh(6.75 - i Inf)) = NaN plus invalid exception",
3140 __real__ result, INVALID_EXCEPTION);
3141 check_isnan ("imag(ccosh(6.75 - i Inf)) = NaN plus invalid exception",
3142 __imag__ result);
3143 result = FUNC(ccosh) (BUILD_COMPLEX (-6.75, minus_infty));
3144 check_isnan_exc ("real(ccosh(-6.75 - i Inf)) = NaN plus invalid exception",
3145 __real__ result, INVALID_EXCEPTION);
3146 check_isnan ("imag(ccosh(-6.75 - i Inf)) = NaN plus invalid exception",
3147 __imag__ result);
3149 result = FUNC(ccosh) (BUILD_COMPLEX (0.0, nan_value));
3150 check_isnan ("real(ccosh(0 + i NaN)) = NaN", __real__ result);
3151 check ("imag(ccosh(0 + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0);
3152 result = FUNC(ccosh) (BUILD_COMPLEX (minus_zero, nan_value));
3153 check_isnan ("real(ccosh(-0 + i NaN)) = NaN", __real__ result);
3154 check ("imag(ccosh(-0 + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0);
3156 result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, nan_value));
3157 check_isinfp ("real(ccosh(+Inf + i NaN)) = +Inf", __real__ result);
3158 check_isnan ("imag(ccosh(+Inf + i NaN)) = NaN", __imag__ result);
3159 result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, nan_value));
3160 check_isinfp ("real(ccosh(-Inf + i NaN)) = +Inf", __real__ result);
3161 check_isnan ("imag(ccosh(-Inf + i NaN)) = NaN", __imag__ result);
3163 result = FUNC(ccosh) (BUILD_COMPLEX (9.0, nan_value));
3164 check_isnan_maybe_exc ("real(ccosh(9.0 + i NaN)) = NaN plus maybe invalid exception",
3165 __real__ result, INVALID_EXCEPTION);
3166 check_isnan ("imag(ccosh(9.0 + i NaN)) = NaN plus maybe invalid exception",
3167 __imag__ result);
3168 result = FUNC(ccosh) (BUILD_COMPLEX (-9.0, nan_value));
3169 check_isnan_maybe_exc ("real(ccosh(-9.0 + i NaN)) = NaN plus maybe invalid exception",
3170 __real__ result, INVALID_EXCEPTION);
3171 check_isnan ("imag(ccosh(-9.0 + i NaN)) = NaN plus maybe invalid exception",
3172 __imag__ result);
3174 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, 0.0));
3175 check_isnan ("real(ccosh(NaN + i0)) = NaN", __real__ result);
3176 check ("imag(ccosh(NaN + i0)) = +-0", FUNC(fabs) (__imag__ result), 0.0);
3177 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, minus_zero));
3178 check_isnan ("real(ccosh(NaN - i0)) = NaN", __real__ result);
3179 check ("imag(ccosh(NaN - i0)) = +-0", FUNC(fabs) (__imag__ result), 0.0);
3181 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, 10.0));
3182 check_isnan_maybe_exc ("real(ccosh(NaN + i10)) = NaN plus maybe invalid exception",
3183 __real__ result, INVALID_EXCEPTION);
3184 check_isnan ("imag(ccosh(NaN + i10)) = NaN plus maybe invalid exception",
3185 __imag__ result);
3186 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, -10.0));
3187 check_isnan_maybe_exc ("real(ccosh(NaN - i10)) = NaN plus maybe invalid exception",
3188 __real__ result, INVALID_EXCEPTION);
3189 check_isnan ("imag(ccosh(NaN - i10)) = NaN plus maybe invalid exception",
3190 __imag__ result);
3192 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, plus_infty));
3193 check_isnan_maybe_exc ("real(ccosh(NaN + i Inf)) = NaN plus maybe invalid exception",
3194 __real__ result, INVALID_EXCEPTION);
3195 check_isnan ("imag(ccosh(NaN + i Inf)) = NaN plus maybe invalid exception",
3196 __imag__ result);
3197 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, minus_infty));
3198 check_isnan_maybe_exc ("real(ccosh(NaN - i Inf)) = NaN plus maybe invalid exception",
3199 __real__ result, INVALID_EXCEPTION);
3200 check_isnan ("imag(ccosh(NaN - i Inf)) = NaN plus maybe invalid exception",
3201 __imag__ result);
3203 result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, nan_value));
3204 check_isnan ("real(ccosh(NaN + i NaN)) = NaN", __real__ result);
3205 check_isnan ("imag(ccosh(NaN + i NaN)) = NaN", __imag__ result);
3209 static void
3210 cacos_test (void)
3212 __complex__ MATHTYPE result;
3214 result = FUNC(cacos) (BUILD_COMPLEX (0, 0));
3215 check ("real(cacos(0 + i0)) = pi/2", __real__ result, M_PI_2);
3216 check ("imag(cacos(0 + i0)) = -0", __imag__ result, minus_zero);
3217 result = FUNC(cacos) (BUILD_COMPLEX (minus_zero, 0));
3218 check ("real(cacos(-0 + i0)) = pi/2", __real__ result, M_PI_2);
3219 check ("imag(cacos(-0 + i0)) = -0", __imag__ result, minus_zero);
3220 result = FUNC(cacos) (BUILD_COMPLEX (0, minus_zero));
3221 check ("real(cacos(0 - i0)) = pi/2", __real__ result, M_PI_2);
3222 check ("imag(cacos(0 - i0)) = 0", __imag__ result, 0);
3223 result = FUNC(cacos) (BUILD_COMPLEX (minus_zero, minus_zero));
3224 check ("real(cacos(-0 - i0)) = pi/2", __real__ result, M_PI_2);
3225 check ("imag(cacos(-0 - i0)) = 0", __imag__ result, 0);
3227 result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, plus_infty));
3228 check ("real(cacos(-Inf + i Inf)) = 3*pi/4", __real__ result, M_PI - M_PI_4);
3229 check_isinfn ("imag(cacos(-Inf + i Inf)) = -Inf", __imag__ result);
3230 result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, minus_infty));
3231 check ("real(cacos(-Inf - i Inf)) = 3*pi/4", __real__ result, M_PI - M_PI_4);
3232 check_isinfp ("imag(cacos(-Inf - i Inf)) = +Inf", __imag__ result);
3234 result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, plus_infty));
3235 check ("real(cacos(+Inf + i Inf)) = pi/4", __real__ result, M_PI_4);
3236 check_isinfn ("imag(cacos(+Inf + i Inf)) = -Inf", __imag__ result);
3237 result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, minus_infty));
3238 check ("real(cacos(+Inf - i Inf)) = pi/4", __real__ result, M_PI_4);
3239 check_isinfp ("imag(cacos(+Inf - i Inf)) = +Inf", __imag__ result);
3241 result = FUNC(cacos) (BUILD_COMPLEX (-10.0, plus_infty));
3242 check ("real(cacos(-10.0 + i Inf)) = pi/2", __real__ result, M_PI_2);
3243 check_isinfn ("imag(cacos(-10.0 + i Inf)) = -Inf", __imag__ result);
3244 result = FUNC(cacos) (BUILD_COMPLEX (-10.0, minus_infty));
3245 check ("real(cacos(-10.0 - i Inf)) = pi/2", __real__ result, M_PI_2);
3246 check_isinfp ("imag(cacos(-10.0 - i Inf)) = +Inf", __imag__ result);
3247 result = FUNC(cacos) (BUILD_COMPLEX (0, plus_infty));
3248 check ("real(cacos(0 + i Inf)) = pi/2", __real__ result, M_PI_2);
3249 check_isinfn ("imag(cacos(0 + i Inf)) = -Inf", __imag__ result);
3250 result = FUNC(cacos) (BUILD_COMPLEX (0, minus_infty));
3251 check ("real(cacos(0 - i Inf)) = pi/2", __real__ result, M_PI_2);
3252 check_isinfp ("imag(cacos(0 - i Inf)) = +Inf", __imag__ result);
3253 result = FUNC(cacos) (BUILD_COMPLEX (0.1, plus_infty));
3254 check ("real(cacos(0.1 + i Inf)) = pi/2", __real__ result, M_PI_2);
3255 check_isinfn ("imag(cacos(0.1 + i Inf)) = -Inf", __imag__ result);
3256 result = FUNC(cacos) (BUILD_COMPLEX (0.1, minus_infty));
3257 check ("real(cacos(0.1 - i Inf)) = pi/2", __real__ result, M_PI_2);
3258 check_isinfp ("imag(cacos(0.1 - i Inf)) = +Inf", __imag__ result);
3260 result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, 0));
3261 check ("real(cacos(-Inf + i0)) = pi", __real__ result, M_PI);
3262 check_isinfn ("imag(cacos(-Inf + i0)) = -Inf", __imag__ result);
3263 result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, minus_zero));
3264 check ("real(cacos(-Inf - i0)) = pi", __real__ result, M_PI);
3265 check_isinfp ("imag(cacos(-Inf - i0)) = +Inf", __imag__ result);
3266 result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, 100));
3267 check ("real(cacos(-Inf + i100)) = pi", __real__ result, M_PI);
3268 check_isinfn ("imag(cacos(-Inf + i100)) = -Inf", __imag__ result);
3269 result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, -100));
3270 check ("real(cacos(-Inf - i100)) = pi", __real__ result, M_PI);
3271 check_isinfp ("imag(cacos(-Inf - i100)) = +Inf", __imag__ result);
3273 result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, 0));
3274 check ("real(cacos(+Inf + i0)) = 0", __real__ result, 0);
3275 check_isinfn ("imag(cacos(+Inf + i0)) = -Inf", __imag__ result);
3276 result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, minus_zero));
3277 check ("real(cacos(+Inf - i0)) = 0", __real__ result, 0);
3278 check_isinfp ("imag(cacos(+Inf - i0)) = +Inf", __imag__ result);
3279 result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, 0.5));
3280 check ("real(cacos(+Inf + i0.5)) = 0", __real__ result, 0);
3281 check_isinfn ("imag(cacos(+Inf + i0.5)) = -Inf", __imag__ result);
3282 result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, -0.5));
3283 check ("real(cacos(+Inf - i0.5)) = 0", __real__ result, 0);
3284 check_isinfp ("imag(cacos(+Inf - i0.5)) = +Inf", __imag__ result);
3286 result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, nan_value));
3287 check_isnan ("real(cacos(+Inf + i NaN)) = NaN", __real__ result);
3288 check_isinfp ("imag(cacos(+Inf + i NaN)) = +-Inf",
3289 FUNC(fabs) (__imag__ result));
3290 result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, nan_value));
3291 check_isnan ("real(cacos(-Inf + i NaN)) = NaN", __real__ result);
3292 check_isinfp ("imag(cacos(-Inf + i NaN)) = +-Inf",
3293 FUNC(fabs) (__imag__ result));
3295 result = FUNC(cacos) (BUILD_COMPLEX (0, nan_value));
3296 check ("real(cacos(0 + i NaN)) = pi/2", __real__ result, M_PI_2);
3297 check_isnan ("imag(cacos(0 + i NaN)) = NaN", __imag__ result);
3298 result = FUNC(cacos) (BUILD_COMPLEX (minus_zero, nan_value));
3299 check ("real(cacos(-0 + i NaN)) = pi/2", __real__ result, M_PI_2);
3300 check_isnan ("imag(cacos(-0 + i NaN)) = NaN", __imag__ result);
3302 result = FUNC(cacos) (BUILD_COMPLEX (nan_value, plus_infty));
3303 check_isnan ("real(cacos(NaN + i Inf)) = NaN", __real__ result);
3304 check_isinfn ("imag(cacos(NaN + i Inf)) = -Inf", __imag__ result);
3305 result = FUNC(cacos) (BUILD_COMPLEX (nan_value, minus_infty));
3306 check_isnan ("real(cacos(NaN - i Inf)) = NaN", __real__ result);
3307 check_isinfp ("imag(cacos(NaN - i Inf)) = +Inf", __imag__ result);
3309 result = FUNC(cacos) (BUILD_COMPLEX (10.5, nan_value));
3310 check_isnan_maybe_exc ("real(cacos(10.5 + i NaN)) = NaN plus maybe invalid exception",
3311 __real__ result, INVALID_EXCEPTION);
3312 check_isnan ("imag(cacos(10.5 + i NaN)) = NaN plus maybe invalid exception",
3313 __imag__ result);
3314 result = FUNC(cacos) (BUILD_COMPLEX (-10.5, nan_value));
3315 check_isnan_maybe_exc ("real(cacos(-10.5 + i NaN)) = NaN plus maybe invalid exception",
3316 __real__ result, INVALID_EXCEPTION);
3317 check_isnan ("imag(cacos(-10.5 + i NaN)) = NaN plus maybe invalid exception",
3318 __imag__ result);
3320 result = FUNC(cacos) (BUILD_COMPLEX (nan_value, 0.75));
3321 check_isnan_maybe_exc ("real(cacos(NaN + i0.75)) = NaN plus maybe invalid exception",
3322 __real__ result, INVALID_EXCEPTION);
3323 check_isnan ("imag(cacos(NaN + i0.75)) = NaN plus maybe invalid exception",
3324 __imag__ result);
3325 result = FUNC(cacos) (BUILD_COMPLEX (-10.5, nan_value));
3326 check_isnan_maybe_exc ("real(cacos(NaN - i0.75)) = NaN plus maybe invalid exception",
3327 __real__ result, INVALID_EXCEPTION);
3328 check_isnan ("imag(cacos(NaN - i0.75)) = NaN plus maybe invalid exception",
3329 __imag__ result);
3331 result = FUNC(cacos) (BUILD_COMPLEX (nan_value, nan_value));
3332 check_isnan ("real(cacos(NaN + i NaN)) = NaN", __real__ result);
3333 check_isnan ("imag(cacos(NaN + i NaN)) = NaN", __imag__ result);
3337 static void
3338 cacosh_test (void)
3340 __complex__ MATHTYPE result;
3342 result = FUNC(cacosh) (BUILD_COMPLEX (0, 0));
3343 check ("real(cacosh(0 + i0)) = 0", __real__ result, 0);
3344 check ("imag(cacosh(0 + i0)) = pi/2", __imag__ result, M_PI_2);
3345 result = FUNC(cacosh) (BUILD_COMPLEX (minus_zero, 0));
3346 check ("real(cacosh(-0 + i0)) = 0", __real__ result, 0);
3347 check ("imag(cacosh(-0 + i0)) = pi/2", __imag__ result, M_PI_2);
3348 result = FUNC(cacosh) (BUILD_COMPLEX (0, minus_zero));
3349 check ("real(cacosh(0 - i0)) = 0", __real__ result, 0);
3350 check ("imag(cacosh(0 - i0)) = -pi/2", __imag__ result, -M_PI_2);
3351 result = FUNC(cacosh) (BUILD_COMPLEX (minus_zero, minus_zero));
3352 check ("real(cacosh(-0 - i0)) = 0", __real__ result, 0);
3353 check ("imag(cacosh(-0 - i0)) = -pi/2", __imag__ result, -M_PI_2);
3355 result = FUNC(cacosh) (BUILD_COMPLEX (minus_infty, plus_infty));
3356 check_isinfp ("real(cacosh(-Inf + i Inf)) = +Inf", __real__ result);
3357 check ("imag(cacosh(-Inf + i Inf)) = 3*pi/4", __imag__ result,
3358 M_PI - M_PI_4);
3359 result = FUNC(cacosh) (BUILD_COMPLEX (minus_infty, minus_infty));
3360 check_isinfp ("real(cacosh(-Inf - i Inf)) = +Inf", __real__ result);
3361 check ("imag(cacosh(-Inf - i Inf)) = -3*pi/4", __imag__ result,
3362 M_PI_4 - M_PI);
3364 result = FUNC(cacosh) (BUILD_COMPLEX (plus_infty, plus_infty));
3365 check_isinfp ("real(cacosh(+Inf + i Inf)) = +Inf", __real__ result);
3366 check ("imag(cacosh(+Inf + i Inf)) = pi/4", __imag__ result, M_PI_4);
3367 result = FUNC(cacosh) (BUILD_COMPLEX (plus_infty, minus_infty));
3368 check_isinfp ("real(cacosh(+Inf - i Inf)) = +Inf", __real__ result);
3369 check ("imag(cacosh(+Inf - i Inf)) = -pi/4", __imag__ result, -M_PI_4);
3371 result = FUNC(cacosh) (BUILD_COMPLEX (-10.0, plus_infty));
3372 check_isinfp ("real(cacosh(-10.0 + i Inf)) = +Inf", __real__ result);
3373 check ("imag(cacosh(-10.0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
3374 result = FUNC(cacosh) (BUILD_COMPLEX (-10.0, minus_infty));
3375 check_isinfp ("real(cacosh(-10.0 - i Inf)) = +Inf", __real__ result);
3376 check ("imag(cacosh(-10.0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3377 result = FUNC(cacosh) (BUILD_COMPLEX (0, plus_infty));
3378 check_isinfp ("real(cacosh(0 + i Inf)) = +Inf", __real__ result);
3379 check ("imag(cacosh(0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
3380 result = FUNC(cacosh) (BUILD_COMPLEX (0, minus_infty));
3381 check_isinfp ("real(cacosh(0 - i Inf)) = +Inf", __real__ result);
3382 check ("imag(cacosh(0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3383 result = FUNC(cacosh) (BUILD_COMPLEX (0.1, plus_infty));
3384 check_isinfp ("real(cacosh(0.1 + i Inf)) = +Inf", __real__ result);
3385 check ("imag(cacosh(0.1 + i Inf)) = pi/2", __imag__ result, M_PI_2);
3386 result = FUNC(cacosh) (BUILD_COMPLEX (0.1, minus_infty));
3387 check_isinfp ("real(cacosh(0.1 - i Inf)) = +Inf", __real__ result);
3388 check ("imag(cacosh(0.1 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3390 result = FUNC(cacosh) (BUILD_COMPLEX (minus_infty, 0));
3391 check_isinfp ("real(cacosh(-Inf + i0)) = +Inf", __real__ result);
3392 check ("imag(cacosh(-Inf + i0)) = pi", __imag__ result, M_PI);
3393 result = FUNC(cacosh) (BUILD_COMPLEX (minus_infty, minus_zero));
3394 check_isinfp ("real(cacosh(-Inf - i0)) = +Inf", __real__ result);
3395 check ("imag(cacosh(-Inf - i0)) = -pi", __imag__ result, -M_PI);
3396 result = FUNC(cacosh) (BUILD_COMPLEX (minus_infty, 100));
3397 check_isinfp ("real(cacosh(-Inf + i100)) = +Inf", __real__ result);
3398 check ("imag(cacosh(-Inf + i100)) = pi", __imag__ result, M_PI);
3399 result = FUNC(cacosh) (BUILD_COMPLEX (minus_infty, -100));
3400 check_isinfp ("real(cacosh(-Inf - i100)) = +Inf", __real__ result);
3401 check ("imag(cacosh(-Inf - i100)) = -pi", __imag__ result, -M_PI);
3403 result = FUNC(cacosh) (BUILD_COMPLEX (plus_infty, 0));
3404 check_isinfp ("real(cacosh(+Inf + i0)) = +Inf", __real__ result);
3405 check ("imag(cacosh(+Inf + i0)) = 0", __imag__ result, 0);
3406 result = FUNC(cacosh) (BUILD_COMPLEX (plus_infty, minus_zero));
3407 check_isinfp ("real(cacosh(+Inf - i0)) = +Inf", __real__ result);
3408 check ("imag(cacosh(+Inf - i0)) = -0", __imag__ result, minus_zero);
3409 result = FUNC(cacosh) (BUILD_COMPLEX (plus_infty, 0.5));
3410 check_isinfp ("real(cacosh(+Inf + i0.5)) = +Inf", __real__ result);
3411 check ("imag(cacosh(+Inf + i0.5)) = 0", __imag__ result, 0);
3412 result = FUNC(cacosh) (BUILD_COMPLEX (plus_infty, -0.5));
3413 check_isinfp ("real(cacosh(+Inf - i0.5)) = +Inf", __real__ result);
3414 check ("imag(cacosh(+Inf - i0.5)) = -0", __imag__ result, minus_zero);
3416 result = FUNC(cacosh) (BUILD_COMPLEX (plus_infty, nan_value));
3417 check_isinfp ("real(cacosh(+Inf + i NaN)) = +Inf", __real__ result);
3418 check_isnan ("imag(cacosh(+Inf + i NaN)) = NaN", __imag__ result);
3419 result = FUNC(cacosh) (BUILD_COMPLEX (minus_infty, nan_value));
3420 check_isinfp ("real(cacosh(-Inf + i NaN)) = +Inf", __real__ result);
3421 check_isnan ("imag(cacosh(-Inf + i NaN)) = NaN", __imag__ result);
3423 result = FUNC(cacosh) (BUILD_COMPLEX (0, nan_value));
3424 check_isnan ("real(cacosh(0 + i NaN)) = NaN", __real__ result);
3425 check_isnan ("imag(cacosh(0 + i NaN)) = NaN", __imag__ result);
3426 result = FUNC(cacosh) (BUILD_COMPLEX (minus_zero, nan_value));
3427 check_isnan ("real(cacosh(-0 + i NaN)) = NaN", __real__ result);
3428 check_isnan ("imag(cacosh(-0 + i NaN)) = NaN", __imag__ result);
3430 result = FUNC(cacosh) (BUILD_COMPLEX (nan_value, plus_infty));
3431 check_isinfp ("real(cacosh(NaN + i Inf)) = +Inf", __real__ result);
3432 check_isnan ("imag(cacosh(NaN + i Inf)) = NaN", __imag__ result);
3433 result = FUNC(cacosh) (BUILD_COMPLEX (nan_value, minus_infty));
3434 check_isinfp ("real(cacosh(NaN - i Inf)) = +Inf", __real__ result);
3435 check_isnan ("imag(cacosh(NaN - i Inf)) = NaN", __imag__ result);
3437 result = FUNC(cacosh) (BUILD_COMPLEX (10.5, nan_value));
3438 check_isnan_maybe_exc ("real(cacosh(10.5 + i NaN)) = NaN plus maybe invalid exception",
3439 __real__ result, INVALID_EXCEPTION);
3440 check_isnan ("imag(cacosh(10.5 + i NaN)) = NaN plus maybe invalid exception",
3441 __imag__ result);
3442 result = FUNC(cacosh) (BUILD_COMPLEX (-10.5, nan_value));
3443 check_isnan_maybe_exc ("real(cacosh(-10.5 + i NaN)) = NaN plus maybe invalid exception",
3444 __real__ result, INVALID_EXCEPTION);
3445 check_isnan ("imag(cacosh(-10.5 + i NaN)) = NaN plus maybe invalid exception",
3446 __imag__ result);
3448 result = FUNC(cacosh) (BUILD_COMPLEX (nan_value, 0.75));
3449 check_isnan_maybe_exc ("real(cacosh(NaN + i0.75)) = NaN plus maybe invalid exception",
3450 __real__ result, INVALID_EXCEPTION);
3451 check_isnan ("imag(cacosh(NaN + i0.75)) = NaN plus maybe invalid exception",
3452 __imag__ result);
3453 result = FUNC(cacosh) (BUILD_COMPLEX (-10.5, nan_value));
3454 check_isnan_maybe_exc ("real(cacosh(NaN - i0.75)) = NaN plus maybe invalid exception",
3455 __real__ result, INVALID_EXCEPTION);
3456 check_isnan ("imag(cacosh(NaN - i0.75)) = NaN plus maybe invalid exception",
3457 __imag__ result);
3459 result = FUNC(cacosh) (BUILD_COMPLEX (nan_value, nan_value));
3460 check_isnan ("real(cacosh(NaN + i NaN)) = NaN", __real__ result);
3461 check_isnan ("imag(cacosh(NaN + i NaN)) = NaN", __imag__ result);
3465 static void
3466 casin_test (void)
3468 __complex__ MATHTYPE result;
3470 result = FUNC(casin) (BUILD_COMPLEX (0, 0));
3471 check ("real(casin(0 + i0)) = 0", __real__ result, 0);
3472 check ("imag(casin(0 + i0)) = 0", __imag__ result, 0);
3473 result = FUNC(casin) (BUILD_COMPLEX (minus_zero, 0));
3474 check ("real(casin(-0 + i0)) = -0", __real__ result, minus_zero);
3475 check ("imag(casin(-0 + i0)) = 0", __imag__ result, 0);
3476 result = FUNC(casin) (BUILD_COMPLEX (0, minus_zero));
3477 check ("real(casin(0 - i0)) = 0", __real__ result, 0);
3478 check ("imag(casin(0 - i0)) = -0", __imag__ result, minus_zero);
3479 result = FUNC(casin) (BUILD_COMPLEX (minus_zero, minus_zero));
3480 check ("real(casin(-0 - i0)) = -0", __real__ result, minus_zero);
3481 check ("imag(casin(-0 - i0)) = -0", __imag__ result, minus_zero);
3483 result = FUNC(casin) (BUILD_COMPLEX (plus_infty, plus_infty));
3484 check ("real(casin(+Inf + i Inf)) = pi/4", __real__ result, M_PI_4);
3485 check_isinfp ("imag(casin(+Inf + i Inf)) = +Inf", __imag__ result);
3486 result = FUNC(casin) (BUILD_COMPLEX (plus_infty, minus_infty));
3487 check ("real(casin(+Inf - i Inf)) = pi/4", __real__ result, M_PI_4);
3488 check_isinfn ("imag(casin(+Inf - i Inf)) = -Inf", __imag__ result);
3489 result = FUNC(casin) (BUILD_COMPLEX (minus_infty, plus_infty));
3490 check ("real(casin(-Inf + i Inf)) = -pi/4", __real__ result, -M_PI_4);
3491 check_isinfp ("imag(casin(-Inf + i Inf)) = +Inf", __imag__ result);
3492 result = FUNC(casin) (BUILD_COMPLEX (minus_infty, minus_infty));
3493 check ("real(casin(-Inf - i Inf)) = -pi/4", __real__ result, -M_PI_4);
3494 check_isinfn ("imag(casin(-Inf - i Inf)) = -Inf", __imag__ result);
3496 result = FUNC(casin) (BUILD_COMPLEX (-10.0, plus_infty));
3497 check ("real(casin(-10.0 + i Inf)) = -0", __real__ result, minus_zero);
3498 check_isinfp ("imag(casin(-10.0 + i Inf)) = +Inf", __imag__ result);
3499 result = FUNC(casin) (BUILD_COMPLEX (-10.0, minus_infty));
3500 check ("real(casin(-10.0 - i Inf)) = -0", __real__ result, minus_zero);
3501 check_isinfn ("imag(casin(-10.0 - i Inf)) = -Inf", __imag__ result);
3502 result = FUNC(casin) (BUILD_COMPLEX (0, plus_infty));
3503 check ("real(casin(0 + i Inf)) = 0", __real__ result, 0.0);
3504 check_isinfp ("imag(casin(0 + i Inf)) = +Inf", __imag__ result);
3505 result = FUNC(casin) (BUILD_COMPLEX (0, minus_infty));
3506 check ("real(casin(0 - i Inf)) = 0", __real__ result, 0.0);
3507 check_isinfn ("imag(casin(0 - i Inf)) = -Inf", __imag__ result);
3508 result = FUNC(casin) (BUILD_COMPLEX (minus_zero, plus_infty));
3509 check ("real(casin(-0 + i Inf)) = -0", __real__ result, minus_zero);
3510 check_isinfp ("imag(casin(-0 + i Inf)) = +Inf", __imag__ result);
3511 result = FUNC(casin) (BUILD_COMPLEX (minus_zero, minus_infty));
3512 check ("real(casin(-0 - i Inf)) = -0", __real__ result, minus_zero);
3513 check_isinfn ("imag(casin(-0 - i Inf)) = -Inf", __imag__ result);
3514 result = FUNC(casin) (BUILD_COMPLEX (0.1, plus_infty));
3515 check ("real(casin(0.1 + i Inf)) = 0", __real__ result, 0);
3516 check_isinfp ("imag(casin(0.1 + i Inf)) = +Inf", __imag__ result);
3517 result = FUNC(casin) (BUILD_COMPLEX (0.1, minus_infty));
3518 check ("real(casin(0.1 - i Inf)) = 0", __real__ result, 0);
3519 check_isinfn ("imag(casin(0.1 - i Inf)) = -Inf", __imag__ result);
3521 result = FUNC(casin) (BUILD_COMPLEX (minus_infty, 0));
3522 check ("real(casin(-Inf + i0)) = -pi/2", __real__ result, -M_PI_2);
3523 check_isinfp ("imag(casin(-Inf + i0)) = +Inf", __imag__ result);
3524 result = FUNC(casin) (BUILD_COMPLEX (minus_infty, minus_zero));
3525 check ("real(casin(-Inf - i0)) = -pi/2", __real__ result, -M_PI_2);
3526 check_isinfn ("imag(casin(-Inf - i0)) = -Inf", __imag__ result);
3527 result = FUNC(casin) (BUILD_COMPLEX (minus_infty, 100));
3528 check ("real(casin(-Inf + i100)) = -pi/2", __real__ result, -M_PI_2);
3529 check_isinfp ("imag(casin(-Inf + i100)) = +Inf", __imag__ result);
3530 result = FUNC(casin) (BUILD_COMPLEX (minus_infty, -100));
3531 check ("real(casin(-Inf - i100)) = -pi/2", __real__ result, -M_PI_2);
3532 check_isinfn ("imag(casin(-Inf - i100)) = -Inf", __imag__ result);
3534 result = FUNC(casin) (BUILD_COMPLEX (plus_infty, 0));
3535 check ("real(casin(+Inf + i0)) = pi/2", __real__ result, M_PI_2);
3536 check_isinfp ("imag(casin(+Inf + i0)) = +Inf", __imag__ result);
3537 result = FUNC(casin) (BUILD_COMPLEX (plus_infty, minus_zero));
3538 check ("real(casin(+Inf - i0)) = pi/2", __real__ result, M_PI_2);
3539 check_isinfn ("imag(casin(+Inf - i0)) = -Inf", __imag__ result);
3540 result = FUNC(casin) (BUILD_COMPLEX (plus_infty, 0.5));
3541 check ("real(casin(+Inf + i0.5)) = pi/2", __real__ result, M_PI_2);
3542 check_isinfp ("imag(casin(+Inf + i0.5)) = +Inf", __imag__ result);
3543 result = FUNC(casin) (BUILD_COMPLEX (plus_infty, -0.5));
3544 check ("real(casin(+Inf - i0.5)) = pi/2", __real__ result, M_PI_2);
3545 check_isinfn ("imag(casin(+Inf - i0.5)) = -Inf", __imag__ result);
3547 result = FUNC(casin) (BUILD_COMPLEX (nan_value, plus_infty));
3548 check_isnan ("real(casin(NaN + i Inf)) = NaN", __real__ result);
3549 check_isinfp ("imag(casin(NaN + i Inf)) = +Inf", __imag__ result);
3550 result = FUNC(casin) (BUILD_COMPLEX (nan_value, minus_infty));
3551 check_isnan ("real(casin(NaN - i Inf)) = NaN", __real__ result);
3552 check_isinfn ("imag(casin(NaN - i Inf)) = -Inf", __imag__ result);
3554 result = FUNC(casin) (BUILD_COMPLEX (0.0, nan_value));
3555 check ("real(casin(0 + i NaN)) = 0", __real__ result, 0.0);
3556 check_isnan ("imag(casin(0 + i NaN)) = NaN", __imag__ result);
3557 result = FUNC(casin) (BUILD_COMPLEX (minus_zero, nan_value));
3558 check ("real(casin(-0 + i NaN)) = -0", __real__ result, minus_zero);
3559 check_isnan ("imag(casin(-0 + i NaN)) = NaN", __imag__ result);
3561 result = FUNC(casin) (BUILD_COMPLEX (plus_infty, nan_value));
3562 check_isnan ("real(casin(+Inf + i NaN)) = NaN", __real__ result);
3563 check_isinfp ("imag(casin(+Inf + i NaN)) = +-Inf",
3564 FUNC(fabs) (__imag__ result));
3565 result = FUNC(casin) (BUILD_COMPLEX (minus_infty, nan_value));
3566 check_isnan ("real(casin(-Inf + i NaN)) = NaN", __real__ result);
3567 check_isinfp ("imag(casin(-Inf + NaN)) = +-Inf",
3568 FUNC(fabs) (__imag__ result));
3570 result = FUNC(casin) (BUILD_COMPLEX (nan_value, 10.5));
3571 check_isnan_maybe_exc ("real(casin(NaN + i10.5)) = NaN plus maybe invalid exception",
3572 __real__ result, INVALID_EXCEPTION);
3573 check_isnan ("imag(casin(NaN + i10.5)) = NaN plus maybe invalid exception",
3574 __imag__ result);
3575 result = FUNC(casin) (BUILD_COMPLEX (nan_value, -10.5));
3576 check_isnan_maybe_exc ("real(casin(NaN - i10.5)) = NaN plus maybe invalid exception",
3577 __real__ result, INVALID_EXCEPTION);
3578 check_isnan ("imag(casin(NaN - i10.5)) = NaN plus maybe invalid exception",
3579 __imag__ result);
3581 result = FUNC(casin) (BUILD_COMPLEX (0.75, nan_value));
3582 check_isnan_maybe_exc ("real(casin(0.75 + i NaN)) = NaN plus maybe invalid exception",
3583 __real__ result, INVALID_EXCEPTION);
3584 check_isnan ("imag(casin(0.75 + i NaN)) = NaN plus maybe invalid exception",
3585 __imag__ result);
3586 result = FUNC(casin) (BUILD_COMPLEX (-0.75, nan_value));
3587 check_isnan_maybe_exc ("real(casin(-0.75 + i NaN)) = NaN plus maybe invalid exception",
3588 __real__ result, INVALID_EXCEPTION);
3589 check_isnan ("imag(casin(-0.75 + i NaN)) = NaN plus maybe invalid exception",
3590 __imag__ result);
3592 result = FUNC(casin) (BUILD_COMPLEX (nan_value, nan_value));
3593 check_isnan ("real(casin(NaN + i NaN)) = NaN", __real__ result);
3594 check_isnan ("imag(casin(NaN + i NaN)) = NaN", __imag__ result);
3598 static void
3599 casinh_test (void)
3601 __complex__ MATHTYPE result;
3603 result = FUNC(casinh) (BUILD_COMPLEX (0, 0));
3604 check ("real(casinh(0 + i0)) = 0", __real__ result, 0);
3605 check ("imag(casinh(0 + i0)) = 0", __imag__ result, 0);
3606 result = FUNC(casinh) (BUILD_COMPLEX (minus_zero, 0));
3607 check ("real(casinh(-0 + i0)) = -0", __real__ result, minus_zero);
3608 check ("imag(casinh(-0 + i0)) = 0", __imag__ result, 0);
3609 result = FUNC(casinh) (BUILD_COMPLEX (0, minus_zero));
3610 check ("real(casinh(0 - i0)) = 0", __real__ result, 0);
3611 check ("imag(casinh(0 - i0)) = -0", __imag__ result, minus_zero);
3612 result = FUNC(casinh) (BUILD_COMPLEX (minus_zero, minus_zero));
3613 check ("real(casinh(-0 - i0)) = -0", __real__ result, minus_zero);
3614 check ("imag(casinh(-0 - i0)) = -0", __imag__ result, minus_zero);
3616 result = FUNC(casinh) (BUILD_COMPLEX (plus_infty, plus_infty));
3617 check_isinfp ("real(casinh(+Inf + i Inf)) = +Inf", __real__ result);
3618 check ("imag(casinh(+Inf + i Inf)) = pi/4", __imag__ result, M_PI_4);
3619 result = FUNC(casinh) (BUILD_COMPLEX (plus_infty, minus_infty));
3620 check_isinfp ("real(casinh(+Inf - i Inf)) = +Inf", __real__ result);
3621 check ("imag(casinh(+Inf - i Inf)) = -pi/4", __imag__ result, -M_PI_4);
3622 result = FUNC(casinh) (BUILD_COMPLEX (minus_infty, plus_infty));
3623 check_isinfn ("real(casinh(-Inf + i Inf)) = -Inf", __real__ result);
3624 check ("imag(casinh(-Inf + i Inf)) = pi/4", __imag__ result, M_PI_4);
3625 result = FUNC(casinh) (BUILD_COMPLEX (minus_infty, minus_infty));
3626 check_isinfn ("real(casinh(-Inf - i Inf)) = -Inf", __real__ result);
3627 check ("imag(casinh(-Inf - i Inf)) = -pi/4", __imag__ result, -M_PI_4);
3629 result = FUNC(casinh) (BUILD_COMPLEX (-10.0, plus_infty));
3630 check_isinfn ("real(casinh(-10.0 + i Inf)) = -Inf", __real__ result);
3631 check ("imag(casinh(-10.0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
3632 result = FUNC(casinh) (BUILD_COMPLEX (-10.0, minus_infty));
3633 check_isinfn ("real(casinh(-10.0 - i Inf)) = -Inf", __real__ result);
3634 check ("imag(casinh(-10.0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3635 result = FUNC(casinh) (BUILD_COMPLEX (0, plus_infty));
3636 check_isinfp ("real(casinh(0 + i Inf)) = +Inf", __real__ result);
3637 check ("imag(casinh(0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
3638 result = FUNC(casinh) (BUILD_COMPLEX (0, minus_infty));
3639 check_isinfp ("real(casinh(0 - i Inf)) = +Inf", __real__ result);
3640 check ("imag(casinh(0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3641 result = FUNC(casinh) (BUILD_COMPLEX (minus_zero, plus_infty));
3642 check_isinfn ("real(casinh(-0 + i Inf)) = -Inf", __real__ result);
3643 check ("imag(casinh(-0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
3644 result = FUNC(casinh) (BUILD_COMPLEX (minus_zero, minus_infty));
3645 check_isinfn ("real(casinh(-0 - i Inf)) = -Inf", __real__ result);
3646 check ("imag(casinh(-0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3647 result = FUNC(casinh) (BUILD_COMPLEX (0.1, plus_infty));
3648 check_isinfp ("real(casinh(0.1 + i Inf)) = +Inf", __real__ result);
3649 check ("imag(casinh(0.1 + i Inf)) = pi/2", __imag__ result, M_PI_2);
3650 result = FUNC(casinh) (BUILD_COMPLEX (0.1, minus_infty));
3651 check_isinfp ("real(casinh(0.1 - i Inf)) = +Inf", __real__ result);
3652 check ("imag(casinh(0.1 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3654 result = FUNC(casinh) (BUILD_COMPLEX (minus_infty, 0));
3655 check_isinfn ("real(casinh(-Inf + i0)) = -Inf", __real__ result);
3656 check ("imag(casinh(-Inf + i0)) = 0", __imag__ result, 0);
3657 result = FUNC(casinh) (BUILD_COMPLEX (minus_infty, minus_zero));
3658 check_isinfn ("real(casinh(-Inf - i0)) = -Inf", __real__ result);
3659 check ("imag(casinh(-Inf - i0)) = -0", __imag__ result, minus_zero);
3660 result = FUNC(casinh) (BUILD_COMPLEX (minus_infty, 100));
3661 check_isinfn ("real(casinh(-Inf + i100)) = -Inf", __real__ result);
3662 check ("imag(casinh(-Inf + i100)) = 0", __imag__ result, 0);
3663 result = FUNC(casinh) (BUILD_COMPLEX (minus_infty, -100));
3664 check_isinfn ("real(casinh(-Inf - i100)) = -Inf", __real__ result);
3665 check ("imag(casinh(-Inf - i100)) = -0", __imag__ result, minus_zero);
3667 result = FUNC(casinh) (BUILD_COMPLEX (plus_infty, 0));
3668 check_isinfp ("real(casinh(+Inf + i0)) = +Inf", __real__ result);
3669 check ("imag(casinh(+Inf + i0)) = 0", __imag__ result, 0);
3670 result = FUNC(casinh) (BUILD_COMPLEX (plus_infty, minus_zero));
3671 check_isinfp ("real(casinh(+Inf - i0)) = +Inf", __real__ result);
3672 check ("imag(casinh(+Inf - i0)) = -0", __imag__ result, minus_zero);
3673 result = FUNC(casinh) (BUILD_COMPLEX (plus_infty, 0.5));
3674 check_isinfp ("real(casinh(+Inf + i0.5)) = +Inf", __real__ result);
3675 check ("imag(casinh(+Inf + i0.5)) = 0", __imag__ result, 0);
3676 result = FUNC(casinh) (BUILD_COMPLEX (plus_infty, -0.5));
3677 check_isinfp ("real(casinh(+Inf - i0.5)) = +Inf", __real__ result);
3678 check ("imag(casinh(+Inf - i0.5)) = -0", __imag__ result, minus_zero);
3680 result = FUNC(casinh) (BUILD_COMPLEX (plus_infty, nan_value));
3681 check_isinfp ("real(casinh(+Inf + i NaN)) = +Inf", __real__ result);
3682 check_isnan ("imag(casinh(+Inf + i NaN)) = NaN", __imag__ result);
3683 result = FUNC(casinh) (BUILD_COMPLEX (minus_infty, nan_value));
3684 check_isinfn ("real(casinh(-Inf + i NaN)) = -Inf", __real__ result);
3685 check_isnan ("imag(casinh(-Inf + i NaN)) = NaN", __imag__ result);
3687 result = FUNC(casinh) (BUILD_COMPLEX (nan_value, 0));
3688 check_isnan ("real(casinh(NaN + i0)) = NaN", __real__ result);
3689 check ("imag(casinh(NaN + i0)) = 0", __imag__ result, 0);
3690 result = FUNC(casinh) (BUILD_COMPLEX (nan_value, minus_zero));
3691 check_isnan ("real(casinh(NaN - i0)) = NaN", __real__ result);
3692 check ("imag(casinh(NaN - i0)) = -0", __imag__ result, minus_zero);
3694 result = FUNC(casinh) (BUILD_COMPLEX (nan_value, plus_infty));
3695 check_isinfp ("real(casinh(NaN + i Inf)) = +-Inf",
3696 FUNC(fabs) (__real__ result));
3697 check_isnan ("imag(casinh(NaN + i Inf)) = NaN", __imag__ result);
3698 result = FUNC(casinh) (BUILD_COMPLEX (nan_value, minus_infty));
3699 check_isinfp ("real(casinh(NaN - i Inf)) = +-Inf",
3700 FUNC(fabs) (__real__ result));
3701 check_isnan ("imag(casinh(NaN - i Inf)) = NaN", __imag__ result);
3703 result = FUNC(casinh) (BUILD_COMPLEX (10.5, nan_value));
3704 check_isnan_maybe_exc ("real(casinh(10.5 + i NaN)) = NaN plus maybe invalid exception",
3705 __real__ result, INVALID_EXCEPTION);
3706 check_isnan ("imag(casinh(10.5 + i NaN)) = NaN plus maybe invalid exception",
3707 __imag__ result);
3708 result = FUNC(casinh) (BUILD_COMPLEX (-10.5, nan_value));
3709 check_isnan_maybe_exc ("real(casinh(-10.5 + i NaN)) = NaN plus maybe invalid exception",
3710 __real__ result, INVALID_EXCEPTION);
3711 check_isnan ("imag(casinh(-10.5 + i NaN)) = NaN plus maybe invalid exception",
3712 __imag__ result);
3714 result = FUNC(casinh) (BUILD_COMPLEX (nan_value, 0.75));
3715 check_isnan_maybe_exc ("real(casinh(NaN + i0.75)) = NaN plus maybe invalid exception",
3716 __real__ result, INVALID_EXCEPTION);
3717 check_isnan ("imag(casinh(NaN + i0.75)) = NaN plus maybe invalid exception",
3718 __imag__ result);
3719 result = FUNC(casinh) (BUILD_COMPLEX (-0.75, nan_value));
3720 check_isnan_maybe_exc ("real(casinh(NaN - i0.75)) = NaN plus maybe invalid exception",
3721 __real__ result, INVALID_EXCEPTION);
3722 check_isnan ("imag(casinh(NaN - i0.75)) = NaN plus maybe invalid exception",
3723 __imag__ result);
3725 result = FUNC(casinh) (BUILD_COMPLEX (nan_value, nan_value));
3726 check_isnan ("real(casinh(NaN + i NaN)) = NaN", __real__ result);
3727 check_isnan ("imag(casinh(NaN + i NaN)) = NaN", __imag__ result);
3731 static void
3732 catan_test (void)
3734 __complex__ MATHTYPE result;
3736 result = FUNC(catan) (BUILD_COMPLEX (0, 0));
3737 check ("real(catan(0 + i0)) = 0", __real__ result, 0);
3738 check ("imag(catan(0 + i0)) = 0", __imag__ result, 0);
3739 result = FUNC(catan) (BUILD_COMPLEX (minus_zero, 0));
3740 check ("real(catan(-0 + i0)) = -0", __real__ result, minus_zero);
3741 check ("imag(catan(-0 + i0)) = 0", __imag__ result, 0);
3742 result = FUNC(catan) (BUILD_COMPLEX (0, minus_zero));
3743 check ("real(catan(0 - i0)) = 0", __real__ result, 0);
3744 check ("imag(catan(0 - i0)) = -0", __imag__ result, minus_zero);
3745 result = FUNC(catan) (BUILD_COMPLEX (minus_zero, minus_zero));
3746 check ("real(catan(-0 - i0)) = -0", __real__ result, minus_zero);
3747 check ("imag(catan(-0 - i0)) = -0", __imag__ result, minus_zero);
3749 result = FUNC(catan) (BUILD_COMPLEX (plus_infty, plus_infty));
3750 check ("real(catan(+Inf + i Inf)) = pi/2", __real__ result, M_PI_2);
3751 check ("imag(catan(+Inf + i Inf)) = 0", __imag__ result, 0);
3752 result = FUNC(catan) (BUILD_COMPLEX (plus_infty, minus_infty));
3753 check ("real(catan(+Inf - i Inf)) = pi/2", __real__ result, M_PI_2);
3754 check ("imag(catan(+Inf - i Inf)) = -0", __imag__ result, minus_zero);
3755 result = FUNC(catan) (BUILD_COMPLEX (minus_infty, plus_infty));
3756 check ("real(catan(-Inf + i Inf)) = -pi/2", __real__ result, -M_PI_2);
3757 check ("imag(catan(-Inf + i Inf)) = 0", __imag__ result, 0.0);
3758 result = FUNC(catan) (BUILD_COMPLEX (minus_infty, minus_infty));
3759 check ("real(catan(-Inf - i Inf)) = -pi/2", __real__ result, -M_PI_2);
3760 check ("imag(catan(-Inf - i Inf)) = -0", __imag__ result, minus_zero);
3762 result = FUNC(catan) (BUILD_COMPLEX (plus_infty, -10.0));
3763 check ("real(catan(+Inf - i10.0)) = pi/2", __real__ result, M_PI_2);
3764 check ("imag(catan(+Inf - i10.0)) = -0", __imag__ result, minus_zero);
3765 result = FUNC(catan) (BUILD_COMPLEX (minus_infty, -10.0));
3766 check ("real(catan(-Inf - i10.0)) = -pi/2", __real__ result, -M_PI_2);
3767 check ("imag(catan(-Inf - i10.0)) = -0", __imag__ result, minus_zero);
3768 result = FUNC(catan) (BUILD_COMPLEX (plus_infty, minus_zero));
3769 check ("real(catan(Inf - i0)) = pi/2", __real__ result, M_PI_2);
3770 check ("imag(catan(Inf - i0)) = -0", __imag__ result, minus_zero);
3771 result = FUNC(catan) (BUILD_COMPLEX (minus_infty, minus_zero));
3772 check ("real(catan(-Inf - i0)) = -pi/2", __real__ result, -M_PI_2);
3773 check ("imag(catan(-Inf - i0)) = -0", __imag__ result, minus_zero);
3774 result = FUNC(catan) (BUILD_COMPLEX (plus_infty, 0.0));
3775 check ("real(catan(Inf + i0)) = pi/2", __real__ result, M_PI_2);
3776 check ("imag(catan(Inf + i0)) = 0", __imag__ result, 0.0);
3777 result = FUNC(catan) (BUILD_COMPLEX (minus_infty, 0.0));
3778 check ("real(catan(-Inf + i0)) = -pi/2", __real__ result, -M_PI_2);
3779 check ("imag(catan(-Inf + i0)) = 0", __imag__ result, 0.0);
3780 result = FUNC(catan) (BUILD_COMPLEX (plus_infty, 0.1));
3781 check ("real(catan(+Inf + i0.1)) = pi/2", __real__ result, M_PI_2);
3782 check ("imag(catan(+Inf + i0.1)) = 0", __imag__ result, 0);
3783 result = FUNC(catan) (BUILD_COMPLEX (minus_infty, 0.1));
3784 check ("real(catan(-Inf + i0.1)) = -pi/2", __real__ result, -M_PI_2);
3785 check ("imag(catan(-Inf + i0.1)) = 0", __imag__ result, 0);
3787 result = FUNC(catan) (BUILD_COMPLEX (0.0, minus_infty));
3788 check ("real(catan(0 - i Inf)) = pi/2", __real__ result, M_PI_2);
3789 check ("imag(catan(0 - i Inf)) = -0", __imag__ result, minus_zero);
3790 result = FUNC(catan) (BUILD_COMPLEX (minus_zero, minus_infty));
3791 check ("real(catan(-0 - i Inf)) = -pi/2", __real__ result, -M_PI_2);
3792 check ("imag(catan(-0 - i Inf)) = -0", __imag__ result, minus_zero);
3793 result = FUNC(catan) (BUILD_COMPLEX (100.0, minus_infty));
3794 check ("real(catan(100 - i Inf)) = pi/2", __real__ result, M_PI_2);
3795 check ("imag(catan(100 - i Inf)) = -0", __imag__ result, minus_zero);
3796 result = FUNC(catan) (BUILD_COMPLEX (-100.0, minus_infty));
3797 check ("real(catan(-100 - i Inf)) = -pi/2", __real__ result, -M_PI_2);
3798 check ("imag(catan(-100 - i Inf)) = -0", __imag__ result, minus_zero);
3800 result = FUNC(catan) (BUILD_COMPLEX (0.0, plus_infty));
3801 check ("real(catan(0 + i Inf)) = pi/2", __real__ result, M_PI_2);
3802 check ("imag(catan(0 + i Inf)) = 0", __imag__ result, 0);
3803 result = FUNC(catan) (BUILD_COMPLEX (minus_zero, plus_infty));
3804 check ("real(catan(-0 + i Inf)) = -pi/2", __real__ result, -M_PI_2);
3805 check ("imag(catan(-0 + i Inf)) = 0", __imag__ result, 0);
3806 result = FUNC(catan) (BUILD_COMPLEX (0.5, plus_infty));
3807 check ("real(catan(0.5 + i Inf)) = pi/2", __real__ result, M_PI_2);
3808 check ("imag(catan(0.5 + i Inf)) = 0", __imag__ result, 0);
3809 result = FUNC(catan) (BUILD_COMPLEX (-0.5, plus_infty));
3810 check ("real(catan(-0.5 + i Inf)) = -pi/2", __real__ result, -M_PI_2);
3811 check ("imag(catan(-0.5 + i Inf)) = 0", __imag__ result, 0);
3813 result = FUNC(catan) (BUILD_COMPLEX (nan_value, 0.0));
3814 check_isnan ("real(catan(NaN + i0)) = NaN", __real__ result);
3815 check ("imag(catan(NaN + i0)) = 0", __imag__ result, 0.0);
3816 result = FUNC(catan) (BUILD_COMPLEX (nan_value, minus_zero));
3817 check_isnan ("real(catan(NaN - i0)) = NaN", __real__ result);
3818 check ("imag(catan(NaN - i0)) = -0", __imag__ result, minus_zero);
3820 result = FUNC(catan) (BUILD_COMPLEX (nan_value, plus_infty));
3821 check_isnan ("real(catan(NaN + i Inf)) = NaN", __real__ result);
3822 check ("imag(catan(NaN + i Inf)) = 0", __imag__ result, 0);
3823 result = FUNC(catan) (BUILD_COMPLEX (nan_value, minus_infty));
3824 check_isnan ("real(catan(NaN - i Inf)) = NaN", __real__ result);
3825 check ("imag(catan(NaN - i Inf)) = -0", __imag__ result, minus_zero);
3827 result = FUNC(catan) (BUILD_COMPLEX (0.0, nan_value));
3828 check_isnan ("real(catan(0 + i NaN)) = NaN", __real__ result);
3829 check_isnan ("imag(catan(0 + i NaN)) = NaN", __imag__ result);
3830 result = FUNC(catan) (BUILD_COMPLEX (minus_zero, nan_value));
3831 check_isnan ("real(catan(-0 + i NaN)) = NaN", __real__ result);
3832 check_isnan ("imag(catan(-0 + i NaN)) = NaN", __imag__ result);
3834 result = FUNC(catan) (BUILD_COMPLEX (plus_infty, nan_value));
3835 check ("real(catan(+Inf + i NaN)) = pi/2", __real__ result, M_PI_2);
3836 check ("imag(catan(+Inf + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0);
3837 result = FUNC(catan) (BUILD_COMPLEX (minus_infty, nan_value));
3838 check ("real(catan(-Inf + i NaN)) = -pi/2", __real__ result, -M_PI_2);
3839 check ("imag(catan(-Inf + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0);
3841 result = FUNC(catan) (BUILD_COMPLEX (nan_value, 10.5));
3842 check_isnan_maybe_exc ("real(catan(NaN + i10.5)) = NaN plus maybe invalid exception",
3843 __real__ result, INVALID_EXCEPTION);
3844 check_isnan ("imag(catan(NaN + i10.5)) = NaN plus maybe invalid exception",
3845 __imag__ result);
3846 result = FUNC(catan) (BUILD_COMPLEX (nan_value, -10.5));
3847 check_isnan_maybe_exc ("real(catan(NaN - i10.5)) = NaN plus maybe invalid exception",
3848 __real__ result, INVALID_EXCEPTION);
3849 check_isnan ("imag(catan(NaN - i10.5)) = NaN plus maybe invalid exception",
3850 __imag__ result);
3852 result = FUNC(catan) (BUILD_COMPLEX (0.75, nan_value));
3853 check_isnan_maybe_exc ("real(catan(0.75 + i NaN)) = NaN plus maybe invalid exception",
3854 __real__ result, INVALID_EXCEPTION);
3855 check_isnan ("imag(catan(0.75 + i NaN)) = NaN plus maybe invalid exception",
3856 __imag__ result);
3857 result = FUNC(catan) (BUILD_COMPLEX (-0.75, nan_value));
3858 check_isnan_maybe_exc ("real(catan(-0.75 + i NaN)) = NaN plus maybe invalid exception",
3859 __real__ result, INVALID_EXCEPTION);
3860 check_isnan ("imag(catan(-0.75 + i NaN)) = NaN plus maybe invalid exception",
3861 __imag__ result);
3863 result = FUNC(catan) (BUILD_COMPLEX (nan_value, nan_value));
3864 check_isnan ("real(catan(NaN + i NaN)) = NaN", __real__ result);
3865 check_isnan ("imag(catan(NaN + i NaN)) = NaN", __imag__ result);
3869 static void
3870 catanh_test (void)
3872 __complex__ MATHTYPE result;
3874 result = FUNC(catanh) (BUILD_COMPLEX (0, 0));
3875 check ("real(catanh(0 + i0)) = 0", __real__ result, 0);
3876 check ("imag(catanh(0 + i0)) = 0", __imag__ result, 0);
3877 result = FUNC(catanh) (BUILD_COMPLEX (minus_zero, 0));
3878 check ("real(catanh(-0 + i0)) = -0", __real__ result, minus_zero);
3879 check ("imag(catanh(-0 + i0)) = 0", __imag__ result, 0);
3880 result = FUNC(catanh) (BUILD_COMPLEX (0, minus_zero));
3881 check ("real(catanh(0 - i0)) = 0", __real__ result, 0);
3882 check ("imag(catanh(0 - i0)) = -0", __imag__ result, minus_zero);
3883 result = FUNC(catanh) (BUILD_COMPLEX (minus_zero, minus_zero));
3884 check ("real(catanh(-0 - i0)) = -0", __real__ result, minus_zero);
3885 check ("imag(catanh(-0 - i0)) = -0", __imag__ result, minus_zero);
3887 result = FUNC(catanh) (BUILD_COMPLEX (plus_infty, plus_infty));
3888 check ("real(catanh(+Inf + i Inf)) = 0", __real__ result, 0);
3889 check ("imag(catanh(+Inf + i Inf)) = pi/2", __imag__ result, M_PI_2);
3890 result = FUNC(catanh) (BUILD_COMPLEX (plus_infty, minus_infty));
3891 check ("real(catanh(+Inf - i Inf)) = 0", __real__ result, 0);
3892 check ("imag(catanh(+Inf - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3893 result = FUNC(catanh) (BUILD_COMPLEX (minus_infty, plus_infty));
3894 check ("real(catanh(-Inf + i Inf)) = -0", __real__ result, minus_zero);
3895 check ("imag(catanh(-Inf + i Inf)) = pi/2", __imag__ result, M_PI_2);
3896 result = FUNC(catanh) (BUILD_COMPLEX (minus_infty, minus_infty));
3897 check ("real(catanh(-Inf - i Inf)) = -0", __real__ result, minus_zero);
3898 check ("imag(catanh(-Inf - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3900 result = FUNC(catanh) (BUILD_COMPLEX (-10.0, plus_infty));
3901 check ("real(catanh(-10.0 + i Inf)) = -0", __real__ result, minus_zero);
3902 check ("imag(catanh(-10.0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
3903 result = FUNC(catanh) (BUILD_COMPLEX (-10.0, minus_infty));
3904 check ("real(catanh(-10.0 - i Inf)) = -0", __real__ result, minus_zero);
3905 check ("imag(catanh(-10.0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3906 result = FUNC(catanh) (BUILD_COMPLEX (minus_zero, plus_infty));
3907 check ("real(catanh(-0 + i Inf)) = -0", __real__ result, minus_zero);
3908 check ("imag(catanh(-0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
3909 result = FUNC(catanh) (BUILD_COMPLEX (minus_zero, minus_infty));
3910 check ("real(catanh(-0 - i Inf)) = -0", __real__ result, minus_zero);
3911 check ("imag(catanh(-0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3912 result = FUNC(catanh) (BUILD_COMPLEX (0, plus_infty));
3913 check ("real(catanh(0 + i Inf)) = 0", __real__ result, 0);
3914 check ("imag(catanh(0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
3915 result = FUNC(catanh) (BUILD_COMPLEX (0, minus_infty));
3916 check ("real(catanh(0 - i Inf)) = 0", __real__ result, 0);
3917 check ("imag(catanh(0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3918 result = FUNC(catanh) (BUILD_COMPLEX (0.1, plus_infty));
3919 check ("real(catanh(0.1 + i Inf)) = 0", __real__ result, 0);
3920 check ("imag(catanh(0.1 + i Inf)) = pi/2", __imag__ result, M_PI_2);
3921 result = FUNC(catanh) (BUILD_COMPLEX (0.1, minus_infty));
3922 check ("real(catanh(0.1 - i Inf)) = 0", __real__ result, 0);
3923 check ("imag(catanh(0.1 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3925 result = FUNC(catanh) (BUILD_COMPLEX (minus_infty, 0));
3926 check ("real(catanh(-Inf + i0)) = -0", __real__ result, minus_zero);
3927 check ("imag(catanh(-Inf + i0)) = pi/2", __imag__ result, M_PI_2);
3928 result = FUNC(catanh) (BUILD_COMPLEX (minus_infty, minus_zero));
3929 check ("real(catanh(-Inf - i0)) = -0", __real__ result, minus_zero);
3930 check ("imag(catanh(-Inf - i0)) = -pi/2", __imag__ result, -M_PI_2);
3931 result = FUNC(catanh) (BUILD_COMPLEX (minus_infty, 100));
3932 check ("real(catanh(-Inf + i100)) = -0", __real__ result, minus_zero);
3933 check ("imag(catanh(-Inf + i100)) = pi/2", __imag__ result, M_PI_2);
3934 result = FUNC(catanh) (BUILD_COMPLEX (minus_infty, -100));
3935 check ("real(catanh(-Inf - i100)) = -0", __real__ result, minus_zero);
3936 check ("imag(catanh(-Inf - i100)) = -pi/2", __imag__ result, -M_PI_2);
3938 result = FUNC(catanh) (BUILD_COMPLEX (plus_infty, 0));
3939 check ("real(catanh(+Inf + i0)) = 0", __real__ result, 0);
3940 check ("imag(catanh(+Inf + i0)) = pi/2", __imag__ result, M_PI_2);
3941 result = FUNC(catanh) (BUILD_COMPLEX (plus_infty, minus_zero));
3942 check ("real(catanh(+Inf - i0)) = 0", __real__ result, 0);
3943 check ("imag(catanh(+Inf - i0)) = -pi/2", __imag__ result, -M_PI_2);
3944 result = FUNC(catanh) (BUILD_COMPLEX (plus_infty, 0.5));
3945 check ("real(catanh(+Inf + i0.5)) = 0", __real__ result, 0);
3946 check ("imag(catanh(+Inf + i0.5)) = pi/2", __imag__ result, M_PI_2);
3947 result = FUNC(catanh) (BUILD_COMPLEX (plus_infty, -0.5));
3948 check ("real(catanh(+Inf - i0.5)) = 0", __real__ result, 0);
3949 check ("imag(catanh(+Inf - i0.5)) = -pi/2", __imag__ result, -M_PI_2);
3951 result = FUNC(catanh) (BUILD_COMPLEX (0, nan_value));
3952 check ("real(catanh(0 + i NaN)) = 0", __real__ result, 0);
3953 check_isnan ("imag(catanh(0 + i NaN)) = NaN", __imag__ result);
3954 result = FUNC(catanh) (BUILD_COMPLEX (minus_zero, nan_value));
3955 check ("real(catanh(-0 + i NaN)) = -0", __real__ result, minus_zero);
3956 check_isnan ("imag(catanh(-0 + i NaN)) = NaN", __imag__ result);
3958 result = FUNC(catanh) (BUILD_COMPLEX (plus_infty, nan_value));
3959 check ("real(catanh(+Inf + i NaN)) = 0", __real__ result, 0);
3960 check_isnan ("imag(catanh(+Inf + i NaN)) = NaN", __imag__ result);
3961 result = FUNC(catanh) (BUILD_COMPLEX (minus_infty, nan_value));
3962 check ("real(catanh(-Inf + i NaN)) = -0", __real__ result, minus_zero);
3963 check_isnan ("imag(catanh(-Inf + i NaN)) = NaN", __imag__ result);
3965 result = FUNC(catanh) (BUILD_COMPLEX (nan_value, 0));
3966 check_isnan ("real(catanh(NaN + i0)) = NaN", __real__ result);
3967 check_isnan ("imag(catanh(NaN + i0)) = NaN", __imag__ result);
3968 result = FUNC(catanh) (BUILD_COMPLEX (nan_value, minus_zero));
3969 check_isnan ("real(catanh(NaN - i0)) = NaN", __real__ result);
3970 check_isnan ("imag(catanh(NaN - i0)) = NaN", __imag__ result);
3972 result = FUNC(catanh) (BUILD_COMPLEX (nan_value, plus_infty));
3973 check ("real(catanh(NaN + i Inf)) = +-0", FUNC(fabs) (__real__ result), 0);
3974 check ("imag(catanh(NaN + i Inf)) = pi/2", __imag__ result, M_PI_2);
3975 result = FUNC(catanh) (BUILD_COMPLEX (nan_value, minus_infty));
3976 check ("real(catanh(NaN - i Inf)) = +-0", FUNC(fabs) (__real__ result), 0);
3977 check ("imag(catanh(NaN - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
3979 result = FUNC(catanh) (BUILD_COMPLEX (10.5, nan_value));
3980 check_isnan_maybe_exc ("real(catanh(10.5 + i NaN)) = NaN plus maybe invalid exception",
3981 __real__ result, INVALID_EXCEPTION);
3982 check_isnan ("imag(catanh(10.5 + i NaN)) = NaN plus maybe invalid exception",
3983 __imag__ result);
3984 result = FUNC(catanh) (BUILD_COMPLEX (-10.5, nan_value));
3985 check_isnan_maybe_exc ("real(catanh(-10.5 + i NaN)) = NaN plus maybe invalid exception",
3986 __real__ result, INVALID_EXCEPTION);
3987 check_isnan ("imag(catanh(-10.5 + i NaN)) = NaN plus maybe invalid exception",
3988 __imag__ result);
3990 result = FUNC(catanh) (BUILD_COMPLEX (nan_value, 0.75));
3991 check_isnan_maybe_exc ("real(catanh(NaN + i0.75)) = NaN plus maybe invalid exception",
3992 __real__ result, INVALID_EXCEPTION);
3993 check_isnan ("imag(catanh(NaN + i0.75)) = NaN plus maybe invalid exception",
3994 __imag__ result);
3995 result = FUNC(catanh) (BUILD_COMPLEX (nan_value, -0.75));
3996 check_isnan_maybe_exc ("real(catanh(NaN - i0.75)) = NaN plus maybe invalid exception",
3997 __real__ result, INVALID_EXCEPTION);
3998 check_isnan ("imag(catanh(NaN - i0.75)) = NaN plus maybe invalid exception",
3999 __imag__ result);
4001 result = FUNC(catanh) (BUILD_COMPLEX (nan_value, nan_value));
4002 check_isnan ("real(catanh(NaN + i NaN)) = NaN", __real__ result);
4003 check_isnan ("imag(catanh(NaN + i NaN)) = NaN", __imag__ result);
4007 static void
4008 ctanh_test (void)
4010 __complex__ MATHTYPE result;
4012 result = FUNC(ctanh) (BUILD_COMPLEX (0, 0));
4013 check ("real(ctanh(0 + i0)) = 0", __real__ result, 0);
4014 check ("imag(ctanh(0 + i0)) = 0", __imag__ result, 0);
4015 result = FUNC(ctanh) (BUILD_COMPLEX (0, minus_zero));
4016 check ("real(ctanh(0 - i0)) = 0", __real__ result, 0);
4017 check ("imag(ctanh(0 - i0)) = -0", __imag__ result, minus_zero);
4018 result = FUNC(ctanh) (BUILD_COMPLEX (minus_zero, 0));
4019 check ("real(ctanh(-0 + i0)) = -0", __real__ result, minus_zero);
4020 check ("imag(ctanh(-0 + i0)) = 0", __imag__ result, 0);
4021 result = FUNC(ctanh) (BUILD_COMPLEX (minus_zero, minus_zero));
4022 check ("real(ctanh(-0 - i0)) = -0", __real__ result, minus_zero);
4023 check ("imag(ctanh(-0 - i0)) = -0", __imag__ result, minus_zero);
4025 result = FUNC(ctanh) (BUILD_COMPLEX (plus_infty, 0));
4026 check ("real(ctanh(+Inf + i0)) = 1", __real__ result, 1);
4027 check ("imag(ctanh(+Inf + i0)) = 0", __imag__ result, 0);
4028 result = FUNC(ctanh) (BUILD_COMPLEX (plus_infty, 1));
4029 check ("real(ctanh(+Inf + i1)) = 1", __real__ result, 1);
4030 check ("imag(ctanh(+Inf + i1)) = 0", __imag__ result, 0);
4031 result = FUNC(ctanh) (BUILD_COMPLEX (plus_infty, minus_zero));
4032 check ("real(ctanh(+Inf - i0)) = 1", __real__ result, 1);
4033 check ("imag(ctanh(+Inf - i0)) = -0", __imag__ result, minus_zero);
4034 result = FUNC(ctanh) (BUILD_COMPLEX (plus_infty, -1));
4035 check ("real(ctanh(+Inf - i1)) = 1", __real__ result, 1);
4036 check ("imag(ctanh(+Inf - i1)) = -0", __imag__ result, minus_zero);
4037 result = FUNC(ctanh) (BUILD_COMPLEX (minus_infty, 0));
4038 check ("real(ctanh(-Inf + i0)) = -1", __real__ result, -1);
4039 check ("imag(ctanh(-Inf + i0)) = 0", __imag__ result, 0);
4040 result = FUNC(ctanh) (BUILD_COMPLEX (minus_infty, 1));
4041 check ("real(ctanh(-Inf + i1)) = -1", __real__ result, -1);
4042 check ("imag(ctanh(-Inf + i1)) = 0", __imag__ result, 0);
4043 result = FUNC(ctanh) (BUILD_COMPLEX (minus_infty, minus_zero));
4044 check ("real(ctanh(-Inf - i0)) = -1", __real__ result, -1);
4045 check ("imag(ctanh(-Inf - i0)) = -0", __imag__ result, minus_zero);
4046 result = FUNC(ctanh) (BUILD_COMPLEX (minus_infty, -1));
4047 check ("real(ctanh(-Inf - i1)) = -1", __real__ result, -1);
4048 check ("imag(ctanh(-Inf - i1)) = -0", __imag__ result, minus_zero);
4050 result = FUNC(ctanh) (BUILD_COMPLEX (0, plus_infty));
4051 check_isnan_exc ("real(ctanh(0 + i Inf)) = NaN plus invalid exception",
4052 __real__ result, INVALID_EXCEPTION);
4053 check_isnan ("imag(ctanh(0 + i Inf)) = NaN plus invalid exception",
4054 __imag__ result);
4055 result = FUNC(ctanh) (BUILD_COMPLEX (2, plus_infty));
4056 check_isnan_exc ("real(ctanh(2 + i Inf)) = NaN plus invalid exception",
4057 __real__ result, INVALID_EXCEPTION);
4058 check_isnan ("imag(ctanh(2 + i Inf)) = NaN plus invalid exception",
4059 __imag__ result);
4060 result = FUNC(ctanh) (BUILD_COMPLEX (0, minus_infty));
4061 check_isnan_exc ("real(ctanh(0 - i Inf)) = NaN plus invalid exception",
4062 __real__ result, INVALID_EXCEPTION);
4063 check_isnan ("imag(ctanh(0 - i Inf)) = NaN plus invalid exception",
4064 __imag__ result);
4065 result = FUNC(ctanh) (BUILD_COMPLEX (2, minus_infty));
4066 check_isnan_exc ("real(ctanh(2 - i Inf)) = NaN plus invalid exception",
4067 __real__ result, INVALID_EXCEPTION);
4068 check_isnan ("imag(ctanh(2 - i Inf)) = NaN plus invalid exception",
4069 __imag__ result);
4070 result = FUNC(ctanh) (BUILD_COMPLEX (minus_zero, plus_infty));
4071 check_isnan_exc ("real(ctanh(-0 + i Inf)) = NaN plus invalid exception",
4072 __real__ result, INVALID_EXCEPTION);
4073 check_isnan ("imag(ctanh(-0 + i Inf)) = NaN plus invalid exception",
4074 __imag__ result);
4075 result = FUNC(ctanh) (BUILD_COMPLEX (-2, plus_infty));
4076 check_isnan_exc ("real(ctanh(-2 + i Inf)) = NaN plus invalid exception",
4077 __real__ result, INVALID_EXCEPTION);
4078 check_isnan ("imag(ctanh(-2 + i Inf)) = NaN plus invalid exception",
4079 __imag__ result);
4080 result = FUNC(ctanh) (BUILD_COMPLEX (minus_zero, minus_infty));
4081 check_isnan_exc ("real(ctanh(-0 - i Inf)) = NaN plus invalid exception",
4082 __real__ result, INVALID_EXCEPTION);
4083 check_isnan ("imag(ctanh(-0 - i Inf)) = NaN plus invalid exception",
4084 __imag__ result);
4085 result = FUNC(ctanh) (BUILD_COMPLEX (-2, minus_infty));
4086 check_isnan_exc ("real(ctanh(-2 - i Inf)) = NaN plus invalid exception",
4087 __real__ result, INVALID_EXCEPTION);
4088 check_isnan ("imag(ctanh(-2 - i Inf)) = NaN plus invalid exception",
4089 __imag__ result);
4091 result = FUNC(ctanh) (BUILD_COMPLEX (plus_infty, nan_value));
4092 check ("real(ctanh(+Inf + i NaN)) = 1", __real__ result, 1);
4093 check ("imag(ctanh(+Inf + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0);
4094 result = FUNC(ctanh) (BUILD_COMPLEX (minus_infty, nan_value));
4095 check ("real(ctanh(-Inf + i NaN)) = -1", __real__ result, -1);
4096 check ("imag(ctanh(-Inf + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0);
4098 result = FUNC(ctanh) (BUILD_COMPLEX (nan_value, 0));
4099 check_isnan ("real(ctanh(NaN + i0)) = NaN", __real__ result);
4100 check ("imag(ctanh(NaN + i0)) = 0", __imag__ result, 0);
4101 result = FUNC(ctanh) (BUILD_COMPLEX (nan_value, minus_zero));
4102 check_isnan ("real(ctanh(NaN - i0)) = NaN", __real__ result);
4103 check ("imag(ctanh(NaN - i0)) = -0", __imag__ result, minus_zero);
4105 result = FUNC(ctanh) (BUILD_COMPLEX (nan_value, 0.5));
4106 check_isnan_maybe_exc ("real(ctanh(NaN + i0.5)) = NaN plus maybe invalid exception",
4107 __real__ result, INVALID_EXCEPTION);
4108 check_isnan ("imag(ctanh(NaN + i0.5)) = NaN plus maybe invalid exception",
4109 __imag__ result);
4110 result = FUNC(ctanh) (BUILD_COMPLEX (nan_value, -4.5));
4111 check_isnan_maybe_exc ("real(ctanh(NaN - i4.5)) = NaN plus maybe invalid exception",
4112 __real__ result, INVALID_EXCEPTION);
4113 check_isnan ("imag(ctanh(NaN - i4.5)) = NaN plus maybe invalid exception",
4114 __imag__ result);
4116 result = FUNC(ctanh) (BUILD_COMPLEX (0, nan_value));
4117 check_isnan_maybe_exc ("real(ctanh(0 + i NaN)) = NaN plus maybe invalid exception",
4118 __real__ result, INVALID_EXCEPTION);
4119 check_isnan ("imag(ctanh(0 + i NaN)) = NaN plus maybe invalid exception",
4120 __imag__ result);
4121 result = FUNC(ctanh) (BUILD_COMPLEX (5, nan_value));
4122 check_isnan_maybe_exc ("real(ctanh(5 + i NaN)) = NaN plus maybe invalid exception",
4123 __real__ result, INVALID_EXCEPTION);
4124 check_isnan ("imag(ctanh(5 + i NaN)) = NaN plus maybe invalid exception",
4125 __imag__ result);
4126 result = FUNC(ctanh) (BUILD_COMPLEX (minus_zero, nan_value));
4127 check_isnan_maybe_exc ("real(ctanh(-0 + i NaN)) = NaN plus maybe invalid exception",
4128 __real__ result, INVALID_EXCEPTION);
4129 check_isnan ("imag(ctanh(-0 + i NaN)) = NaN plus maybe invalid exception",
4130 __imag__ result);
4131 result = FUNC(ctanh) (BUILD_COMPLEX (-0.25, nan_value));
4132 check_isnan_maybe_exc ("real(ctanh(-0.25 + i NaN)) = NaN plus maybe invalid exception",
4133 __real__ result, INVALID_EXCEPTION);
4134 check_isnan ("imag(ctanh(-0.25 + i NaN)) = NaN plus maybe invalid exception",
4135 __imag__ result);
4137 result = FUNC(ctanh) (BUILD_COMPLEX (nan_value, nan_value));
4138 check_isnan ("real(ctanh(NaN + i NaN)) = NaN", __real__ result);
4139 check_isnan ("imag(ctanh(NaN + i NaN)) = NaN", __imag__ result);
4143 static void
4144 clog_test (void)
4146 __complex__ MATHTYPE result;
4148 result = FUNC(clog) (BUILD_COMPLEX (minus_zero, 0));
4149 check_isinfn_exc ("real(clog(-0 + i0)) = -Inf plus divide-by-zero exception",
4150 __real__ result, DIVIDE_BY_ZERO_EXCEPTION);
4151 check ("imag(clog(-0 + i0)) = pi plus divide-by-zero exception",
4152 __imag__ result, M_PI);
4153 result = FUNC(clog) (BUILD_COMPLEX (minus_zero, minus_zero));
4154 check_isinfn_exc ("real(clog(-0 - i0)) = -Inf plus divide-by-zero exception",
4155 __real__ result, DIVIDE_BY_ZERO_EXCEPTION);
4156 check ("imag(clog(-0 - i0)) = -pi plus divide-by-zero exception",
4157 __imag__ result, -M_PI);
4159 result = FUNC(clog) (BUILD_COMPLEX (0, 0));
4160 check_isinfn_exc ("real(clog(0 + i0)) = -Inf plus divide-by-zero exception",
4161 __real__ result, DIVIDE_BY_ZERO_EXCEPTION);
4162 check ("imag(clog(0 + i0)) = 0 plus divide-by-zero exception",
4163 __imag__ result, 0);
4164 result = FUNC(clog) (BUILD_COMPLEX (0, minus_zero));
4165 check_isinfn_exc ("real(clog(0 - i0)) = -Inf plus divide-by-zero exception",
4166 __real__ result, DIVIDE_BY_ZERO_EXCEPTION);
4167 check ("imag(clog(0 - i0)) = -0 plus divide-by-zero exception",
4168 __imag__ result, minus_zero);
4170 result = FUNC(clog) (BUILD_COMPLEX (minus_infty, plus_infty));
4171 check_isinfp ("real(clog(-Inf + i Inf)) = +Inf", __real__ result);
4172 check ("imag(clog(-Inf + i Inf)) = 3*pi/4", __imag__ result, M_PI - M_PI_4);
4173 result = FUNC(clog) (BUILD_COMPLEX (minus_infty, minus_infty));
4174 check_isinfp ("real(clog(-Inf - i Inf)) = +Inf", __real__ result);
4175 check ("imag(clog(-Inf - i Inf)) = -3*pi/4", __imag__ result, M_PI_4 - M_PI);
4177 result = FUNC(clog) (BUILD_COMPLEX (plus_infty, plus_infty));
4178 check_isinfp ("real(clog(+Inf + i Inf)) = +Inf", __real__ result);
4179 check ("imag(clog(+Inf + i Inf)) = pi/4", __imag__ result, M_PI_4);
4180 result = FUNC(clog) (BUILD_COMPLEX (plus_infty, minus_infty));
4181 check_isinfp ("real(clog(+Inf - i Inf)) = +Inf", __real__ result);
4182 check ("imag(clog(+Inf - i Inf)) = -pi/4", __imag__ result, -M_PI_4);
4184 result = FUNC(clog) (BUILD_COMPLEX (0, plus_infty));
4185 check_isinfp ("real(clog(0 + i Inf)) = +Inf", __real__ result);
4186 check ("imag(clog(0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
4187 result = FUNC(clog) (BUILD_COMPLEX (3, plus_infty));
4188 check_isinfp ("real(clog(3 + i Inf)) = +Inf", __real__ result);
4189 check ("imag(clog(3 + i Inf)) = pi/2", __imag__ result, M_PI_2);
4190 result = FUNC(clog) (BUILD_COMPLEX (minus_zero, plus_infty));
4191 check_isinfp ("real(clog(-0 + i Inf)) = +Inf", __real__ result);
4192 check ("imag(clog(-0 + i Inf)) = pi/2", __imag__ result, M_PI_2);
4193 result = FUNC(clog) (BUILD_COMPLEX (-3, plus_infty));
4194 check_isinfp ("real(clog(-3 + i Inf)) = +Inf", __real__ result);
4195 check ("imag(clog(-3 + i Inf)) = pi/2", __imag__ result, M_PI_2);
4196 result = FUNC(clog) (BUILD_COMPLEX (0, minus_infty));
4197 check_isinfp ("real(clog(0 - i Inf)) = +Inf", __real__ result);
4198 check ("imag(clog(0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
4199 result = FUNC(clog) (BUILD_COMPLEX (3, minus_infty));
4200 check_isinfp ("real(clog(3 - i Inf)) = +Inf", __real__ result);
4201 check ("imag(clog(3 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
4202 result = FUNC(clog) (BUILD_COMPLEX (minus_zero, minus_infty));
4203 check_isinfp ("real(clog(-0 - i Inf)) = +Inf", __real__ result);
4204 check ("imag(clog(-0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
4205 result = FUNC(clog) (BUILD_COMPLEX (-3, minus_infty));
4206 check_isinfp ("real(clog(-3 - i Inf)) = +Inf", __real__ result);
4207 check ("imag(clog(-3 - i Inf)) = -pi/2", __imag__ result, -M_PI_2);
4209 result = FUNC(clog) (BUILD_COMPLEX (minus_infty, 0));
4210 check_isinfp ("real(clog(-Inf + i0)) = +Inf", __real__ result);
4211 check ("imag(clog(-Inf + i0)) = pi", __imag__ result, M_PI);
4212 result = FUNC(clog) (BUILD_COMPLEX (minus_infty, 1));
4213 check_isinfp ("real(clog(-Inf + i1)) = +Inf", __real__ result);
4214 check ("imag(clog(-Inf + i1)) = pi", __imag__ result, M_PI);
4215 result = FUNC(clog) (BUILD_COMPLEX (minus_infty, minus_zero));
4216 check_isinfp ("real(clog(-Inf - i0)) = +Inf", __real__ result);
4217 check ("imag(clog(-Inf - i0)) = -pi", __imag__ result, -M_PI);
4218 result = FUNC(clog) (BUILD_COMPLEX (minus_infty, -1));
4219 check_isinfp ("real(clog(-Inf - i1)) = +Inf", __real__ result);
4220 check ("imag(clog(-Inf - i1)) = -pi", __imag__ result, -M_PI);
4222 result = FUNC(clog) (BUILD_COMPLEX (plus_infty, 0));
4223 check_isinfp ("real(clog(+Inf + i0)) = +Inf", __real__ result);
4224 check ("imag(clog(+Inf + i0)) = 0", __imag__ result, 0);
4225 result = FUNC(clog) (BUILD_COMPLEX (plus_infty, 1));
4226 check_isinfp ("real(clog(+Inf + i1)) = +Inf", __real__ result);
4227 check ("imag(clog(+Inf + i1)) = 0", __imag__ result, 0);
4228 result = FUNC(clog) (BUILD_COMPLEX (plus_infty, minus_zero));
4229 check_isinfp ("real(clog(+Inf - i0)) = +Inf", __real__ result);
4230 check ("imag(clog(+Inf - i0)) = -0", __imag__ result, minus_zero);
4231 result = FUNC(clog) (BUILD_COMPLEX (plus_infty, -1));
4232 check_isinfp ("real(clog(+Inf - i1)) = +Inf", __real__ result);
4233 check ("imag(clog(+Inf - i1)) = -0", __imag__ result, minus_zero);
4235 result = FUNC(clog) (BUILD_COMPLEX (plus_infty, nan_value));
4236 check_isinfp ("real(clog(+Inf + i NaN)) = +Inf", __real__ result);
4237 check_isnan ("imag(clog(+Inf + i NaN)) = NaN", __imag__ result);
4238 result = FUNC(clog) (BUILD_COMPLEX (minus_infty, nan_value));
4239 check_isinfp ("real(clog(-Inf + i NaN)) = +Inf", __real__ result);
4240 check_isnan ("imag(clog(-Inf + i NaN)) = NaN", __imag__ result);
4242 result = FUNC(clog) (BUILD_COMPLEX (nan_value, plus_infty));
4243 check_isinfp ("real(clog(NaN + i Inf)) = +Inf", __real__ result);
4244 check_isnan ("imag(clog(NaN + i Inf)) = NaN", __imag__ result);
4245 result = FUNC(clog) (BUILD_COMPLEX (nan_value, minus_infty));
4246 check_isinfp ("real(clog(NaN - i Inf)) = +Inf", __real__ result);
4247 check_isnan ("imag(clog(NaN - i Inf)) = NaN", __imag__ result);
4249 result = FUNC(clog) (BUILD_COMPLEX (0, nan_value));
4250 check_isnan_maybe_exc ("real(clog(0 + i NaN)) = NaN plus maybe invalid exception",
4251 __real__ result, INVALID_EXCEPTION);
4252 check_isnan ("imag(clog(0 + i NaN)) = NaN plus maybe invalid exception",
4253 __imag__ result);
4254 result = FUNC(clog) (BUILD_COMPLEX (3, nan_value));
4255 check_isnan_maybe_exc ("real(clog(3 + i NaN)) = NaN plus maybe invalid exception",
4256 __real__ result, INVALID_EXCEPTION);
4257 check_isnan ("imag(clog(3 + i NaN)) = NaN plus maybe invalid exception",
4258 __imag__ result);
4259 result = FUNC(clog) (BUILD_COMPLEX (minus_zero, nan_value));
4260 check_isnan_maybe_exc ("real(clog(-0 + i NaN)) = NaN plus maybe invalid exception",
4261 __real__ result, INVALID_EXCEPTION);
4262 check_isnan ("imag(clog(-0 + i NaN)) = NaN plus maybe invalid exception",
4263 __imag__ result);
4264 result = FUNC(clog) (BUILD_COMPLEX (-3, nan_value));
4265 check_isnan_maybe_exc ("real(clog(-3 + i NaN)) = NaN plus maybe invalid exception",
4266 __real__ result, INVALID_EXCEPTION);
4267 check_isnan ("imag(clog(-3 + i NaN)) = NaN plus maybe invalid exception",
4268 __imag__ result);
4270 result = FUNC(clog) (BUILD_COMPLEX (nan_value, 0));
4271 check_isnan_maybe_exc ("real(clog(NaN + i0)) = NaN plus maybe invalid exception",
4272 __real__ result, INVALID_EXCEPTION);
4273 check_isnan ("imag(clog(NaN + i0)) = NaN plus maybe invalid exception",
4274 __imag__ result);
4275 result = FUNC(clog) (BUILD_COMPLEX (nan_value, 5));
4276 check_isnan_maybe_exc ("real(clog(NaN + i5)) = NaN plus maybe invalid exception",
4277 __real__ result, INVALID_EXCEPTION);
4278 check_isnan ("imag(clog(NaN + i5)) = NaN plus maybe invalid exception",
4279 __imag__ result);
4280 result = FUNC(clog) (BUILD_COMPLEX (nan_value, minus_zero));
4281 check_isnan_maybe_exc ("real(clog(NaN - i0)) = NaN plus maybe invalid exception",
4282 __real__ result, INVALID_EXCEPTION);
4283 check_isnan ("imag(clog(NaN - i0)) = NaN plus maybe invalid exception",
4284 __imag__ result);
4285 result = FUNC(clog) (BUILD_COMPLEX (nan_value, -5));
4286 check_isnan_maybe_exc ("real(clog(NaN - i5)) = NaN plus maybe invalid exception",
4287 __real__ result, INVALID_EXCEPTION);
4288 check_isnan ("imag(clog(NaN - i5)) = NaN plus maybe invalid exception",
4289 __imag__ result);
4291 result = FUNC(clog) (BUILD_COMPLEX (nan_value, nan_value));
4292 check_isnan ("real(clog(NaN + i NaN)) = NaN", __real__ result);
4293 check_isnan ("imag(clog(NaN + i NaN)) = NaN", __imag__ result);
4297 static void
4298 csqrt_test (void)
4300 __complex__ MATHTYPE result;
4302 result = FUNC(csqrt) (BUILD_COMPLEX (0, 0));
4303 check ("real(csqrt(0 + i0)) = 0", __real__ result, 0);
4304 check ("imag(csqrt(0 + i0)) = 0", __imag__ result, 0);
4305 result = FUNC(csqrt) (BUILD_COMPLEX (0, minus_zero));
4306 check ("real(csqrt(0 - i0)) = 0", __real__ result, 0);
4307 check ("imag(csqrt(0 - i0)) = -0", __imag__ result, minus_zero);
4308 result = FUNC(csqrt) (BUILD_COMPLEX (minus_zero, 0));
4309 check ("real(csqrt(-0 + i0)) = 0", __real__ result, 0);
4310 check ("imag(csqrt(-0 + i0)) = 0", __imag__ result, 0);
4311 result = FUNC(csqrt) (BUILD_COMPLEX (minus_zero, minus_zero));
4312 check ("real(csqrt(-0 - i0)) = 0", __real__ result, 0);
4313 check ("imag(csqrt(-0 - i0)) = -0", __imag__ result, minus_zero);
4315 result = FUNC(csqrt) (BUILD_COMPLEX (minus_infty, 0));
4316 check ("real(csqrt(-Inf + i0)) = 0", __real__ result, 0);
4317 check_isinfp ("imag(csqrt(-Inf + i0)) = +Inf", __imag__ result);
4318 result = FUNC(csqrt) (BUILD_COMPLEX (minus_infty, 6));
4319 check ("real(csqrt(-Inf + i6)) = 0", __real__ result, 0);
4320 check_isinfp ("imag(csqrt(-Inf + i6)) = +Inf", __imag__ result);
4321 result = FUNC(csqrt) (BUILD_COMPLEX (minus_infty, minus_zero));
4322 check ("real(csqrt(-Inf - i0)) = 0", __real__ result, 0);
4323 check_isinfn ("imag(csqrt(-Inf - i0)) = -Inf", __imag__ result);
4324 result = FUNC(csqrt) (BUILD_COMPLEX (minus_infty, -6));
4325 check ("real(csqrt(-Inf - i6)) = 0", __real__ result, 0);
4326 check_isinfn ("imag(csqrt(-Inf - i6)) = -Inf", __imag__ result);
4328 result = FUNC(csqrt) (BUILD_COMPLEX (plus_infty, 0));
4329 check_isinfp ("real(csqrt(+Inf + i0)) = +Inf", __real__ result);
4330 check ("imag(csqrt(+Inf + i0)) = 0", __imag__ result, 0);
4331 result = FUNC(csqrt) (BUILD_COMPLEX (plus_infty, 6));
4332 check_isinfp ("real(csqrt(+Inf + i6)) = +Inf", __real__ result);
4333 check ("imag(csqrt(+Inf + i6)) = 0", __imag__ result, 0);
4334 result = FUNC(csqrt) (BUILD_COMPLEX (plus_infty, minus_zero));
4335 check_isinfp ("real(csqrt(+Inf - i0)) = +Inf", __real__ result);
4336 check ("imag(csqrt(+Inf - i0)) = -0", __imag__ result, minus_zero);
4337 result = FUNC(csqrt) (BUILD_COMPLEX (plus_infty, -6));
4338 check_isinfp ("real(csqrt(+Inf - i6)) = +Inf", __real__ result);
4339 check ("imag(csqrt(+Inf - i6)) = -0", __imag__ result, minus_zero);
4341 result = FUNC(csqrt) (BUILD_COMPLEX (0, plus_infty));
4342 check_isinfp ("real(csqrt(0 + i Inf)) = +Inf", __real__ result);
4343 check_isinfp ("imag(csqrt(0 + i Inf)) = +Inf", __imag__ result);
4344 result = FUNC(csqrt) (BUILD_COMPLEX (4, plus_infty));
4345 check_isinfp ("real(csqrt(4 + i Inf)) = +Inf", __real__ result);
4346 check_isinfp ("imag(csqrt(4 + i Inf)) = +Inf", __imag__ result);
4347 result = FUNC(csqrt) (BUILD_COMPLEX (plus_infty, plus_infty));
4348 check_isinfp ("real(csqrt(+Inf + i Inf)) = +Inf", __real__ result);
4349 check_isinfp ("imag(csqrt(+Inf + i Inf)) = +Inf", __imag__ result);
4350 result = FUNC(csqrt) (BUILD_COMPLEX (minus_zero, plus_infty));
4351 check_isinfp ("real(csqrt(-0 + i Inf)) = +Inf", __real__ result);
4352 check_isinfp ("imag(csqrt(-0 + i Inf)) = +Inf", __imag__ result);
4353 result = FUNC(csqrt) (BUILD_COMPLEX (-4, plus_infty));
4354 check_isinfp ("real(csqrt(-4 + i Inf)) = +Inf", __real__ result);
4355 check_isinfp ("imag(csqrt(-4 + i Inf)) = +Inf", __imag__ result);
4356 result = FUNC(csqrt) (BUILD_COMPLEX (minus_infty, plus_infty));
4357 check_isinfp ("real(csqrt(-Inf + i Inf)) = +Inf", __real__ result);
4358 check_isinfp ("imag(csqrt(-Inf + i Inf)) = +Inf", __imag__ result);
4359 result = FUNC(csqrt) (BUILD_COMPLEX (0, minus_infty));
4360 check_isinfp ("real(csqrt(0 - i Inf)) = +Inf", __real__ result);
4361 check_isinfn ("imag(csqrt(0 - i Inf)) = -Inf", __imag__ result);
4362 result = FUNC(csqrt) (BUILD_COMPLEX (4, minus_infty));
4363 check_isinfp ("real(csqrt(4 - i Inf)) = +Inf", __real__ result);
4364 check_isinfn ("imag(csqrt(4 - i Inf)) = -Inf", __imag__ result);
4365 result = FUNC(csqrt) (BUILD_COMPLEX (plus_infty, minus_infty));
4366 check_isinfp ("real(csqrt(+Inf - i Inf)) = +Inf", __real__ result);
4367 check_isinfn ("imag(csqrt(+Inf - i Inf)) = -Inf", __imag__ result);
4368 result = FUNC(csqrt) (BUILD_COMPLEX (minus_zero, minus_infty));
4369 check_isinfp ("real(csqrt(-0 - i Inf)) = +Inf", __real__ result);
4370 check_isinfn ("imag(csqrt(-0 - i Inf)) = -Inf", __imag__ result);
4371 result = FUNC(csqrt) (BUILD_COMPLEX (-4, minus_infty));
4372 check_isinfp ("real(csqrt(-4 - i Inf)) = +Inf", __real__ result);
4373 check_isinfn ("imag(csqrt(-4 - i Inf)) = -Inf", __imag__ result);
4374 result = FUNC(csqrt) (BUILD_COMPLEX (minus_infty, minus_infty));
4375 check_isinfp ("real(csqrt(-Inf - i Inf)) = +Inf", __real__ result);
4376 check_isinfn ("imag(csqrt(-Inf - i Inf)) = -Inf", __imag__ result);
4378 result = FUNC(csqrt) (BUILD_COMPLEX (minus_infty, nan_value));
4379 check_isnan ("real(csqrt(-Inf + i NaN)) = NaN", __real__ result);
4380 check_isinfp ("imag(csqrt(-Inf + i NaN)) = +-Inf",
4381 FUNC(fabs) (__imag__ result));
4383 result = FUNC(csqrt) (BUILD_COMPLEX (plus_infty, nan_value));
4384 check_isinfp ("real(csqrt(+Inf + i NaN)) = +Inf", __real__ result);
4385 check_isnan ("imag(csqrt(+Inf + i NaN)) = NaN", __imag__ result);
4387 result = FUNC(csqrt) (BUILD_COMPLEX (0, nan_value));
4388 check_isnan_maybe_exc ("real(csqrt(0 + i NaN)) = NaN plus maybe invalid exception",
4389 __real__ result, INVALID_EXCEPTION);
4390 check_isnan ("imag(csqrt(0 + i NaN)) = NaN plus maybe invalid exception",
4391 __imag__ result);
4392 result = FUNC(csqrt) (BUILD_COMPLEX (1, nan_value));
4393 check_isnan_maybe_exc ("real(csqrt(1 + i NaN)) = NaN plus maybe invalid exception",
4394 __real__ result, INVALID_EXCEPTION);
4395 check_isnan ("imag(csqrt(1 + i NaN)) = NaN plus maybe invalid exception",
4396 __imag__ result);
4397 result = FUNC(csqrt) (BUILD_COMPLEX (minus_zero, nan_value));
4398 check_isnan_maybe_exc ("real(csqrt(-0 + i NaN)) = NaN plus maybe invalid exception",
4399 __real__ result, INVALID_EXCEPTION);
4400 check_isnan ("imag(csqrt(-0 + i NaN)) = NaN plus maybe invalid exception",
4401 __imag__ result);
4402 result = FUNC(csqrt) (BUILD_COMPLEX (-1, nan_value));
4403 check_isnan_maybe_exc ("real(csqrt(-1 + i NaN)) = NaN plus maybe invalid exception",
4404 __real__ result, INVALID_EXCEPTION);
4405 check_isnan ("imag(csqrt(-1 + i NaN)) = NaN plus maybe invalid exception",
4406 __imag__ result);
4408 result = FUNC(csqrt) (BUILD_COMPLEX (nan_value, 0));
4409 check_isnan_maybe_exc ("real(csqrt(NaN + i0)) = NaN plus maybe invalid exception",
4410 __real__ result, INVALID_EXCEPTION);
4411 check_isnan ("imag(csqrt(NaN + i0)) = NaN plus maybe invalid exception",
4412 __imag__ result);
4413 result = FUNC(csqrt) (BUILD_COMPLEX (nan_value, 8));
4414 check_isnan_maybe_exc ("real(csqrt(NaN + i8)) = NaN plus maybe invalid exception",
4415 __real__ result, INVALID_EXCEPTION);
4416 check_isnan ("imag(csqrt(NaN + i8)) = NaN plus maybe invalid exception",
4417 __imag__ result);
4418 result = FUNC(csqrt) (BUILD_COMPLEX (nan_value, minus_zero));
4419 check_isnan_maybe_exc ("real(csqrt(NaN - i0)) = NaN plus maybe invalid exception",
4420 __real__ result, INVALID_EXCEPTION);
4421 check_isnan ("imag(csqrt(NaN - i0)) = NaN plus maybe invalid exception",
4422 __imag__ result);
4423 result = FUNC(csqrt) (BUILD_COMPLEX (nan_value, -8));
4424 check_isnan_maybe_exc ("real(csqrt(NaN - i8)) = NaN plus maybe invalid exception",
4425 __real__ result, INVALID_EXCEPTION);
4426 check_isnan ("imag(csqrt(NaN - i8)) = NaN plus maybe invalid exception",
4427 __imag__ result);
4429 result = FUNC(csqrt) (BUILD_COMPLEX (nan_value, nan_value));
4430 check_isnan ("real(csqrt(NaN + i NaN)) = NaN", __real__ result);
4431 check_isnan ("imag(csqrt(NaN + i NaN)) = NaN", __imag__ result);
4435 static void
4436 cpow_test (void)
4438 __complex__ MATHTYPE result;
4440 result = FUNC (cpow) (BUILD_COMPLEX (1, 0), BUILD_COMPLEX (0, 0));
4441 check ("real(cpow (1 + i0), (0 + i0)) = 0", __real__ result, 1);
4442 check ("imag(cpow (1 + i0), (0 + i0)) = 0", __imag__ result, 0);
4444 result = FUNC (cpow) (BUILD_COMPLEX (2, 0), BUILD_COMPLEX (10, 0));
4445 check_eps ("real(cpow (2 + i0), (10 + i0)) = 1024", __real__ result, 1024,
4446 CHOOSE (2e-16L, 0, 0));
4447 check ("imag(cpow (2 + i0), (10 + i0)) = 0", __imag__ result, 0);
4452 static void
4453 nearbyint_test (void)
4455 check ("nearbyint(+0) = 0", FUNC(nearbyint) (0.0), 0.0);
4456 check ("nearbyint(-0) = -0", FUNC(nearbyint) (minus_zero), minus_zero);
4457 check_isinfp ("nearbyint(+Inf) = +Inf", FUNC(nearbyint) (plus_infty));
4458 check_isinfn ("nearbyint(-Inf) = -Inf", FUNC(nearbyint) (minus_infty));
4462 static void
4463 rint_test (void)
4465 check ("rint(0) = 0", FUNC(rint) (0.0), 0.0);
4466 check ("rint(-0) = -0", FUNC(rint) (minus_zero), minus_zero);
4467 check_isinfp ("rint(+Inf) = +Inf", FUNC(rint) (plus_infty));
4468 check_isinfn ("rint(-Inf) = -Inf", FUNC(rint) (minus_infty));
4472 static void
4473 lrint_test (void)
4475 /* XXX this test is incomplete. We need to have a way to specifiy
4476 the rounding method and test the critical cases. So far, only
4477 unproblematic numbers are tested. */
4479 check_long ("lrint(0) = 0", lrint (0.0), 0);
4480 check_long ("lrint(-0) = 0", lrint (minus_zero), 0);
4481 check_long ("lrint(0.2) = 0", lrint (0.2), 0);
4482 check_long ("lrint(-0.2) = 0", lrint (-0.2), 0);
4484 check_long ("lrint(1.4) = 1", lrint (1.4), 1);
4485 check_long ("lrint(-1.4) = -1", lrint (-1.4), -1);
4487 check_long ("lrint(8388600.3) = 8388600", lrint (8388600.3), 8388600);
4488 check_long ("lrint(-8388600.3) = -8388600", lrint (-8388600.3),
4489 -8388600);
4493 static void
4494 llrint_test (void)
4496 /* XXX this test is incomplete. We need to have a way to specifiy
4497 the rounding method and test the critical cases. So far, only
4498 unproblematic numbers are tested. */
4500 check_longlong ("llrint(0) = 0", llrint (0.0), 0);
4501 check_longlong ("llrint(-0) = 0", llrint (minus_zero), 0);
4502 check_longlong ("llrint(0.2) = 0", llrint (0.2), 0);
4503 check_longlong ("llrint(-0.2) = 0", llrint (-0.2), 0);
4505 check_longlong ("llrint(1.4) = 1", llrint (1.4), 1);
4506 check_longlong ("llrint(-1.4) = -1", llrint (-1.4), -1);
4508 check_longlong ("llrint(8388600.3) = 8388600", llrint (8388600.3),
4509 8388600);
4510 check_longlong ("llrint(-8388600.3) = -8388600", llrint (-8388600.3),
4511 -8388600);
4515 static void
4516 round_test (void)
4518 check ("round(0) = 0", FUNC(round) (0), 0);
4519 check ("round(-0) = -0", FUNC(round) (minus_zero), minus_zero);
4520 check ("round(0.2) = 0", FUNC(round) (0.2), 0.0);
4521 check ("round(-0.2) = -0", FUNC(round) (-0.2), minus_zero);
4522 check ("round(0.5) = 1", FUNC(round) (0.5), 1.0);
4523 check ("round(-0.5) = -1", FUNC(round) (-0.5), -1.0);
4524 check ("round(0.8) = 1", FUNC(round) (0.8), 1.0);
4525 check ("round(-0.8) = -1", FUNC(round) (-0.8), -1.0);
4526 check ("round(1.5) = 2", FUNC(round) (1.5), 2.0);
4527 check ("round(-1.5) = -2", FUNC(round) (-1.5), -2.0);
4528 check ("round(2097152.5) = 2097153", FUNC(round) (2097152.5), 2097153);
4529 check ("round(-2097152.5) = -2097153", FUNC(round) (-2097152.5), -2097153);
4533 static void
4534 lround_test (void)
4536 check_long ("lround(0) = 0", lround (0), 0);
4537 check_long ("lround(-0) = 0", lround (minus_zero), 0);
4538 check_long ("lround(0.2) = 0", lround (0.2), 0.0);
4539 check_long ("lround(-0.2) = 0", lround (-0.2), 0);
4540 check_long ("lround(0.5) = 1", lround (0.5), 1);
4541 check_long ("lround(-0.5) = -1", lround (-0.5), -1);
4542 check_long ("lround(0.8) = 1", lround (0.8), 1);
4543 check_long ("lround(-0.8) = -1", lround (-0.8), -1);
4544 check_long ("lround(1.5) = 2", lround (1.5), 2);
4545 check_long ("lround(-1.5) = -2", lround (-1.5), -2);
4546 check_long ("lround(2097152.5) = 2097153", lround (2097152.5), 2097153);
4547 check_long ("lround(-2097152.5) = -2097153", lround (-2097152.5),
4548 -2097153);
4552 static void
4553 llround_test (void)
4555 check_longlong ("llround(0) = 0", llround (0), 0);
4556 check_longlong ("llround(-0) = 0", llround (minus_zero), 0);
4557 check_longlong ("llround(0.2) = 0", llround (0.2), 0.0);
4558 check_longlong ("llround(-0.2) = 0", llround (-0.2), 0);
4559 check_longlong ("llround(0.5) = 1", llround (0.5), 1);
4560 check_longlong ("llround(-0.5) = -1", llround (-0.5), -1);
4561 check_longlong ("llround(0.8) = 1", llround (0.8), 1);
4562 check_longlong ("llround(-0.8) = -1", llround (-0.8), -1);
4563 check_longlong ("llround(1.5) = 2", llround (1.5), 2);
4564 check_longlong ("llround(-1.5) = -2", llround (-1.5), -2);
4565 check_longlong ("llround(2097152.5) = 2097153",
4566 llround (2097152.5), 2097153);
4567 check_longlong ("llround(-2097152.5) = -2097153",
4568 llround (-2097152.5), -2097153);
4569 check_longlong ("llround(34359738368.5) = 34359738369",
4570 llround (34359738368.5), 34359738369ll);
4571 check_longlong ("llround(-34359738368.5) = -34359738369",
4572 llround (-34359738368.5), -34359738369ll);
4576 static void
4577 inverse_func_pair_test (const char *test_name,
4578 mathfunc f1, mathfunc inverse,
4579 MATHTYPE x, MATHTYPE epsilon)
4581 MATHTYPE a, b, difference;
4582 int result;
4584 a = f1 (x);
4585 (void) &a;
4586 b = inverse (a);
4587 (void) &b;
4589 output_new_test (test_name);
4590 result = check_equal (b, x, epsilon, &difference);
4591 output_result (test_name, result,
4592 b, x, difference, PRINT, PRINT);
4596 static void
4597 inverse_functions (void)
4599 inverse_func_pair_test ("asin(sin(x)) == x",
4600 FUNC(sin), FUNC(asin), 1.0, CHOOSE (2e-18L, 0, 1e-7L));
4601 inverse_func_pair_test ("sin(asin(x)) == x",
4602 FUNC(asin), FUNC(sin), 1.0, 0.0);
4604 inverse_func_pair_test ("acos(cos(x)) == x",
4605 FUNC(cos), FUNC(acos), 1.0, CHOOSE (4e-18L, 1e-15L, 0));
4606 inverse_func_pair_test ("cos(acos(x)) == x",
4607 FUNC(acos), FUNC(cos), 1.0, 0.0);
4608 inverse_func_pair_test ("atan(tan(x)) == x",
4609 FUNC(tan), FUNC(atan), 1.0, CHOOSE (2e-18L, 0, 0));
4610 inverse_func_pair_test ("tan(atan(x)) == x",
4611 FUNC(atan), FUNC(tan), 1.0, CHOOSE (2e-18L, 1e-15L, 0));
4613 inverse_func_pair_test ("asinh(sinh(x)) == x",
4614 FUNC(sinh), FUNC(asinh), 1.0, CHOOSE (1e-18L, 0, 1e-7));
4615 inverse_func_pair_test ("sinh(asinh(x)) == x",
4616 FUNC(asinh), FUNC(sinh), 1.0, CHOOSE (2e-18L, 0, 0));
4618 inverse_func_pair_test ("acosh(cosh(x)) == x",
4619 FUNC(cosh), FUNC(acosh), 1.0, CHOOSE (1e-18L, 1e-15L, 0));
4620 inverse_func_pair_test ("cosh(acosh(x)) == x",
4621 FUNC(acosh), FUNC(cosh), 1.0, 0.0);
4623 inverse_func_pair_test ("atanh(tanh(x)) == x",
4624 FUNC(tanh), FUNC(atanh), 1.0, CHOOSE (1e-18L, 1e-15L, 0));
4625 inverse_func_pair_test ("tanh(atanh(x)) == x",
4626 FUNC(atanh), FUNC(tanh), 1.0, 0.0);
4630 /* Test sin and cos with the identity: sin(x)^2 + cos(x)^2 = 1. */
4631 static void
4632 identities1_test (MATHTYPE x, MATHTYPE epsilon)
4634 MATHTYPE res1, res2, res3, diff;
4635 int result;
4637 res1 = FUNC(sin) (x);
4638 (void) &res1;
4639 res2 = FUNC(cos) (x);
4640 (void) &res2;
4641 res3 = res1 * res1 + res2 * res2;
4642 (void) &res3;
4644 output_new_test ("sin^2 + cos^2 == 1");
4645 result = check_equal (res3, 1.0, epsilon, &diff);
4646 output_result_ext ("sin^2 + cos^2 == 1", result,
4647 res3, 1.0, diff, x, PRINT, PRINT);
4651 /* Test sin, cos, tan with the following relation: tan = sin/cos. */
4652 static void
4653 identities2_test (MATHTYPE x, MATHTYPE epsilon)
4655 MATHTYPE res1, res2, res3, res4, diff;
4656 int result;
4658 res1 = FUNC(sin) (x);
4659 (void) &res1;
4660 res2 = FUNC(cos) (x);
4661 (void) &res2;
4662 res3 = FUNC(tan) (x);
4663 (void) &res3;
4664 res4 = res1 / res2;
4665 (void) &res4;
4667 output_new_test ("sin/cos == tan");
4668 result = check_equal (res4, res3, epsilon, &diff);
4669 output_result_ext ("sin/cos == tan", result,
4670 res4, res3, diff, x, PRINT, PRINT);
4674 /* Test cosh and sinh with the identity cosh^2 - sinh^2 = 1. */
4675 static void
4676 identities3_test (MATHTYPE x, MATHTYPE epsilon)
4678 MATHTYPE res1, res2, res3, diff;
4679 int result;
4681 res1 = FUNC(sinh) (x);
4682 (void) &res1;
4683 res2 = FUNC(cosh) (x);
4684 (void) &res2;
4685 res3 = res2 * res2 - res1 * res1;
4686 (void) &res3;
4688 output_new_test ("cosh^2 - sinh^2 == 1");
4689 result = check_equal (res3, 1.0, epsilon, &diff);
4690 output_result_ext ("cosh^2 - sinh^2 == 1", result,
4691 res3, 1.0, diff, x, PRINT, PRINT);
4695 static void
4696 identities (void)
4698 identities1_test (0.2L, CHOOSE (1e-18L, 0, 2e-7));
4699 identities1_test (0.9L, CHOOSE (1e-18L, 0, 1e-7));
4700 identities1_test (0, 0);
4701 identities1_test (-1, CHOOSE (1e-18L, 0, 1e-7));
4703 identities2_test (0.2L, CHOOSE (0, 1e-16, 0));
4704 identities2_test (0.9L, CHOOSE (0, 1e-15, 0));
4705 identities2_test (0, 0);
4706 identities2_test (-1, CHOOSE (1e-18L, 1e-15, 0));
4708 identities3_test (0.2L, CHOOSE (1e-18L, 0, 1e-7));
4709 identities3_test (0.9L, CHOOSE (1e-18L, 1e-15, 1e-6));
4710 identities3_test (0, CHOOSE (0, 0, 1e-6));
4711 identities3_test (-1, CHOOSE (1e-18L, 0, 1e-6));
4716 Let's test that basic arithmetic is working
4717 tests: Infinity and NaN
4719 static void
4720 basic_tests (void)
4722 /* variables are declared volatile to forbid some compiler
4723 optimizations */
4724 volatile MATHTYPE Inf_var, NaN_var, zero_var, one_var;
4725 MATHTYPE x1, x2;
4727 zero_var = 0.0;
4728 one_var = 1.0;
4729 NaN_var = nan_value;
4730 Inf_var = one_var / zero_var;
4732 (void) &zero_var;
4733 (void) &one_var;
4734 (void) &NaN_var;
4735 (void) &Inf_var;
4737 /* Clear all exceptions. The previous computations raised exceptions. */
4738 feclearexcept (FE_ALL_EXCEPT);
4740 check_isinfp ("isinf (inf) == +1", Inf_var);
4741 check_isinfn ("isinf (-inf) == -1", -Inf_var);
4742 check_bool ("!isinf (1)", !(FUNC(isinf) (one_var)));
4743 check_bool ("!isinf (NaN)", !(FUNC(isinf) (NaN_var)));
4745 check_isnan ("isnan (NaN)", NaN_var);
4746 check_isnan ("isnan (-NaN)", -NaN_var);
4747 check_bool ("!isnan (1)", !(FUNC(isnan) (one_var)));
4748 check_bool ("!isnan (inf)", !(FUNC(isnan) (Inf_var)));
4750 check_bool ("inf == inf", Inf_var == Inf_var);
4751 check_bool ("-inf == -inf", -Inf_var == -Inf_var);
4752 check_bool ("inf != -inf", Inf_var != -Inf_var);
4753 check_bool ("NaN != NaN", NaN_var != NaN_var);
4756 the same tests but this time with NAN from <bits/nan.h>
4757 NAN is a double const
4759 check_bool ("isnan (NAN)", isnan (NAN));
4760 check_bool ("isnan (-NAN)", isnan (-NAN));
4761 check_bool ("!isinf (NAN)", !(isinf (NAN)));
4762 check_bool ("!isinf (-NAN)", !(isinf (-NAN)));
4763 check_bool ("NAN != NAN", NAN != NAN);
4766 And again with the value returned by the `nan' function.
4768 check_bool ("isnan (NAN)", FUNC(isnan) (FUNC(nan) ("")));
4769 check_bool ("isnan (-NAN)", FUNC(isnan) (-FUNC(nan) ("")));
4770 check_bool ("!isinf (NAN)", !(FUNC(isinf) (FUNC(nan) (""))));
4771 check_bool ("!isinf (-NAN)", !(FUNC(isinf) (-FUNC(nan) (""))));
4772 check_bool ("NAN != NAN", FUNC(nan) ("") != FUNC(nan) (""));
4774 /* test if EPSILON is ok */
4775 x1 = MATHCONST (1.0);
4776 x2 = x1 + CHOOSE (LDBL_EPSILON, DBL_EPSILON, FLT_EPSILON);
4777 check_bool ("1 != 1+EPSILON", x1 != x2);
4779 x1 = MATHCONST (1.0);
4780 x2 = x1 - CHOOSE (LDBL_EPSILON, DBL_EPSILON, FLT_EPSILON);
4781 check_bool ("1 != 1-EPSILON", x1 != x2);
4783 /* test if HUGE_VALx is ok */
4784 x1 = CHOOSE (HUGE_VALL, HUGE_VAL, HUGE_VALF);
4785 check_bool ("isinf (HUGE_VALx) == +1", ISINF (x1) == +1);
4786 x1 = -CHOOSE (HUGE_VALL, HUGE_VAL, HUGE_VALF);
4787 check_bool ("isinf (-HUGE_VALx) == -1", ISINF (x1) == -1);
4792 static void
4793 initialize (void)
4795 fpstack_test ("start *init*");
4796 plus_zero = 0.0;
4797 nan_value = plus_zero / plus_zero; /* Suppress GCC warning */
4799 minus_zero = FUNC (copysign) (0.0, -1.0);
4800 plus_infty = CHOOSE (HUGE_VALL, HUGE_VAL, HUGE_VALF);
4801 minus_infty = -CHOOSE (HUGE_VALL, HUGE_VAL, HUGE_VALF);
4803 (void) &plus_zero;
4804 (void) &nan_value;
4805 (void) &minus_zero;
4806 (void) &plus_infty;
4807 (void) &minus_infty;
4809 /* Clear all exceptions. From now on we must not get random exceptions. */
4810 feclearexcept (FE_ALL_EXCEPT);
4812 /* Test to make sure we start correctly. */
4813 fpstack_test ("end *init*");
4817 static struct option long_options[] =
4819 {"verbose", optional_argument, NULL, 'v'},
4820 {"silent", no_argument, NULL, 's'},
4821 {0, 0, 0, 0}
4825 static void
4826 parse_options (int argc, char *argv[])
4828 int c;
4829 int option_index;
4831 verbose = 1;
4833 while (1)
4835 c = getopt_long (argc, argv, "v::s",
4836 long_options, &option_index);
4838 /* Detect the end of the options. */
4839 if (c == -1)
4840 break;
4842 switch (c)
4844 case 'v':
4845 if (optarg)
4846 verbose = (unsigned int) strtoul (optarg, NULL, 0);
4847 else
4848 verbose = 4;
4849 break;
4850 case 's':
4851 verbose = 0;
4852 default:
4853 break;
4860 main (int argc, char *argv[])
4863 parse_options (argc, argv);
4865 initialize ();
4866 printf (TEST_MSG);
4868 basic_tests ();
4870 /* keep the tests a wee bit ordered (according to ISO 9X) */
4871 /* classification functions */
4872 fpclassify_test ();
4873 isfinite_test ();
4874 isnormal_test ();
4875 signbit_test ();
4877 /* trigonometric functions */
4878 acos_test ();
4879 asin_test ();
4880 atan_test ();
4881 atan2_test ();
4882 cos_test ();
4883 sin_test ();
4884 sincos_test ();
4885 tan_test ();
4887 /* hyperbolic functions */
4888 acosh_test ();
4889 asinh_test ();
4890 atanh_test ();
4891 cosh_test ();
4892 sinh_test ();
4893 tanh_test ();
4895 /* exponential and logarithmic functions */
4896 exp_test ();
4897 exp2_test ();
4898 expm1_test ();
4899 frexp_test ();
4900 ldexp_test ();
4901 log_test ();
4902 log10_test ();
4903 log1p_test ();
4904 log2_test ();
4905 logb_test ();
4906 modf_test ();
4907 ilogb_test ();
4908 scalb_test ();
4909 scalbn_test ();
4911 /* power and absolute value functions */
4912 cbrt_test ();
4913 fabs_test ();
4914 hypot_test ();
4915 pow_test ();
4916 sqrt_test ();
4918 /* error and gamma functions */
4919 erf_test ();
4920 erfc_test ();
4921 gamma_test ();
4922 lgamma_test ();
4924 /* nearest integer functions */
4925 ceil_test ();
4926 floor_test ();
4927 nearbyint_test ();
4928 rint_test ();
4929 lrint_test ();
4930 llrint_test ();
4931 round_test ();
4932 lround_test ();
4933 llround_test ();
4934 trunc_test ();
4936 /* remainder functions */
4937 fmod_test ();
4938 remainder_test ();
4939 remquo_test ();
4941 /* manipulation functions */
4942 copysign_test ();
4943 nextafter_test ();
4945 /* maximum, minimum and positive difference functions */
4946 fdim_test ();
4947 fmin_test ();
4948 fmax_test ();
4950 /* complex functions */
4951 cexp_test ();
4952 csin_test ();
4953 csinh_test ();
4954 ccos_test ();
4955 ccosh_test ();
4956 clog_test ();
4957 cacos_test ();
4958 cacosh_test ();
4959 casin_test ();
4960 casinh_test ();
4961 catan_test ();
4962 catanh_test ();
4963 ctanh_test ();
4964 csqrt_test ();
4965 cpow_test ();
4967 /* special tests */
4968 identities ();
4969 inverse_functions ();
4971 if (noErrors)
4973 printf ("\n%d errors occured.\n", noErrors);
4974 exit (1);
4976 printf ("\n All tests passed successfully.\n");
4977 exit (0);