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