]>
Commit | Line | Data |
---|---|---|
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, | |
36ecfe56 | 45 | cbrt, ceil, copysign, cos, cosh, erf, erfc, exp, exp10, exp2, expm1, |
f43ce637 | 46 | fabs, fdim, floor, fma, fmax, fmin, fmod, fpclassify, |
900bec85 UD |
47 | frexp, gamma, hypot, |
48 | ilogb, isfinite, isinf, isnan, isnormal, | |
d111572f | 49 | isless, islessequal, isgreater, isgreaterequal, islessgreater, isunordered, |
900bec85 UD |
50 | ldexp, lgamma, log, log10, log1p, log2, logb, |
51 | modf, nearbyint, nextafter, | |
d705269e UD |
52 | pow, remainder, remquo, rint, lrint, llrint, |
53 | round, lround, llround, | |
e852e889 | 54 | scalb, scalbn, signbit, sin, sincos, sinh, sqrt, tan, tanh, tgamma, trunc |
76b87c03 UD |
55 | |
56 | and for the following complex math functions: | |
04be94a8 UD |
57 | cabs, cacos, cacosh, carg, casin, casinh, catan, catanh, |
58 | ccos, ccosh, cexp, clog, cpow, csin, csinh, csqrt, ctan, ctanh. | |
76b87c03 UD |
59 | |
60 | At the moment the following functions aren't tested: | |
adac8450 | 61 | OB conj, cproj, cimag, creal, drem, |
76b87c03 | 62 | j0, j1, jn, y0, y1, yn, |
900bec85 | 63 | significand, |
d111572f | 64 | nan |
0d8733c4 UD |
65 | |
66 | The routines using random variables are still under construction. I don't | |
67 | like it the way it's working now and will change it. | |
68 | ||
0d8733c4 | 69 | Parameter handling is primitive in the moment: |
76b87c03 | 70 | --verbose=[0..4] for different levels of output: |
0d8733c4 | 71 | 0: only error count |
76b87c03 | 72 | 1: basic report on failed tests (default) |
0d8733c4 | 73 | 2: full report on failed tests |
76b87c03 UD |
74 | 3: full report on failed and passed tests |
75 | 4: additional report on exceptions | |
76 | -v for full output (equals --verbose=4) | |
0d8733c4 UD |
77 | -s,--silent outputs only the error count (equals --verbose=0) |
78 | */ | |
79 | ||
76b87c03 UD |
80 | /* "Philosophy": |
81 | ||
cbdee279 UD |
82 | This suite tests some aspects of the correct implementation of |
83 | mathematical functions in libm. Some simple, specific parameters | |
84 | are tested for correctness but there's no exhaustive | |
85 | testing. Handling of specific inputs (e.g. infinity, not-a-number) | |
86 | is also tested. Correct handling of exceptions is checked | |
87 | against. These implemented tests should check all cases that are | |
88 | specified in ISO C 9X. | |
76b87c03 | 89 | |
900bec85 UD |
90 | Exception testing: At the moment only divide-by-zero and invalid |
91 | exceptions are tested. Overflow/underflow and inexact exceptions | |
92 | aren't checked at the moment. | |
93 | ||
94 | NaN values: There exist signalling and quiet NaNs. This implementation | |
95 | only uses signalling NaN as parameter but does not differenciate | |
96 | between the two kinds of NaNs as result. | |
e7f1f046 | 97 | |
76b87c03 UD |
98 | Inline functions: Inlining functions should give an improvement in |
99 | speed - but not in precission. The inlined functions return | |
100 | reasonable values for a reasonable range of input values. The | |
101 | result is not necessarily correct for all values and exceptions are | |
102 | not correctly raised in all cases. Problematic input and return | |
103 | values are infinity, not-a-number and minus zero. This suite | |
104 | therefore does not check these specific inputs and the exception | |
105 | handling for inlined mathematical functions - just the "reasonable" | |
106 | values are checked. | |
107 | ||
108 | Beware: The tests might fail for any of the following reasons: | |
109 | - Tests are wrong | |
110 | - Functions are wrong | |
111 | - Floating Point Unit not working properly | |
112 | - Compiler has errors | |
113 | ||
114 | With e.g. gcc 2.7.2.2 the test for cexp fails because of a compiler error. | |
900bec85 | 115 | |
76b87c03 UD |
116 | */ |
117 | ||
c57abfa7 UD |
118 | #ifndef _GNU_SOURCE |
119 | # define _GNU_SOURCE | |
120 | #endif | |
0d8733c4 | 121 | |
3e5f5557 | 122 | #include <complex.h> |
0d8733c4 UD |
123 | #include <math.h> |
124 | #include <float.h> | |
779ae82e | 125 | #include <fenv.h> |
0d8733c4 UD |
126 | |
127 | #include <errno.h> | |
128 | #include <stdlib.h> | |
129 | #include <stdio.h> | |
0d8733c4 UD |
130 | #include <getopt.h> |
131 | ||
0d8733c4 UD |
132 | /* Possible exceptions */ |
133 | #define NO_EXCEPTION 0x0 | |
134 | #define INVALID_EXCEPTION 0x1 | |
135 | #define DIVIDE_BY_ZERO_EXCEPTION 0x2 | |
136 | ||
137 | #define PRINT 1 | |
138 | #define NO_PRINT 0 | |
139 | ||
60c96635 | 140 | /* Various constants (we must supply them precalculated for accuracy). */ |
0a614877 UD |
141 | #define M_PI_6l .52359877559829887308L |
142 | #define M_E2l 7.389056098930650227230L | |
143 | #define M_E3l 20.08553692318766774093L | |
0d8733c4 | 144 | |
f43ce637 UD |
145 | static int noErrors; /* number of errors */ |
146 | static int noTests; /* number of tests (without testing exceptions) */ | |
147 | static int noExcTests; /* number of tests for exception flags */ | |
0d8733c4 UD |
148 | |
149 | static int verbose = 3; | |
150 | static MATHTYPE minus_zero, plus_zero; | |
151 | static MATHTYPE plus_infty, minus_infty, nan_value; | |
152 | ||
153 | typedef MATHTYPE (*mathfunc) (MATHTYPE); | |
154 | ||
e7fd8a39 UD |
155 | #define BUILD_COMPLEX(real, imag) \ |
156 | ({ __complex__ MATHTYPE __retval; \ | |
157 | __real__ __retval = (real); \ | |
158 | __imag__ __retval = (imag); \ | |
159 | __retval; }) | |
160 | ||
0d8733c4 | 161 | |
bc9f6000 UD |
162 | #define ISINF(x) \ |
163 | (sizeof (x) == sizeof (float) ? \ | |
164 | isinff (x) \ | |
165 | : sizeof (x) == sizeof (double) ? \ | |
0d8733c4 UD |
166 | isinf (x) : isinfl (x)) |
167 | ||
168 | ||
169 | /* | |
170 | Test if Floating-Point stack hasn't changed | |
171 | */ | |
172 | static void | |
173 | fpstack_test (const char *test_name) | |
174 | { | |
175 | #ifdef i386 | |
176 | static int old_stack; | |
177 | int sw; | |
178 | asm ("fnstsw":"=a" (sw)); | |
179 | sw >>= 11; | |
180 | sw &= 7; | |
181 | if (sw != old_stack) | |
182 | { | |
183 | printf ("FP-Stack wrong after test %s\n", test_name); | |
184 | if (verbose > 2) | |
185 | printf ("=======> stack = %d\n", sw); | |
186 | ++noErrors; | |
187 | old_stack = sw; | |
188 | } | |
189 | #endif | |
190 | } | |
191 | ||
192 | ||
0d8733c4 UD |
193 | /* |
194 | Get a random value x with min_value < x < max_value | |
195 | and min_value, max_value finite, | |
196 | max_value and min_value shouldn't be too close together | |
197 | */ | |
198 | static MATHTYPE | |
199 | random_value (MATHTYPE min_value, MATHTYPE max_value) | |
200 | { | |
201 | int r; | |
202 | MATHTYPE x; | |
203 | ||
204 | r = rand (); | |
205 | ||
206 | x = (max_value - min_value) / RAND_MAX * (MATHTYPE) r + min_value; | |
207 | ||
208 | if ((x <= min_value) || (x >= max_value) || !isfinite (x)) | |
209 | x = (max_value - min_value) / 2 + min_value; | |
210 | ||
779ae82e UD |
211 | /* Make sure the RNG has no influence on the exceptions. */ |
212 | feclearexcept (FE_ALL_EXCEPT); | |
213 | ||
0d8733c4 UD |
214 | return x; |
215 | } | |
216 | ||
217 | /* Get a random value x with x > min_value. */ | |
218 | static MATHTYPE | |
219 | random_greater (MATHTYPE min_value) | |
220 | { | |
221 | return random_value (min_value, 1e6); /* CHOOSE (LDBL_MAX, DBL_MAX, FLT_MAX) */ | |
222 | } | |
223 | ||
224 | /* Get a random value x with x < max_value. */ | |
225 | static MATHTYPE | |
226 | random_less (MATHTYPE max_value) | |
227 | { | |
228 | return random_value (-1e6, max_value); | |
229 | } | |
76b87c03 UD |
230 | |
231 | ||
232 | static void | |
233 | output_new_test (const char *test_name) | |
234 | { | |
235 | if (verbose > 2) | |
236 | printf ("\nTesting: %s\n", test_name); | |
237 | } | |
238 | ||
239 | ||
240 | static void | |
241 | output_pass_value (void) | |
242 | { | |
243 | if (verbose > 2) | |
244 | printf ("Pass: Value Ok.\n"); | |
245 | } | |
246 | ||
247 | ||
248 | static void | |
249 | output_fail_value (const char * test_name) | |
250 | { | |
251 | if (verbose > 0 && verbose < 3) | |
252 | printf ("Fail: %s\n", test_name); | |
253 | if (verbose >= 3) | |
254 | printf ("Fail:\n"); | |
255 | } | |
0d8733c4 UD |
256 | |
257 | ||
779ae82e UD |
258 | /* Test whether a given exception was raised. */ |
259 | static void | |
260 | test_single_exception (const char *test_name, | |
261 | short int exception, | |
262 | short int exc_flag, | |
5ae3e846 | 263 | int fe_flag, |
779ae82e UD |
264 | const char *flag_name) |
265 | { | |
76b87c03 | 266 | #ifndef TEST_INLINE |
779ae82e UD |
267 | if (exception & exc_flag) |
268 | { | |
269 | if (fetestexcept (fe_flag)) | |
270 | { | |
76b87c03 UD |
271 | if (verbose > 3) |
272 | printf ("Pass: Exception \"%s\" set\n", flag_name); | |
779ae82e UD |
273 | } |
274 | else | |
275 | { | |
76b87c03 UD |
276 | if (verbose && verbose < 3) |
277 | printf ("Fail: %s: Exception \"%s\" not set\n", | |
779ae82e | 278 | test_name, flag_name); |
76b87c03 UD |
279 | if (verbose >= 3) |
280 | printf ("Fail: Exception \"%s\" not set\n", | |
281 | flag_name); | |
779ae82e UD |
282 | ++noErrors; |
283 | } | |
284 | } | |
285 | else | |
286 | { | |
287 | if (fetestexcept (fe_flag)) | |
288 | { | |
76b87c03 UD |
289 | if (verbose && verbose < 3) |
290 | printf ("Fail: %s: Exception \"%s\" set\n", | |
779ae82e | 291 | test_name, flag_name); |
76b87c03 UD |
292 | if (verbose >= 3) |
293 | printf ("Fail: Exception \"%s\" set\n", | |
294 | flag_name); | |
779ae82e UD |
295 | ++noErrors; |
296 | } | |
297 | else | |
298 | { | |
76b87c03 UD |
299 | if (verbose > 3) |
300 | printf ("Pass: Exception \"%s\" not set\n", | |
301 | flag_name); | |
779ae82e UD |
302 | } |
303 | } | |
76b87c03 | 304 | #endif |
779ae82e UD |
305 | } |
306 | ||
307 | ||
308 | /* Test whether exception given by EXCEPTION are raised. */ | |
309 | static void | |
310 | test_not_exception (const char *test_name, short int exception) | |
311 | { | |
f43ce637 | 312 | ++noExcTests; |
779ae82e | 313 | #ifdef FE_DIVBYZERO |
51702635 | 314 | if ((exception & DIVIDE_BY_ZERO_EXCEPTION) == 0) |
779ae82e UD |
315 | test_single_exception (test_name, exception, |
316 | DIVIDE_BY_ZERO_EXCEPTION, FE_DIVBYZERO, | |
317 | "Divide by zero"); | |
318 | #endif | |
319 | #ifdef FE_INVALID | |
51702635 | 320 | if ((exception & INVALID_EXCEPTION) == 0) |
779ae82e UD |
321 | test_single_exception (test_name, exception, INVALID_EXCEPTION, FE_INVALID, |
322 | "Invalid operation"); | |
323 | #endif | |
324 | feclearexcept (FE_ALL_EXCEPT); | |
325 | } | |
326 | ||
327 | ||
328 | /* Test whether exceptions given by EXCEPTION are raised. */ | |
329 | static void | |
330 | test_exceptions (const char *test_name, short int exception) | |
331 | { | |
f43ce637 | 332 | ++noExcTests; |
779ae82e UD |
333 | #ifdef FE_DIVBYZERO |
334 | test_single_exception (test_name, exception, | |
335 | DIVIDE_BY_ZERO_EXCEPTION, FE_DIVBYZERO, | |
336 | "Divide by zero"); | |
337 | #endif | |
338 | #ifdef FE_INVALID | |
339 | test_single_exception (test_name, exception, INVALID_EXCEPTION, FE_INVALID, | |
340 | "Invalid operation"); | |
341 | #endif | |
342 | feclearexcept (FE_ALL_EXCEPT); | |
343 | } | |
344 | ||
345 | ||
0d8733c4 UD |
346 | /* Test if two floating point numbers are equal. */ |
347 | static int | |
348 | check_equal (MATHTYPE computed, MATHTYPE supplied, MATHTYPE eps, MATHTYPE * diff) | |
349 | { | |
76b87c03 UD |
350 | int ret_value; |
351 | ||
0d8733c4 UD |
352 | /* Both plus Infinity or both minus infinity. */ |
353 | if (ISINF (computed) && (ISINF (computed) == ISINF (supplied))) | |
354 | return 1; | |
355 | ||
356 | if (isnan (computed) && isnan (supplied)) /* isnan works for all types */ | |
357 | return 1; | |
358 | ||
359 | *diff = FUNC(fabs) (computed - supplied); | |
360 | ||
0d8733c4 | 361 | |
76b87c03 UD |
362 | ret_value = (*diff <= eps && |
363 | (signbit (computed) == signbit (supplied) || eps != 0.0)); | |
364 | ||
d111572f | 365 | /* Make sure the subtraction/comparison have no influence on the exceptions. */ |
76b87c03 UD |
366 | feclearexcept (FE_ALL_EXCEPT); |
367 | ||
368 | return ret_value; | |
0d8733c4 UD |
369 | } |
370 | ||
371 | ||
76b87c03 | 372 | |
0d8733c4 UD |
373 | static void |
374 | output_result_bool (const char *test_name, int result) | |
375 | { | |
f43ce637 | 376 | ++noTests; |
0d8733c4 UD |
377 | if (result) |
378 | { | |
76b87c03 | 379 | output_pass_value (); |
0d8733c4 UD |
380 | } |
381 | else | |
382 | { | |
76b87c03 | 383 | output_fail_value (test_name); |
900bec85 UD |
384 | if (verbose > 1) |
385 | printf (" Value: %d\n", result); | |
c57abfa7 | 386 | ++noErrors; |
0d8733c4 UD |
387 | } |
388 | ||
389 | fpstack_test (test_name); | |
390 | } | |
391 | ||
392 | ||
393 | static void | |
394 | output_isvalue (const char *test_name, int result, | |
395 | MATHTYPE value) | |
396 | { | |
f43ce637 | 397 | ++noTests; |
0d8733c4 UD |
398 | if (result) |
399 | { | |
76b87c03 | 400 | output_pass_value (); |
0d8733c4 UD |
401 | } |
402 | else | |
403 | { | |
76b87c03 | 404 | output_fail_value (test_name); |
0d8733c4 | 405 | if (verbose > 1) |
f43ce637 UD |
406 | printf (" Value: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR "\n", |
407 | value, value); | |
408 | ++noErrors; | |
0d8733c4 UD |
409 | } |
410 | ||
411 | fpstack_test (test_name); | |
412 | } | |
413 | ||
414 | ||
415 | static void | |
416 | output_isvalue_ext (const char *test_name, int result, | |
417 | MATHTYPE value, MATHTYPE parameter) | |
418 | { | |
f43ce637 | 419 | ++noTests; |
0d8733c4 UD |
420 | if (result) |
421 | { | |
76b87c03 | 422 | output_pass_value (); |
0d8733c4 UD |
423 | } |
424 | else | |
425 | { | |
76b87c03 | 426 | output_fail_value (test_name); |
0d8733c4 UD |
427 | if (verbose > 1) |
428 | { | |
f43ce637 UD |
429 | printf (" Value: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR "\n", |
430 | value, value); | |
431 | printf (" Parameter: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR "\n", | |
432 | parameter, parameter); | |
0d8733c4 UD |
433 | } |
434 | noErrors++; | |
435 | } | |
436 | ||
437 | fpstack_test (test_name); | |
438 | } | |
439 | ||
440 | ||
441 | static void | |
442 | output_result (const char *test_name, int result, | |
443 | MATHTYPE computed, MATHTYPE expected, | |
444 | MATHTYPE difference, | |
445 | int print_values, int print_diff) | |
446 | { | |
f43ce637 | 447 | ++noTests; |
0d8733c4 UD |
448 | if (result) |
449 | { | |
76b87c03 | 450 | output_pass_value (); |
0d8733c4 UD |
451 | } |
452 | else | |
453 | { | |
76b87c03 | 454 | output_fail_value (test_name); |
0d8733c4 UD |
455 | if (verbose > 1 && print_values) |
456 | { | |
457 | printf ("Result:\n"); | |
f43ce637 UD |
458 | printf (" is: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR "\n", |
459 | computed, computed); | |
460 | printf (" should be: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR "\n", | |
461 | expected, expected); | |
0d8733c4 | 462 | if (print_diff) |
f43ce637 UD |
463 | printf (" difference: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR |
464 | "\n", difference, difference); | |
0d8733c4 | 465 | } |
f43ce637 | 466 | ++noErrors; |
0d8733c4 UD |
467 | } |
468 | ||
469 | fpstack_test (test_name); | |
470 | } | |
471 | ||
472 | ||
473 | static void | |
474 | output_result_ext (const char *test_name, int result, | |
475 | MATHTYPE computed, MATHTYPE expected, | |
476 | MATHTYPE difference, | |
477 | MATHTYPE parameter, | |
478 | int print_values, int print_diff) | |
479 | { | |
f43ce637 | 480 | ++noTests; |
0d8733c4 UD |
481 | if (result) |
482 | { | |
76b87c03 | 483 | output_pass_value (); |
0d8733c4 UD |
484 | } |
485 | else | |
486 | { | |
76b87c03 | 487 | output_fail_value (test_name); |
0d8733c4 UD |
488 | if (verbose > 1 && print_values) |
489 | { | |
490 | printf ("Result:\n"); | |
f43ce637 UD |
491 | printf (" is: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR "\n", |
492 | computed, computed); | |
493 | printf (" should be: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR "\n", | |
494 | expected, expected); | |
0d8733c4 | 495 | if (print_diff) |
f43ce637 UD |
496 | printf (" difference: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR |
497 | "\n", difference, difference); | |
498 | printf ("Parameter: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR "\n", | |
499 | parameter, parameter); | |
0d8733c4 | 500 | } |
f43ce637 | 501 | ++noErrors; |
0d8733c4 UD |
502 | } |
503 | ||
504 | fpstack_test (test_name); | |
505 | } | |
506 | ||
76b87c03 UD |
507 | /* |
508 | check that computed and expected values are the same | |
509 | */ | |
0d8733c4 UD |
510 | static void |
511 | check (const char *test_name, MATHTYPE computed, MATHTYPE expected) | |
512 | { | |
513 | MATHTYPE diff; | |
514 | int result; | |
515 | ||
76b87c03 | 516 | output_new_test (test_name); |
779ae82e | 517 | test_exceptions (test_name, NO_EXCEPTION); |
0d8733c4 UD |
518 | result = check_equal (computed, expected, 0, &diff); |
519 | output_result (test_name, result, | |
520 | computed, expected, diff, PRINT, PRINT); | |
521 | } | |
522 | ||
523 | ||
76b87c03 UD |
524 | /* |
525 | check that computed and expected values are the same, | |
526 | outputs the parameter to the function | |
527 | */ | |
0d8733c4 UD |
528 | static void |
529 | check_ext (const char *test_name, MATHTYPE computed, MATHTYPE expected, | |
530 | MATHTYPE parameter) | |
531 | { | |
532 | MATHTYPE diff; | |
533 | int result; | |
534 | ||
76b87c03 | 535 | output_new_test (test_name); |
779ae82e | 536 | test_exceptions (test_name, NO_EXCEPTION); |
0d8733c4 UD |
537 | result = check_equal (computed, expected, 0, &diff); |
538 | output_result_ext (test_name, result, | |
539 | computed, expected, diff, parameter, PRINT, PRINT); | |
540 | } | |
541 | ||
542 | ||
76b87c03 UD |
543 | /* |
544 | check that computed and expected values are the same and | |
545 | checks also for exception flags | |
546 | */ | |
779ae82e UD |
547 | static void |
548 | check_exc (const char *test_name, MATHTYPE computed, MATHTYPE expected, | |
549 | short exception) | |
550 | { | |
551 | MATHTYPE diff; | |
552 | int result; | |
553 | ||
76b87c03 | 554 | output_new_test (test_name); |
779ae82e UD |
555 | test_exceptions (test_name, exception); |
556 | result = check_equal (computed, expected, 0, &diff); | |
557 | output_result (test_name, result, | |
558 | computed, expected, diff, PRINT, PRINT); | |
559 | } | |
560 | ||
76b87c03 UD |
561 | /* |
562 | check that computed and expected values are close enough | |
563 | */ | |
0d8733c4 UD |
564 | static void |
565 | check_eps (const char *test_name, MATHTYPE computed, MATHTYPE expected, | |
566 | MATHTYPE epsilon) | |
567 | { | |
568 | MATHTYPE diff; | |
569 | int result; | |
570 | ||
76b87c03 | 571 | output_new_test (test_name); |
779ae82e | 572 | test_exceptions (test_name, NO_EXCEPTION); |
0d8733c4 UD |
573 | result = check_equal (computed, expected, epsilon, &diff); |
574 | output_result (test_name, result, | |
575 | computed, expected, diff, PRINT, PRINT); | |
576 | } | |
577 | ||
76b87c03 UD |
578 | /* |
579 | check a boolean condition | |
580 | */ | |
0d8733c4 UD |
581 | static void |
582 | check_bool (const char *test_name, int computed) | |
583 | { | |
76b87c03 | 584 | output_new_test (test_name); |
779ae82e | 585 | test_exceptions (test_name, NO_EXCEPTION); |
0d8733c4 UD |
586 | output_result_bool (test_name, computed); |
587 | } | |
588 | ||
900bec85 UD |
589 | |
590 | ||
591 | /* | |
592 | check that computed and expected values are equal (int values) | |
593 | */ | |
594 | static void | |
595 | check_int (const char *test_name, int computed, int expected) | |
596 | { | |
597 | int diff = computed - expected; | |
598 | int result = diff == 0; | |
599 | ||
600 | output_new_test (test_name); | |
601 | test_exceptions (test_name, NO_EXCEPTION); | |
602 | ||
603 | if (result) | |
604 | { | |
605 | output_pass_value (); | |
606 | } | |
607 | else | |
608 | { | |
609 | output_fail_value (test_name); | |
610 | if (verbose > 1) | |
611 | { | |
612 | printf ("Result:\n"); | |
613 | printf (" is: %d\n", computed); | |
614 | printf (" should be: %d\n", expected); | |
615 | } | |
616 | noErrors++; | |
617 | } | |
618 | ||
619 | fpstack_test (test_name); | |
620 | } | |
621 | ||
622 | ||
76b87c03 UD |
623 | /* |
624 | check that computed and expected values are equal (long int values) | |
625 | */ | |
c131718c UD |
626 | static void |
627 | check_long (const char *test_name, long int computed, long int expected) | |
628 | { | |
629 | long int diff = computed - expected; | |
630 | int result = diff == 0; | |
631 | ||
f43ce637 | 632 | ++noTests; |
76b87c03 | 633 | output_new_test (test_name); |
779ae82e UD |
634 | test_exceptions (test_name, NO_EXCEPTION); |
635 | ||
c131718c UD |
636 | if (result) |
637 | { | |
76b87c03 | 638 | output_pass_value (); |
c131718c UD |
639 | } |
640 | else | |
641 | { | |
76b87c03 | 642 | output_fail_value (test_name); |
c131718c UD |
643 | if (verbose > 1) |
644 | { | |
645 | printf ("Result:\n"); | |
646 | printf (" is: %ld\n", computed); | |
647 | printf (" should be: %ld\n", expected); | |
648 | } | |
649 | noErrors++; | |
650 | } | |
651 | ||
652 | fpstack_test (test_name); | |
653 | } | |
654 | ||
76b87c03 UD |
655 | /* |
656 | check that computed and expected values are equal (long long int values) | |
657 | */ | |
c131718c UD |
658 | static void |
659 | check_longlong (const char *test_name, long long int computed, | |
660 | long long int expected) | |
661 | { | |
662 | long long int diff = computed - expected; | |
663 | int result = diff == 0; | |
664 | ||
f43ce637 | 665 | ++noTests; |
76b87c03 | 666 | output_new_test (test_name); |
779ae82e UD |
667 | test_exceptions (test_name, NO_EXCEPTION); |
668 | ||
c131718c UD |
669 | if (result) |
670 | { | |
76b87c03 | 671 | output_pass_value (); |
c131718c UD |
672 | } |
673 | else | |
674 | { | |
76b87c03 | 675 | output_fail_value (test_name); |
c131718c UD |
676 | if (verbose > 1) |
677 | { | |
678 | printf ("Result:\n"); | |
679 | printf (" is: %lld\n", computed); | |
680 | printf (" should be: %lld\n", expected); | |
681 | } | |
682 | noErrors++; | |
683 | } | |
684 | ||
685 | fpstack_test (test_name); | |
686 | } | |
687 | ||
76b87c03 UD |
688 | /* |
689 | check that computed value is not-a-number | |
690 | */ | |
0d8733c4 UD |
691 | static void |
692 | check_isnan (const char *test_name, MATHTYPE computed) | |
693 | { | |
76b87c03 | 694 | output_new_test (test_name); |
779ae82e | 695 | test_exceptions (test_name, NO_EXCEPTION); |
0d8733c4 UD |
696 | output_isvalue (test_name, isnan (computed), computed); |
697 | } | |
698 | ||
699 | ||
76b87c03 UD |
700 | /* |
701 | check that computed value is not-a-number and test for exceptions | |
702 | */ | |
0d8733c4 UD |
703 | static void |
704 | check_isnan_exc (const char *test_name, MATHTYPE computed, | |
779ae82e | 705 | short exception) |
0d8733c4 | 706 | { |
76b87c03 | 707 | output_new_test (test_name); |
779ae82e UD |
708 | test_exceptions (test_name, exception); |
709 | output_isvalue (test_name, isnan (computed), computed); | |
710 | } | |
711 | ||
712 | ||
76b87c03 UD |
713 | /* |
714 | check that computed value is not-a-number and test for exceptions | |
715 | */ | |
779ae82e UD |
716 | static void |
717 | check_isnan_maybe_exc (const char *test_name, MATHTYPE computed, | |
718 | short exception) | |
719 | { | |
76b87c03 | 720 | output_new_test (test_name); |
779ae82e | 721 | test_not_exception (test_name, exception); |
0d8733c4 UD |
722 | output_isvalue (test_name, isnan (computed), computed); |
723 | } | |
724 | ||
76b87c03 UD |
725 | /* |
726 | check that computed value is not-a-number and supply parameter | |
727 | */ | |
728 | #ifndef TEST_INLINE | |
0d8733c4 UD |
729 | static void |
730 | check_isnan_ext (const char *test_name, MATHTYPE computed, | |
731 | MATHTYPE parameter) | |
732 | { | |
76b87c03 | 733 | output_new_test (test_name); |
779ae82e | 734 | test_exceptions (test_name, NO_EXCEPTION); |
0d8733c4 UD |
735 | output_isvalue_ext (test_name, isnan (computed), computed, parameter); |
736 | } | |
76b87c03 | 737 | #endif |
0d8733c4 | 738 | |
900bec85 UD |
739 | /* |
740 | check that computed value is not-a-number, test for exceptions | |
741 | and supply parameter | |
742 | */ | |
743 | static void | |
744 | check_isnan_exc_ext (const char *test_name, MATHTYPE computed, | |
745 | short exception, MATHTYPE parameter) | |
746 | { | |
747 | output_new_test (test_name); | |
748 | test_exceptions (test_name,exception); | |
749 | output_isvalue_ext (test_name, isnan (computed), computed, parameter); | |
750 | } | |
751 | ||
0d8733c4 UD |
752 | |
753 | /* Tests if computed is +Inf */ | |
754 | static void | |
755 | check_isinfp (const char *test_name, MATHTYPE computed) | |
756 | { | |
76b87c03 | 757 | output_new_test (test_name); |
779ae82e | 758 | test_exceptions (test_name, NO_EXCEPTION); |
0d8733c4 UD |
759 | output_isvalue (test_name, (ISINF (computed) == +1), computed); |
760 | } | |
761 | ||
762 | ||
763 | static void | |
764 | check_isinfp_ext (const char *test_name, MATHTYPE computed, | |
765 | MATHTYPE parameter) | |
766 | { | |
76b87c03 | 767 | output_new_test (test_name); |
779ae82e | 768 | test_exceptions (test_name, NO_EXCEPTION); |
0d8733c4 UD |
769 | output_isvalue_ext (test_name, (ISINF (computed) == +1), computed, parameter); |
770 | } | |
771 | ||
772 | ||
773 | /* Tests if computed is +Inf */ | |
774 | static void | |
775 | check_isinfp_exc (const char *test_name, MATHTYPE computed, | |
779ae82e | 776 | int exception) |
0d8733c4 | 777 | { |
76b87c03 | 778 | output_new_test (test_name); |
779ae82e | 779 | test_exceptions (test_name, exception); |
0d8733c4 UD |
780 | output_isvalue (test_name, (ISINF (computed) == +1), computed); |
781 | } | |
782 | ||
783 | /* Tests if computed is -Inf */ | |
784 | static void | |
785 | check_isinfn (const char *test_name, MATHTYPE computed) | |
786 | { | |
76b87c03 | 787 | output_new_test (test_name); |
779ae82e | 788 | test_exceptions (test_name, NO_EXCEPTION); |
0d8733c4 UD |
789 | output_isvalue (test_name, (ISINF (computed) == -1), computed); |
790 | } | |
791 | ||
792 | ||
76b87c03 | 793 | #ifndef TEST_INLINE |
0d8733c4 UD |
794 | static void |
795 | check_isinfn_ext (const char *test_name, MATHTYPE computed, | |
796 | MATHTYPE parameter) | |
797 | { | |
76b87c03 | 798 | output_new_test (test_name); |
779ae82e | 799 | test_exceptions (test_name, NO_EXCEPTION); |
0d8733c4 UD |
800 | output_isvalue_ext (test_name, (ISINF (computed) == -1), computed, parameter); |
801 | } | |
76b87c03 | 802 | #endif |
0d8733c4 UD |
803 | |
804 | ||
805 | /* Tests if computed is -Inf */ | |
806 | static void | |
807 | check_isinfn_exc (const char *test_name, MATHTYPE computed, | |
779ae82e | 808 | int exception) |
0d8733c4 | 809 | { |
76b87c03 | 810 | output_new_test (test_name); |
779ae82e | 811 | test_exceptions (test_name, exception); |
0d8733c4 UD |
812 | output_isvalue (test_name, (ISINF (computed) == -1), computed); |
813 | } | |
814 | ||
815 | ||
5107cf1d UD |
816 | /* This is to prevent messages from the SVID libm emulation. */ |
817 | int | |
818 | matherr (struct exception *x __attribute__ ((unused))) | |
819 | { | |
820 | return 1; | |
821 | } | |
822 | ||
823 | ||
0d8733c4 UD |
824 | /**************************************************************************** |
825 | Test for single functions of libm | |
826 | ****************************************************************************/ | |
827 | ||
828 | static void | |
829 | acos_test (void) | |
830 | { | |
76b87c03 | 831 | #ifndef TEST_INLINE |
0d8733c4 UD |
832 | MATHTYPE x; |
833 | ||
0d8733c4 | 834 | x = random_greater (1); |
779ae82e | 835 | check_isnan_exc ("acos (x) == NaN plus invalid exception for |x| > 1", |
0d8733c4 UD |
836 | FUNC(acos) (x), |
837 | INVALID_EXCEPTION); | |
900bec85 UD |
838 | |
839 | x = random_less (1); | |
840 | check_isnan_exc ("acos (x) == NaN plus invalid exception for |x| > 1", | |
841 | FUNC(acos) (x), | |
842 | INVALID_EXCEPTION); | |
76b87c03 | 843 | #endif |
0a614877 UD |
844 | check ("acos (0) == pi/2", FUNC(acos) (0), M_PI_2l); |
845 | check ("acos (-0) == pi/2", FUNC(acos) (minus_zero), M_PI_2l); | |
76b87c03 UD |
846 | |
847 | check ("acos (1) == 0", FUNC(acos) (1), 0); | |
0a614877 | 848 | check ("acos (-1) == pi", FUNC(acos) (-1), M_PIl); |
cbdee279 | 849 | |
0a614877 | 850 | check_eps ("acos (0.5) == pi/3", FUNC(acos) (0.5), M_PI_6l * 2.0, |
9756dfe1 | 851 | CHOOSE (1e-18, 0, 0)); |
0a614877 | 852 | check_eps ("acos (-0.5) == 2*pi/3", FUNC(acos) (-0.5), M_PI_6l * 4.0, |
9756dfe1 | 853 | CHOOSE (1e-17, 0, 0)); |
cbdee279 | 854 | |
bd355af0 UD |
855 | check_eps ("acos (0.7) == 0.795398830...", FUNC(acos) (0.7), |
856 | 0.7953988301841435554L, CHOOSE(7e-17L, 0, 0)); | |
857 | ||
0d8733c4 UD |
858 | } |
859 | ||
900bec85 | 860 | |
0d8733c4 UD |
861 | static void |
862 | acosh_test (void) | |
863 | { | |
76b87c03 | 864 | #ifndef TEST_INLINE |
0d8733c4 UD |
865 | MATHTYPE x; |
866 | ||
0d8733c4 UD |
867 | check_isinfp ("acosh(+inf) == +inf", FUNC(acosh) (plus_infty)); |
868 | ||
869 | x = random_less (1); | |
870 | check_isnan_exc ("acosh(x) == NaN plus invalid exception if x < 1", | |
871 | FUNC(acosh) (x), INVALID_EXCEPTION); | |
76b87c03 UD |
872 | #endif |
873 | ||
874 | check ("acosh(1) == 0", FUNC(acosh) (1), 0); | |
74015205 UD |
875 | check_eps ("acosh(7) == 2.633915793...", FUNC(acosh) (7), |
876 | 2.6339157938496334172L, CHOOSE (3e-19, 0, 0)); | |
0d8733c4 UD |
877 | } |
878 | ||
879 | ||
880 | static void | |
881 | asin_test (void) | |
882 | { | |
76b87c03 | 883 | #ifndef TEST_INLINE |
0d8733c4 | 884 | MATHTYPE x; |
0d8733c4 UD |
885 | |
886 | x = random_greater (1); | |
779ae82e | 887 | check_isnan_exc ("asin x == NaN plus invalid exception for |x| > 1", |
0d8733c4 UD |
888 | FUNC(asin) (x), |
889 | INVALID_EXCEPTION); | |
900bec85 UD |
890 | |
891 | x = random_less (1); | |
892 | check_isnan_exc ("asin x == NaN plus invalid exception for |x| > 1", | |
893 | FUNC(asin) (x), | |
894 | INVALID_EXCEPTION); | |
76b87c03 UD |
895 | #endif |
896 | ||
897 | check ("asin (0) == 0", FUNC(asin) (0), 0); | |
cbdee279 | 898 | check ("asin (-0) == -0", FUNC(asin) (minus_zero), minus_zero); |
0a614877 | 899 | check_eps ("asin (0.5) == pi/6", FUNC(asin) (0.5), M_PI_6l, |
6973fc01 | 900 | CHOOSE(3.5e-18, 0, 2e-7)); |
0a614877 | 901 | check_eps ("asin (-0.5) == -pi/6", FUNC(asin) (-0.5), -M_PI_6l, |
cbdee279 | 902 | CHOOSE(3.5e-18, 0, 2e-7)); |
0a614877 UD |
903 | check ("asin (1.0) == pi/2", FUNC(asin) (1.0), M_PI_2l); |
904 | check ("asin (-1.0) == -pi/2", FUNC(asin) (-1.0), -M_PI_2l); | |
bd355af0 | 905 | check_eps ("asin (0.7) == 0.775397496...", FUNC(asin) (0.7), |
14e9dd67 | 906 | 0.7753974966107530637L, CHOOSE(7e-17L, 2e-16, 2e-7)); |
0d8733c4 UD |
907 | } |
908 | ||
76b87c03 | 909 | |
0d8733c4 UD |
910 | static void |
911 | asinh_test (void) | |
912 | { | |
913 | ||
914 | check ("asinh(+0) == +0", FUNC(asinh) (0), 0); | |
76b87c03 | 915 | #ifndef TEST_INLINE |
0d8733c4 | 916 | check ("asinh(-0) == -0", FUNC(asinh) (minus_zero), minus_zero); |
900bec85 UD |
917 | check_isinfp ("asinh(+inf) == +inf", FUNC(asinh) (plus_infty)); |
918 | check_isinfn ("asinh(-inf) == -inf", FUNC(asinh) (minus_infty)); | |
76b87c03 | 919 | #endif |
bd355af0 | 920 | check_eps ("asinh(0.7) == 0.652666566...", FUNC(asinh) (0.7), |
14e9dd67 | 921 | 0.652666566082355786L, CHOOSE(4e-17L, 0, 6e-8)); |
e7f1f046 | 922 | |
0d8733c4 UD |
923 | } |
924 | ||
925 | ||
926 | static void | |
927 | atan_test (void) | |
928 | { | |
929 | check ("atan (0) == 0", FUNC(atan) (0), 0); | |
930 | check ("atan (-0) == -0", FUNC(atan) (minus_zero), minus_zero); | |
931 | ||
0a614877 UD |
932 | check ("atan (+inf) == pi/2", FUNC(atan) (plus_infty), M_PI_2l); |
933 | check ("atan (-inf) == -pi/2", FUNC(atan) (minus_infty), -M_PI_2l); | |
cbdee279 | 934 | |
0a614877 | 935 | check_eps ("atan (1) == pi/4", FUNC(atan) (1), M_PI_4l, |
9756dfe1 | 936 | CHOOSE (1e-18, 0, 0)); |
0a614877 | 937 | check_eps ("atan (-1) == -pi/4", FUNC(atan) (1), M_PI_4l, |
9756dfe1 | 938 | CHOOSE (1e-18, 0, 0)); |
cbdee279 | 939 | |
bd355af0 UD |
940 | check_eps ("atan (0.7) == 0.610725964...", FUNC(atan) (0.7), |
941 | 0.6107259643892086165L, CHOOSE(3e-17L, 0, 0)); | |
0d8733c4 UD |
942 | } |
943 | ||
900bec85 | 944 | |
0d8733c4 UD |
945 | static void |
946 | atan2_test (void) | |
947 | { | |
948 | MATHTYPE x; | |
949 | ||
950 | x = random_greater (0); | |
951 | check ("atan2 (0,x) == 0 for x > 0", | |
952 | FUNC(atan2) (0, x), 0); | |
953 | x = random_greater (0); | |
954 | check ("atan2 (-0,x) == -0 for x > 0", | |
955 | FUNC(atan2) (minus_zero, x), minus_zero); | |
956 | ||
957 | check ("atan2 (+0,+0) == +0", FUNC(atan2) (0, 0), 0); | |
958 | check ("atan2 (-0,+0) == -0", FUNC(atan2) (minus_zero, 0), minus_zero); | |
959 | ||
960 | x = -random_greater (0); | |
0a614877 | 961 | check ("atan2 (+0,x) == +pi for x < 0", FUNC(atan2) (0, x), M_PIl); |
0d8733c4 UD |
962 | |
963 | x = -random_greater (0); | |
0a614877 | 964 | check ("atan2 (-0,x) == -pi for x < 0", FUNC(atan2) (minus_zero, x), -M_PIl); |
0d8733c4 | 965 | |
0a614877 UD |
966 | check ("atan2 (+0,-0) == +pi", FUNC(atan2) (0, minus_zero), M_PIl); |
967 | check ("atan2 (-0,-0) == -pi", FUNC(atan2) (minus_zero, minus_zero), -M_PIl); | |
0d8733c4 UD |
968 | |
969 | x = random_greater (0); | |
0a614877 | 970 | check ("atan2 (y,+0) == pi/2 for y > 0", FUNC(atan2) (x, 0), M_PI_2l); |
0d8733c4 UD |
971 | |
972 | x = random_greater (0); | |
0a614877 UD |
973 | check ("atan2 (y,-0) == pi/2 for y > 0", FUNC(atan2) (x, minus_zero), |
974 | M_PI_2l); | |
0d8733c4 | 975 | |
900bec85 | 976 | x = random_less (0); |
0a614877 | 977 | check ("atan2 (y,+0) == -pi/2 for y < 0", FUNC(atan2) (x, 0), -M_PI_2l); |
900bec85 UD |
978 | |
979 | x = random_less (0); | |
0a614877 UD |
980 | check ("atan2 (y,-0) == -pi/2 for y < 0", FUNC(atan2) (x, minus_zero), |
981 | -M_PI_2l); | |
900bec85 UD |
982 | |
983 | x = random_greater (0); | |
984 | check ("atan2 (y,inf) == +0 for finite y > 0", | |
985 | FUNC(atan2) (x, plus_infty), 0); | |
986 | ||
987 | x = -random_greater (0); | |
988 | check ("atan2 (y,inf) == -0 for finite y < 0", | |
989 | FUNC(atan2) (x, plus_infty), minus_zero); | |
990 | ||
991 | x = random_value (-1e4, 1e4); | |
992 | check ("atan2(+inf, x) == pi/2 for finite x", | |
0a614877 | 993 | FUNC(atan2) (plus_infty, x), M_PI_2l); |
900bec85 UD |
994 | |
995 | x = random_value (-1e4, 1e4); | |
996 | check ("atan2(-inf, x) == -pi/2 for finite x", | |
0a614877 | 997 | FUNC(atan2) (minus_infty, x), -M_PI_2l); |
900bec85 | 998 | |
0d8733c4 UD |
999 | x = random_greater (0); |
1000 | check ("atan2 (y,-inf) == +pi for finite y > 0", | |
0a614877 | 1001 | FUNC(atan2) (x, minus_infty), M_PIl); |
0d8733c4 UD |
1002 | |
1003 | x = -random_greater (0); | |
1004 | check ("atan2 (y,-inf) == -pi for finite y < 0", | |
0a614877 | 1005 | FUNC(atan2) (x, minus_infty), -M_PIl); |
0d8733c4 UD |
1006 | |
1007 | check ("atan2 (+inf,+inf) == +pi/4", | |
0a614877 | 1008 | FUNC(atan2) (plus_infty, plus_infty), M_PI_4l); |
0d8733c4 UD |
1009 | |
1010 | check ("atan2 (-inf,+inf) == -pi/4", | |
0a614877 | 1011 | FUNC(atan2) (minus_infty, plus_infty), -M_PI_4l); |
0d8733c4 UD |
1012 | |
1013 | check ("atan2 (+inf,-inf) == +3*pi/4", | |
0a614877 | 1014 | FUNC(atan2) (plus_infty, minus_infty), 3 * M_PI_4l); |
0d8733c4 UD |
1015 | |
1016 | check ("atan2 (-inf,-inf) == -3*pi/4", | |
0a614877 | 1017 | FUNC(atan2) (minus_infty, minus_infty), -3 * M_PI_4l); |
900bec85 UD |
1018 | |
1019 | /* FIXME: Add some specific tests */ | |
9756dfe1 UD |
1020 | check_eps ("atan2 (0.7,1) == 0.61072...", FUNC(atan2) (0.7,1), |
1021 | 0.6107259643892086165L, CHOOSE(3e-17L, 0, 0)); | |
1022 | check_eps ("atan2 (0.4,0.0003) == 1.57004...", FUNC(atan2) (0.4, 0.0003), | |
5edb9387 | 1023 | 1.5700463269355215718L, CHOOSE(2e-19L, 0, 1.2e-7)); |
9756dfe1 | 1024 | |
0d8733c4 UD |
1025 | } |
1026 | ||
1027 | ||
1028 | static void | |
1029 | atanh_test (void) | |
1030 | { | |
d705269e | 1031 | #ifndef TEST_INLINE |
900bec85 | 1032 | MATHTYPE x; |
d705269e | 1033 | #endif |
0d8733c4 UD |
1034 | |
1035 | check ("atanh(+0) == +0", FUNC(atanh) (0), 0); | |
76b87c03 | 1036 | #ifndef TEST_INLINE |
0d8733c4 | 1037 | check ("atanh(-0) == -0", FUNC(atanh) (minus_zero), minus_zero); |
76b87c03 | 1038 | |
0d8733c4 UD |
1039 | check_isinfp_exc ("atanh(+1) == +inf plus divide-by-zero exception", |
1040 | FUNC(atanh) (1), DIVIDE_BY_ZERO_EXCEPTION); | |
1041 | check_isinfn_exc ("atanh(-1) == -inf plus divide-by-zero exception", | |
1042 | FUNC(atanh) (-1), DIVIDE_BY_ZERO_EXCEPTION); | |
900bec85 UD |
1043 | |
1044 | x = random_greater (1.0); | |
1045 | check_isnan_exc_ext ("atanh (x) == NaN plus invalid exception if |x| > 1", | |
1046 | FUNC(atanh) (x), INVALID_EXCEPTION, x); | |
1047 | ||
1048 | x = random_less (1.0); | |
1049 | check_isnan_exc_ext ("atanh (x) == NaN plus invalid exception if |x| > 1", | |
1050 | FUNC(atanh) (x), INVALID_EXCEPTION, x); | |
e7f1f046 | 1051 | |
76b87c03 | 1052 | #endif |
bd355af0 UD |
1053 | check_eps ("atanh(0.7) == 0.867300527...", FUNC(atanh) (0.7), |
1054 | 0.8673005276940531944L, CHOOSE(9e-17L, 2e-16, 0)); | |
0d8733c4 UD |
1055 | } |
1056 | ||
1057 | ||
1058 | static void | |
1059 | cbrt_test (void) | |
1060 | { | |
1061 | check ("cbrt (+0) == +0", FUNC(cbrt) (0.0), 0.0); | |
1062 | check ("cbrt (-0) == -0", FUNC(cbrt) (minus_zero), minus_zero); | |
1063 | ||
76b87c03 | 1064 | #ifndef TEST_INLINE |
26dee9c4 UD |
1065 | check_isinfp ("cbrt (+inf) == +inf", FUNC(cbrt) (plus_infty)); |
1066 | check_isinfn ("cbrt (-inf) == -inf", FUNC(cbrt) (minus_infty)); | |
1067 | check_isnan ("cbrt (NaN) == NaN", FUNC(cbrt) (nan_value)); | |
76b87c03 | 1068 | #endif |
ca34d7a7 UD |
1069 | check_eps ("cbrt (-0.001) == -0.1", FUNC(cbrt) (-0.001), -0.1, |
1070 | CHOOSE (5e-18L, 0, 0)); | |
63551311 UD |
1071 | check_eps ("cbrt (8) == 2", FUNC(cbrt) (8), 2, CHOOSE (5e-17L, 0, 0)); |
1072 | check_eps ("cbrt (-27) == -3", FUNC(cbrt) (-27.0), -3.0, | |
9a0a462c | 1073 | CHOOSE (3e-16L, 5e-16, 0)); |
e99ce132 | 1074 | check_eps ("cbrt (0.970299) == 0.99", FUNC(cbrt) (0.970299), 0.99, |
66000494 | 1075 | CHOOSE (2e-17L, 2e-16, 0)); |
bd355af0 | 1076 | check_eps ("cbrt (0.7) == .8879040017...", FUNC(cbrt) (0.7), |
74015205 | 1077 | 0.8879040017426007084L, CHOOSE(2e-17L, 6e-16, 0)); |
bd355af0 | 1078 | |
0d8733c4 UD |
1079 | } |
1080 | ||
1081 | ||
1082 | static void | |
1083 | ceil_test (void) | |
1084 | { | |
1085 | check ("ceil (+0) == +0", FUNC(ceil) (0.0), 0.0); | |
1086 | check ("ceil (-0) == -0", FUNC(ceil) (minus_zero), minus_zero); | |
1087 | check_isinfp ("ceil (+inf) == +inf", FUNC(ceil) (plus_infty)); | |
1088 | check_isinfn ("ceil (-inf) == -inf", FUNC(ceil) (minus_infty)); | |
1089 | ||
0a614877 UD |
1090 | check ("ceil (pi) == 4", FUNC(ceil) (M_PIl), 4.0); |
1091 | check ("ceil (-pi) == -3", FUNC(ceil) (-M_PIl), -3.0); | |
0d8733c4 UD |
1092 | } |
1093 | ||
1094 | ||
1095 | static void | |
1096 | cos_test (void) | |
1097 | { | |
1098 | ||
1099 | check ("cos (+0) == 1", FUNC(cos) (0), 1); | |
1100 | check ("cos (-0) == 1", FUNC(cos) (minus_zero), 1); | |
1101 | check_isnan_exc ("cos (+inf) == NaN plus invalid exception", | |
1102 | FUNC(cos) (plus_infty), | |
1103 | INVALID_EXCEPTION); | |
1104 | check_isnan_exc ("cos (-inf) == NaN plus invalid exception", | |
1105 | FUNC(cos) (minus_infty), | |
1106 | INVALID_EXCEPTION); | |
1107 | ||
0a614877 | 1108 | check_eps ("cos (pi/3) == 0.5", FUNC(cos) (M_PI_6l * 2.0), |
3e5f5557 | 1109 | 0.5, CHOOSE (4e-18L, 1e-15L, 1e-7L)); |
0a614877 | 1110 | check_eps ("cos (2*pi/3) == -0.5", FUNC(cos) (M_PI_6l * 4.0), |
cbdee279 | 1111 | -0.5, CHOOSE (4e-18L, 1e-15L, 1e-7L)); |
0a614877 | 1112 | check_eps ("cos (pi/2) == 0", FUNC(cos) (M_PI_2l), |
0d8733c4 UD |
1113 | 0, CHOOSE (1e-19L, 1e-16L, 1e-7L)); |
1114 | ||
bd355af0 | 1115 | check_eps ("cos (0.7) == 0.7648421872...", FUNC(cos) (0.7), |
66000494 | 1116 | 0.7648421872844884262L, CHOOSE(3e-17, 2e-16, 6e-8)); |
0d8733c4 UD |
1117 | } |
1118 | ||
1119 | static void | |
1120 | cosh_test (void) | |
1121 | { | |
1122 | check ("cosh (+0) == 1", FUNC(cosh) (0), 1); | |
1123 | check ("cosh (-0) == 1", FUNC(cosh) (minus_zero), 1); | |
1124 | ||
76b87c03 | 1125 | #ifndef TEST_INLINE |
0d8733c4 UD |
1126 | check_isinfp ("cosh (+inf) == +inf", FUNC(cosh) (plus_infty)); |
1127 | check_isinfp ("cosh (-inf) == +inf", FUNC(cosh) (minus_infty)); | |
76b87c03 | 1128 | #endif |
bd355af0 UD |
1129 | |
1130 | check_eps ("cosh (0.7) == 1.2551690056...", FUNC(cosh) (0.7), | |
1131 | 1.255169005630943018L, CHOOSE(4e-17L, 0, 0)); | |
0d8733c4 UD |
1132 | } |
1133 | ||
1134 | ||
900bec85 UD |
1135 | static void |
1136 | erf_test (void) | |
1137 | { | |
1138 | errno = 0; | |
1139 | FUNC(erf) (0); | |
1140 | if (errno == ENOSYS) | |
1141 | /* Function not implemented. */ | |
1142 | return; | |
1143 | ||
1144 | check ("erf (+0) == +0", FUNC(erf) (0), 0); | |
1145 | check ("erf (-0) == -0", FUNC(erf) (minus_zero), minus_zero); | |
1146 | check ("erf (+inf) == +1", FUNC(erf) (plus_infty), 1); | |
1147 | check ("erf (-inf) == -1", FUNC(erf) (minus_infty), -1); | |
bd355af0 UD |
1148 | |
1149 | check_eps ("erf (0.7) == 0.6778011938...", FUNC(erf) (0.7), | |
1150 | 0.67780119383741847297L, CHOOSE(0, 2e-16, 0)); | |
900bec85 UD |
1151 | } |
1152 | ||
1153 | ||
1154 | static void | |
1155 | erfc_test (void) | |
1156 | { | |
1157 | errno = 0; | |
1158 | FUNC(erfc) (0); | |
1159 | if (errno == ENOSYS) | |
1160 | /* Function not implemented. */ | |
1161 | return; | |
1162 | ||
1163 | check ("erfc (+inf) == 0", FUNC(erfc) (plus_infty), 0.0); | |
1164 | check ("erfc (-inf) == 2", FUNC(erfc) (minus_infty), 2.0); | |
1165 | check ("erfc (+0) == 1", FUNC(erfc) (0.0), 1.0); | |
1166 | check ("erfc (-0) == 1", FUNC(erfc) (minus_zero), 1.0); | |
bd355af0 UD |
1167 | |
1168 | check_eps ("erfc (0.7) == 0.3221988061...", FUNC(erfc) (0.7), | |
1169 | 0.32219880616258152702L, CHOOSE(0, 6e-17, 0)); | |
900bec85 UD |
1170 | } |
1171 | ||
1172 | ||
0d8733c4 UD |
1173 | static void |
1174 | exp_test (void) | |
1175 | { | |
1176 | check ("exp (+0) == 1", FUNC(exp) (0), 1); | |
1177 | check ("exp (-0) == 1", FUNC(exp) (minus_zero), 1); | |
1178 | ||
76b87c03 | 1179 | #ifndef TEST_INLINE |
0d8733c4 UD |
1180 | check_isinfp ("exp (+inf) == +inf", FUNC(exp) (plus_infty)); |
1181 | check ("exp (-inf) == 0", FUNC(exp) (minus_infty), 0); | |
76b87c03 | 1182 | #endif |
0a614877 | 1183 | check_eps ("exp (1) == e", FUNC(exp) (1), M_El, CHOOSE (4e-18L, 0, 0)); |
cbdee279 | 1184 | |
0a614877 | 1185 | check_eps ("exp (2) == e^2", FUNC(exp) (2), M_E2l, |
9756dfe1 | 1186 | CHOOSE (1e-18, 0, 0)); |
0a614877 | 1187 | check_eps ("exp (3) == e^3", FUNC(exp) (3), M_E3l, |
9756dfe1 | 1188 | CHOOSE (1.5e-17, 0, 0)); |
bd355af0 UD |
1189 | check_eps ("exp (0.7) == 2.0137527074...", FUNC(exp) (0.7), |
1190 | 2.0137527074704765216L, CHOOSE(9e-17L, 0, 0)); | |
0d8733c4 UD |
1191 | } |
1192 | ||
1193 | ||
36ecfe56 UD |
1194 | static void |
1195 | exp10_test (void) | |
1196 | { | |
1197 | errno = 0; | |
1198 | FUNC(exp10) (0); | |
1199 | if (errno == ENOSYS) | |
1200 | /* Function not implemented. */ | |
1201 | return; | |
1202 | ||
1203 | check ("exp10 (+0) == 1", FUNC(exp10) (0), 1); | |
1204 | check ("exp10 (-0) == 1", FUNC(exp10) (minus_zero), 1); | |
1205 | ||
1206 | check_isinfp ("exp10 (+inf) == +inf", FUNC(exp10) (plus_infty)); | |
1207 | check ("exp10 (-inf) == 0", FUNC(exp10) (minus_infty), 0); | |
1208 | check_eps ("exp10 (3) == 1000", FUNC(exp10) (3), 1000, | |
adac8450 | 1209 | CHOOSE(5e-16, 7e-13, 2e-4)); |
36ecfe56 | 1210 | check_eps ("exp10 (-1) == 0.1", FUNC(exp10) (-1), 0.1, |
adac8450 | 1211 | CHOOSE(6e-18, 3e-17, 8e-09)); |
36ecfe56 UD |
1212 | check_isinfp ("exp10 (1e6) == +inf", FUNC(exp10) (1e6)); |
1213 | check ("exp10 (-1e6) == 0", FUNC(exp10) (-1e6), 0); | |
1214 | check_eps ("exp10 (0.7) == 5.0118723...", FUNC(exp10) (0.7), | |
adac8450 | 1215 | 5.0118723362727228500L, CHOOSE(6e-16, 9e-16, 5e-7)); |
36ecfe56 UD |
1216 | } |
1217 | ||
1218 | ||
0d8733c4 UD |
1219 | static void |
1220 | exp2_test (void) | |
1221 | { | |
e7fd8a39 | 1222 | errno = 0; |
d705269e | 1223 | FUNC(exp2) (0); |
e7fd8a39 UD |
1224 | if (errno == ENOSYS) |
1225 | /* Function not implemented. */ | |
1226 | return; | |
1227 | ||
0d8733c4 UD |
1228 | check ("exp2 (+0) == 1", FUNC(exp2) (0), 1); |
1229 | check ("exp2 (-0) == 1", FUNC(exp2) (minus_zero), 1); | |
1230 | ||
1231 | check_isinfp ("exp2 (+inf) == +inf", FUNC(exp2) (plus_infty)); | |
1232 | check ("exp2 (-inf) == 0", FUNC(exp2) (minus_infty), 0); | |
1233 | check ("exp2 (10) == 1024", FUNC(exp2) (10), 1024); | |
650425ce UD |
1234 | check ("exp2 (-1) == 0.5", FUNC(exp2) (-1), 0.5); |
1235 | check_isinfp ("exp2 (1e6) == +inf", FUNC(exp2) (1e6)); | |
1236 | check ("exp2 (-1e6) == 0", FUNC(exp2) (-1e6), 0); | |
bd355af0 UD |
1237 | check_eps ("exp2 (0.7) == 1.6245047927...", FUNC(exp2) (0.7), |
1238 | 1.6245047927124710452L, CHOOSE(6e-17L, 0, 6e-8)); | |
0d8733c4 | 1239 | } |
0d8733c4 UD |
1240 | |
1241 | ||
1242 | static void | |
1243 | expm1_test (void) | |
1244 | { | |
1245 | check ("expm1 (+0) == 0", FUNC(expm1) (0), 0); | |
ca34d7a7 | 1246 | #ifndef TEST_INLINE |
0d8733c4 UD |
1247 | check ("expm1 (-0) == -0", FUNC(expm1) (minus_zero), minus_zero); |
1248 | ||
1249 | check_isinfp ("expm1 (+inf) == +inf", FUNC(expm1) (plus_infty)); | |
1250 | check ("expm1 (-inf) == -1", FUNC(expm1) (minus_infty), -1); | |
ca34d7a7 | 1251 | #endif |
0d8733c4 | 1252 | |
0a614877 | 1253 | check_eps ("expm1 (1) == e-1", FUNC(expm1) (1), M_El - 1.0, |
9a0a462c | 1254 | CHOOSE (4e-18L, 0, 2e-7)); |
9756dfe1 UD |
1255 | |
1256 | check_eps ("expm1 (0.7) == 1.01375...", FUNC(expm1) (0.7), | |
1257 | 1.0137527074704765216L, CHOOSE(9e-17L, 0, 0)); | |
0d8733c4 UD |
1258 | } |
1259 | ||
1260 | ||
1261 | ||
1262 | ||
1263 | static void | |
1264 | check_frexp (const char *test_name, MATHTYPE computed, MATHTYPE expected, | |
1265 | int comp_int, int exp_int) | |
1266 | { | |
1267 | MATHTYPE diff; | |
1268 | int result; | |
1269 | ||
1270 | result = (check_equal (computed, expected, 0, &diff) | |
1271 | && (comp_int == exp_int)); | |
1272 | ||
1273 | if (result) | |
1274 | { | |
1275 | if (verbose > 2) | |
1276 | printf ("Pass: %s\n", test_name); | |
1277 | } | |
1278 | else | |
1279 | { | |
1280 | if (verbose) | |
1281 | printf ("Fail: %s\n", test_name); | |
1282 | if (verbose > 1) | |
1283 | { | |
1284 | printf ("Result:\n"); | |
f43ce637 UD |
1285 | printf (" is: %.20" PRINTF_EXPR " *2^%d %.20" |
1286 | PRINTF_XEXPR "*2^%d\n", | |
1287 | computed, comp_int, computed, comp_int); | |
1288 | printf (" should be: %.20" PRINTF_EXPR " *2^%d %.20" | |
1289 | PRINTF_XEXPR "*2^%d\n", | |
1290 | expected, exp_int, expected, exp_int); | |
1291 | printf (" difference: %.20" PRINTF_EXPR " %.20" PRINTF_XEXPR "\n", | |
1292 | diff, diff); | |
0d8733c4 UD |
1293 | } |
1294 | noErrors++; | |
1295 | } | |
1296 | fpstack_test (test_name); | |
1297 | output_result (test_name, result, | |
1298 | computed, expected, diff, PRINT, PRINT); | |
1299 | } | |
1300 | ||
1301 | ||
1302 | static void | |
1303 | frexp_test (void) | |
1304 | { | |
1305 | int x_int; | |
1306 | MATHTYPE result; | |
1307 | ||
1308 | result = FUNC(frexp) (plus_infty, &x_int); | |
1309 | check_isinfp ("frexp (+inf, expr) == +inf", result); | |
1310 | ||
1311 | result = FUNC(frexp) (minus_infty, &x_int); | |
1312 | check_isinfn ("frexp (-inf, expr) == -inf", result); | |
1313 | ||
1314 | result = FUNC(frexp) (nan_value, &x_int); | |
1315 | check_isnan ("frexp (Nan, expr) == NaN", result); | |
1316 | ||
1317 | result = FUNC(frexp) (0, &x_int); | |
1318 | check_frexp ("frexp: +0 == 0 * 2^0", result, 0, x_int, 0); | |
1319 | ||
1320 | result = FUNC(frexp) (minus_zero, &x_int); | |
1321 | check_frexp ("frexp: -0 == -0 * 2^0", result, minus_zero, x_int, 0); | |
1322 | ||
1323 | result = FUNC(frexp) (12.8L, &x_int); | |
1324 | check_frexp ("frexp: 12.8 == 0.8 * 2^4", result, 0.8L, x_int, 4); | |
1325 | ||
1326 | result = FUNC(frexp) (-27.34L, &x_int); | |
1327 | check_frexp ("frexp: -27.34 == -0.854375 * 2^5", result, -0.854375L, x_int, 5); | |
1328 | ||
1329 | } | |
1330 | ||
1331 | ||
1332 | #if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 1) | |
1333 | /* All floating-point numbers can be put in one of these categories. */ | |
1334 | enum | |
1335 | { | |
1336 | FP_NAN, | |
1337 | #define FP_NAN FP_NAN | |
1338 | FP_INFINITE, | |
1339 | #define FP_INFINITE FP_INFINITE | |
1340 | FP_ZERO, | |
1341 | #define FP_ZERO FP_ZERO | |
1342 | FP_SUBNORMAL, | |
1343 | #define FP_SUBNORMAL FP_SUBNORMAL | |
1344 | FP_NORMAL | |
1345 | #define FP_NORMAL FP_NORMAL | |
1346 | }; | |
1347 | #endif | |
1348 | ||
1349 | ||
1350 | static void | |
1351 | fpclassify_test (void) | |
1352 | { | |
1353 | MATHTYPE x; | |
1354 | ||
1355 | /* fpclassify is a macro, don't give it constants as parameter */ | |
1356 | check_bool ("fpclassify (NaN) == FP_NAN", fpclassify (nan_value) == FP_NAN); | |
1357 | check_bool ("fpclassify (+inf) == FP_INFINITE", | |
1358 | fpclassify (plus_infty) == FP_INFINITE); | |
1359 | check_bool ("fpclassify (-inf) == FP_INFINITE", | |
1360 | fpclassify (minus_infty) == FP_INFINITE); | |
1361 | check_bool ("fpclassify (+0) == FP_ZERO", | |
1362 | fpclassify (plus_zero) == FP_ZERO); | |
1363 | check_bool ("fpclassify (-0) == FP_ZERO", | |
1364 | fpclassify (minus_zero) == FP_ZERO); | |
1365 | ||
1366 | x = 1000.0; | |
1367 | check_bool ("fpclassify (1000) == FP_NORMAL", | |
1368 | fpclassify (x) == FP_NORMAL); | |
1369 | } | |
1370 | ||
1371 | ||
900bec85 UD |
1372 | static void |
1373 | isfinite_test (void) | |
1374 | { | |
1375 | check_bool ("isfinite (0) != 0", isfinite (0)); | |
1376 | check_bool ("isfinite (-0) != 0", isfinite (minus_zero)); | |
1377 | check_bool ("isfinite (10) != 0", isfinite (10)); | |
1378 | check_bool ("isfinite (+inf) == 0", isfinite (plus_infty) == 0); | |
1379 | check_bool ("isfinite (-inf) == 0", isfinite (minus_infty) == 0); | |
1380 | check_bool ("isfinite (NaN) == 0", isfinite (nan_value) == 0); | |
1381 | } | |
1382 | ||
1383 | ||
1384 | static void | |
1385 | isnormal_test (void) | |
1386 | { | |
1387 | check_bool ("isnormal (0) == 0", isnormal (0) == 0); | |
1388 | check_bool ("isnormal (-0) == 0", isnormal (minus_zero) == 0); | |
1389 | check_bool ("isnormal (10) != 0", isnormal (10)); | |
1390 | check_bool ("isnormal (+inf) == 0", isnormal (plus_infty) == 0); | |
1391 | check_bool ("isnormal (-inf) == 0", isnormal (minus_infty) == 0); | |
1392 | check_bool ("isnormal (NaN) == 0", isnormal (nan_value) == 0); | |
1393 | ||
1394 | } | |
1395 | ||
1396 | ||
1397 | static void | |
1398 | signbit_test (void) | |
1399 | { | |
1400 | MATHTYPE x; | |
e7f1f046 | 1401 | |
900bec85 UD |
1402 | check_bool ("signbit (+0) == 0", signbit (0) == 0); |
1403 | check_bool ("signbit (-0) != 0", signbit (minus_zero)); | |
1404 | check_bool ("signbit (+inf) == 0", signbit (plus_infty) == 0); | |
1405 | check_bool ("signbit (-inf) != 0", signbit (minus_infty)); | |
900bec85 UD |
1406 | |
1407 | x = random_less (0); | |
1408 | check_bool ("signbit (x) != 0 for x < 0", signbit (x)); | |
1409 | ||
1410 | x = random_greater (0); | |
1411 | check_bool ("signbit (x) == 0 for x > 0", signbit (x) == 0); | |
e7f1f046 | 1412 | |
900bec85 UD |
1413 | } |
1414 | ||
1415 | ||
900bec85 UD |
1416 | static void |
1417 | gamma_test (void) | |
1418 | { | |
d705269e | 1419 | errno = 0; |
478b92f0 | 1420 | FUNC(gamma) (1); |
d705269e UD |
1421 | if (errno == ENOSYS) |
1422 | /* Function not implemented. */ | |
1423 | return; | |
1424 | feclearexcept (FE_ALL_EXCEPT); | |
900bec85 | 1425 | |
5107cf1d | 1426 | |
5107cf1d | 1427 | check_isinfp ("gamma (+inf) == +inf", FUNC(gamma) (plus_infty)); |
e852e889 UD |
1428 | check_isinfp_exc ("gamma (0) == +inf plus divide by zero exception", |
1429 | FUNC(gamma) (0), DIVIDE_BY_ZERO_EXCEPTION); | |
5107cf1d | 1430 | |
e852e889 UD |
1431 | check_isinfp_exc ("gamma (x) == +inf plus divide by zero exception for integer x <= 0", |
1432 | FUNC(gamma) (-3), DIVIDE_BY_ZERO_EXCEPTION); | |
5107cf1d UD |
1433 | check_isnan_exc ("gamma (-inf) == NaN plus invalid exception", |
1434 | FUNC(gamma) (minus_infty), INVALID_EXCEPTION); | |
1435 | ||
1436 | signgam = 0; | |
1437 | check ("gamma (1) == 0", FUNC(gamma) (1), 0); | |
cc60175e | 1438 | check_int ("gamma (1) sets signgam to 1", signgam, 1); |
5107cf1d UD |
1439 | |
1440 | signgam = 0; | |
0a614877 | 1441 | check ("gamma (3) == M_LN2", FUNC(gamma) (3), M_LN2l); |
5107cf1d UD |
1442 | check_int ("gamma (3) sets signgam to 1", signgam, 1); |
1443 | ||
1444 | signgam = 0; | |
1445 | check_eps ("gamma (0.5) == log(sqrt(pi))", FUNC(gamma) (0.5), | |
0a614877 | 1446 | FUNC(log) (FUNC(sqrt) (M_PIl)), CHOOSE (0, 1e-15, 1e-7)); |
5107cf1d UD |
1447 | check_int ("gamma (0.5) sets signgam to 1", signgam, 1); |
1448 | ||
1449 | signgam = 0; | |
1450 | check_eps ("gamma (-0.5) == log(2*sqrt(pi))", FUNC(gamma) (-0.5), | |
0a614877 | 1451 | FUNC(log) (2*FUNC(sqrt) (M_PIl)), CHOOSE (0, 1e-15, 0)); |
5107cf1d UD |
1452 | |
1453 | check_int ("gamma (-0.5) sets signgam to -1", signgam, -1); | |
e852e889 | 1454 | } |
5107cf1d UD |
1455 | |
1456 | ||
e852e889 UD |
1457 | static void |
1458 | tgamma_test (void) | |
1459 | { | |
1460 | errno = 0; | |
1461 | FUNC(tgamma) (1); | |
1462 | if (errno == ENOSYS) | |
1463 | /* Function not implemented. */ | |
1464 | return; | |
1465 | feclearexcept (FE_ALL_EXCEPT); | |
5107cf1d | 1466 | |
900bec85 | 1467 | |
e852e889 UD |
1468 | check_isinfp ("tgamma (+inf) == +inf", FUNC(tgamma) (plus_infty)); |
1469 | check_isnan_exc ("tgamma (0) == NaN plus invalid exception", | |
1470 | FUNC(tgamma) (0), INVALID_EXCEPTION); | |
1471 | ||
1472 | check_isnan_exc_ext ("tgamma (x) == NaN plus invalid exception for integer x <= 0", | |
1473 | FUNC(tgamma) (-2), INVALID_EXCEPTION, -2); | |
1474 | check_isnan_exc ("tgamma (-inf) == NaN plus invalid exception", | |
1475 | FUNC(tgamma) (minus_infty), INVALID_EXCEPTION); | |
900bec85 | 1476 | |
bd355af0 | 1477 | #ifdef TODO |
e852e889 UD |
1478 | check_eps ("tgamma (0.5) == sqrt(pi)", FUNC(tgamma) (0.5), |
1479 | FUNC(sqrt) (M_PIl), CHOOSE (0, 5e-16, 2e-7)); | |
bd355af0 | 1480 | #endif |
e852e889 | 1481 | check_eps ("tgamma (-0.5) == -2*sqrt(pi)", FUNC(tgamma) (-0.5), |
0a614877 | 1482 | -2*FUNC(sqrt) (M_PIl), CHOOSE (0, 5e-16, 3e-7)); |
900bec85 | 1483 | |
e852e889 UD |
1484 | check ("tgamma (1) == 1", FUNC(tgamma) (1), 1); |
1485 | check ("tgamma (4) == 6", FUNC(tgamma) (4), 6); | |
e7f1f046 | 1486 | |
e852e889 | 1487 | check_eps ("tgamma (0.7) == 1.29805...", FUNC(tgamma) (0.7), |
9756dfe1 | 1488 | 1.29805533264755778568L, CHOOSE(0, 3e-16, 2e-7)); |
e852e889 UD |
1489 | check ("tgamma (1.2) == 0.91816...", FUNC(tgamma) (1.2), |
1490 | 0.91816874239976061064L); | |
900bec85 UD |
1491 | } |
1492 | ||
1493 | ||
1494 | static void | |
1495 | lgamma_test (void) | |
1496 | { | |
d705269e UD |
1497 | errno = 0; |
1498 | FUNC(lgamma) (0); | |
1499 | if (errno == ENOSYS) | |
1500 | /* Function not implemented. */ | |
1501 | return; | |
1502 | feclearexcept (FE_ALL_EXCEPT); | |
e7f1f046 | 1503 | |
900bec85 | 1504 | check_isinfp ("lgamma (+inf) == +inf", FUNC(lgamma) (plus_infty)); |
d705269e UD |
1505 | check_isinfp_exc ("lgamma (0) == +inf plus divide by zero exception", |
1506 | FUNC(lgamma) (0), DIVIDE_BY_ZERO_EXCEPTION); | |
900bec85 | 1507 | |
d705269e UD |
1508 | check_isinfp_exc ("lgamma (x) == +inf plus divide by zero exception for integer x <= 0", |
1509 | FUNC(lgamma) (-3), DIVIDE_BY_ZERO_EXCEPTION); | |
900bec85 UD |
1510 | check_isnan_exc ("lgamma (-inf) == NaN plus invalid exception", |
1511 | FUNC(lgamma) (minus_infty), INVALID_EXCEPTION); | |
1512 | ||
5107cf1d | 1513 | signgam = 0; |
900bec85 UD |
1514 | check ("lgamma (1) == 0", FUNC(lgamma) (1), 0); |
1515 | check_int ("lgamma (0) sets signgam to 1", signgam, 1); | |
1516 | ||
5107cf1d | 1517 | signgam = 0; |
0a614877 | 1518 | check ("lgamma (3) == M_LN2", FUNC(lgamma) (3), M_LN2l); |
900bec85 UD |
1519 | check_int ("lgamma (3) sets signgam to 1", signgam, 1); |
1520 | ||
5107cf1d | 1521 | signgam = 0; |
900bec85 | 1522 | check_eps ("lgamma (0.5) == log(sqrt(pi))", FUNC(lgamma) (0.5), |
0a614877 | 1523 | FUNC(log) (FUNC(sqrt) (M_PIl)), CHOOSE (0, 1e-15, 1e-7)); |
900bec85 UD |
1524 | check_int ("lgamma (0.5) sets signgam to 1", signgam, 1); |
1525 | ||
5107cf1d | 1526 | signgam = 0; |
900bec85 | 1527 | check_eps ("lgamma (-0.5) == log(2*sqrt(pi))", FUNC(lgamma) (-0.5), |
0a614877 | 1528 | FUNC(log) (2*FUNC(sqrt) (M_PIl)), CHOOSE (0, 1e-15, 0)); |
900bec85 UD |
1529 | |
1530 | check_int ("lgamma (-0.5) sets signgam to -1", signgam, -1); | |
1531 | ||
9756dfe1 UD |
1532 | signgam = 0; |
1533 | check_eps ("lgamma (0.7) == 0.26086...", FUNC(lgamma) (0.7), | |
1534 | 0.26086724653166651439L, CHOOSE(0, 6e-17, 3e-8)); | |
1535 | check_int ("lgamma (0.7) sets signgam to 1", signgam, 1); | |
1536 | ||
1537 | signgam = 0; | |
1538 | check_eps ("lgamma (1.2) == -0.08537...", FUNC(lgamma) (1.2), | |
1539 | -0.853740900033158497197e-1L, CHOOSE(0, 2e-17, 2e-8)); | |
1540 | check_int ("lgamma (1.2) sets signgam to 1", signgam, 1); | |
1541 | ||
900bec85 UD |
1542 | } |
1543 | ||
1544 | ||
3e5f5557 UD |
1545 | static void |
1546 | ilogb_test (void) | |
1547 | { | |
478b92f0 | 1548 | int i; |
3e5f5557 | 1549 | |
d705269e | 1550 | check_int ("ilogb (1) == 0", FUNC(ilogb) (1), 0); |
0a614877 | 1551 | check_int ("ilogb (e) == 1", FUNC(ilogb) (M_El), 1); |
d705269e UD |
1552 | check_int ("ilogb (1024) == 10", FUNC(ilogb) (1024), 10); |
1553 | check_int ("ilogb (-2000) == 10", FUNC(ilogb) (-2000), 10); | |
3e5f5557 | 1554 | |
478b92f0 UD |
1555 | /* XXX We have a problem here: the standard does not tell us whether |
1556 | exceptions are allowed/required. ignore them for now. */ | |
1557 | i = FUNC (ilogb) (0.0); | |
1558 | feclearexcept (FE_ALL_EXCEPT); | |
1559 | check_int ("ilogb (0) == FP_ILOGB0", i, FP_ILOGB0); | |
1560 | i = FUNC(ilogb) (nan_value); | |
1561 | feclearexcept (FE_ALL_EXCEPT); | |
1562 | check_int ("ilogb (NaN) == FP_ILOGBNAN", i, FP_ILOGBNAN); | |
3e5f5557 UD |
1563 | |
1564 | } | |
1565 | ||
1566 | ||
0d8733c4 UD |
1567 | static void |
1568 | ldexp_test (void) | |
1569 | { | |
3e5f5557 UD |
1570 | MATHTYPE x; |
1571 | ||
0d8733c4 UD |
1572 | check ("ldexp (0, 0) == 0", FUNC(ldexp) (0, 0), 0); |
1573 | ||
1574 | check_isinfp ("ldexp (+inf, 1) == +inf", FUNC(ldexp) (plus_infty, 1)); | |
1575 | check_isinfn ("ldexp (-inf, 1) == -inf", FUNC(ldexp) (minus_infty, 1)); | |
1576 | check_isnan ("ldexp (NaN, 1) == NaN", FUNC(ldexp) (nan_value, 1)); | |
1577 | ||
1578 | check ("ldexp (0.8, 4) == 12.8", FUNC(ldexp) (0.8L, 4), 12.8L); | |
1579 | check ("ldexp (-0.854375, 5) == -27.34", FUNC(ldexp) (-0.854375L, 5), -27.34L); | |
3e5f5557 UD |
1580 | |
1581 | x = random_greater (0.0); | |
1582 | check_ext ("ldexp (x, 0) == x", FUNC(ldexp) (x, 0L), x, x); | |
1583 | ||
0d8733c4 UD |
1584 | } |
1585 | ||
1586 | ||
1587 | static void | |
1588 | log_test (void) | |
1589 | { | |
779ae82e UD |
1590 | check_isinfn_exc ("log (+0) == -inf plus divide-by-zero exception", |
1591 | FUNC(log) (0), DIVIDE_BY_ZERO_EXCEPTION); | |
1592 | check_isinfn_exc ("log (-0) == -inf plus divide-by-zero exception", | |
1593 | FUNC(log) (minus_zero), DIVIDE_BY_ZERO_EXCEPTION); | |
0d8733c4 UD |
1594 | |
1595 | check ("log (1) == 0", FUNC(log) (1), 0); | |
1596 | ||
779ae82e | 1597 | check_isnan_exc ("log (x) == NaN plus invalid exception if x < 0", |
0d8733c4 UD |
1598 | FUNC(log) (-1), INVALID_EXCEPTION); |
1599 | check_isinfp ("log (+inf) == +inf", FUNC(log) (plus_infty)); | |
1600 | ||
0a614877 UD |
1601 | check_eps ("log (e) == 1", FUNC(log) (M_El), 1, CHOOSE (1e-18L, 0, 9e-8L)); |
1602 | check_eps ("log (1/e) == -1", FUNC(log) (1.0 / M_El), -1, | |
3e5f5557 | 1603 | CHOOSE (2e-18L, 0, 0)); |
5edb9387 UD |
1604 | check_eps ("log (2) == M_LN2", FUNC(log) (2), M_LN2l, |
1605 | CHOOSE (6e-20L, 0, 0)); | |
0a614877 | 1606 | check_eps ("log (10) == M_LN10", FUNC(log) (10), M_LN10l, |
3e5f5557 | 1607 | CHOOSE (1e-18L, 0, 0)); |
bd355af0 UD |
1608 | check_eps ("log (0.7) == -0.3566749439...", FUNC(log) (0.7), |
1609 | -0.35667494393873237891L, CHOOSE(7e-17L, 6e-17, 3e-8)); | |
0d8733c4 UD |
1610 | } |
1611 | ||
1612 | ||
1613 | static void | |
1614 | log10_test (void) | |
1615 | { | |
779ae82e UD |
1616 | check_isinfn_exc ("log10 (+0) == -inf plus divide-by-zero exception", |
1617 | FUNC(log10) (0), DIVIDE_BY_ZERO_EXCEPTION); | |
1618 | check_isinfn_exc ("log10 (-0) == -inf plus divide-by-zero exception", | |
1619 | FUNC(log10) (minus_zero), DIVIDE_BY_ZERO_EXCEPTION); | |
0d8733c4 UD |
1620 | |
1621 | check ("log10 (1) == +0", FUNC(log10) (1), 0); | |
1622 | ||
779ae82e | 1623 | check_isnan_exc ("log10 (x) == NaN plus invalid exception if x < 0", |
0d8733c4 UD |
1624 | FUNC(log10) (-1), INVALID_EXCEPTION); |
1625 | ||
1626 | check_isinfp ("log10 (+inf) == +inf", FUNC(log10) (plus_infty)); | |
1627 | ||
3e5f5557 UD |
1628 | check_eps ("log10 (0.1) == -1", FUNC(log10) (0.1L), -1, |
1629 | CHOOSE (1e-18L, 0, 0)); | |
1630 | check_eps ("log10 (10) == 1", FUNC(log10) (10.0), 1, | |
1631 | CHOOSE (1e-18L, 0, 0)); | |
1632 | check_eps ("log10 (100) == 2", FUNC(log10) (100.0), 2, | |
1633 | CHOOSE (1e-18L, 0, 0)); | |
0d8733c4 | 1634 | check ("log10 (10000) == 4", FUNC(log10) (10000.0), 4); |
0a614877 | 1635 | check_eps ("log10 (e) == M_LOG10E", FUNC(log10) (M_El), M_LOG10El, |
3e5f5557 | 1636 | CHOOSE (1e-18, 0, 9e-8)); |
bd355af0 | 1637 | check_eps ("log10 (0.7) == -0.1549019599...", FUNC(log10) (0.7), |
66000494 | 1638 | -0.15490195998574316929L, CHOOSE(3e-17L, 3e-17, 2e-8)); |
0d8733c4 UD |
1639 | } |
1640 | ||
1641 | ||
1642 | static void | |
1643 | log1p_test (void) | |
1644 | { | |
1645 | check ("log1p (+0) == +0", FUNC(log1p) (0), 0); | |
1646 | check ("log1p (-0) == -0", FUNC(log1p) (minus_zero), minus_zero); | |
1647 | ||
779ae82e UD |
1648 | check_isinfn_exc ("log1p (-1) == -inf plus divide-by-zero exception", |
1649 | FUNC(log1p) (-1), DIVIDE_BY_ZERO_EXCEPTION); | |
1650 | check_isnan_exc ("log1p (x) == NaN plus invalid exception if x < -1", | |
0d8733c4 UD |
1651 | FUNC(log1p) (-2), INVALID_EXCEPTION); |
1652 | ||
1653 | check_isinfp ("log1p (+inf) == +inf", FUNC(log1p) (plus_infty)); | |
1654 | ||
0a614877 | 1655 | check_eps ("log1p (e-1) == 1", FUNC(log1p) (M_El - 1.0), 1, |
6973fc01 | 1656 | CHOOSE (1e-18L, 0, 6e-8)); |
0d8733c4 | 1657 | |
9756dfe1 UD |
1658 | check_eps ("log1p (-0.3) == -0.35667...", FUNC(log1p) (-0.3), |
1659 | -0.35667494393873237891L, CHOOSE(2e-17L, 6e-17, 3e-8)); | |
0d8733c4 UD |
1660 | } |
1661 | ||
1662 | ||
0d8733c4 UD |
1663 | static void |
1664 | log2_test (void) | |
1665 | { | |
779ae82e UD |
1666 | check_isinfn_exc ("log2 (+0) == -inf plus divide-by-zero exception", |
1667 | FUNC(log2) (0), DIVIDE_BY_ZERO_EXCEPTION); | |
1668 | check_isinfn_exc ("log2 (-0) == -inf plus divide-by-zero exception", | |
1669 | FUNC(log2) (minus_zero), DIVIDE_BY_ZERO_EXCEPTION); | |
0d8733c4 UD |
1670 | |
1671 | check ("log2 (1) == +0", FUNC(log2) (1), 0); | |
1672 | ||
779ae82e | 1673 | check_isnan_exc ("log2 (x) == NaN plus invalid exception if x < 0", |
0d8733c4 UD |
1674 | FUNC(log2) (-1), INVALID_EXCEPTION); |
1675 | ||
1676 | check_isinfp ("log2 (+inf) == +inf", FUNC(log2) (plus_infty)); | |
1677 | ||
0a614877 | 1678 | check_eps ("log2 (e) == M_LOG2E", FUNC(log2) (M_El), M_LOG2El, |
22d57dd3 | 1679 | CHOOSE (1e-18L, 0, 0)); |
0d8733c4 | 1680 | check ("log2 (2) == 1", FUNC(log2) (2.0), 1); |
22d57dd3 | 1681 | check_eps ("log2 (16) == 4", FUNC(log2) (16.0), 4, CHOOSE (1e-18L, 0, 0)); |
0d8733c4 | 1682 | check ("log2 (256) == 8", FUNC(log2) (256.0), 8); |
bd355af0 UD |
1683 | check_eps ("log2 (0.7) == -0.5145731728...", FUNC(log2) (0.7), |
1684 | -0.51457317282975824043L, CHOOSE(1e-16L, 2e-16, 6e-8)); | |
0d8733c4 UD |
1685 | |
1686 | } | |
0d8733c4 UD |
1687 | |
1688 | ||
1689 | static void | |
1690 | logb_test (void) | |
1691 | { | |
1692 | check_isinfp ("logb (+inf) == +inf", FUNC(logb) (plus_infty)); | |
1693 | check_isinfp ("logb (-inf) == +inf", FUNC(logb) (minus_infty)); | |
1694 | ||
1695 | check_isinfn_exc ("logb (+0) == -inf plus divide-by-zero exception", | |
1696 | FUNC(logb) (0), DIVIDE_BY_ZERO_EXCEPTION); | |
1697 | ||
1698 | check_isinfn_exc ("logb (-0) == -inf plus divide-by-zero exception", | |
1699 | FUNC(logb) (minus_zero), DIVIDE_BY_ZERO_EXCEPTION); | |
1700 | ||
1701 | check ("logb (1) == 0", FUNC(logb) (1), 0); | |
0a614877 | 1702 | check ("logb (e) == 1", FUNC(logb) (M_El), 1); |
0d8733c4 UD |
1703 | check ("logb (1024) == 10", FUNC(logb) (1024), 10); |
1704 | check ("logb (-2000) == 10", FUNC(logb) (-2000), 10); | |
1705 | ||
1706 | } | |
1707 | ||
1708 | ||
c57abfa7 UD |
1709 | static void |
1710 | modf_test (void) | |
1711 | { | |
1712 | MATHTYPE result, intpart; | |
1713 | ||
1714 | result = FUNC(modf) (plus_infty, &intpart); | |
1715 | check ("modf (+inf, &x) returns +0", result, 0); | |
1716 | check_isinfp ("modf (+inf, &x) set x to +inf", intpart); | |
1717 | ||
1718 | result = FUNC(modf) (minus_infty, &intpart); | |
1719 | check ("modf (-inf, &x) returns -0", result, minus_zero); | |
1720 | check_isinfn ("modf (-inf, &x) sets x to -inf", intpart); | |
1721 | ||
1722 | result = FUNC(modf) (nan_value, &intpart); | |
1723 | check_isnan ("modf (NaN, &x) returns NaN", result); | |
22d57dd3 | 1724 | check_isnan ("modf (NaN, &x) sets x to NaN", intpart); |
c57abfa7 UD |
1725 | |
1726 | result = FUNC(modf) (0, &intpart); | |
1727 | check ("modf (0, &x) returns 0", result, 0); | |
1728 | check ("modf (0, &x) sets x to 0", intpart, 0); | |
1729 | ||
1730 | result = FUNC(modf) (minus_zero, &intpart); | |
1731 | check ("modf (-0, &x) returns -0", result, minus_zero); | |
1732 | check ("modf (-0, &x) sets x to -0", intpart, minus_zero); | |
1733 | ||
c6222ab9 UD |
1734 | result = FUNC(modf) (1.5, &intpart); |
1735 | check ("modf (1.5, &x) returns 0.5", result, 0.5); | |
1736 | check ("modf (1.5, &x) sets x to 1", intpart, 1); | |
1737 | ||
c57abfa7 UD |
1738 | result = FUNC(modf) (2.5, &intpart); |
1739 | check ("modf (2.5, &x) returns 0.5", result, 0.5); | |
1740 | check ("modf (2.5, &x) sets x to 2", intpart, 2); | |
1741 | ||
1742 | result = FUNC(modf) (-2.5, &intpart); | |
1743 | check ("modf (-2.5, &x) returns -0.5", result, -0.5); | |
1744 | check ("modf (-2.5, &x) sets x to -2", intpart, -2); | |
1745 | ||
af69217f UD |
1746 | result = FUNC(modf) (20, &intpart); |
1747 | check ("modf (20, &x) returns 0", result, 0); | |
1748 | check ("modf (20, &x) sets x to 20", intpart, 20); | |
1749 | ||
1750 | result = FUNC(modf) (21, &intpart); | |
1751 | check ("modf (21, &x) returns 0", result, 0); | |
1752 | check ("modf (21, &x) sets x to 21", intpart, 21); | |
241b119d UD |
1753 | |
1754 | result = FUNC(modf) (89.6, &intpart); | |
1755 | check_eps ("modf (89.6, &x) returns 0.6", result, 0.6, | |
1756 | CHOOSE(6e-15L, 6e-15, 2e-6)); | |
1757 | check ("modf (89.6, &x) sets x to 89", intpart, 89); | |
c57abfa7 UD |
1758 | } |
1759 | ||
1760 | ||
3e5f5557 UD |
1761 | static void |
1762 | scalb_test (void) | |
1763 | { | |
1764 | MATHTYPE x; | |
1765 | ||
d705269e UD |
1766 | check_isnan ("scalb (2, 0.5) == NaN", FUNC(scalb) (2, 0.5)); |
1767 | check_isnan ("scalb (3, -2.5) == NaN", FUNC(scalb) (3, -2.5)); | |
1768 | ||
1769 | check_isnan ("scalb (0, NaN) == NaN", FUNC(scalb) (0, nan_value)); | |
1770 | check_isnan ("scalb (1, NaN) == NaN", FUNC(scalb) (1, nan_value)); | |
1771 | ||
1772 | x = random_greater (0.0); | |
1773 | check ("scalb (x, 0) == 0", FUNC(scalb) (x, 0), x); | |
1774 | x = random_greater (0.0); | |
1775 | check ("scalb (-x, 0) == 0", FUNC(scalb) (-x, 0), -x); | |
1776 | ||
1777 | check_isnan_exc ("scalb (+0, +inf) == NaN plus invalid exception", | |
1778 | FUNC(scalb) (0, plus_infty), INVALID_EXCEPTION); | |
1779 | check_isnan_exc ("scalb (-0, +inf) == NaN plus invalid exception", | |
1780 | FUNC(scalb) (minus_zero, plus_infty), INVALID_EXCEPTION); | |
1781 | ||
1782 | check ("scalb (+0, 2) == +0", FUNC(scalb) (0, 2), 0); | |
1783 | check ("scalb (-0, 4) == -0", FUNC(scalb) (minus_zero, -4), minus_zero); | |
1784 | check ("scalb (+0, 0) == +0", FUNC(scalb) (0, 0), 0); | |
1785 | check ("scalb (-0, 0) == -0", FUNC(scalb) (minus_zero, 0), minus_zero); | |
1786 | check ("scalb (+0, -1) == +0", FUNC(scalb) (0, -1), 0); | |
1787 | check ("scalb (-0, -10) == -0", FUNC(scalb) (minus_zero, -10), minus_zero); | |
1788 | check ("scalb (+0, -inf) == +0", FUNC(scalb) (0, minus_infty), 0); | |
1789 | check ("scalb (-0, -inf) == -0", FUNC(scalb) (minus_zero, minus_infty), | |
1790 | minus_zero); | |
1791 | ||
1792 | check_isinfp ("scalb (+inf, -1) == +inf", FUNC(scalb) (plus_infty, -1)); | |
1793 | check_isinfn ("scalb (-inf, -10) == -inf", FUNC(scalb) (minus_infty, -10)); | |
1794 | check_isinfp ("scalb (+inf, 0) == +inf", FUNC(scalb) (plus_infty, 0)); | |
1795 | check_isinfn ("scalb (-inf, 0) == -inf", FUNC(scalb) (minus_infty, 0)); | |
1796 | check_isinfp ("scalb (+inf, 2) == +inf", FUNC(scalb) (plus_infty, 2)); | |
1797 | check_isinfn ("scalb (-inf, 100) == -inf", FUNC(scalb) (minus_infty, 100)); | |
1798 | ||
d705269e UD |
1799 | x = random_greater (0.0); |
1800 | check ("scalb (x, -inf) == 0", FUNC(scalb) (x, minus_infty), 0.0); | |
1801 | check ("scalb (-x, -inf) == -0", FUNC(scalb) (-x, minus_infty), minus_zero); | |
1802 | ||
1803 | x = random_greater (0.0); | |
1804 | check_isinfp ("scalb (x, +inf) == +inf", FUNC(scalb) (x, plus_infty)); | |
1805 | x = random_greater (0.0); | |
1806 | check_isinfn ("scalb (-x, +inf) == -inf", FUNC(scalb) (-x, plus_infty)); | |
1807 | check_isinfp ("scalb (+inf, +inf) == +inf", | |
1808 | FUNC(scalb) (plus_infty, plus_infty)); | |
1809 | check_isinfn ("scalb (-inf, +inf) == -inf", | |
1810 | FUNC(scalb) (minus_infty, plus_infty)); | |
1811 | ||
1812 | check_isnan ("scalb (+inf, -inf) == NaN", | |
1813 | FUNC(scalb) (plus_infty, minus_infty)); | |
1814 | check_isnan ("scalb (-inf, -inf) == NaN", | |
1815 | FUNC(scalb) (minus_infty, minus_infty)); | |
3e5f5557 | 1816 | |
3e5f5557 | 1817 | check_isnan ("scalb (NaN, 1) == NaN", FUNC(scalb) (nan_value, 1)); |
d705269e UD |
1818 | check_isnan ("scalb (1, NaN) == NaN", FUNC(scalb) (1, nan_value)); |
1819 | check_isnan ("scalb (NaN, 0) == NaN", FUNC(scalb) (nan_value, 0)); | |
1820 | check_isnan ("scalb (0, NaN) == NaN", FUNC(scalb) (0, nan_value)); | |
1821 | check_isnan ("scalb (NaN, +inf) == NaN", | |
1822 | FUNC(scalb) (nan_value, plus_infty)); | |
1823 | check_isnan ("scalb (+inf, NaN) == NaN", | |
1824 | FUNC(scalb) (plus_infty, nan_value)); | |
1825 | check_isnan ("scalb (NaN, NaN) == NaN", FUNC(scalb) (nan_value, nan_value)); | |
3e5f5557 UD |
1826 | |
1827 | check ("scalb (0.8, 4) == 12.8", FUNC(scalb) (0.8L, 4), 12.8L); | |
1828 | check ("scalb (-0.854375, 5) == -27.34", FUNC(scalb) (-0.854375L, 5), -27.34L); | |
3e5f5557 UD |
1829 | } |
1830 | ||
1831 | ||
1832 | static void | |
1833 | scalbn_test (void) | |
1834 | { | |
1835 | MATHTYPE x; | |
1836 | ||
1837 | check ("scalbn (0, 0) == 0", FUNC(scalbn) (0, 0), 0); | |
1838 | ||
1839 | check_isinfp ("scalbn (+inf, 1) == +inf", FUNC(scalbn) (plus_infty, 1)); | |
1840 | check_isinfn ("scalbn (-inf, 1) == -inf", FUNC(scalbn) (minus_infty, 1)); | |
1841 | check_isnan ("scalbn (NaN, 1) == NaN", FUNC(scalbn) (nan_value, 1)); | |
1842 | ||
1843 | check ("scalbn (0.8, 4) == 12.8", FUNC(scalbn) (0.8L, 4), 12.8L); | |
1844 | check ("scalbn (-0.854375, 5) == -27.34", FUNC(scalbn) (-0.854375L, 5), -27.34L); | |
1845 | ||
1846 | x = random_greater (0.0); | |
1847 | check_ext ("scalbn (x, 0) == x", FUNC(scalbn) (x, 0L), x, x); | |
1848 | } | |
1849 | ||
1850 | ||
0d8733c4 UD |
1851 | static void |
1852 | sin_test (void) | |
1853 | { | |
1854 | check ("sin (+0) == +0", FUNC(sin) (0), 0); | |
1855 | check ("sin (-0) == -0", FUNC(sin) (minus_zero), minus_zero); | |
1856 | check_isnan_exc ("sin (+inf) == NaN plus invalid exception", | |
1857 | FUNC(sin) (plus_infty), | |
1858 | INVALID_EXCEPTION); | |
1859 | check_isnan_exc ("sin (-inf) == NaN plus invalid exception", | |
1860 | FUNC(sin) (minus_infty), | |
1861 | INVALID_EXCEPTION); | |
1862 | ||
0a614877 | 1863 | check_eps ("sin (pi/6) == 0.5", FUNC(sin) (M_PI_6l), |
cbdee279 | 1864 | 0.5, CHOOSE (4e-18L, 0, 0)); |
0a614877 | 1865 | check_eps ("sin (-pi/6) == -0.5", FUNC(sin) (-M_PI_6l), |
cbdee279 | 1866 | -0.5, CHOOSE (4e-18L, 0, 0)); |
0a614877 UD |
1867 | check ("sin (pi/2) == 1", FUNC(sin) (M_PI_2l), 1); |
1868 | check ("sin (-pi/2) == -1", FUNC(sin) (-M_PI_2l), -1); | |
bd355af0 UD |
1869 | check_eps ("sin (0.7) == 0.6442176872...", FUNC(sin) (0.7), |
1870 | 0.64421768723769105367L, CHOOSE(4e-17L, 0, 0)); | |
0d8733c4 UD |
1871 | } |
1872 | ||
1873 | ||
1874 | static void | |
1875 | sinh_test (void) | |
1876 | { | |
1877 | check ("sinh (+0) == +0", FUNC(sinh) (0), 0); | |
76b87c03 UD |
1878 | |
1879 | #ifndef TEST_INLINE | |
0d8733c4 UD |
1880 | check ("sinh (-0) == -0", FUNC(sinh) (minus_zero), minus_zero); |
1881 | ||
1882 | check_isinfp ("sinh (+inf) == +inf", FUNC(sinh) (plus_infty)); | |
1883 | check_isinfn ("sinh (-inf) == -inf", FUNC(sinh) (minus_infty)); | |
76b87c03 | 1884 | #endif |
bd355af0 UD |
1885 | |
1886 | check_eps ("sinh (0.7) == 0.7585837018...", FUNC(sinh) (0.7), | |
66000494 | 1887 | 0.75858370183953350346L, CHOOSE(6e-17L, 2e-16, 6e-8)); |
0d8733c4 UD |
1888 | } |
1889 | ||
1890 | ||
900bec85 UD |
1891 | static void |
1892 | sincos_test (void) | |
1893 | { | |
1894 | MATHTYPE sin_res, cos_res; | |
1895 | fenv_t fenv; | |
e7f1f046 | 1896 | |
900bec85 UD |
1897 | FUNC(sincos) (0, &sin_res, &cos_res); |
1898 | fegetenv (&fenv); | |
1899 | check ("sincos (+0, &sin, &cos) puts +0 in sin", sin_res, 0); | |
1900 | fesetenv (&fenv); | |
1901 | check ("sincos (+0, &sin, &cos) puts 1 in cos", cos_res, 1); | |
1902 | ||
e7f1f046 | 1903 | FUNC(sincos) (minus_zero, &sin_res, &cos_res); |
900bec85 UD |
1904 | fegetenv (&fenv); |
1905 | check ("sincos (-0, &sin, &cos) puts -0 in sin", sin_res, minus_zero); | |
1906 | fesetenv (&fenv); | |
1907 | check ("sincos (-0, &sin, &cos) puts 1 in cos", cos_res, 1); | |
1908 | ||
1909 | FUNC(sincos) (plus_infty, &sin_res, &cos_res); | |
1910 | fegetenv (&fenv); | |
1911 | check_isnan_exc ("sincos (+inf, &sin, &cos) puts NaN in sin plus invalid exception", | |
1912 | sin_res, INVALID_EXCEPTION); | |
1913 | fesetenv (&fenv); | |
1914 | check_isnan_exc ("sincos (+inf, &sin, &cos) puts NaN in cos plus invalid exception", | |
1915 | cos_res, INVALID_EXCEPTION); | |
1916 | ||
1917 | FUNC(sincos) (minus_infty, &sin_res, &cos_res); | |
1918 | fegetenv (&fenv); | |
1919 | check_isnan_exc ("sincos (-inf,&sin, &cos) puts NaN in sin plus invalid exception", | |
1920 | sin_res, INVALID_EXCEPTION); | |
1921 | fesetenv (&fenv); | |
1922 | check_isnan_exc ("sincos (-inf,&sin, &cos) puts NaN in cos plus invalid exception", | |
1923 | cos_res, INVALID_EXCEPTION); | |
1924 | ||
0a614877 | 1925 | FUNC(sincos) (M_PI_2l, &sin_res, &cos_res); |
900bec85 UD |
1926 | fegetenv (&fenv); |
1927 | check ("sincos (pi/2, &sin, &cos) puts 1 in sin", sin_res, 1); | |
1928 | fesetenv (&fenv); | |
1929 | check_eps ("sincos (pi/2, &sin, &cos) puts 0 in cos", cos_res, 0, | |
d705269e | 1930 | CHOOSE (1e-18L, 1e-16, 1e-7)); |
900bec85 | 1931 | |
0a614877 | 1932 | FUNC(sincos) (M_PI_6l, &sin_res, &cos_res); |
d705269e UD |
1933 | check_eps ("sincos (pi/6, &sin, &cos) puts 0.5 in sin", sin_res, 0.5, |
1934 | CHOOSE (5e-18L, 0, 0)); | |
900bec85 | 1935 | |
0a614877 | 1936 | FUNC(sincos) (M_PI_6l*2.0, &sin_res, &cos_res); |
900bec85 | 1937 | check_eps ("sincos (pi/3, &sin, &cos) puts 0.5 in cos", cos_res, 0.5, |
d705269e | 1938 | CHOOSE (5e-18L, 1e-15, 1e-7)); |
900bec85 | 1939 | |
bd355af0 UD |
1940 | FUNC(sincos) (0.7, &sin_res, &cos_res); |
1941 | check_eps ("sincos (0.7, &sin, &cos) puts 0.6442176872... in sin", sin_res, | |
1942 | 0.64421768723769105367L, CHOOSE(4e-17L, 0, 0)); | |
1943 | check_eps ("sincos (0.7, &sin, &cos) puts 0.7648421872... in cos", cos_res, | |
66000494 | 1944 | 0.76484218728448842626L, CHOOSE(3e-17L, 2e-16, 6e-8)); |
900bec85 UD |
1945 | } |
1946 | ||
1947 | ||
0d8733c4 UD |
1948 | static void |
1949 | tan_test (void) | |
1950 | { | |
3e5f5557 | 1951 | check ("tan (+0) == +0", FUNC(tan) (0), 0); |
0d8733c4 UD |
1952 | check ("tan (-0) == -0", FUNC(tan) (minus_zero), minus_zero); |
1953 | check_isnan_exc ("tan (+inf) == NaN plus invalid exception", | |
1954 | FUNC(tan) (plus_infty), INVALID_EXCEPTION); | |
1955 | check_isnan_exc ("tan (-inf) == NaN plus invalid exception", | |
1956 | FUNC(tan) (minus_infty), INVALID_EXCEPTION); | |
1957 | ||
0a614877 | 1958 | check_eps ("tan (pi/4) == 1", FUNC(tan) (M_PI_4l), 1, |
6973fc01 | 1959 | CHOOSE (2e-18L, 1e-15L, 2e-7)); |
bd355af0 UD |
1960 | check_eps ("tan (0.7) == 0.8422883804...", FUNC(tan) (0.7), |
1961 | 0.84228838046307944813L, CHOOSE(8e-17L, 0, 0)); | |
0d8733c4 UD |
1962 | } |
1963 | ||
1964 | ||
1965 | static void | |
1966 | tanh_test (void) | |
1967 | { | |
1968 | check ("tanh (+0) == +0", FUNC(tanh) (0), 0); | |
76b87c03 | 1969 | #ifndef TEST_INLINE |
0d8733c4 UD |
1970 | check ("tanh (-0) == -0", FUNC(tanh) (minus_zero), minus_zero); |
1971 | ||
1972 | check ("tanh (+inf) == +1", FUNC(tanh) (plus_infty), 1); | |
1973 | check ("tanh (-inf) == -1", FUNC(tanh) (minus_infty), -1); | |
76b87c03 | 1974 | #endif |
bd355af0 | 1975 | check_eps ("tanh (0.7) == 0.6043677771...", FUNC(tanh) (0.7), |
66000494 | 1976 | 0.60436777711716349631L, CHOOSE(3e-17L, 2e-16, 6e-8)); |
0d8733c4 UD |
1977 | } |
1978 | ||
1979 | ||
1980 | static void | |
1981 | fabs_test (void) | |
1982 | { | |
1983 | check ("fabs (+0) == +0", FUNC(fabs) (0), 0); | |
1984 | check ("fabs (-0) == +0", FUNC(fabs) (minus_zero), 0); | |
1985 | ||
1986 | check_isinfp ("fabs (+inf) == +inf", FUNC(fabs) (plus_infty)); | |
1987 | check_isinfp ("fabs (-inf) == +inf", FUNC(fabs) (minus_infty)); | |
1988 | ||
1989 | check ("fabs (+38) == 38", FUNC(fabs) (38.0), 38.0); | |
0a614877 | 1990 | check ("fabs (-e) == e", FUNC(fabs) (-M_El), M_El); |
0d8733c4 UD |
1991 | } |
1992 | ||
1993 | ||
1994 | static void | |
1995 | floor_test (void) | |
1996 | { | |
1997 | check ("floor (+0) == +0", FUNC(floor) (0.0), 0.0); | |
1998 | check ("floor (-0) == -0", FUNC(floor) (minus_zero), minus_zero); | |
1999 | check_isinfp ("floor (+inf) == +inf", FUNC(floor) (plus_infty)); | |
2000 | check_isinfn ("floor (-inf) == -inf", FUNC(floor) (minus_infty)); | |
2001 | ||
0a614877 UD |
2002 | check ("floor (pi) == 3", FUNC(floor) (M_PIl), 3.0); |
2003 | check ("floor (-pi) == -4", FUNC(floor) (-M_PIl), -4.0); | |
0d8733c4 UD |
2004 | } |
2005 | ||
2006 | ||
2007 | static void | |
c57abfa7 | 2008 | hypot_test (void) |
0d8733c4 | 2009 | { |
c57abfa7 | 2010 | MATHTYPE a; |
0d8733c4 | 2011 | |
c57abfa7 UD |
2012 | a = random_greater (0); |
2013 | check_isinfp_ext ("hypot (+inf, x) == +inf", FUNC(hypot) (plus_infty, a), a); | |
2014 | check_isinfp_ext ("hypot (-inf, x) == +inf", FUNC(hypot) (minus_infty, a), a); | |
0d8733c4 | 2015 | |
900bec85 | 2016 | #ifndef TEST_INLINE |
9639d014 | 2017 | check_isinfp ("hypot (+inf, NaN) == +inf", FUNC(hypot) (plus_infty, nan_value)); |
900bec85 UD |
2018 | check_isinfp ("hypot (-inf, NaN) == +inf", FUNC(hypot) (minus_infty, nan_value)); |
2019 | #endif | |
e7f1f046 | 2020 | |
c57abfa7 | 2021 | check_isnan ("hypot (NaN, NaN) == NaN", FUNC(hypot) (nan_value, nan_value)); |
0d8733c4 | 2022 | |
c57abfa7 UD |
2023 | a = FUNC(hypot) (12.4L, 0.7L); |
2024 | check ("hypot (x,y) == hypot (y,x)", FUNC(hypot) (0.7L, 12.4L), a); | |
2025 | check ("hypot (x,y) == hypot (-x,y)", FUNC(hypot) (-12.4L, 0.7L), a); | |
2026 | check ("hypot (x,y) == hypot (-y,x)", FUNC(hypot) (-0.7L, 12.4L), a); | |
2027 | check ("hypot (x,y) == hypot (-x,-y)", FUNC(hypot) (-12.4L, -0.7L), a); | |
2028 | check ("hypot (x,y) == hypot (-y,-x)", FUNC(hypot) (-0.7L, -12.4L), a); | |
0d8733c4 UD |
2029 | check ("hypot (x,0) == fabs (x)", FUNC(hypot) (-0.7L, 0), 0.7L); |
2030 | check ("hypot (x,0) == fabs (x)", FUNC(hypot) (0.7L, 0), 0.7L); | |
2031 | check ("hypot (x,0) == fabs (x)", FUNC(hypot) (-1.0L, 0), 1.0L); | |
c57abfa7 | 2032 | check ("hypot (x,0) == fabs (x)", FUNC(hypot) (1.0L, 0), 1.0L); |
0d8733c4 | 2033 | check ("hypot (x,0) == fabs (x)", FUNC(hypot) (-5.7e7L, 0), 5.7e7L); |
c57abfa7 | 2034 | check ("hypot (x,0) == fabs (x)", FUNC(hypot) (5.7e7L, 0), 5.7e7L); |
9756dfe1 UD |
2035 | |
2036 | check_eps ("hypot (0.7,1.2) == 1.38924...", FUNC(hypot) (0.7, 1.2), | |
2037 | 1.3892443989449804508L, CHOOSE(7e-17L, 3e-16, 0)); | |
0d8733c4 UD |
2038 | } |
2039 | ||
2040 | ||
2041 | static void | |
2042 | pow_test (void) | |
2043 | { | |
2044 | MATHTYPE x; | |
2045 | ||
2046 | check ("pow (+0, +0) == 1", FUNC(pow) (0, 0), 1); | |
2047 | check ("pow (+0, -0) == 1", FUNC(pow) (0, minus_zero), 1); | |
2048 | check ("pow (-0, +0) == 1", FUNC(pow) (minus_zero, 0), 1); | |
2049 | check ("pow (-0, -0) == 1", FUNC(pow) (minus_zero, minus_zero), 1); | |
2050 | ||
2051 | check ("pow (+10, +0) == 1", FUNC(pow) (10, 0), 1); | |
2052 | check ("pow (+10, -0) == 1", FUNC(pow) (10, minus_zero), 1); | |
2053 | check ("pow (-10, +0) == 1", FUNC(pow) (-10, 0), 1); | |
2054 | check ("pow (-10, -0) == 1", FUNC(pow) (-10, minus_zero), 1); | |
2055 | ||
2056 | check ("pow (NaN, +0) == 1", FUNC(pow) (nan_value, 0), 1); | |
2057 | check ("pow (NaN, -0) == 1", FUNC(pow) (nan_value, minus_zero), 1); | |
2058 | ||
76b87c03 | 2059 | #ifndef TEST_INLINE |
0d8733c4 UD |
2060 | check_isinfp ("pow (+1.1, +inf) == +inf", FUNC(pow) (1.1, plus_infty)); |
2061 | check_isinfp ("pow (+inf, +inf) == +inf", FUNC(pow) (plus_infty, plus_infty)); | |
2062 | check_isinfp ("pow (-1.1, +inf) == +inf", FUNC(pow) (-1.1, plus_infty)); | |
2063 | check_isinfp ("pow (-inf, +inf) == +inf", FUNC(pow) (minus_infty, plus_infty)); | |
2064 | ||
2065 | check ("pow (0.9, +inf) == +0", FUNC(pow) (0.9L, plus_infty), 0); | |
2066 | check ("pow (1e-7, +inf) == +0", FUNC(pow) (1e-7L, plus_infty), 0); | |
2067 | check ("pow (-0.9, +inf) == +0", FUNC(pow) (-0.9L, plus_infty), 0); | |
2068 | check ("pow (-1e-7, +inf) == +0", FUNC(pow) (-1e-7L, plus_infty), 0); | |
2069 | ||
3e5f5557 UD |
2070 | check ("pow (+1.1, -inf) == 0", FUNC(pow) (1.1, minus_infty), 0); |
2071 | check ("pow (+inf, -inf) == 0", FUNC(pow) (plus_infty, minus_infty), 0); | |
2072 | check ("pow (-1.1, -inf) == 0", FUNC(pow) (-1.1, minus_infty), 0); | |
2073 | check ("pow (-inf, -inf) == 0", FUNC(pow) (minus_infty, minus_infty), 0); | |
0d8733c4 | 2074 | |
3e5f5557 UD |
2075 | check_isinfp ("pow (0.9, -inf) == +inf", FUNC(pow) (0.9L, minus_infty)); |
2076 | check_isinfp ("pow (1e-7, -inf) == +inf", FUNC(pow) (1e-7L, minus_infty)); | |
2077 | check_isinfp ("pow (-0.9, -inf) == +inf", FUNC(pow) (-0.9L, minus_infty)); | |
2078 | check_isinfp ("pow (-1e-7, -inf) == +inf", FUNC(pow) (-1e-7L, minus_infty)); | |
0d8733c4 UD |
2079 | |
2080 | check_isinfp ("pow (+inf, 1e-7) == +inf", FUNC(pow) (plus_infty, 1e-7L)); | |
2081 | check_isinfp ("pow (+inf, 1) == +inf", FUNC(pow) (plus_infty, 1)); | |
2082 | check_isinfp ("pow (+inf, 1e7) == +inf", FUNC(pow) (plus_infty, 1e7L)); | |
2083 | ||
2084 | check ("pow (+inf, -1e-7) == 0", FUNC(pow) (plus_infty, -1e-7L), 0); | |
2085 | check ("pow (+inf, -1) == 0", FUNC(pow) (plus_infty, -1), 0); | |
2086 | check ("pow (+inf, -1e7) == 0", FUNC(pow) (plus_infty, -1e7L), 0); | |
2087 | ||
2088 | check_isinfn ("pow (-inf, 1) == -inf", FUNC(pow) (minus_infty, 1)); | |
2089 | check_isinfn ("pow (-inf, 11) == -inf", FUNC(pow) (minus_infty, 11)); | |
2090 | check_isinfn ("pow (-inf, 1001) == -inf", FUNC(pow) (minus_infty, 1001)); | |
2091 | ||
2092 | check_isinfp ("pow (-inf, 2) == +inf", FUNC(pow) (minus_infty, 2)); | |
2093 | check_isinfp ("pow (-inf, 12) == +inf", FUNC(pow) (minus_infty, 12)); | |
2094 | check_isinfp ("pow (-inf, 1002) == +inf", FUNC(pow) (minus_infty, 1002)); | |
2095 | check_isinfp ("pow (-inf, 0.1) == +inf", FUNC(pow) (minus_infty, 0.1)); | |
2096 | check_isinfp ("pow (-inf, 1.1) == +inf", FUNC(pow) (minus_infty, 1.1)); | |
2097 | check_isinfp ("pow (-inf, 11.1) == +inf", FUNC(pow) (minus_infty, 11.1)); | |
2098 | check_isinfp ("pow (-inf, 1001.1) == +inf", FUNC(pow) (minus_infty, 1001.1)); | |
2099 | ||
c57abfa7 UD |
2100 | check ("pow (-inf, -1) == -0", FUNC(pow) (minus_infty, -1), minus_zero); |
2101 | check ("pow (-inf, -11) == -0", FUNC(pow) (minus_infty, -11), minus_zero); | |
2102 | check ("pow (-inf, -1001) == -0", FUNC(pow) (minus_infty, -1001), minus_zero); | |
0d8733c4 UD |
2103 | |
2104 | check ("pow (-inf, -2) == +0", FUNC(pow) (minus_infty, -2), 0); | |
2105 | check ("pow (-inf, -12) == +0", FUNC(pow) (minus_infty, -12), 0); | |
2106 | check ("pow (-inf, -1002) == +0", FUNC(pow) (minus_infty, -1002), 0); | |
2107 | check ("pow (-inf, -0.1) == +0", FUNC(pow) (minus_infty, -0.1), 0); | |
2108 | check ("pow (-inf, -1.1) == +0", FUNC(pow) (minus_infty, -1.1), 0); | |
2109 | check ("pow (-inf, -11.1) == +0", FUNC(pow) (minus_infty, -11.1), 0); | |
2110 | check ("pow (-inf, -1001.1) == +0", FUNC(pow) (minus_infty, -1001.1), 0); | |
2111 | ||
2112 | check_isnan ("pow (NaN, NaN) == NaN", FUNC(pow) (nan_value, nan_value)); | |
2113 | check_isnan ("pow (0, NaN) == NaN", FUNC(pow) (0, nan_value)); | |
2114 | check_isnan ("pow (1, NaN) == NaN", FUNC(pow) (1, nan_value)); | |
2115 | check_isnan ("pow (-1, NaN) == NaN", FUNC(pow) (-1, nan_value)); | |
2116 | check_isnan ("pow (NaN, 1) == NaN", FUNC(pow) (nan_value, 1)); | |
2117 | check_isnan ("pow (NaN, -1) == NaN", FUNC(pow) (nan_value, -1)); | |
2118 | ||
2119 | x = random_greater (0.0); | |
2120 | check_isnan_ext ("pow (x, NaN) == NaN", FUNC(pow) (x, nan_value), x); | |
2121 | ||
779ae82e UD |
2122 | check_isnan_exc ("pow (+1, +inf) == NaN plus invalid exception", |
2123 | FUNC(pow) (1, plus_infty), INVALID_EXCEPTION); | |
2124 | check_isnan_exc ("pow (-1, +inf) == NaN plus invalid exception", | |
2125 | FUNC(pow) (-1, plus_infty), INVALID_EXCEPTION); | |
2126 | check_isnan_exc ("pow (+1, -inf) == NaN plus invalid exception", | |
2127 | FUNC(pow) (1, minus_infty), INVALID_EXCEPTION); | |
2128 | check_isnan_exc ("pow (-1, -inf) == NaN plus invalid exception", | |
2129 | FUNC(pow) (-1, minus_infty), INVALID_EXCEPTION); | |
2130 | ||
2131 | check_isnan_exc ("pow (-0.1, 1.1) == NaN plus invalid exception", | |
2132 | FUNC(pow) (-0.1, 1.1), INVALID_EXCEPTION); | |
2133 | check_isnan_exc ("pow (-0.1, -1.1) == NaN plus invalid exception", | |
2134 | FUNC(pow) (-0.1, -1.1), INVALID_EXCEPTION); | |
2135 | check_isnan_exc ("pow (-10.1, 1.1) == NaN plus invalid exception", | |
2136 | FUNC(pow) (-10.1, 1.1), INVALID_EXCEPTION); | |
2137 | check_isnan_exc ("pow (-10.1, -1.1) == NaN plus invalid exception", | |
2138 | FUNC(pow) (-10.1, -1.1), INVALID_EXCEPTION); | |
2139 | ||
2140 | check_isinfp_exc ("pow (+0, -1) == +inf plus divide-by-zero exception", | |
2141 | FUNC(pow) (0, -1), DIVIDE_BY_ZERO_EXCEPTION); | |
2142 | check_isinfp_exc ("pow (+0, -11) == +inf plus divide-by-zero exception", | |
2143 | FUNC(pow) (0, -11), DIVIDE_BY_ZERO_EXCEPTION); | |
2144 | check_isinfn_exc ("pow (-0, -1) == -inf plus divide-by-zero exception", | |
2145 | FUNC(pow) (minus_zero, -1), DIVIDE_BY_ZERO_EXCEPTION); | |
2146 | check_isinfn_exc ("pow (-0, -11) == -inf plus divide-by-zero exception", | |
2147 | FUNC(pow) (minus_zero, -11), DIVIDE_BY_ZERO_EXCEPTION); | |
2148 | ||
2149 | check_isinfp_exc ("pow (+0, -2) == +inf plus divide-by-zero exception", | |
2150 | FUNC(pow) (0, -2), DIVIDE_BY_ZERO_EXCEPTION); | |
2151 | check_isinfp_exc ("pow (+0, -11.1) == +inf plus divide-by-zero exception", | |
2152 | FUNC(pow) (0, -11.1), DIVIDE_BY_ZERO_EXCEPTION); | |
2153 | check_isinfp_exc ("pow (-0, -2) == +inf plus divide-by-zero exception", | |
2154 | FUNC(pow) (minus_zero, -2), DIVIDE_BY_ZERO_EXCEPTION); | |
2155 | check_isinfp_exc ("pow (-0, -11.1) == +inf plus divide-by-zero exception", | |
2156 | FUNC(pow) (minus_zero, -11.1), DIVIDE_BY_ZERO_EXCEPTION); | |
76b87c03 | 2157 | #endif |
0d8733c4 UD |
2158 | |
2159 | check ("pow (+0, 1) == +0", FUNC(pow) (0, 1), 0); | |
2160 | check ("pow (+0, 11) == +0", FUNC(pow) (0, 11), 0); | |
76b87c03 | 2161 | #ifndef TEST_INLINE |
0d8733c4 UD |
2162 | check ("pow (-0, 1) == -0", FUNC(pow) (minus_zero, 1), minus_zero); |
2163 | check ("pow (-0, 11) == -0", FUNC(pow) (minus_zero, 11), minus_zero); | |
76b87c03 | 2164 | #endif |
0d8733c4 UD |
2165 | |
2166 | check ("pow (+0, 2) == +0", FUNC(pow) (0, 2), 0); | |
2167 | check ("pow (+0, 11.1) == +0", FUNC(pow) (0, 11.1), 0); | |
76b87c03 UD |
2168 | |
2169 | #ifndef TEST_INLINE | |
0d8733c4 UD |
2170 | check ("pow (-0, 2) == +0", FUNC(pow) (minus_zero, 2), 0); |
2171 | check ("pow (-0, 11.1) == +0", FUNC(pow) (minus_zero, 11.1), 0); | |
2172 | ||
3e5f5557 | 2173 | x = random_greater (1.0); |
0d8733c4 UD |
2174 | check_isinfp_ext ("pow (x, +inf) == +inf for |x| > 1", |
2175 | FUNC(pow) (x, plus_infty), x); | |
2176 | ||
2177 | x = random_value (-1.0, 1.0); | |
2178 | check_ext ("pow (x, +inf) == +0 for |x| < 1", | |
76b87c03 | 2179 | FUNC(pow) (x, plus_infty), 0.0, x); |
0d8733c4 | 2180 | |
3e5f5557 | 2181 | x = random_greater (1.0); |
0d8733c4 | 2182 | check_ext ("pow (x, -inf) == +0 for |x| > 1", |
76b87c03 | 2183 | FUNC(pow) (x, minus_infty), 0.0, x); |
0d8733c4 UD |
2184 | |
2185 | x = random_value (-1.0, 1.0); | |
2186 | check_isinfp_ext ("pow (x, -inf) == +inf for |x| < 1", | |
2187 | FUNC(pow) (x, minus_infty), x); | |
2188 | ||
2189 | x = random_greater (0.0); | |
2190 | check_isinfp_ext ("pow (+inf, y) == +inf for y > 0", | |
2191 | FUNC(pow) (plus_infty, x), x); | |
2192 | ||
2193 | x = random_less (0.0); | |
2194 | check_ext ("pow (+inf, y) == +0 for y < 0", | |
2195 | FUNC(pow) (plus_infty, x), 0.0, x); | |
2196 | ||
2197 | x = (rand () % 1000000) * 2.0 + 1; /* Get random odd integer > 0 */ | |
2198 | check_isinfn_ext ("pow (-inf, y) == -inf for y an odd integer > 0", | |
2199 | FUNC(pow) (minus_infty, x), x); | |
2200 | ||
2201 | x = ((rand () % 1000000) + 1) * 2.0; /* Get random even integer > 1 */ | |
2202 | check_isinfp_ext ("pow (-inf, y) == +inf for y > 0 and not an odd integer", | |
2203 | FUNC(pow) (minus_infty, x), x); | |
2204 | ||
2205 | x = -((rand () % 1000000) * 2.0 + 1); /* Get random odd integer < 0 */ | |
2206 | check_ext ("pow (-inf, y) == -0 for y an odd integer < 0", | |
2207 | FUNC(pow) (minus_infty, x), minus_zero, x); | |
2208 | ||
2209 | x = ((rand () % 1000000) + 1) * -2.0; /* Get random even integer < 0 */ | |
3e5f5557 | 2210 | check_ext ("pow (-inf, y) == +0 for y < 0 and not an odd integer", |
c57abfa7 | 2211 | FUNC(pow) (minus_infty, x), 0.0, x); |
76b87c03 | 2212 | #endif |
0d8733c4 UD |
2213 | |
2214 | x = (rand () % 1000000) * 2.0 + 1; /* Get random odd integer > 0 */ | |
2215 | check_ext ("pow (+0, y) == +0 for y an odd integer > 0", | |
2216 | FUNC(pow) (0.0, x), 0.0, x); | |
76b87c03 | 2217 | #ifndef TEST_INLINE |
0d8733c4 UD |
2218 | x = (rand () % 1000000) * 2.0 + 1; /* Get random odd integer > 0 */ |
2219 | check_ext ("pow (-0, y) == -0 for y an odd integer > 0", | |
2220 | FUNC(pow) (minus_zero, x), minus_zero, x); | |
76b87c03 | 2221 | #endif |
0d8733c4 UD |
2222 | |
2223 | x = ((rand () % 1000000) + 1) * 2.0; /* Get random even integer > 1 */ | |
2224 | check_ext ("pow (+0, y) == +0 for y > 0 and not an odd integer", | |
2225 | FUNC(pow) (0.0, x), 0.0, x); | |
2226 | ||
2227 | x = ((rand () % 1000000) + 1) * 2.0; /* Get random even integer > 1 */ | |
2228 | check_ext ("pow (-0, y) == +0 for y > 0 and not an odd integer", | |
2229 | FUNC(pow) (minus_zero, x), 0.0, x); | |
9756dfe1 UD |
2230 | |
2231 | check_eps ("pow (0.7, 1.2) == 0.65180...", FUNC(pow) (0.7, 1.2), | |
2232 | 0.65180494056638638188L, CHOOSE(4e-17L, 0, 0)); | |
b22fc5f5 UD |
2233 | |
2234 | #ifdef TEST_DOUBLE | |
2235 | check ("pow (-7.49321e+133, -9.80818e+16) == 0", | |
2236 | FUNC(pow) (-7.49321e+133, -9.80818e+16), 0); | |
2237 | #endif | |
0d8733c4 UD |
2238 | } |
2239 | ||
2240 | ||
bc9f6000 UD |
2241 | static void |
2242 | fdim_test (void) | |
2243 | { | |
2244 | check ("fdim (+0, +0) = +0", FUNC(fdim) (0, 0), 0); | |
2245 | check ("fdim (9, 0) = 9", FUNC(fdim) (9, 0), 9); | |
2246 | check ("fdim (0, 9) = 0", FUNC(fdim) (0, 9), 0); | |
2247 | check ("fdim (-9, 0) = 9", FUNC(fdim) (-9, 0), 0); | |
2248 | check ("fdim (0, -9) = 9", FUNC(fdim) (0, -9), 9); | |
2249 | ||
2250 | check_isinfp ("fdim (+inf, 9) = +inf", FUNC(fdim) (plus_infty, 9)); | |
2251 | check_isinfp ("fdim (+inf, -9) = +inf", FUNC(fdim) (plus_infty, -9)); | |
2252 | check ("fdim (-inf, 9) = 0", FUNC(fdim) (minus_infty, 9), 0); | |
2253 | check ("fdim (-inf, -9) = 0", FUNC(fdim) (minus_infty, -9), 0); | |
2254 | check_isinfp ("fdim (+9, -inf) = +inf", FUNC(fdim) (9, minus_infty)); | |
2255 | check_isinfp ("fdim (-9, -inf) = +inf", FUNC(fdim) (-9, minus_infty)); | |
2256 | check ("fdim (9, inf) = 0", FUNC(fdim) (9, plus_infty), 0); | |
2257 | check ("fdim (-9, inf) = 0", FUNC(fdim) (-9, plus_infty), 0); | |
2258 | ||
2259 | check_isnan ("fdim (0, NaN) = NaN", FUNC(fdim) (0, nan_value)); | |
2260 | check_isnan ("fdim (9, NaN) = NaN", FUNC(fdim) (9, nan_value)); | |
2261 | check_isnan ("fdim (-9, NaN) = NaN", FUNC(fdim) (-9, nan_value)); | |
2262 | check_isnan ("fdim (NaN, 9) = NaN", FUNC(fdim) (nan_value, 9)); | |
2263 | check_isnan ("fdim (NaN, -9) = NaN", FUNC(fdim) (nan_value, -9)); | |
2264 | check_isnan ("fdim (+inf, NaN) = NaN", FUNC(fdim) (plus_infty, nan_value)); | |
2265 | check_isnan ("fdim (-inf, NaN) = NaN", FUNC(fdim) (minus_infty, nan_value)); | |
2266 | check_isnan ("fdim (NaN, +inf) = NaN", FUNC(fdim) (nan_value, plus_infty)); | |
2267 | check_isnan ("fdim (NaN, -inf) = NaN", FUNC(fdim) (nan_value, minus_infty)); | |
2268 | check_isnan ("fdim (NaN, NaN) = NaN", FUNC(fdim) (nan_value, nan_value)); | |
2269 | } | |
2270 | ||
2271 | ||
2272 | static void | |
2273 | fmin_test (void) | |
2274 | { | |
2275 | check ("fmin (+0, +0) = +0", FUNC(fmin) (0, 0), 0); | |
2276 | check ("fmin (9, 0) = 0", FUNC(fmin) (9, 0), 0); | |
2277 | check ("fmin (0, 9) = 0", FUNC(fmin) (0, 9), 0); | |
2278 | check ("fmin (-9, 0) = -9", FUNC(fmin) (-9, 0), -9); | |
2279 | check ("fmin (0, -9) = -9", FUNC(fmin) (0, -9), -9); | |
2280 | ||
2281 | check ("fmin (+inf, 9) = 9", FUNC(fmin) (plus_infty, 9), 9); | |
2282 | check ("fmin (9, +inf) = 9", FUNC(fmin) (9, plus_infty), 9); | |
2283 | check ("fmin (+inf, -9) = -9", FUNC(fmin) (plus_infty, -9), -9); | |
2284 | check ("fmin (-9, +inf) = -9", FUNC(fmin) (-9, plus_infty), -9); | |
2285 | check_isinfn ("fmin (-inf, 9) = -inf", FUNC(fmin) (minus_infty, 9)); | |
2286 | check_isinfn ("fmin (-inf, -9) = -inf", FUNC(fmin) (minus_infty, -9)); | |
2287 | check_isinfn ("fmin (+9, -inf) = -inf", FUNC(fmin) (9, minus_infty)); | |
2288 | check_isinfn ("fmin (-9, -inf) = -inf", FUNC(fmin) (-9, minus_infty)); | |
2289 | ||
2290 | check ("fmin (0, NaN) = 0", FUNC(fmin) (0, nan_value), 0); | |
2291 | check ("fmin (9, NaN) = 9", FUNC(fmin) (9, nan_value), 9); | |
2292 | check ("fmin (-9, NaN) = 9", FUNC(fmin) (-9, nan_value), -9); | |
2293 | check ("fmin (NaN, 0) = 0", FUNC(fmin) (nan_value, 0), 0); | |
2294 | check ("fmin (NaN, 9) = NaN", FUNC(fmin) (nan_value, 9), 9); | |
2295 | check ("fmin (NaN, -9) = NaN", FUNC(fmin) (nan_value, -9), -9); | |
2296 | check_isinfp ("fmin (+inf, NaN) = +inf", FUNC(fmin) (plus_infty, nan_value)); | |
2297 | check_isinfn ("fmin (-inf, NaN) = -inf", FUNC(fmin) (minus_infty, nan_value)); | |
2298 | check_isinfp ("fmin (NaN, +inf) = +inf", FUNC(fmin) (nan_value, plus_infty)); | |
2299 | check_isinfn ("fmin (NaN, -inf) = -inf", FUNC(fmin) (nan_value, minus_infty)); | |
2300 | check_isnan ("fmin (NaN, NaN) = NaN", FUNC(fmin) (nan_value, nan_value)); | |
2301 | } | |
2302 | ||
2303 | ||
2304 | static void | |
2305 | fmax_test (void) | |
2306 | { | |
2307 | check ("fmax (+0, +0) = +0", FUNC(fmax) (0, 0), 0); | |
2308 | check ("fmax (9, 0) = 9", FUNC(fmax) (9, 0), 9); | |
2309 | check ("fmax (0, 9) = 9", FUNC(fmax) (0, 9), 9); | |
2310 | check ("fmax (-9, 0) = 0", FUNC(fmax) (-9, 0), 0); | |
2311 | check ("fmax (0, -9) = 0", FUNC(fmax) (0, -9), 0); | |
2312 | ||
2313 | check_isinfp ("fmax (+inf, 9) = +inf", FUNC(fmax) (plus_infty, 9)); | |
2314 | check_isinfp ("fmax (9, +inf) = +inf", FUNC(fmax) (0, plus_infty)); | |
2315 | check_isinfp ("fmax (-9, +inf) = +inf", FUNC(fmax) (-9, plus_infty)); | |
2316 | check_isinfp ("fmax (+inf, -9) = +inf", FUNC(fmax) (plus_infty, -9)); | |
2317 | check ("fmax (-inf, 9) = 9", FUNC(fmax) (minus_infty, 9), 9); | |
2318 | check ("fmax (-inf, -9) = -9", FUNC(fmax) (minus_infty, -9), -9); | |
2319 | check ("fmax (+9, -inf) = 9", FUNC(fmax) (9, minus_infty), 9); | |
2320 | check ("fmax (-9, -inf) = -9", FUNC(fmax) (-9, minus_infty), -9); | |
2321 | ||
2322 | check ("fmax (0, NaN) = 0", FUNC(fmax) (0, nan_value), 0); | |
2323 | check ("fmax (9, NaN) = 9", FUNC(fmax) (9, nan_value), 9); | |
2324 | check ("fmax (-9, NaN) = 9", FUNC(fmax) (-9, nan_value), -9); | |
2325 | check ("fmax (NaN, 0) = 0", FUNC(fmax) (nan_value, 0), 0); | |
2326 | check ("fmax (NaN, 9) = NaN", FUNC(fmax) (nan_value, 9), 9); | |
2327 | check ("fmax (NaN, -9) = NaN", FUNC(fmax) (nan_value, -9), -9); | |
2328 | check_isinfp ("fmax (+inf, NaN) = +inf", FUNC(fmax) (plus_infty, nan_value)); | |
2329 | check_isinfn ("fmax (-inf, NaN) = -inf", FUNC(fmax) (minus_infty, nan_value)); | |
2330 | check_isinfp ("fmax (NaN, +inf) = +inf", FUNC(fmax) (nan_value, plus_infty)); | |
2331 | check_isinfn ("fmax (NaN, -inf) = -inf", FUNC(fmax) (nan_value, minus_infty)); | |
2332 | check_isnan ("fmax (NaN, NaN) = NaN", FUNC(fmax) (nan_value, nan_value)); | |
2333 | } | |
2334 | ||
2335 | ||
900bec85 UD |
2336 | static void |
2337 | fmod_test (void) | |
2338 | { | |
2339 | MATHTYPE x; | |
e7f1f046 | 2340 | |
900bec85 UD |
2341 | x = random_greater (0); |
2342 | check_ext ("fmod (+0, y) == +0 for y != 0", FUNC(fmod) (0, x), 0, x); | |
2343 | ||
2344 | x = random_greater (0); | |
2345 | check_ext ("fmod (-0, y) == -0 for y != 0", FUNC(fmod) (minus_zero, x), | |
2346 | minus_zero, x); | |
2347 | ||
2348 | check_isnan_exc_ext ("fmod (+inf, y) == NaN plus invalid exception", | |
2349 | FUNC(fmod) (plus_infty, x), INVALID_EXCEPTION, x); | |
2350 | check_isnan_exc_ext ("fmod (-inf, y) == NaN plus invalid exception", | |
2351 | FUNC(fmod) (minus_infty, x), INVALID_EXCEPTION, x); | |
2352 | check_isnan_exc_ext ("fmod (x, +0) == NaN plus invalid exception", | |
2353 | FUNC(fmod) (x, 0), INVALID_EXCEPTION, x); | |
2354 | check_isnan_exc_ext ("fmod (x, -0) == NaN plus invalid exception", | |
2355 | FUNC(fmod) (x, minus_zero), INVALID_EXCEPTION, x); | |
2356 | ||
2357 | x = random_greater (0); | |
2358 | check_ext ("fmod (x, +inf) == x for x not infinite", | |
2359 | FUNC(fmod) (x, plus_infty), x, x); | |
2360 | x = random_greater (0); | |
2361 | check_ext ("fmod (x, -inf) == x for x not infinite", | |
2362 | FUNC(fmod) (x, minus_infty), x, x); | |
2363 | ||
2364 | check_eps ("fmod (6.5, 2.3) == 1.9", FUNC(fmod) (6.5, 2.3), 1.9, | |
d705269e | 2365 | CHOOSE(5e-16, 1e-15, 2e-7)); |
e7f1f046 | 2366 | check_eps ("fmod (-6.5, 2.3) == -1.9", FUNC(fmod) (-6.5, 2.3), -1.9, |
d705269e | 2367 | CHOOSE(5e-16, 1e-15, 2e-7)); |
900bec85 | 2368 | check_eps ("fmod (6.5, -2.3) == 1.9", FUNC(fmod) (6.5, -2.3), 1.9, |
d705269e | 2369 | CHOOSE(5e-16, 1e-15, 2e-7)); |
e7f1f046 | 2370 | check_eps ("fmod (-6.5, -2.3) == -1.9", FUNC(fmod) (-6.5, -2.3), -1.9, |
d705269e | 2371 | CHOOSE(5e-16, 1e-15, 2e-7)); |
900bec85 | 2372 | |
e7f1f046 | 2373 | |
900bec85 UD |
2374 | } |
2375 | ||
2376 | ||
bc9f6000 UD |
2377 | static void |
2378 | nextafter_test (void) | |
2379 | { | |
2380 | MATHTYPE x; | |
2381 | ||
2382 | check ("nextafter (+0, +0) = +0", FUNC(nextafter) (0, 0), 0); | |
2383 | check ("nextafter (-0, +0) = +0", FUNC(nextafter) (minus_zero, 0), 0); | |
2384 | check ("nextafter (+0, -0) = -0", FUNC(nextafter) (0, minus_zero), | |
2385 | minus_zero); | |
2386 | check ("nextafter (-0, -0) = -0", FUNC(nextafter) (minus_zero, minus_zero), | |
2387 | minus_zero); | |
2388 | ||
2389 | check ("nextafter (9, 9) = 9", FUNC(nextafter) (9, 9), 9); | |
2390 | check ("nextafter (-9, -9) = -9", FUNC(nextafter) (-9, -9), -9); | |
2391 | check_isinfp ("nextafter (+inf, +inf) = +inf", | |
2392 | FUNC(nextafter) (plus_infty, plus_infty)); | |
2393 | check_isinfn ("nextafter (-inf, -inf) = -inf", | |
2394 | FUNC(nextafter) (minus_infty, minus_infty)); | |
2395 | ||
2396 | x = rand () * 1.1; | |
2397 | check_isnan ("nextafter (NaN, x) = NaN", FUNC(nextafter) (nan_value, x)); | |
2398 | check_isnan ("nextafter (x, NaN) = NaN", FUNC(nextafter) (x, nan_value)); | |
2399 | check_isnan ("nextafter (NaN, NaN) = NaN", FUNC(nextafter) (nan_value, | |
2400 | nan_value)); | |
2401 | ||
2402 | /* XXX We need the hexadecimal FP number representation here for further | |
2403 | tests. */ | |
2404 | } | |
2405 | ||
2406 | ||
2407 | static void | |
2408 | copysign_test (void) | |
2409 | { | |
2410 | check ("copysign (0, 4) = 0", FUNC(copysign) (0, 4), 0); | |
2411 | check ("copysign (0, -4) = -0", FUNC(copysign) (0, -4), minus_zero); | |
2412 | check ("copysign (-0, 4) = 0", FUNC(copysign) (minus_zero, 4), 0); | |
2413 | check ("copysign (-0, -4) = -0", FUNC(copysign) (minus_zero, -4), | |
2414 | minus_zero); | |
2415 | ||
2416 | check_isinfp ("copysign (+inf, 0) = +inf", FUNC(copysign) (plus_infty, 0)); | |
2417 | check_isinfn ("copysign (+inf, -0) = -inf", FUNC(copysign) (plus_infty, | |
2418 | minus_zero)); | |
2419 | check_isinfp ("copysign (-inf, 0) = +inf", FUNC(copysign) (minus_infty, 0)); | |
2420 | check_isinfn ("copysign (-inf, -0) = -inf", FUNC(copysign) (minus_infty, | |
2421 | minus_zero)); | |
2422 | ||
2423 | check ("copysign (0, +inf) = 0", FUNC(copysign) (0, plus_infty), 0); | |
2424 | check ("copysign (0, -inf) = -0", FUNC(copysign) (0, minus_zero), | |
2425 | minus_zero); | |
2426 | check ("copysign (-0, +inf) = 0", FUNC(copysign) (minus_zero, plus_infty), | |
2427 | 0); | |
2428 | check ("copysign (-0, -inf) = -0", FUNC(copysign) (minus_zero, minus_zero), | |
2429 | minus_zero); | |
2430 | ||
2431 | /* XXX More correctly we would have to check the sign of the NaN. */ | |
3e5f5557 UD |
2432 | check_isnan ("copysign (+NaN, 0) = +NaN", FUNC(copysign) (nan_value, 0)); |
2433 | check_isnan ("copysign (+NaN, -0) = -NaN", FUNC(copysign) (nan_value, | |
bc9f6000 | 2434 | minus_zero)); |
3e5f5557 UD |
2435 | check_isnan ("copysign (-NaN, 0) = +NaN", FUNC(copysign) (-nan_value, 0)); |
2436 | check_isnan ("copysign (-NaN, -0) = -NaN", FUNC(copysign) (-nan_value, | |
bc9f6000 UD |
2437 | minus_zero)); |
2438 | } | |
2439 | ||
2440 | ||
2441 | static void | |
2442 | trunc_test (void) | |
2443 | { | |
2444 | check ("trunc(0) = 0", FUNC(trunc) (0), 0); | |
2445 | check ("trunc(-0) = -0", FUNC(trunc) (minus_zero), minus_zero); | |
2446 | check ("trunc(0.625) = 0", FUNC(trunc) (0.625), 0); | |
2447 | check ("trunc(-0.625) = -0", FUNC(trunc) (-0.625), minus_zero); | |
2448 | check ("trunc(1) = 1", FUNC(trunc) (1), 1); | |
2449 | check ("trunc(-1) = -1", FUNC(trunc) (-1), -1); | |
2450 | check ("trunc(1.625) = 1", FUNC(trunc) (1.625), 1); | |
2451 | check ("trunc(-1.625) = -1", FUNC(trunc) (-1.625), -1); | |
2452 | ||
2453 | check ("trunc(1048580.625) = 1048580", FUNC(trunc) (1048580.625L), | |
2454 | 1048580L); | |
2455 | check ("trunc(-1048580.625) = -1048580", FUNC(trunc) (-1048580.625L), | |
2456 | -1048580L); | |
2457 | ||
2458 | check ("trunc(8388610.125) = 8388610", FUNC(trunc) (8388610.125L), | |
2459 | 8388610.0L); | |
2460 | check ("trunc(-8388610.125) = -8388610", FUNC(trunc) (-8388610.125L), | |
2461 | -8388610.0L); | |
2462 | ||
2463 | check ("trunc(4294967296.625) = 4294967296", FUNC(trunc) (4294967296.625L), | |
2464 | 4294967296.0L); | |
2465 | check ("trunc(-4294967296.625) = -4294967296", | |
2466 | FUNC(trunc) (-4294967296.625L), -4294967296.0L); | |
2467 | ||
2468 | check_isinfp ("trunc(+inf) = +inf", FUNC(trunc) (plus_infty)); | |
2469 | check_isinfn ("trunc(-inf) = -inf", FUNC(trunc) (minus_infty)); | |
2470 | check_isnan ("trunc(NaN) = NaN", FUNC(trunc) (nan_value)); | |
2471 | } | |
2472 | ||
2473 | ||
3e5f5557 UD |
2474 | static void |
2475 | sqrt_test (void) | |
2476 | { | |
2477 | MATHTYPE x; | |
2478 | ||
2479 | ||
2480 | /* XXX Tests fuer negative x are missing */ | |
2481 | check ("sqrt (0) == 0", FUNC(sqrt) (0), 0); | |
2482 | check_isnan ("sqrt (NaN) == NaN", FUNC(sqrt) (nan_value)); | |
2483 | check_isinfp ("sqrt (+inf) == +inf", FUNC(sqrt) (plus_infty)); | |
2484 | ||
900bec85 UD |
2485 | check ("sqrt (-0) == -0", FUNC(sqrt) (0), 0); |
2486 | ||
2487 | x = random_less (0.0); | |
2488 | check_isnan_exc_ext ("sqrt (x) == NaN plus invalid exception for x < 0", | |
2489 | FUNC(sqrt) (x), INVALID_EXCEPTION, x); | |
2490 | ||
3e5f5557 | 2491 | x = random_value (0, 10000); |
22d57dd3 | 2492 | check_ext ("sqrt (x*x) == x", FUNC(sqrt) (x*x), x, x); |
3e5f5557 | 2493 | check ("sqrt (4) == 2", FUNC(sqrt) (4), 2); |
d111572f | 2494 | check ("sqrt (2) == 1.14142...", FUNC(sqrt) (2), M_SQRT2l); |
cc3fa755 | 2495 | check ("sqrt (0.25) == 0.5", FUNC(sqrt) (0.25), 0.5); |
cbdee279 UD |
2496 | check ("sqrt (6642.25) == 81.5", FUNC(sqrt) (6642.25), 81.5); |
2497 | check_eps ("sqrt (15239.903) == 123.45", FUNC(sqrt) (15239.903), 123.45, | |
2498 | CHOOSE (3e-6L, 3e-6, 8e-6)); | |
bd355af0 UD |
2499 | check_eps ("sqrt (0.7) == 0.8366600265", FUNC(sqrt) (0.7), |
2500 | 0.83666002653407554798L, CHOOSE(3e-17L, 0, 0)); | |
3e5f5557 UD |
2501 | } |
2502 | ||
900bec85 UD |
2503 | static void |
2504 | remainder_test (void) | |
2505 | { | |
2506 | MATHTYPE result; | |
e7f1f046 | 2507 | |
900bec85 UD |
2508 | result = FUNC(remainder) (1, 0); |
2509 | check_isnan_exc ("remainder(1, +0) == NaN plus invalid exception", | |
2510 | result, INVALID_EXCEPTION); | |
e7f1f046 | 2511 | |
900bec85 UD |
2512 | result = FUNC(remainder) (1, minus_zero); |
2513 | check_isnan_exc ("remainder(1, -0) == NaN plus invalid exception", | |
2514 | result, INVALID_EXCEPTION); | |
e7f1f046 | 2515 | |
900bec85 UD |
2516 | result = FUNC(remainder) (plus_infty, 1); |
2517 | check_isnan_exc ("remainder(+inf, 1) == NaN plus invalid exception", | |
2518 | result, INVALID_EXCEPTION); | |
e7f1f046 | 2519 | |
900bec85 UD |
2520 | result = FUNC(remainder) (minus_infty, 1); |
2521 | check_isnan_exc ("remainder(-inf, 1) == NaN plus invalid exception", | |
2522 | result, INVALID_EXCEPTION); | |
e7f1f046 | 2523 | |
900bec85 UD |
2524 | result = FUNC(remainder) (1.625, 1.0); |
2525 | check ("remainder(1.625, 1.0) == -0.375", result, -0.375); | |
e7f1f046 | 2526 | |
900bec85 UD |
2527 | result = FUNC(remainder) (-1.625, 1.0); |
2528 | check ("remainder(-1.625, 1.0) == 0.375", result, 0.375); | |
e7f1f046 | 2529 | |
900bec85 UD |
2530 | result = FUNC(remainder) (1.625, -1.0); |
2531 | check ("remainder(1.625, -1.0) == -0.375", result, -0.375); | |
e7f1f046 | 2532 | |
900bec85 UD |
2533 | result = FUNC(remainder) (-1.625, -1.0); |
2534 | check ("remainder(-1.625, -1.0) == 0.375", result, 0.375); | |
e7f1f046 | 2535 | |
900bec85 UD |
2536 | result = FUNC(remainder) (5.0, 2.0); |
2537 | check ("remainder(5.0, 2.0) == 1.0", result, 1.0); | |
e7f1f046 | 2538 | |
900bec85 UD |
2539 | result = FUNC(remainder) (3.0, 2.0); |
2540 | check ("remainder(3.0, 2.0) == -1.0", result, -1.0); | |
2541 | } | |
2542 | ||
3e5f5557 | 2543 | |
bc9f6000 UD |
2544 | static void |
2545 | remquo_test (void) | |
2546 | { | |
2547 | int quo; | |
2548 | MATHTYPE result; | |
2549 | ||
900bec85 UD |
2550 | result = FUNC(remquo) (1, 0, &quo); |
2551 | check_isnan_exc ("remquo(1, +0, &x) == NaN plus invalid exception", | |
2552 | result, INVALID_EXCEPTION); | |
2553 | ||
2554 | result = FUNC(remquo) (1, minus_zero, &quo); | |
2555 | check_isnan_exc ("remquo(1, -0, &x) == NaN plus invalid exception", | |
2556 | result, INVALID_EXCEPTION); | |
2557 | ||
2558 | result = FUNC(remquo) (plus_infty, 1, &quo); | |
2559 | check_isnan_exc ("remquo(+inf, 1, &x) == NaN plus invalid exception", | |
2560 | result, INVALID_EXCEPTION); | |
2561 | ||
2562 | result = FUNC(remquo) (minus_infty, 1, &quo); | |
2563 | check_isnan_exc ("remquo(-inf, 1, &x) == NaN plus invalid exception", | |
2564 | result, INVALID_EXCEPTION); | |
2565 | ||
bc9f6000 UD |
2566 | result = FUNC(remquo) (1.625, 1.0, &quo); |
2567 | check ("remquo(1.625, 1.0, &x) == -0.375", result, -0.375); | |
900bec85 | 2568 | check_long ("remquo(1.625, 1.0, &x) puts 2 in x", quo, 2); |
e7f1f046 | 2569 | |
bc9f6000 UD |
2570 | result = FUNC(remquo) (-1.625, 1.0, &quo); |
2571 | check ("remquo(-1.625, 1.0, &x) == 0.375", result, 0.375); | |
900bec85 | 2572 | check_long ("remquo(-1.625, 1.0, &x) puts -2 in x", quo, -2); |
e7f1f046 | 2573 | |
bc9f6000 | 2574 | result = FUNC(remquo) (1.625, -1.0, &quo); |
63551311 | 2575 | check ("remquo(1.625, -1.0, &x) == -0.375", result, -0.375); |
900bec85 | 2576 | check_long ("remquo(1.625, -1.0, &x) puts -2 in x", quo, -2); |
e7f1f046 | 2577 | |
bc9f6000 | 2578 | result = FUNC(remquo) (-1.625, -1.0, &quo); |
63551311 | 2579 | check ("remquo(-1.625, -1.0, &x) == 0.375", result, 0.375); |
900bec85 UD |
2580 | check_long ("remquo(-1.625, -1.0, &x) puts 2 in x", quo, 2); |
2581 | ||
2582 | result = FUNC(remquo) (5.0, 2.0, &quo); | |
2583 | check ("remquo(5.0, 2.0, &x) == 1.0", result, 1.0); | |
2584 | check_long ("remquo (5.0, 2.0, &x) puts 2 in x", quo, 2); | |
2585 | ||
2586 | result = FUNC(remquo) (3.0, 2.0, &quo); | |
2587 | check ("remquo(3.0, 2.0, &x) == -1.0", result, -1.0); | |
2588 | check_long ("remquo (3.0, 2.0, &x) puts 2 in x", quo, 2); | |
bc9f6000 UD |
2589 | } |
2590 | ||
2591 | ||
3e5f5557 UD |
2592 | static void |
2593 | cexp_test (void) | |
2594 | { | |
2595 | __complex__ MATHTYPE result; | |
2596 | ||
e7fd8a39 | 2597 | result = FUNC(cexp) (BUILD_COMPLEX (plus_zero, plus_zero)); |
3e5f5557 UD |
2598 | check ("real(cexp(0 + 0i)) = 1", __real__ result, 1); |
2599 | check ("imag(cexp(0 + 0i)) = 0", __imag__ result, 0); | |
e7fd8a39 | 2600 | result = FUNC(cexp) (BUILD_COMPLEX (minus_zero, plus_zero)); |
3e5f5557 UD |
2601 | check ("real(cexp(-0 + 0i)) = 1", __real__ result, 1); |
2602 | check ("imag(cexp(-0 + 0i)) = 0", __imag__ result, 0); | |
e7fd8a39 | 2603 | result = FUNC(cexp) (BUILD_COMPLEX (plus_zero, minus_zero)); |
3e5f5557 | 2604 | check ("real(cexp(0 - 0i)) = 1", __real__ result, 1); |
e7fd8a39 UD |
2605 | check ("imag(cexp(0 - 0i)) = -0", __imag__ result, minus_zero); |
2606 | result = FUNC(cexp) (BUILD_COMPLEX (minus_zero, minus_zero)); | |
3e5f5557 | 2607 | check ("real(cexp(-0 - 0i)) = 1", __real__ result, 1); |
e7fd8a39 | 2608 | check ("imag(cexp(-0 - 0i)) = -0", __imag__ result, minus_zero); |
3e5f5557 | 2609 | |
e7fd8a39 | 2610 | result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, plus_zero)); |
3e5f5557 UD |
2611 | check_isinfp ("real(cexp(+inf + 0i)) = +inf", __real__ result); |
2612 | check ("imag(cexp(+inf + 0i)) = 0", __imag__ result, 0); | |
e7fd8a39 | 2613 | result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, minus_zero)); |
3e5f5557 | 2614 | check_isinfp ("real(cexp(+inf - 0i)) = +inf", __real__ result); |
993b3242 | 2615 | check ("imag(cexp(+inf - 0i)) = -0", __imag__ result, minus_zero); |
3e5f5557 | 2616 | |
e7fd8a39 | 2617 | result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, plus_zero)); |
3e5f5557 UD |
2618 | check ("real(cexp(-inf + 0i)) = 0", __real__ result, 0); |
2619 | check ("imag(cexp(-inf + 0i)) = 0", __imag__ result, 0); | |
e7fd8a39 | 2620 | result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, minus_zero)); |
3e5f5557 | 2621 | check ("real(cexp(-inf - 0i)) = 0", __real__ result, 0); |
e7fd8a39 UD |
2622 | check ("imag(cexp(-inf - 0i)) = -0", __imag__ result, minus_zero); |
2623 | ||
76b87c03 | 2624 | |
779ae82e UD |
2625 | result = FUNC(cexp) (BUILD_COMPLEX (0.0, plus_infty)); |
2626 | check_isnan_exc ("real(cexp(0 + i inf)) = NaN plus invalid exception", | |
51702635 | 2627 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
2628 | check_isnan ("imag(cexp(0 + i inf)) = NaN plus invalid exception", |
2629 | __imag__ result); | |
76b87c03 | 2630 | |
cbdee279 | 2631 | #if defined __GNUC__ && __GNUC__ <= 2 && __GNUC_MINOR__ <= 7 |
76b87c03 UD |
2632 | if (verbose) |
2633 | printf ("The following test for cexp might fail due to a gcc compiler error!\n"); | |
2634 | #endif | |
2635 | ||
779ae82e UD |
2636 | result = FUNC(cexp) (BUILD_COMPLEX (minus_zero, plus_infty)); |
2637 | check_isnan_exc ("real(cexp(-0 + i inf)) = NaN plus invalid exception", | |
51702635 | 2638 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
2639 | check_isnan ("imag(cexp(-0 + i inf)) = NaN plus invalid exception", |
2640 | __imag__ result); | |
2641 | result = FUNC(cexp) (BUILD_COMPLEX (0.0, minus_infty)); | |
2642 | check_isnan_exc ("real(cexp(0 - i inf)) = NaN plus invalid exception", | |
51702635 | 2643 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
2644 | check_isnan ("imag(cexp(0 - i inf)) = NaN plus invalid exception", |
2645 | __imag__ result); | |
2646 | result = FUNC(cexp) (BUILD_COMPLEX (minus_zero, minus_infty)); | |
2647 | check_isnan_exc ("real(cexp(-0 - i inf)) = NaN plus invalid exception", | |
51702635 | 2648 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
2649 | check_isnan ("imag(cexp(-0 - i inf)) = NaN plus invalid exception", |
2650 | __imag__ result); | |
2651 | ||
e7fd8a39 | 2652 | result = FUNC(cexp) (BUILD_COMPLEX (100.0, plus_infty)); |
779ae82e | 2653 | check_isnan_exc ("real(cexp(100.0 + i inf)) = NaN plus invalid exception", |
51702635 | 2654 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
2655 | check_isnan ("imag(cexp(100.0 + i inf)) = NaN plus invalid exception", |
2656 | __imag__ result); | |
2657 | result = FUNC(cexp) (BUILD_COMPLEX (-100.0, plus_infty)); | |
2658 | check_isnan_exc ("real(cexp(-100.0 + i inf)) = NaN plus invalid exception", | |
51702635 | 2659 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
2660 | check_isnan ("imag(cexp(-100.0 + i inf)) = NaN plus invalid exception", |
2661 | __imag__ result); | |
e7fd8a39 | 2662 | result = FUNC(cexp) (BUILD_COMPLEX (100.0, minus_infty)); |
779ae82e | 2663 | check_isnan_exc ("real(cexp(100.0 - i inf)) = NaN plus invalid exception", |
51702635 | 2664 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
2665 | check_isnan ("imag(cexp(100.0 - i inf)) = NaN plus invalid exception", |
2666 | __imag__ result); | |
2667 | result = FUNC(cexp) (BUILD_COMPLEX (-100.0, minus_infty)); | |
2668 | check_isnan_exc ("real(cexp(-100.0 - i inf)) = NaN plus invalid exception", | |
51702635 | 2669 | __real__ result, INVALID_EXCEPTION); |
779ae82e | 2670 | check_isnan ("imag(cexp(-100.0 - i inf)) = NaN", __imag__ result); |
e7fd8a39 UD |
2671 | |
2672 | result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, 2.0)); | |
2673 | check ("real(cexp(-inf + 2.0i)) = -0", __real__ result, minus_zero); | |
2674 | check ("imag(cexp(-inf + 2.0i)) = 0", __imag__ result, 0); | |
2675 | result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, 4.0)); | |
2676 | check ("real(cexp(-inf + 4.0i)) = -0", __real__ result, minus_zero); | |
2677 | check ("imag(cexp(-inf + 4.0i)) = -0", __imag__ result, minus_zero); | |
2678 | ||
2679 | result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, 2.0)); | |
993b3242 UD |
2680 | check_isinfn ("real(cexp(+inf + 2.0i)) = -inf", __real__ result); |
2681 | check_isinfp ("imag(cexp(+inf + 2.0i)) = +inf", __imag__ result); | |
e7fd8a39 | 2682 | result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, 4.0)); |
993b3242 UD |
2683 | check_isinfn ("real(cexp(+inf + 4.0i)) = -inf", __real__ result); |
2684 | check_isinfn ("imag(cexp(+inf + 4.0i)) = -inf", __imag__ result); | |
e7fd8a39 UD |
2685 | |
2686 | result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, plus_infty)); | |
779ae82e | 2687 | check_isinfp_exc ("real(cexp(+inf + i inf)) = +inf plus invalid exception", |
51702635 | 2688 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
2689 | check_isnan ("imag(cexp(+inf + i inf)) = NaN plus invalid exception", |
2690 | __imag__ result); | |
e7fd8a39 | 2691 | result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, minus_infty)); |
779ae82e | 2692 | check_isinfp_exc ("real(cexp(+inf - i inf)) = +inf plus invalid exception", |
51702635 | 2693 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
2694 | check_isnan ("imag(cexp(+inf - i inf)) = NaN plus invalid exception", |
2695 | __imag__ result); | |
e7fd8a39 UD |
2696 | |
2697 | result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, plus_infty)); | |
2698 | check ("real(cexp(-inf + i inf)) = 0", __real__ result, 0); | |
2699 | check ("imag(cexp(-inf + i inf)) = 0", __imag__ result, 0); | |
2700 | result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, minus_infty)); | |
2701 | check ("real(cexp(-inf - i inf)) = 0", __real__ result, 0); | |
993b3242 | 2702 | check ("imag(cexp(-inf - i inf)) = -0", __imag__ result, minus_zero); |
e7fd8a39 UD |
2703 | |
2704 | result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, nan_value)); | |
2705 | check ("real(cexp(-inf + i NaN)) = 0", __real__ result, 0); | |
2706 | check ("imag(cexp(-inf + i NaN)) = 0", fabs (__imag__ result), 0); | |
2707 | ||
2708 | result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, nan_value)); | |
2709 | check_isinfp ("real(cexp(+inf + i NaN)) = +inf", __real__ result); | |
2710 | check_isnan ("imag(cexp(+inf + i NaN)) = NaN", __imag__ result); | |
2711 | ||
779ae82e UD |
2712 | result = FUNC(cexp) (BUILD_COMPLEX (nan_value, 0.0)); |
2713 | check_isnan_maybe_exc ("real(cexp(NaN + i0)) = NaN plus maybe invalid exception", | |
51702635 | 2714 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
2715 | check_isnan ("imag(cexp(NaN + i0)) = NaN plus maybe invalid exception", |
2716 | __imag__ result); | |
e7fd8a39 | 2717 | result = FUNC(cexp) (BUILD_COMPLEX (nan_value, 1.0)); |
779ae82e | 2718 | check_isnan_maybe_exc ("real(cexp(NaN + 1i)) = NaN plus maybe invalid exception", |
51702635 | 2719 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
2720 | check_isnan ("imag(cexp(NaN + 1i)) = NaN plus maybe invalid exception", |
2721 | __imag__ result); | |
63551311 | 2722 | result = FUNC(cexp) (BUILD_COMPLEX (nan_value, plus_infty)); |
779ae82e | 2723 | check_isnan_maybe_exc ("real(cexp(NaN + i inf)) = NaN plus maybe invalid exception", |
51702635 | 2724 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
2725 | check_isnan ("imag(cexp(NaN + i inf)) = NaN plus maybe invalid exception", |
2726 | __imag__ result); | |
2727 | ||
2728 | result = FUNC(cexp) (BUILD_COMPLEX (0, nan_value)); | |
2729 | check_isnan_maybe_exc ("real(cexp(0 + i NaN)) = NaN plus maybe invalid exception", | |
51702635 | 2730 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
2731 | check_isnan ("imag(cexp(0 + i NaN)) = NaN plus maybe invalid exception", |
2732 | __imag__ result); | |
2733 | result = FUNC(cexp) (BUILD_COMPLEX (1, nan_value)); | |
2734 | check_isnan_maybe_exc ("real(cexp(1 + i NaN)) = NaN plus maybe invalid exception", | |
51702635 | 2735 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
2736 | check_isnan ("imag(cexp(1 + i NaN)) = NaN plus maybe invalid exception", |
2737 | __imag__ result); | |
2738 | ||
63551311 | 2739 | result = FUNC(cexp) (BUILD_COMPLEX (nan_value, nan_value)); |
e7fd8a39 UD |
2740 | check_isnan ("real(cexp(NaN + i NaN)) = NaN", __real__ result); |
2741 | check_isnan ("imag(cexp(NaN + i NaN)) = NaN", __imag__ result); | |
bd355af0 UD |
2742 | |
2743 | result = FUNC(cexp) (BUILD_COMPLEX (0.7, 1.2)); | |
2744 | check_eps ("real(cexp(0.7 + i 1.2)) == 0.72969...", __real__ result, | |
14e9dd67 | 2745 | 0.7296989091503236012L, CHOOSE(6e-17L, 2e-16, 2e-7)); |
bd355af0 | 2746 | check_eps ("imag(cexp(0.7 + i 1.2)) == 1.87689...", __imag__ result, |
5edb9387 | 2747 | 1.8768962328348102821L, CHOOSE(2e-16L, 2.5e-16, 3e-7)); |
bd355af0 UD |
2748 | |
2749 | result = FUNC(cexp) (BUILD_COMPLEX (-2, -3)); | |
74015205 | 2750 | check_eps ("real(cexp(-2 - i 3)) == -0.13398...", __real__ result, |
5edb9387 | 2751 | -0.1339809149295426134L, CHOOSE(6.8e-20L, 0, 2e-8)); |
bd355af0 | 2752 | check_eps ("imag(cexp(-2 - i 3)) == -0.01909...", __imag__ result, |
74015205 | 2753 | -0.0190985162611351964L, CHOOSE(4e-20L, 0, 2e-9)); |
779ae82e | 2754 | } |
e7fd8a39 | 2755 | |
779ae82e UD |
2756 | |
2757 | static void | |
2758 | csin_test (void) | |
2759 | { | |
2760 | __complex__ MATHTYPE result; | |
2761 | ||
2762 | result = FUNC(csin) (BUILD_COMPLEX (0.0, 0.0)); | |
2763 | check ("real(csin(0 + 0i)) = 0", __real__ result, 0); | |
2764 | check ("imag(csin(0 + 0i)) = 0", __imag__ result, 0); | |
2765 | result = FUNC(csin) (BUILD_COMPLEX (minus_zero, 0.0)); | |
2766 | check ("real(csin(-0 + 0i)) = -0", __real__ result, minus_zero); | |
2767 | check ("imag(csin(-0 + 0i)) = 0", __imag__ result, 0); | |
2768 | result = FUNC(csin) (BUILD_COMPLEX (0.0, minus_zero)); | |
2769 | check ("real(csin(0 - 0i)) = 0", __real__ result, 0); | |
2770 | check ("imag(csin(0 - 0i)) = -0", __imag__ result, minus_zero); | |
2771 | result = FUNC(csin) (BUILD_COMPLEX (minus_zero, minus_zero)); | |
2772 | check ("real(csin(-0 - 0i)) = -0", __real__ result, minus_zero); | |
2773 | check ("imag(csin(-0 - 0i)) = -0", __imag__ result, minus_zero); | |
2774 | ||
2775 | result = FUNC(csin) (BUILD_COMPLEX (0.0, plus_infty)); | |
2776 | check ("real(csin(0 + i Inf)) = 0", __real__ result, 0); | |
2777 | check_isinfp ("imag(csin(0 + i Inf)) = +Inf", __imag__ result); | |
2778 | result = FUNC(csin) (BUILD_COMPLEX (minus_zero, plus_infty)); | |
2779 | check ("real(csin(-0 + i Inf)) = -0", __real__ result, minus_zero); | |
2780 | check_isinfp ("imag(csin(-0 + i Inf)) = +Inf", __imag__ result); | |
2781 | result = FUNC(csin) (BUILD_COMPLEX (0.0, minus_infty)); | |
2782 | check ("real(csin(0 - i Inf)) = 0", __real__ result, 0); | |
2783 | check_isinfn ("imag(csin(0 - i Inf)) = -Inf", __imag__ result); | |
2784 | result = FUNC(csin) (BUILD_COMPLEX (minus_zero, minus_infty)); | |
2785 | check ("real(csin(-0 - i Inf)) = -0", __real__ result, minus_zero); | |
2786 | check_isinfn("imag(csin(-0 - i Inf)) = -Inf", __imag__ result); | |
2787 | ||
2788 | result = FUNC(csin) (BUILD_COMPLEX (plus_infty, 0.0)); | |
2789 | check_isnan_exc ("real(csin(+Inf + 0i)) = NaN plus invalid exception", | |
51702635 | 2790 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
2791 | check ("imag(csin(+Inf + 0i)) = +-0 plus invalid exception", |
2792 | FUNC(fabs) (__imag__ result), 0); | |
2793 | result = FUNC(csin) (BUILD_COMPLEX (minus_infty, 0.0)); | |
2794 | check_isnan_exc ("real(csin(-Inf + 0i)) = NaN plus invalid exception", | |
51702635 | 2795 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
2796 | check ("imag(csin(-Inf + 0i)) = +-0 plus invalid exception", |
2797 | FUNC(fabs) (__imag__ result), 0); | |
2798 | result = FUNC(csin) (BUILD_COMPLEX (plus_infty, minus_zero)); | |
2799 | check_isnan_exc ("real(csin(+Inf - 0i)) = NaN plus invalid exception", | |
51702635 | 2800 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
2801 | check ("imag(csin(+Inf - 0i)) = +-0 plus invalid exception", |
2802 | FUNC(fabs) (__imag__ result), 0.0); | |
2803 | result = FUNC(csin) (BUILD_COMPLEX (minus_infty, minus_zero)); | |
2804 | check_isnan_exc ("real(csin(-Inf - 0i)) = NaN plus invalid exception", | |
51702635 | 2805 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
2806 | check ("imag(csin(-Inf - 0i)) = +-0 plus invalid exception", |
2807 | FUNC(fabs) (__imag__ result), 0.0); | |
2808 | ||
2809 | result = FUNC(csin) (BUILD_COMPLEX (plus_infty, plus_infty)); | |
2810 | check_isnan_exc ("real(csin(+Inf + i Inf)) = NaN plus invalid exception", | |
51702635 | 2811 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
2812 | check_isinfp ("imag(csin(+Inf + i Inf)) = +-Inf plus invalid exception", |
2813 | FUNC(fabs) (__imag__ result)); | |
2814 | result = FUNC(csin) (BUILD_COMPLEX (minus_infty, plus_infty)); | |
2815 | check_isnan_exc ("real(csin(-Inf + i Inf)) = NaN plus invalid exception", | |
51702635 | 2816 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
2817 | check_isinfp ("imag(csin(-Inf + i Inf)) = +-Inf plus invalid exception", |
2818 | FUNC(fabs) (__imag__ result)); | |
2819 | result = FUNC(csin) (BUILD_COMPLEX (plus_infty, minus_infty)); | |
2820 | check_isnan_exc ("real(csin(Inf - i Inf)) = NaN plus invalid exception", | |
51702635 | 2821 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
2822 | check_isinfp ("imag(csin(Inf - i Inf)) = +-Inf plus invalid exception", |
2823 | FUNC(fabs) (__imag__ result)); | |
2824 | result = FUNC(csin) (BUILD_COMPLEX (minus_infty, minus_infty)); | |
2825 | check_isnan_exc ("real(csin(-Inf - i Inf)) = NaN plus invalid exception", | |
51702635 | 2826 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
2827 | check_isinfp ("imag(csin(-Inf - i Inf)) = +-Inf plus invalid exception", |
2828 | FUNC(fabs) (__imag__ result)); | |
2829 | ||
2830 | result = FUNC(csin) (BUILD_COMPLEX (plus_infty, 6.75)); | |
2831 | check_isnan_exc ("real(csin(+Inf + i 6.75)) = NaN plus invalid exception", | |
51702635 | 2832 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
2833 | check_isnan ("imag(csin(+Inf + i6.75)) = NaN plus invalid exception", |
2834 | __imag__ result); | |
2835 | result = FUNC(csin) (BUILD_COMPLEX (plus_infty, -6.75)); | |
2836 | check_isnan_exc ("real(csin(+Inf - i 6.75)) = NaN plus invalid exception", | |
51702635 | 2837 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
2838 | check_isnan ("imag(csin(+Inf - i6.75)) = NaN plus invalid exception", |
2839 | __imag__ result); | |
2840 | result = FUNC(csin) (BUILD_COMPLEX (minus_infty, 6.75)); | |
2841 | check_isnan_exc ("real(csin(-Inf + i6.75)) = NaN plus invalid exception", | |
51702635 | 2842 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
2843 | check_isnan ("imag(csin(-Inf + i6.75)) = NaN plus invalid exception", |
2844 | __imag__ result); | |
2845 | result = FUNC(csin) (BUILD_COMPLEX (minus_infty, -6.75)); | |
2846 | check_isnan_exc ("real(csin(-Inf - i6.75)) = NaN plus invalid exception", | |
51702635 | 2847 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
2848 | check_isnan ("imag(csin(-Inf - i6.75)) = NaN plus invalid exception", |
2849 | __imag__ result); | |
2850 | ||
2851 | result = FUNC(csin) (BUILD_COMPLEX (4.625, plus_infty)); | |
2852 | check_isinfn ("real(csin(4.625 + i Inf)) = -Inf", __real__ result); | |
2853 | check_isinfn ("imag(csin(4.625 + i Inf)) = -Inf", __imag__ result); | |
2854 | result = FUNC(csin) (BUILD_COMPLEX (4.625, minus_infty)); | |
2855 | check_isinfn ("real(csin(4.625 - i Inf)) = -Inf", __real__ result); | |
2856 | check_isinfp ("imag(csin(4.625 - i Inf)) = +Inf", __imag__ result); | |
2857 | result = FUNC(csin) (BUILD_COMPLEX (-4.625, plus_infty)); | |
2858 | check_isinfp ("real(csin(-4.625 + i Inf)) = +Inf", __real__ result); | |
2859 | check_isinfn ("imag(csin(-4.625 + i Inf)) = -Inf", __imag__ result); | |
2860 | result = FUNC(csin) (BUILD_COMPLEX (-4.625, minus_infty)); | |
2861 | check_isinfp ("real(csin(-4.625 - i Inf)) = +Inf", __real__ result); | |
2862 | check_isinfp ("imag(csin(-4.625 - i Inf)) = +Inf", __imag__ result); | |
2863 | ||
2864 | result = FUNC(csin) (BUILD_COMPLEX (nan_value, 0.0)); | |
2865 | check_isnan ("real(csin(NaN + i0)) = NaN", __real__ result); | |
2866 | check ("imag(csin(NaN + i0)) = +-0", FUNC(fabs) (__imag__ result), 0); | |
2867 | result = FUNC(csin) (BUILD_COMPLEX (nan_value, minus_zero)); | |
2868 | check_isnan ("real(csin(NaN - i0)) = NaN", __real__ result); | |
2869 | check ("imag(csin(NaN - i0)) = +-0", FUNC(fabs) (__imag__ result), 0); | |
2870 | ||
2871 | result = FUNC(csin) (BUILD_COMPLEX (nan_value, plus_infty)); | |
2872 | check_isnan ("real(csin(NaN + i Inf)) = NaN", __real__ result); | |
2873 | check_isinfp ("imag(csin(NaN + i Inf)) = +-Inf", | |
2874 | FUNC(fabs) (__imag__ result)); | |
2875 | result = FUNC(csin) (BUILD_COMPLEX (nan_value, minus_infty)); | |
2876 | check_isnan ("real(csin(NaN - i Inf)) = NaN", __real__ result); | |
2877 | check_isinfp ("real(csin(NaN - i Inf)) = +-Inf", | |
2878 | FUNC(fabs) (__imag__ result)); | |
2879 | ||
2880 | result = FUNC(csin) (BUILD_COMPLEX (nan_value, 9.0)); | |
51702635 UD |
2881 | check_isnan_maybe_exc ("real(csin(NaN + i9.0)) = NaN plus maybe invalid exception", |
2882 | __real__ result, INVALID_EXCEPTION); | |
2883 | check_isnan ("imag(csin(NaN + i9.0)) = NaN plus maybe invalid exception", | |
779ae82e UD |
2884 | __imag__ result); |
2885 | result = FUNC(csin) (BUILD_COMPLEX (nan_value, -9.0)); | |
51702635 UD |
2886 | check_isnan_maybe_exc ("real(csin(NaN - i9.0)) = NaN plus maybe invalid exception", |
2887 | __real__ result, INVALID_EXCEPTION); | |
2888 | check_isnan ("imag(csin(NaN - i9.0)) = NaN plus maybe invalid exception", | |
779ae82e UD |
2889 | __imag__ result); |
2890 | ||
2891 | result = FUNC(csin) (BUILD_COMPLEX (0.0, nan_value)); | |
2892 | check ("real(csin(0 + i NaN))", __real__ result, 0.0); | |
2893 | check_isnan ("imag(csin(0 + i NaN)) = NaN", __imag__ result); | |
2894 | result = FUNC(csin) (BUILD_COMPLEX (minus_zero, nan_value)); | |
2895 | check ("real(csin(-0 + i NaN)) = -0", __real__ result, minus_zero); | |
2896 | check_isnan ("imag(csin(-0 + NaN)) = NaN", __imag__ result); | |
2897 | ||
2898 | result = FUNC(csin) (BUILD_COMPLEX (10.0, nan_value)); | |
51702635 UD |
2899 | check_isnan_maybe_exc ("real(csin(10 + i NaN)) = NaN plus maybe invalid exception", |
2900 | __real__ result, INVALID_EXCEPTION); | |
2901 | check_isnan ("imag(csin(10 + i NaN)) = NaN plus maybe invalid exception", | |
779ae82e UD |
2902 | __imag__ result); |
2903 | result = FUNC(csin) (BUILD_COMPLEX (nan_value, -10.0)); | |
51702635 UD |
2904 | check_isnan_maybe_exc ("real(csin(-10 + i NaN)) = NaN plus maybe invalid exception", |
2905 | __real__ result, INVALID_EXCEPTION); | |
2906 | check_isnan ("imag(csin(-10 + i NaN)) = NaN plus maybe invalid exception", | |
779ae82e UD |
2907 | __imag__ result); |
2908 | ||
2909 | result = FUNC(csin) (BUILD_COMPLEX (plus_infty, nan_value)); | |
51702635 UD |
2910 | check_isnan_maybe_exc ("real(csin(+Inf + i NaN)) = NaN plus maybe invalid exception", |
2911 | __real__ result, INVALID_EXCEPTION); | |
2912 | check_isnan ("imag(csin(+Inf + i NaN)) = NaN plus maybe invalid exception", | |
2913 | __imag__ result); | |
779ae82e | 2914 | result = FUNC(csin) (BUILD_COMPLEX (minus_infty, nan_value)); |
51702635 UD |
2915 | check_isnan_maybe_exc ("real(csin(-Inf + i NaN)) = NaN plus maybe invalid exception", |
2916 | __real__ result, INVALID_EXCEPTION); | |
2917 | check_isnan ("imag(csin(-Inf + i NaN)) = NaN plus maybe invalid exception", | |
2918 | __imag__ result); | |
779ae82e UD |
2919 | |
2920 | result = FUNC(csin) (BUILD_COMPLEX (nan_value, nan_value)); | |
2921 | check_isnan ("real(csin(NaN + i NaN)) = NaN", __real__ result); | |
2922 | check_isnan ("imag(csin(NaN + i NaN)) = NaN", __imag__ result); | |
bd355af0 UD |
2923 | |
2924 | result = FUNC(csin) (BUILD_COMPLEX (0.7, 1.2)); | |
2925 | check_eps ("real(csin(0.7 + i 1.2)) = 1.166456341...", __real__ result, | |
2926 | 1.1664563419657581376L, CHOOSE(2e-16L, 0, 0)); | |
2927 | check_eps ("imag(csin(0.7 + i 1.2)) = 1.154499724...", __imag__ result, | |
74015205 | 2928 | 1.1544997246948547371L, CHOOSE(2e-17L, 0, 2e-7)); |
bd355af0 UD |
2929 | |
2930 | result = FUNC(csin) (BUILD_COMPLEX (-2, -3)); | |
74015205 UD |
2931 | check_eps ("real(csin(-2 - i 3)) == -9.15449...", __real__ result, |
2932 | -9.1544991469114295734L, CHOOSE(4e-18L, 0, 1e-6)); | |
2933 | check_eps ("imag(csin(-2 - i 3)) == -4.16890...", __imag__ result, | |
2934 | 4.1689069599665643507L, CHOOSE(2e-17L, 0, 5e-7)); | |
3e5f5557 UD |
2935 | } |
2936 | ||
2937 | ||
993b3242 UD |
2938 | static void |
2939 | csinh_test (void) | |
2940 | { | |
2941 | __complex__ MATHTYPE result; | |
2942 | ||
2943 | result = FUNC(csinh) (BUILD_COMPLEX (0.0, 0.0)); | |
2944 | check ("real(csinh(0 + 0i)) = 0", __real__ result, 0); | |
2945 | check ("imag(csinh(0 + 0i)) = 0", __imag__ result, 0); | |
2946 | result = FUNC(csinh) (BUILD_COMPLEX (minus_zero, 0.0)); | |
2947 | check ("real(csinh(-0 + 0i)) = -0", __real__ result, minus_zero); | |
2948 | check ("imag(csinh(-0 + 0i)) = 0", __imag__ result, 0); | |
2949 | result = FUNC(csinh) (BUILD_COMPLEX (0.0, minus_zero)); | |
2950 | check ("real(csinh(0 - 0i)) = 0", __real__ result, 0); | |
2951 | check ("imag(csinh(0 - 0i)) = -0", __imag__ result, minus_zero); | |
2952 | result = FUNC(csinh) (BUILD_COMPLEX (minus_zero, minus_zero)); | |
2953 | check ("real(csinh(-0 - 0i)) = -0", __real__ result, minus_zero); | |
2954 | check ("imag(csinh(-0 - 0i)) = -0", __imag__ result, minus_zero); | |
2955 | ||
2956 | result = FUNC(csinh) (BUILD_COMPLEX (0.0, plus_infty)); | |
779ae82e | 2957 | check_exc ("real(csinh(0 + i Inf)) = +-0 plus invalid exception", |
51702635 | 2958 | FUNC(fabs) (__real__ result), 0, INVALID_EXCEPTION); |
779ae82e UD |
2959 | check_isnan ("imag(csinh(0 + i Inf)) = NaN plus invalid exception", |
2960 | __imag__ result); | |
993b3242 | 2961 | result = FUNC(csinh) (BUILD_COMPLEX (minus_zero, plus_infty)); |
779ae82e | 2962 | check_exc ("real(csinh(-0 + i Inf)) = +-0 plus invalid exception", |
51702635 | 2963 | FUNC(fabs) (__real__ result), 0, INVALID_EXCEPTION); |
779ae82e UD |
2964 | check_isnan ("imag(csinh(-0 + i Inf)) = NaN plus invalid exception", |
2965 | __imag__ result); | |
993b3242 | 2966 | result = FUNC(csinh) (BUILD_COMPLEX (0.0, minus_infty)); |
779ae82e | 2967 | check_exc ("real(csinh(0 - i Inf)) = +-0 plus invalid exception", |
51702635 | 2968 | FUNC(fabs) (__real__ result), 0, INVALID_EXCEPTION); |
779ae82e UD |
2969 | check_isnan ("imag(csinh(0 - i Inf)) = NaN plus invalid exception", |
2970 | __imag__ result); | |
993b3242 | 2971 | result = FUNC(csinh) (BUILD_COMPLEX (minus_zero, minus_infty)); |
779ae82e | 2972 | check_exc ("real(csinh(-0 - i Inf)) = +-0 plus invalid exception", |
51702635 | 2973 | FUNC(fabs) (__real__ result), 0, INVALID_EXCEPTION); |
779ae82e UD |
2974 | check_isnan ("imag(csinh(-0 - i Inf)) = NaN plus invalid exception", |
2975 | __imag__ result); | |
993b3242 UD |
2976 | |
2977 | result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, 0.0)); | |
2978 | check_isinfp ("real(csinh(+Inf + 0i)) = +Inf", __real__ result); | |
2979 | check ("imag(csinh(+Inf + 0i)) = 0", __imag__ result, 0); | |
2980 | result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, 0.0)); | |
2981 | check_isinfn ("real(csinh(-Inf + 0i)) = -Inf", __real__ result); | |
2982 | check ("imag(csinh(-Inf + 0i)) = 0", __imag__ result, 0); | |
2983 | result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, minus_zero)); | |
2984 | check_isinfp ("real(csinh(+Inf - 0i)) = +Inf", __real__ result); | |
2985 | check ("imag(csinh(+Inf - 0i)) = -0", __imag__ result, minus_zero); | |
2986 | result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, minus_zero)); | |
2987 | check_isinfn ("real(csinh(-Inf - 0i)) = -Inf", __real__ result); | |
2988 | check ("imag(csinh(-Inf - 0i)) = -0", __imag__ result, minus_zero); | |
2989 | ||
2990 | result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, plus_infty)); | |
779ae82e | 2991 | check_isinfp_exc ("real(csinh(+Inf + i Inf)) = +-Inf plus invalid exception", |
51702635 | 2992 | FUNC(fabs) (__real__ result), INVALID_EXCEPTION); |
779ae82e UD |
2993 | check_isnan ("imag(csinh(+Inf + i Inf)) = NaN plus invalid exception", |
2994 | __imag__ result); | |
993b3242 | 2995 | result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, plus_infty)); |
779ae82e | 2996 | check_isinfp_exc ("real(csinh(-Inf + i Inf)) = +-Inf plus invalid exception", |
51702635 | 2997 | FUNC(fabs) (__real__ result), INVALID_EXCEPTION); |
779ae82e UD |
2998 | check_isnan ("imag(csinh(-Inf + i Inf)) = NaN plus invalid exception", |
2999 | __imag__ result); | |
993b3242 | 3000 | result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, minus_infty)); |
779ae82e | 3001 | check_isinfp_exc ("real(csinh(Inf - i Inf)) = +-Inf plus invalid exception", |
51702635 | 3002 | FUNC(fabs) (__real__ result), INVALID_EXCEPTION); |
779ae82e UD |
3003 | check_isnan ("imag(csinh(Inf - i Inf)) = NaN plus invalid exception", |
3004 | __imag__ result); | |
993b3242 | 3005 | result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, minus_infty)); |
779ae82e | 3006 | check_isinfp_exc ("real(csinh(-Inf - i Inf)) = +-Inf plus invalid exception", |
51702635 | 3007 | FUNC(fabs) (__real__ result), INVALID_EXCEPTION); |
779ae82e UD |
3008 | check_isnan ("imag(csinh(-Inf - i Inf)) = NaN plus invalid exception", |
3009 | __imag__ result); | |
993b3242 UD |
3010 | |
3011 | result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, 4.625)); | |
3012 | check_isinfn ("real(csinh(+Inf + i4.625)) = -Inf", __real__ result); | |
3013 | check_isinfn ("imag(csinh(+Inf + i4.625)) = -Inf", __imag__ result); | |
3014 | result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, 4.625)); | |
3015 | check_isinfp ("real(csinh(-Inf + i4.625)) = +Inf", __real__ result); | |
3016 | check_isinfn ("imag(csinh(-Inf + i4.625)) = -Inf", __imag__ result); | |
3017 | result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, -4.625)); | |
3018 | check_isinfn ("real(csinh(+Inf - i4.625)) = -Inf", __real__ result); | |
3019 | check_isinfp ("imag(csinh(+Inf - i4.625)) = +Inf", __imag__ result); | |
3020 | result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, -4.625)); | |
3021 | check_isinfp ("real(csinh(-Inf - i4.625)) = +Inf", __real__ result); | |
3022 | check_isinfp ("imag(csinh(-Inf - i4.625)) = +Inf", __imag__ result); | |
3023 | ||
3024 | result = FUNC(csinh) (BUILD_COMPLEX (6.75, plus_infty)); | |
779ae82e | 3025 | check_isnan_exc ("real(csinh(6.75 + i Inf)) = NaN plus invalid exception", |
51702635 | 3026 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3027 | check_isnan ("imag(csinh(6.75 + i Inf)) = NaN plus invalid exception", |
3028 | __imag__ result); | |
993b3242 | 3029 | result = FUNC(csinh) (BUILD_COMPLEX (-6.75, plus_infty)); |
779ae82e | 3030 | check_isnan_exc ("real(csinh(-6.75 + i Inf)) = NaN plus invalid exception", |
51702635 | 3031 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3032 | check_isnan ("imag(csinh(-6.75 + i Inf)) = NaN plus invalid exception", |
3033 | __imag__ result); | |
993b3242 | 3034 | result = FUNC(csinh) (BUILD_COMPLEX (6.75, minus_infty)); |
779ae82e | 3035 | check_isnan_exc ("real(csinh(6.75 - i Inf)) = NaN plus invalid exception", |
51702635 | 3036 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3037 | check_isnan ("imag(csinh(6.75 - i Inf)) = NaN plus invalid exception", |
3038 | __imag__ result); | |
993b3242 | 3039 | result = FUNC(csinh) (BUILD_COMPLEX (-6.75, minus_infty)); |
779ae82e | 3040 | check_isnan_exc ("real(csinh(-6.75 - i Inf)) = NaN plus invalid exception", |
51702635 | 3041 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3042 | check_isnan ("imag(csinh(-6.75 - i Inf)) = NaN plus invalid exception", |
3043 | __imag__ result); | |
993b3242 UD |
3044 | |
3045 | result = FUNC(csinh) (BUILD_COMPLEX (0.0, nan_value)); | |
63551311 | 3046 | check ("real(csinh(0 + i NaN)) = +-0", FUNC(fabs) (__real__ result), 0); |
993b3242 UD |
3047 | check_isnan ("imag(csinh(0 + i NaN)) = NaN", __imag__ result); |
3048 | result = FUNC(csinh) (BUILD_COMPLEX (minus_zero, nan_value)); | |
63551311 | 3049 | check ("real(csinh(-0 + i NaN)) = +-0", FUNC(fabs) (__real__ result), 0); |
993b3242 UD |
3050 | check_isnan ("imag(csinh(-0 + i NaN)) = NaN", __imag__ result); |
3051 | ||
3052 | result = FUNC(csinh) (BUILD_COMPLEX (plus_infty, nan_value)); | |
3053 | check_isinfp ("real(csinh(+Inf + i NaN)) = +-Inf", | |
3054 | FUNC(fabs) (__real__ result)); | |
3055 | check_isnan ("imag(csinh(+Inf + i NaN)) = NaN", __imag__ result); | |
3056 | result = FUNC(csinh) (BUILD_COMPLEX (minus_infty, nan_value)); | |
3057 | check_isinfp ("real(csinh(-Inf + i NaN)) = +-Inf", | |
3058 | FUNC(fabs) (__real__ result)); | |
63551311 | 3059 | check_isnan ("imag(csinh(-Inf + i NaN)) = NaN", __imag__ result); |
993b3242 UD |
3060 | |
3061 | result = FUNC(csinh) (BUILD_COMPLEX (9.0, nan_value)); | |
779ae82e | 3062 | check_isnan_maybe_exc ("real(csinh(9.0 + i NaN)) = NaN plus maybe invalid exception", |
51702635 | 3063 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3064 | check_isnan ("imag(csinh(9.0 + i NaN)) = NaN plus maybe invalid exception", |
3065 | __imag__ result); | |
993b3242 | 3066 | result = FUNC(csinh) (BUILD_COMPLEX (-9.0, nan_value)); |
779ae82e | 3067 | check_isnan_maybe_exc ("real(csinh(-9.0 + i NaN)) = NaN plus maybe invalid exception", |
51702635 | 3068 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3069 | check_isnan ("imag(csinh(-9.0 + i NaN)) = NaN plus maybe invalid exception", |
3070 | __imag__ result); | |
993b3242 UD |
3071 | |
3072 | result = FUNC(csinh) (BUILD_COMPLEX (nan_value, 0.0)); | |
3073 | check_isnan ("real(csinh(NaN + i0)) = NaN", __real__ result); | |
63551311 | 3074 | check ("imag(csinh(NaN + i0)) = 0", __imag__ result, 0.0); |
993b3242 UD |
3075 | result = FUNC(csinh) (BUILD_COMPLEX (nan_value, minus_zero)); |
3076 | check_isnan ("real(csinh(NaN - i0)) = NaN", __real__ result); | |
63551311 | 3077 | check ("imag(csinh(NaN - i0)) = -0", __imag__ result, minus_zero); |
993b3242 UD |
3078 | |
3079 | result = FUNC(csinh) (BUILD_COMPLEX (nan_value, 10.0)); | |
779ae82e | 3080 | check_isnan_maybe_exc ("real(csinh(NaN + i10)) = NaN plus maybe invalid exception", |
51702635 | 3081 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3082 | check_isnan ("imag(csinh(NaN + i10)) = NaN plus maybe invalid exception", |
3083 | __imag__ result); | |
993b3242 | 3084 | result = FUNC(csinh) (BUILD_COMPLEX (nan_value, -10.0)); |
779ae82e | 3085 | check_isnan_maybe_exc ("real(csinh(NaN - i10)) = NaN plus maybe invalid exception", |
51702635 | 3086 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3087 | check_isnan ("imag(csinh(NaN - i10)) = NaN plus maybe invalid exception", |
3088 | __imag__ result); | |
993b3242 UD |
3089 | |
3090 | result = FUNC(csinh) (BUILD_COMPLEX (nan_value, plus_infty)); | |
51702635 UD |
3091 | check_isnan_maybe_exc ("real(csinh(NaN + i Inf)) = NaN plus maybe invalid exception", |
3092 | __real__ result, INVALID_EXCEPTION); | |
3093 | check_isnan ("imag(csinh(NaN + i Inf)) = NaN plus maybe invalid exception", | |
3094 | __imag__ result); | |
993b3242 | 3095 | result = FUNC(csinh) (BUILD_COMPLEX (nan_value, minus_infty)); |
51702635 UD |
3096 | check_isnan_maybe_exc ("real(csinh(NaN - i Inf)) = NaN plus maybe invalid exception", |
3097 | __real__ result, INVALID_EXCEPTION); | |
3098 | check_isnan ("imag(csinh(NaN - i Inf)) = NaN plus maybe invalid exception", | |
3099 | __imag__ result); | |
993b3242 UD |
3100 | |
3101 | result = FUNC(csinh) (BUILD_COMPLEX (nan_value, nan_value)); | |
3102 | check_isnan ("real(csinh(NaN + i NaN)) = NaN", __real__ result); | |
3103 | check_isnan ("imag(csinh(NaN + i NaN)) = NaN", __imag__ result); | |
bd355af0 UD |
3104 | |
3105 | result = FUNC(csinh) (BUILD_COMPLEX (0.7, 1.2)); | |
3106 | check_eps ("real(csinh(0.7 + i 1.2)) = 0.274878686...", __real__ result, | |
3107 | 0.27487868678117583582L, CHOOSE(2e-17L, 6e-17, 3e-8)); | |
3108 | check_eps ("imag(csinh(0.7 + i 1.2)) = 1.169866572...", __imag__ result, | |
74015205 | 3109 | 1.1698665727426565139L, CHOOSE(6e-17L, 0, 2e-7)); |
bd355af0 UD |
3110 | |
3111 | result = FUNC(csinh) (BUILD_COMPLEX (-2, -3)); | |
3112 | check_eps ("real(csinh(-2 - i 3)) == -3.59056...", __real__ result, | |
74015205 | 3113 | 3.5905645899857799520L, CHOOSE(7e-19L, 5e-16, 3e-7)); |
bd355af0 | 3114 | check_eps ("imag(csinh(-2 - i 3)) == -0.53092...", __imag__ result, |
74015205 | 3115 | -0.5309210862485198052L, CHOOSE(3e-19L, 2e-16, 6e-8)); |
993b3242 UD |
3116 | } |
3117 | ||
3118 | ||
63551311 UD |
3119 | static void |
3120 | ccos_test (void) | |
3121 | { | |
3122 | __complex__ MATHTYPE result; | |
3123 | ||
3124 | result = FUNC(ccos) (BUILD_COMPLEX (0.0, 0.0)); | |
3125 | check ("real(ccos(0 + 0i)) = 1.0", __real__ result, 1.0); | |
0a54e401 | 3126 | check ("imag(ccos(0 + 0i)) = -0", __imag__ result, minus_zero); |
63551311 UD |
3127 | result = FUNC(ccos) (BUILD_COMPLEX (minus_zero, 0.0)); |
3128 | check ("real(ccos(-0 + 0i)) = 1.0", __real__ result, 1.0); | |
0a54e401 | 3129 | check ("imag(ccos(-0 + 0i)) = 0", __imag__ result, 0.0); |
63551311 UD |
3130 | result = FUNC(ccos) (BUILD_COMPLEX (0.0, minus_zero)); |
3131 | check ("real(ccos(0 - 0i)) = 1.0", __real__ result, 1.0); | |
3132 | check ("imag(ccos(0 - 0i)) = 0", __imag__ result, 0.0); | |
3133 | result = FUNC(ccos) (BUILD_COMPLEX (minus_zero, minus_zero)); | |
3134 | check ("real(ccos(-0 - 0i)) = 1.0", __real__ result, 1.0); | |
3135 | check ("imag(ccos(-0 - 0i)) = -0", __imag__ result, minus_zero); | |
3136 | ||
3137 | result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, 0.0)); | |
779ae82e | 3138 | check_isnan_exc ("real(ccos(+Inf + i0)) = NaN plus invalid exception", |
51702635 | 3139 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3140 | check ("imag(ccos(Inf + i0)) = +-0 plus invalid exception", |
3141 | FUNC(fabs) (__imag__ result), 0); | |
63551311 | 3142 | result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, minus_zero)); |
779ae82e | 3143 | check_isnan_exc ("real(ccos(Inf - i0)) = NaN plus invalid exception", |
51702635 | 3144 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3145 | check ("imag(ccos(Inf - i0)) = +-0 plus invalid exception", |
3146 | FUNC(fabs) (__imag__ result), 0); | |
63551311 | 3147 | result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, 0.0)); |
779ae82e | 3148 | check_isnan_exc ("real(ccos(-Inf + i0)) = NaN plus invalid exception", |
51702635 | 3149 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3150 | check ("imag(ccos(-Inf + i0)) = +-0 plus invalid exception", |
3151 | FUNC(fabs) (__imag__ result), 0); | |
63551311 | 3152 | result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, minus_zero)); |
779ae82e | 3153 | check_isnan_exc ("real(ccos(-Inf - i0)) = NaN plus invalid exception", |
51702635 | 3154 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3155 | check ("imag(ccos(-Inf - i0)) = +-0 plus invalid exception", |
3156 | FUNC(fabs) (__imag__ result), 0); | |
63551311 UD |
3157 | |
3158 | result = FUNC(ccos) (BUILD_COMPLEX (0.0, plus_infty)); | |
3159 | check_isinfp ("real(ccos(0 + i Inf)) = +Inf", __real__ result); | |
0a54e401 | 3160 | check ("imag(ccos(0 + i Inf)) = -0", __imag__ result, minus_zero); |
63551311 UD |
3161 | result = FUNC(ccos) (BUILD_COMPLEX (0.0, minus_infty)); |
3162 | check_isinfp ("real(ccos(0 - i Inf)) = +Inf", __real__ result); | |
3163 | check ("imag(ccos(0 - i Inf)) = 0", __imag__ result, 0); | |
3164 | result = FUNC(ccos) (BUILD_COMPLEX (minus_zero, plus_infty)); | |
3165 | check_isinfp ("real(ccos(-0 + i Inf)) = +Inf", __real__ result); | |
0a54e401 | 3166 | check ("imag(ccos(-0 + i Inf)) = 0", __imag__ result, 0.0); |
63551311 UD |
3167 | result = FUNC(ccos) (BUILD_COMPLEX (minus_zero, minus_infty)); |
3168 | check_isinfp ("real(ccos(-0 - i Inf)) = +Inf", __real__ result); | |
3169 | check ("imag(ccos(-0 - i Inf)) = -0", __imag__ result, minus_zero); | |
3170 | ||
3171 | result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, plus_infty)); | |
779ae82e | 3172 | check_isinfp_exc ("real(ccos(+Inf + i Inf)) = +Inf plus invalid exception", |
51702635 | 3173 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3174 | check_isnan ("imag(ccos(+Inf + i Inf)) = NaN plus invalid exception", |
3175 | __imag__ result); | |
63551311 | 3176 | result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, plus_infty)); |
779ae82e | 3177 | check_isinfp_exc ("real(ccos(-Inf + i Inf)) = +Inf plus invalid exception", |
51702635 | 3178 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3179 | check_isnan ("imag(ccos(-Inf + i Inf)) = NaN plus invalid exception", |
3180 | __imag__ result); | |
63551311 | 3181 | result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, minus_infty)); |
779ae82e | 3182 | check_isinfp_exc ("real(ccos(Inf - i Inf)) = +Inf plus invalid exception", |
51702635 | 3183 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3184 | check_isnan ("imag(ccos(Inf - i Inf)) = NaN plus invalid exception", |
3185 | __imag__ result); | |
63551311 | 3186 | result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, minus_infty)); |
779ae82e | 3187 | check_isinfp_exc ("real(ccos(-Inf - i Inf)) = +Inf plus invalid exception", |
51702635 | 3188 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3189 | check_isnan ("imag(ccos(-Inf - i Inf)) = NaN plus invalid exception", |
3190 | __imag__ result); | |
63551311 UD |
3191 | |
3192 | result = FUNC(ccos) (BUILD_COMPLEX (4.625, plus_infty)); | |
3193 | check_isinfn ("real(ccos(4.625 + i Inf)) = -Inf", __real__ result); | |
0a54e401 | 3194 | check_isinfp ("imag(ccos(4.625 + i Inf)) = +Inf", __imag__ result); |
63551311 UD |
3195 | result = FUNC(ccos) (BUILD_COMPLEX (4.625, minus_infty)); |
3196 | check_isinfn ("real(ccos(4.625 - i Inf)) = -Inf", __real__ result); | |
3197 | check_isinfn ("imag(ccos(4.625 - i Inf)) = -Inf", __imag__ result); | |
3198 | result = FUNC(ccos) (BUILD_COMPLEX (-4.625, plus_infty)); | |
3199 | check_isinfn ("real(ccos(-4.625 + i Inf)) = -Inf", __real__ result); | |
0a54e401 | 3200 | check_isinfn ("imag(ccos(-4.625 + i Inf)) = -Inf", __imag__ result); |
63551311 UD |
3201 | result = FUNC(ccos) (BUILD_COMPLEX (-4.625, minus_infty)); |
3202 | check_isinfn ("real(ccos(-4.625 - i Inf)) = -Inf", __real__ result); | |
3203 | check_isinfp ("imag(ccos(-4.625 - i Inf)) = +Inf", __imag__ result); | |
3204 | ||
3205 | result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, 6.75)); | |
779ae82e | 3206 | check_isnan_exc ("real(ccos(+Inf + i6.75)) = NaN plus invalid exception", |
51702635 | 3207 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3208 | check_isnan ("imag(ccos(+Inf + i6.75)) = NaN plus invalid exception", |
3209 | __imag__ result); | |
63551311 | 3210 | result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, -6.75)); |
779ae82e | 3211 | check_isnan_exc ("real(ccos(+Inf - i6.75)) = NaN plus invalid exception", |
51702635 | 3212 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3213 | check_isnan ("imag(ccos(+Inf - i6.75)) = NaN plus invalid exception", |
3214 | __imag__ result); | |
63551311 | 3215 | result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, 6.75)); |
779ae82e | 3216 | check_isnan_exc ("real(ccos(-Inf + i6.75)) = NaN plus invalid exception", |
51702635 | 3217 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3218 | check_isnan ("imag(ccos(-Inf + i6.75)) = NaN plus invalid exception", |
3219 | __imag__ result); | |
63551311 | 3220 | result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, -6.75)); |
779ae82e | 3221 | check_isnan_exc ("real(ccos(-Inf - i6.75)) = NaN plus invalid exception", |
51702635 | 3222 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3223 | check_isnan ("imag(ccos(-Inf - i6.75)) = NaN plus invalid exception", |
3224 | __imag__ result); | |
63551311 UD |
3225 | |
3226 | result = FUNC(ccos) (BUILD_COMPLEX (nan_value, 0.0)); | |
3227 | check_isnan ("real(ccos(NaN + i0)) = NaN", __real__ result); | |
3228 | check ("imag(ccos(NaN + i0)) = +-0", FUNC(fabs) (__imag__ result), 0); | |
3229 | result = FUNC(ccos) (BUILD_COMPLEX (nan_value, minus_zero)); | |
3230 | check_isnan ("real(ccos(NaN - i0)) = NaN", __real__ result); | |
3231 | check ("imag(ccos(NaN - i0)) = +-0", FUNC(fabs) (__imag__ result), 0); | |
3232 | ||
3233 | result = FUNC(ccos) (BUILD_COMPLEX (nan_value, plus_infty)); | |
3234 | check_isinfp ("real(ccos(NaN + i Inf)) = +Inf", __real__ result); | |
3235 | check_isnan ("imag(ccos(NaN + i Inf)) = NaN", __imag__ result); | |
3236 | result = FUNC(ccos) (BUILD_COMPLEX (nan_value, minus_infty)); | |
3237 | check_isinfp ("real(ccos(NaN - i Inf)) = +Inf", __real__ result); | |
3238 | check_isnan ("imag(ccos(NaN - i Inf)) = NaN", __imag__ result); | |
3239 | ||
3240 | result = FUNC(ccos) (BUILD_COMPLEX (nan_value, 9.0)); | |
779ae82e | 3241 | check_isnan_maybe_exc ("real(ccos(NaN + i9.0)) = NaN plus maybe invalid exception", |
51702635 | 3242 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3243 | check_isnan ("imag(ccos(NaN + i9.0)) = NaN plus maybe invalid exception", |
3244 | __imag__ result); | |
63551311 | 3245 | result = FUNC(ccos) (BUILD_COMPLEX (nan_value, -9.0)); |
779ae82e | 3246 | check_isnan_maybe_exc ("real(ccos(NaN - i9.0)) = NaN plus maybe invalid exception", |
51702635 | 3247 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3248 | check_isnan ("imag(ccos(NaN - i9.0)) = NaN plus maybe invalid exception", |
3249 | __imag__ result); | |
63551311 UD |
3250 | |
3251 | result = FUNC(ccos) (BUILD_COMPLEX (0.0, nan_value)); | |
3252 | check_isnan ("real(ccos(0 + i NaN)) = NaN", __real__ result); | |
3253 | check ("imag(ccos(0 + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0.0); | |
3254 | result = FUNC(ccos) (BUILD_COMPLEX (minus_zero, nan_value)); | |
3255 | check_isnan ("real(ccos(-0 + i NaN)) = NaN", __real__ result); | |
3256 | check ("imag(ccos(-0 + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0.0); | |
3257 | ||
3258 | result = FUNC(ccos) (BUILD_COMPLEX (10.0, nan_value)); | |
779ae82e | 3259 | check_isnan_maybe_exc ("real(ccos(10 + i NaN)) = NaN plus maybe invalid exception", |
51702635 | 3260 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3261 | check_isnan ("imag(ccos(10 + i NaN)) = NaN plus maybe invalid exception", |
3262 | __imag__ result); | |
63551311 | 3263 | result = FUNC(ccos) (BUILD_COMPLEX (-10.0, nan_value)); |
779ae82e | 3264 | check_isnan_maybe_exc ("real(ccos(-10 + i NaN)) = NaN plus maybe invalid exception", |
51702635 | 3265 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3266 | check_isnan ("imag(ccos(-10 + i NaN)) = NaN plus maybe invalid exception", |
3267 | __imag__ result); | |
63551311 UD |
3268 | |
3269 | result = FUNC(ccos) (BUILD_COMPLEX (plus_infty, nan_value)); | |
779ae82e | 3270 | check_isnan_maybe_exc ("real(ccos(+Inf + i NaN)) = NaN plus maybe invalid exception", |
51702635 | 3271 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3272 | check_isnan ("imag(ccos(+Inf + i NaN)) = NaN plus maybe invalid exception", |
3273 | __imag__ result); | |
63551311 | 3274 | result = FUNC(ccos) (BUILD_COMPLEX (minus_infty, nan_value)); |
779ae82e | 3275 | check_isnan_maybe_exc ("real(ccos(-Inf + i NaN)) = NaN plus maybe invalid exception", |
51702635 | 3276 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3277 | check_isnan ("imag(ccos(-Inf + i NaN)) = NaN plus maybe invalid exception", |
3278 | __imag__ result); | |
63551311 UD |
3279 | |
3280 | result = FUNC(ccos) (BUILD_COMPLEX (nan_value, nan_value)); | |
3281 | check_isnan ("real(ccos(NaN + i NaN)) = NaN", __real__ result); | |
3282 | check_isnan ("imag(ccos(NaN + i NaN)) = NaN", __imag__ result); | |
bd355af0 UD |
3283 | |
3284 | result = FUNC(ccos) (BUILD_COMPLEX (0.7, 1.2)); | |
3285 | check_eps ("real(ccos(0.7 + i 1.2)) = 1.384865764...", __real__ result, | |
74015205 | 3286 | 1.3848657645312111080L, CHOOSE(4e-18L, 3e-16, 2e-7)); |
bd355af0 UD |
3287 | check_eps ("imag(ccos(0.7 + i 1.2)) = -0.972421703...", __imag__ result, |
3288 | -0.97242170335830028619L, CHOOSE(2e-16L, 2e-16, 0)); | |
3289 | ||
3290 | result = FUNC(ccos) (BUILD_COMPLEX (-2, -3)); | |
74015205 UD |
3291 | check_eps ("real(ccos(-2 - i 3)) == -4.18962...", __real__ result, |
3292 | -4.1896256909688072301L, CHOOSE(2e-17L, 0, 5e-7)); | |
bd355af0 | 3293 | check_eps ("imag(ccos(-2 - i 3)) == -9.10922...", __imag__ result, |
74015205 | 3294 | -9.1092278937553365979L, CHOOSE(3e-18L, 0, 1e-6)); |
63551311 UD |
3295 | } |
3296 | ||
3297 | ||
993b3242 UD |
3298 | static void |
3299 | ccosh_test (void) | |
3300 | { | |
3301 | __complex__ MATHTYPE result; | |
3302 | ||
3303 | result = FUNC(ccosh) (BUILD_COMPLEX (0.0, 0.0)); | |
63551311 | 3304 | check ("real(ccosh(0 + 0i)) = 1.0", __real__ result, 1.0); |
993b3242 UD |
3305 | check ("imag(ccosh(0 + 0i)) = 0", __imag__ result, 0); |
3306 | result = FUNC(ccosh) (BUILD_COMPLEX (minus_zero, 0.0)); | |
63551311 | 3307 | check ("real(ccosh(-0 + 0i)) = 1.0", __real__ result, 1.0); |
0a54e401 | 3308 | check ("imag(ccosh(-0 + 0i)) = -0", __imag__ result, minus_zero); |
993b3242 | 3309 | result = FUNC(ccosh) (BUILD_COMPLEX (0.0, minus_zero)); |
63551311 | 3310 | check ("real(ccosh(0 - 0i)) = 1.0", __real__ result, 1.0); |
993b3242 UD |
3311 | check ("imag(ccosh(0 - 0i)) = -0", __imag__ result, minus_zero); |
3312 | result = FUNC(ccosh) (BUILD_COMPLEX (minus_zero, minus_zero)); | |
63551311 | 3313 | check ("real(ccosh(-0 - 0i)) = 1.0", __real__ result, 1.0); |
0a54e401 | 3314 | check ("imag(ccosh(-0 - 0i)) = 0", __imag__ result, 0.0); |
993b3242 UD |
3315 | |
3316 | result = FUNC(ccosh) (BUILD_COMPLEX (0.0, plus_infty)); | |
779ae82e | 3317 | check_isnan_exc ("real(ccosh(0 + i Inf)) = NaN plus invalid exception", |
51702635 | 3318 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3319 | check ("imag(ccosh(0 + i Inf)) = +-0 plus invalid exception", |
3320 | FUNC(fabs) (__imag__ result), 0); | |
993b3242 | 3321 | result = FUNC(ccosh) (BUILD_COMPLEX (minus_zero, plus_infty)); |
779ae82e | 3322 | check_isnan_exc ("real(ccosh(-0 + i Inf)) = NaN plus invalid exception", |
51702635 | 3323 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3324 | check ("imag(ccosh(-0 + i Inf)) = +-0 plus invalid exception", |
3325 | FUNC(fabs) (__imag__ result), 0); | |
993b3242 | 3326 | result = FUNC(ccosh) (BUILD_COMPLEX (0.0, minus_infty)); |
779ae82e | 3327 | check_isnan_exc ("real(ccosh(0 - i Inf)) = NaN plus invalid exception", |
51702635 | 3328 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3329 | check ("imag(ccosh(0 - i Inf)) = +-0 plus invalid exception", |
3330 | FUNC(fabs) (__imag__ result), 0); | |
993b3242 | 3331 | result = FUNC(ccosh) (BUILD_COMPLEX (minus_zero, minus_infty)); |
779ae82e | 3332 | check_isnan_exc ("real(ccosh(-0 - i Inf)) = NaN plus invalid exception", |
51702635 | 3333 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3334 | check ("imag(ccosh(-0 - i Inf)) = +-0 plus invalid exception", |
3335 | FUNC(fabs) (__imag__ result), 0); | |
993b3242 UD |
3336 | |
3337 | result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, 0.0)); | |
3338 | check_isinfp ("real(ccosh(+Inf + 0i)) = +Inf", __real__ result); | |
3339 | check ("imag(ccosh(+Inf + 0i)) = 0", __imag__ result, 0); | |
3340 | result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, 0.0)); | |
3341 | check_isinfp ("real(ccosh(-Inf + 0i)) = +Inf", __real__ result); | |
0a54e401 | 3342 | check ("imag(ccosh(-Inf + 0i)) = -0", __imag__ result, minus_zero); |
993b3242 UD |
3343 | result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, minus_zero)); |
3344 | check_isinfp ("real(ccosh(+Inf - 0i)) = +Inf", __real__ result); | |
3345 | check ("imag(ccosh(+Inf - 0i)) = -0", __imag__ result, minus_zero); | |
3346 | result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, minus_zero)); | |
3347 | check_isinfp ("real(ccosh(-Inf - 0i)) = +Inf", __real__ result); | |
0a54e401 | 3348 | check ("imag(ccosh(-Inf - 0i)) = 0", __imag__ result, 0.0); |
993b3242 UD |
3349 | |
3350 | result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, plus_infty)); | |
779ae82e | 3351 | check_isinfp_exc ("real(ccosh(+Inf + i Inf)) = +Inf plus invalid exception", |
51702635 | 3352 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3353 | check_isnan ("imag(ccosh(+Inf + i Inf)) = NaN plus invalid exception", |
3354 | __imag__ result); | |
993b3242 | 3355 | result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, plus_infty)); |
779ae82e | 3356 | check_isinfp_exc ("real(ccosh(-Inf + i Inf)) = +Inf plus invalid exception", |
51702635 | 3357 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3358 | check_isnan ("imag(ccosh(-Inf + i Inf)) = NaN plus invalid exception", |
3359 | __imag__ result); | |
993b3242 | 3360 | result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, minus_infty)); |
779ae82e | 3361 | check_isinfp_exc ("real(ccosh(Inf - i Inf)) = +Inf plus invalid exception", |
51702635 | 3362 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3363 | check_isnan ("imag(ccosh(Inf - i Inf)) = NaN plus invalid exception", |
3364 | __imag__ result); | |
993b3242 | 3365 | result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, minus_infty)); |
779ae82e | 3366 | check_isinfp_exc ("real(ccosh(-Inf - i Inf)) = +Inf plus invalid exception", |
51702635 | 3367 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3368 | check_isnan ("imag(ccosh(-Inf - i Inf)) = NaN plus invalid exception", |
3369 | __imag__ result); | |
993b3242 UD |
3370 | |
3371 | result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, 4.625)); | |
3372 | check_isinfn ("real(ccosh(+Inf + i4.625)) = -Inf", __real__ result); | |
3373 | check_isinfn ("imag(ccosh(+Inf + i4.625)) = -Inf", __imag__ result); | |
3374 | result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, 4.625)); | |
3375 | check_isinfn ("real(ccosh(-Inf + i4.625)) = -Inf", __real__ result); | |
0a54e401 | 3376 | check_isinfp ("imag(ccosh(-Inf + i4.625)) = Inf", __imag__ result); |
993b3242 UD |
3377 | result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, -4.625)); |
3378 | check_isinfn ("real(ccosh(+Inf - i4.625)) = -Inf", __real__ result); | |
3379 | check_isinfp ("imag(ccosh(+Inf - i4.625)) = +Inf", __imag__ result); | |
3380 | result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, -4.625)); | |
3381 | check_isinfn ("real(ccosh(-Inf - i4.625)) = -Inf", __real__ result); | |
0a54e401 | 3382 | check_isinfn ("imag(ccosh(-Inf - i4.625)) = -Inf", __imag__ result); |
993b3242 UD |
3383 | |
3384 | result = FUNC(ccosh) (BUILD_COMPLEX (6.75, plus_infty)); | |
779ae82e | 3385 | check_isnan_exc ("real(ccosh(6.75 + i Inf)) = NaN plus invalid exception", |
51702635 | 3386 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3387 | check_isnan ("imag(ccosh(6.75 + i Inf)) = NaN plus invalid exception", |
3388 | __imag__ result); | |
993b3242 | 3389 | result = FUNC(ccosh) (BUILD_COMPLEX (-6.75, plus_infty)); |
779ae82e | 3390 | check_isnan_exc ("real(ccosh(-6.75 + i Inf)) = NaN plus invalid exception", |
51702635 | 3391 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3392 | check_isnan ("imag(ccosh(-6.75 + i Inf)) = NaN plus invalid exception", |
3393 | __imag__ result); | |
993b3242 | 3394 | result = FUNC(ccosh) (BUILD_COMPLEX (6.75, minus_infty)); |
779ae82e | 3395 | check_isnan_exc ("real(ccosh(6.75 - i Inf)) = NaN plus invalid exception", |
51702635 | 3396 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3397 | check_isnan ("imag(ccosh(6.75 - i Inf)) = NaN plus invalid exception", |
3398 | __imag__ result); | |
993b3242 | 3399 | result = FUNC(ccosh) (BUILD_COMPLEX (-6.75, minus_infty)); |
779ae82e | 3400 | check_isnan_exc ("real(ccosh(-6.75 - i Inf)) = NaN plus invalid exception", |
51702635 | 3401 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3402 | check_isnan ("imag(ccosh(-6.75 - i Inf)) = NaN plus invalid exception", |
3403 | __imag__ result); | |
993b3242 UD |
3404 | |
3405 | result = FUNC(ccosh) (BUILD_COMPLEX (0.0, nan_value)); | |
3406 | check_isnan ("real(ccosh(0 + i NaN)) = NaN", __real__ result); | |
3407 | check ("imag(ccosh(0 + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0); | |
3408 | result = FUNC(ccosh) (BUILD_COMPLEX (minus_zero, nan_value)); | |
3409 | check_isnan ("real(ccosh(-0 + i NaN)) = NaN", __real__ result); | |
3410 | check ("imag(ccosh(-0 + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0); | |
3411 | ||
3412 | result = FUNC(ccosh) (BUILD_COMPLEX (plus_infty, nan_value)); | |
3413 | check_isinfp ("real(ccosh(+Inf + i NaN)) = +Inf", __real__ result); | |
3414 | check_isnan ("imag(ccosh(+Inf + i NaN)) = NaN", __imag__ result); | |
3415 | result = FUNC(ccosh) (BUILD_COMPLEX (minus_infty, nan_value)); | |
3416 | check_isinfp ("real(ccosh(-Inf + i NaN)) = +Inf", __real__ result); | |
63551311 | 3417 | check_isnan ("imag(ccosh(-Inf + i NaN)) = NaN", __imag__ result); |
993b3242 UD |
3418 | |
3419 | result = FUNC(ccosh) (BUILD_COMPLEX (9.0, nan_value)); | |
779ae82e | 3420 | check_isnan_maybe_exc ("real(ccosh(9.0 + i NaN)) = NaN plus maybe invalid exception", |
51702635 | 3421 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3422 | check_isnan ("imag(ccosh(9.0 + i NaN)) = NaN plus maybe invalid exception", |
3423 | __imag__ result); | |
993b3242 | 3424 | result = FUNC(ccosh) (BUILD_COMPLEX (-9.0, nan_value)); |
779ae82e | 3425 | check_isnan_maybe_exc ("real(ccosh(-9.0 + i NaN)) = NaN plus maybe invalid exception", |
51702635 | 3426 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3427 | check_isnan ("imag(ccosh(-9.0 + i NaN)) = NaN plus maybe invalid exception", |
3428 | __imag__ result); | |
993b3242 UD |
3429 | |
3430 | result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, 0.0)); | |
3431 | check_isnan ("real(ccosh(NaN + i0)) = NaN", __real__ result); | |
63551311 | 3432 | check ("imag(ccosh(NaN + i0)) = +-0", FUNC(fabs) (__imag__ result), 0.0); |
993b3242 UD |
3433 | result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, minus_zero)); |
3434 | check_isnan ("real(ccosh(NaN - i0)) = NaN", __real__ result); | |
63551311 | 3435 | check ("imag(ccosh(NaN - i0)) = +-0", FUNC(fabs) (__imag__ result), 0.0); |
993b3242 UD |
3436 | |
3437 | result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, 10.0)); | |
779ae82e | 3438 | check_isnan_maybe_exc ("real(ccosh(NaN + i10)) = NaN plus maybe invalid exception", |
51702635 | 3439 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3440 | check_isnan ("imag(ccosh(NaN + i10)) = NaN plus maybe invalid exception", |
3441 | __imag__ result); | |
993b3242 | 3442 | result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, -10.0)); |
779ae82e | 3443 | check_isnan_maybe_exc ("real(ccosh(NaN - i10)) = NaN plus maybe invalid exception", |
51702635 | 3444 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3445 | check_isnan ("imag(ccosh(NaN - i10)) = NaN plus maybe invalid exception", |
3446 | __imag__ result); | |
993b3242 UD |
3447 | |
3448 | result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, plus_infty)); | |
779ae82e | 3449 | check_isnan_maybe_exc ("real(ccosh(NaN + i Inf)) = NaN plus maybe invalid exception", |
51702635 | 3450 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3451 | check_isnan ("imag(ccosh(NaN + i Inf)) = NaN plus maybe invalid exception", |
3452 | __imag__ result); | |
993b3242 | 3453 | result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, minus_infty)); |
779ae82e | 3454 | check_isnan_maybe_exc ("real(ccosh(NaN - i Inf)) = NaN plus maybe invalid exception", |
51702635 | 3455 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3456 | check_isnan ("imag(ccosh(NaN - i Inf)) = NaN plus maybe invalid exception", |
3457 | __imag__ result); | |
993b3242 UD |
3458 | |
3459 | result = FUNC(ccosh) (BUILD_COMPLEX (nan_value, nan_value)); | |
3460 | check_isnan ("real(ccosh(NaN + i NaN)) = NaN", __real__ result); | |
3461 | check_isnan ("imag(ccosh(NaN + i NaN)) = NaN", __imag__ result); | |
bd355af0 UD |
3462 | |
3463 | result = FUNC(ccosh) (BUILD_COMPLEX (0.7, 1.2)); | |
3464 | check_eps ("real(ccosh(0.7 + i 1.2)) == 0.45482...", __real__ result, | |
74015205 | 3465 | 0.4548202223691477654L, CHOOSE(5e-17L, 6e-17, 9e-8)); |
bd355af0 | 3466 | check_eps ("imag(ccosh(0.7 + i 1.2)) == 0.70702...", __imag__ result, |
66000494 | 3467 | 0.7070296600921537682L, CHOOSE(7e-17L, 2e-16, 0)); |
bd355af0 UD |
3468 | |
3469 | result = FUNC(ccosh) (BUILD_COMPLEX (-2, -3)); | |
74015205 UD |
3470 | check_eps ("real(ccosh(-2 - i 3)) == -3.72454...", __real__ result, |
3471 | -3.7245455049153225654L, CHOOSE(7e-19L, 0, 3e-7)); | |
bd355af0 | 3472 | check_eps ("imag(ccosh(-2 - i 3)) == -0.51182...", __imag__ result, |
74015205 | 3473 | 0.5118225699873846088L, CHOOSE(3e-19L, 2e-16, 6e-8)); |
993b3242 UD |
3474 | } |
3475 | ||
3476 | ||
993b3242 UD |
3477 | static void |
3478 | cacos_test (void) | |
3479 | { | |
3480 | __complex__ MATHTYPE result; | |
3481 | ||
3482 | result = FUNC(cacos) (BUILD_COMPLEX (0, 0)); | |
0a614877 | 3483 | check ("real(cacos(0 + i0)) = pi/2", __real__ result, M_PI_2l); |
993b3242 UD |
3484 | check ("imag(cacos(0 + i0)) = -0", __imag__ result, minus_zero); |
3485 | result = FUNC(cacos) (BUILD_COMPLEX (minus_zero, 0)); | |
0a614877 | 3486 | check ("real(cacos(-0 + i0)) = pi/2", __real__ result, M_PI_2l); |
993b3242 UD |
3487 | check ("imag(cacos(-0 + i0)) = -0", __imag__ result, minus_zero); |
3488 | result = FUNC(cacos) (BUILD_COMPLEX (0, minus_zero)); | |
0a614877 | 3489 | check ("real(cacos(0 - i0)) = pi/2", __real__ result, M_PI_2l); |
993b3242 UD |
3490 | check ("imag(cacos(0 - i0)) = 0", __imag__ result, 0); |
3491 | result = FUNC(cacos) (BUILD_COMPLEX (minus_zero, minus_zero)); | |
0a614877 | 3492 | check ("real(cacos(-0 - i0)) = pi/2", __real__ result, M_PI_2l); |
993b3242 UD |
3493 | check ("imag(cacos(-0 - i0)) = 0", __imag__ result, 0); |
3494 | ||
3495 | result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, plus_infty)); | |
0a614877 UD |
3496 | check ("real(cacos(-Inf + i Inf)) = 3*pi/4", __real__ result, |
3497 | M_PIl - M_PI_4l); | |
993b3242 UD |
3498 | check_isinfn ("imag(cacos(-Inf + i Inf)) = -Inf", __imag__ result); |
3499 | result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, minus_infty)); | |
0a614877 UD |
3500 | check ("real(cacos(-Inf - i Inf)) = 3*pi/4", __real__ result, |
3501 | M_PIl - M_PI_4l); | |
993b3242 UD |
3502 | check_isinfp ("imag(cacos(-Inf - i Inf)) = +Inf", __imag__ result); |
3503 | ||
3504 | result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, plus_infty)); | |
0a614877 | 3505 | check ("real(cacos(+Inf + i Inf)) = pi/4", __real__ result, M_PI_4l); |
993b3242 UD |
3506 | check_isinfn ("imag(cacos(+Inf + i Inf)) = -Inf", __imag__ result); |
3507 | result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, minus_infty)); | |
0a614877 | 3508 | check ("real(cacos(+Inf - i Inf)) = pi/4", __real__ result, M_PI_4l); |
993b3242 UD |
3509 | check_isinfp ("imag(cacos(+Inf - i Inf)) = +Inf", __imag__ result); |
3510 | ||
3511 | result = FUNC(cacos) (BUILD_COMPLEX (-10.0, plus_infty)); | |
0a614877 | 3512 | check ("real(cacos(-10.0 + i Inf)) = pi/2", __real__ result, M_PI_2l); |
993b3242 UD |
3513 | check_isinfn ("imag(cacos(-10.0 + i Inf)) = -Inf", __imag__ result); |
3514 | result = FUNC(cacos) (BUILD_COMPLEX (-10.0, minus_infty)); | |
0a614877 | 3515 | check ("real(cacos(-10.0 - i Inf)) = pi/2", __real__ result, M_PI_2l); |
993b3242 UD |
3516 | check_isinfp ("imag(cacos(-10.0 - i Inf)) = +Inf", __imag__ result); |
3517 | result = FUNC(cacos) (BUILD_COMPLEX (0, plus_infty)); | |
0a614877 | 3518 | check ("real(cacos(0 + i Inf)) = pi/2", __real__ result, M_PI_2l); |
993b3242 UD |
3519 | check_isinfn ("imag(cacos(0 + i Inf)) = -Inf", __imag__ result); |
3520 | result = FUNC(cacos) (BUILD_COMPLEX (0, minus_infty)); | |
0a614877 | 3521 | check ("real(cacos(0 - i Inf)) = pi/2", __real__ result, M_PI_2l); |
993b3242 UD |
3522 | check_isinfp ("imag(cacos(0 - i Inf)) = +Inf", __imag__ result); |
3523 | result = FUNC(cacos) (BUILD_COMPLEX (0.1, plus_infty)); | |
0a614877 | 3524 | check ("real(cacos(0.1 + i Inf)) = pi/2", __real__ result, M_PI_2l); |
993b3242 UD |
3525 | check_isinfn ("imag(cacos(0.1 + i Inf)) = -Inf", __imag__ result); |
3526 | result = FUNC(cacos) (BUILD_COMPLEX (0.1, minus_infty)); | |
0a614877 | 3527 | check ("real(cacos(0.1 - i Inf)) = pi/2", __real__ result, M_PI_2l); |
993b3242 UD |
3528 | check_isinfp ("imag(cacos(0.1 - i Inf)) = +Inf", __imag__ result); |
3529 | ||
3530 | result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, 0)); | |
0a614877 | 3531 | check ("real(cacos(-Inf + i0)) = pi", __real__ result, M_PIl); |
993b3242 UD |
3532 | check_isinfn ("imag(cacos(-Inf + i0)) = -Inf", __imag__ result); |
3533 | result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, minus_zero)); | |
0a614877 | 3534 | check ("real(cacos(-Inf - i0)) = pi", __real__ result, M_PIl); |
993b3242 UD |
3535 | check_isinfp ("imag(cacos(-Inf - i0)) = +Inf", __imag__ result); |
3536 | result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, 100)); | |
0a614877 | 3537 | check ("real(cacos(-Inf + i100)) = pi", __real__ result, M_PIl); |
993b3242 UD |
3538 | check_isinfn ("imag(cacos(-Inf + i100)) = -Inf", __imag__ result); |
3539 | result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, -100)); | |
0a614877 | 3540 | check ("real(cacos(-Inf - i100)) = pi", __real__ result, M_PIl); |
993b3242 UD |
3541 | check_isinfp ("imag(cacos(-Inf - i100)) = +Inf", __imag__ result); |
3542 | ||
3543 | result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, 0)); | |
3544 | check ("real(cacos(+Inf + i0)) = 0", __real__ result, 0); | |
3545 | check_isinfn ("imag(cacos(+Inf + i0)) = -Inf", __imag__ result); | |
3546 | result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, minus_zero)); | |
3547 | check ("real(cacos(+Inf - i0)) = 0", __real__ result, 0); | |
3548 | check_isinfp ("imag(cacos(+Inf - i0)) = +Inf", __imag__ result); | |
3549 | result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, 0.5)); | |
3550 | check ("real(cacos(+Inf + i0.5)) = 0", __real__ result, 0); | |
3551 | check_isinfn ("imag(cacos(+Inf + i0.5)) = -Inf", __imag__ result); | |
3552 | result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, -0.5)); | |
3553 | check ("real(cacos(+Inf - i0.5)) = 0", __real__ result, 0); | |
3554 | check_isinfp ("imag(cacos(+Inf - i0.5)) = +Inf", __imag__ result); | |
3555 | ||
3556 | result = FUNC(cacos) (BUILD_COMPLEX (plus_infty, nan_value)); | |
3557 | check_isnan ("real(cacos(+Inf + i NaN)) = NaN", __real__ result); | |
3558 | check_isinfp ("imag(cacos(+Inf + i NaN)) = +-Inf", | |
3559 | FUNC(fabs) (__imag__ result)); | |
3560 | result = FUNC(cacos) (BUILD_COMPLEX (minus_infty, nan_value)); | |
3561 | check_isnan ("real(cacos(-Inf + i NaN)) = NaN", __real__ result); | |
3562 | check_isinfp ("imag(cacos(-Inf + i NaN)) = +-Inf", | |
3563 | FUNC(fabs) (__imag__ result)); | |
3564 | ||
3565 | result = FUNC(cacos) (BUILD_COMPLEX (0, nan_value)); | |
0a614877 | 3566 | check ("real(cacos(0 + i NaN)) = pi/2", __real__ result, M_PI_2l); |
993b3242 UD |
3567 | check_isnan ("imag(cacos(0 + i NaN)) = NaN", __imag__ result); |
3568 | result = FUNC(cacos) (BUILD_COMPLEX (minus_zero, nan_value)); | |
0a614877 | 3569 | check ("real(cacos(-0 + i NaN)) = pi/2", __real__ result, M_PI_2l); |
993b3242 UD |
3570 | check_isnan ("imag(cacos(-0 + i NaN)) = NaN", __imag__ result); |
3571 | ||
3572 | result = FUNC(cacos) (BUILD_COMPLEX (nan_value, plus_infty)); | |
3573 | check_isnan ("real(cacos(NaN + i Inf)) = NaN", __real__ result); | |
3574 | check_isinfn ("imag(cacos(NaN + i Inf)) = -Inf", __imag__ result); | |
3575 | result = FUNC(cacos) (BUILD_COMPLEX (nan_value, minus_infty)); | |
3576 | check_isnan ("real(cacos(NaN - i Inf)) = NaN", __real__ result); | |
3577 | check_isinfp ("imag(cacos(NaN - i Inf)) = +Inf", __imag__ result); | |
3578 | ||
3579 | result = FUNC(cacos) (BUILD_COMPLEX (10.5, nan_value)); | |
779ae82e | 3580 | check_isnan_maybe_exc ("real(cacos(10.5 + i NaN)) = NaN plus maybe invalid exception", |
51702635 | 3581 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3582 | check_isnan ("imag(cacos(10.5 + i NaN)) = NaN plus maybe invalid exception", |
3583 | __imag__ result); | |
993b3242 | 3584 | result = FUNC(cacos) (BUILD_COMPLEX (-10.5, nan_value)); |
779ae82e | 3585 | check_isnan_maybe_exc ("real(cacos(-10.5 + i NaN)) = NaN plus maybe invalid exception", |
51702635 | 3586 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3587 | check_isnan ("imag(cacos(-10.5 + i NaN)) = NaN plus maybe invalid exception", |
3588 | __imag__ result); | |
993b3242 UD |
3589 | |
3590 | result = FUNC(cacos) (BUILD_COMPLEX (nan_value, 0.75)); | |
779ae82e | 3591 | check_isnan_maybe_exc ("real(cacos(NaN + i0.75)) = NaN plus maybe invalid exception", |
51702635 | 3592 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3593 | check_isnan ("imag(cacos(NaN + i0.75)) = NaN plus maybe invalid exception", |
3594 | __imag__ result); | |
993b3242 | 3595 | result = FUNC(cacos) (BUILD_COMPLEX (-10.5, nan_value)); |
779ae82e | 3596 | check_isnan_maybe_exc ("real(cacos(NaN - i0.75)) = NaN plus maybe invalid exception", |
51702635 | 3597 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3598 | check_isnan ("imag(cacos(NaN - i0.75)) = NaN plus maybe invalid exception", |
3599 | __imag__ result); | |
993b3242 UD |
3600 | |
3601 | result = FUNC(cacos) (BUILD_COMPLEX (nan_value, nan_value)); | |
3602 | check_isnan ("real(cacos(NaN + i NaN)) = NaN", __real__ result); | |
3603 | check_isnan ("imag(cacos(NaN + i NaN)) = NaN", __imag__ result); | |
bd355af0 UD |
3604 | |
3605 | result = FUNC(cacos) (BUILD_COMPLEX (0.7, 1.2)); | |
3606 | check_eps ("real(cacos(0.7 + i 1.2)) == 1.13518...", __real__ result, | |
3607 | 1.1351827477151551089L, CHOOSE(2e-17L, 3e-16, 2e-7)); | |
3608 | check_eps ("imag(cacos(0.7 + i 1.2)) == -1.09276...", __imag__ result, | |
66000494 | 3609 | -1.0927647857577371459L, CHOOSE(4e-17L, 3e-16, 3e-7)); |
bd355af0 UD |
3610 | |
3611 | result = FUNC(cacos) (BUILD_COMPLEX (-2, -3)); | |
74015205 UD |
3612 | check_eps ("real(cacos(-2 - i 3)) == 2.14144...", __real__ result, |
3613 | 2.1414491111159960199L, CHOOSE(3e-19L, 0, 0)); | |
bd355af0 | 3614 | check_eps ("imag(cacos(-2 - i 3)) == -1.98338...", __imag__ result, |
74015205 | 3615 | 1.9833870299165354323L, CHOOSE(3e-19L, 0, 0)); |
993b3242 UD |
3616 | } |
3617 | ||
3618 | ||
3619 | static void | |
3620 | cacosh_test (void) | |
3621 | { | |
3622 | __complex__ MATHTYPE result; | |
3623 | ||
3624 | result = FUNC(cacosh) (BUILD_COMPLEX (0, 0)); | |
3625 | check ("real(cacosh(0 + i0)) = 0", __real__ result, 0); | |
0a614877 | 3626 | check ("imag(cacosh(0 + i0)) = pi/2", __imag__ result, M_PI_2l); |
993b3242 UD |
3627 | result = FUNC(cacosh) (BUILD_COMPLEX (minus_zero, 0)); |
3628 | check ("real(cacosh(-0 + i0)) = 0", __real__ result, 0); | |
0a614877 | 3629 | check ("imag(cacosh(-0 + i0)) = pi/2", __imag__ result, M_PI_2l); |
993b3242 UD |
3630 | result = FUNC(cacosh) (BUILD_COMPLEX (0, minus_zero)); |
3631 | check ("real(cacosh(0 - i0)) = 0", __real__ result, 0); | |
0a614877 | 3632 | check ("imag(cacosh(0 - i0)) = -pi/2", __imag__ result, -M_PI_2l); |
993b3242 UD |
3633 | result = FUNC(cacosh) (BUILD_COMPLEX (minus_zero, minus_zero)); |
3634 | check ("real(cacosh(-0 - i0)) = 0", __real__ result, 0); | |
0a614877 | 3635 | check ("imag(cacosh(-0 - i0)) = -pi/2", __imag__ result, -M_PI_2l); |
993b3242 UD |
3636 | |
3637 | result = FUNC(cacosh) (BUILD_COMPLEX (minus_infty, plus_infty)); | |
3638 | check_isinfp ("real(cacosh(-Inf + i Inf)) = +Inf", __real__ result); | |
3639 | check ("imag(cacosh(-Inf + i Inf)) = 3*pi/4", __imag__ result, | |
0a614877 | 3640 | M_PIl - M_PI_4l); |
993b3242 UD |
3641 | result = FUNC(cacosh) (BUILD_COMPLEX (minus_infty, minus_infty)); |
3642 | check_isinfp ("real(cacosh(-Inf - i Inf)) = +Inf", __real__ result); | |
3643 | check ("imag(cacosh(-Inf - i Inf)) = -3*pi/4", __imag__ result, | |
0a614877 | 3644 | M_PI_4l - M_PIl); |
993b3242 UD |
3645 | |
3646 | result = FUNC(cacosh) (BUILD_COMPLEX (plus_infty, plus_infty)); | |
3647 | check_isinfp ("real(cacosh(+Inf + i Inf)) = +Inf", __real__ result); | |
0a614877 | 3648 | check ("imag(cacosh(+Inf + i Inf)) = pi/4", __imag__ result, M_PI_4l); |
993b3242 UD |
3649 | result = FUNC(cacosh) (BUILD_COMPLEX (plus_infty, minus_infty)); |
3650 | check_isinfp ("real(cacosh(+Inf - i Inf)) = +Inf", __real__ result); | |
0a614877 | 3651 | check ("imag(cacosh(+Inf - i Inf)) = -pi/4", __imag__ result, -M_PI_4l); |
993b3242 UD |
3652 | |
3653 | result = FUNC(cacosh) (BUILD_COMPLEX (-10.0, plus_infty)); | |
3654 | check_isinfp ("real(cacosh(-10.0 + i Inf)) = +Inf", __real__ result); | |
0a614877 | 3655 | check ("imag(cacosh(-10.0 + i Inf)) = pi/2", __imag__ result, M_PI_2l); |
993b3242 UD |
3656 | result = FUNC(cacosh) (BUILD_COMPLEX (-10.0, minus_infty)); |
3657 | check_isinfp ("real(cacosh(-10.0 - i Inf)) = +Inf", __real__ result); | |
0a614877 | 3658 | check ("imag(cacosh(-10.0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2l); |
993b3242 UD |
3659 | result = FUNC(cacosh) (BUILD_COMPLEX (0, plus_infty)); |
3660 | check_isinfp ("real(cacosh(0 + i Inf)) = +Inf", __real__ result); | |
0a614877 | 3661 | check ("imag(cacosh(0 + i Inf)) = pi/2", __imag__ result, M_PI_2l); |
993b3242 UD |
3662 | result = FUNC(cacosh) (BUILD_COMPLEX (0, minus_infty)); |
3663 | check_isinfp ("real(cacosh(0 - i Inf)) = +Inf", __real__ result); | |
0a614877 | 3664 | check ("imag(cacosh(0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2l); |
993b3242 UD |
3665 | result = FUNC(cacosh) (BUILD_COMPLEX (0.1, plus_infty)); |
3666 | check_isinfp ("real(cacosh(0.1 + i Inf)) = +Inf", __real__ result); | |
0a614877 | 3667 | check ("imag(cacosh(0.1 + i Inf)) = pi/2", __imag__ result, M_PI_2l); |
993b3242 UD |
3668 | result = FUNC(cacosh) (BUILD_COMPLEX (0.1, minus_infty)); |
3669 | check_isinfp ("real(cacosh(0.1 - i Inf)) = +Inf", __real__ result); | |
0a614877 | 3670 | check ("imag(cacosh(0.1 - i Inf)) = -pi/2", __imag__ result, -M_PI_2l); |
993b3242 UD |
3671 | |
3672 | result = FUNC(cacosh) (BUILD_COMPLEX (minus_infty, 0)); | |
3673 | check_isinfp ("real(cacosh(-Inf + i0)) = +Inf", __real__ result); | |
0a614877 | 3674 | check ("imag(cacosh(-Inf + i0)) = pi", __imag__ result, M_PIl); |
993b3242 UD |
3675 | result = FUNC(cacosh) (BUILD_COMPLEX (minus_infty, minus_zero)); |
3676 | check_isinfp ("real(cacosh(-Inf - i0)) = +Inf", __real__ result); | |
0a614877 | 3677 | check ("imag(cacosh(-Inf - i0)) = -pi", __imag__ result, -M_PIl); |
993b3242 UD |
3678 | result = FUNC(cacosh) (BUILD_COMPLEX (minus_infty, 100)); |
3679 | check_isinfp ("real(cacosh(-Inf + i100)) = +Inf", __real__ result); | |
0a614877 | 3680 | check ("imag(cacosh(-Inf + i100)) = pi", __imag__ result, M_PIl); |
993b3242 UD |
3681 | result = FUNC(cacosh) (BUILD_COMPLEX (minus_infty, -100)); |
3682 | check_isinfp ("real(cacosh(-Inf - i100)) = +Inf", __real__ result); | |
0a614877 | 3683 | check ("imag(cacosh(-Inf - i100)) = -pi", __imag__ result, -M_PIl); |
993b3242 UD |
3684 | |
3685 | result = FUNC(cacosh) (BUILD_COMPLEX (plus_infty, 0)); | |
3686 | check_isinfp ("real(cacosh(+Inf + i0)) = +Inf", __real__ result); | |
3687 | check ("imag(cacosh(+Inf + i0)) = 0", __imag__ result, 0); | |
3688 | result = FUNC(cacosh) (BUILD_COMPLEX (plus_infty, minus_zero)); | |
3689 | check_isinfp ("real(cacosh(+Inf - i0)) = +Inf", __real__ result); | |
3690 | check ("imag(cacosh(+Inf - i0)) = -0", __imag__ result, minus_zero); | |
3691 | result = FUNC(cacosh) (BUILD_COMPLEX (plus_infty, 0.5)); | |
3692 | check_isinfp ("real(cacosh(+Inf + i0.5)) = +Inf", __real__ result); | |
3693 | check ("imag(cacosh(+Inf + i0.5)) = 0", __imag__ result, 0); | |
3694 | result = FUNC(cacosh) (BUILD_COMPLEX (plus_infty, -0.5)); | |
3695 | check_isinfp ("real(cacosh(+Inf - i0.5)) = +Inf", __real__ result); | |
3696 | check ("imag(cacosh(+Inf - i0.5)) = -0", __imag__ result, minus_zero); | |
3697 | ||
3698 | result = FUNC(cacosh) (BUILD_COMPLEX (plus_infty, nan_value)); | |
3699 | check_isinfp ("real(cacosh(+Inf + i NaN)) = +Inf", __real__ result); | |
3700 | check_isnan ("imag(cacosh(+Inf + i NaN)) = NaN", __imag__ result); | |
3701 | result = FUNC(cacosh) (BUILD_COMPLEX (minus_infty, nan_value)); | |
3702 | check_isinfp ("real(cacosh(-Inf + i NaN)) = +Inf", __real__ result); | |
3703 | check_isnan ("imag(cacosh(-Inf + i NaN)) = NaN", __imag__ result); | |
3704 | ||
3705 | result = FUNC(cacosh) (BUILD_COMPLEX (0, nan_value)); | |
3706 | check_isnan ("real(cacosh(0 + i NaN)) = NaN", __real__ result); | |
3707 | check_isnan ("imag(cacosh(0 + i NaN)) = NaN", __imag__ result); | |
3708 | result = FUNC(cacosh) (BUILD_COMPLEX (minus_zero, nan_value)); | |
3709 | check_isnan ("real(cacosh(-0 + i NaN)) = NaN", __real__ result); | |
3710 | check_isnan ("imag(cacosh(-0 + i NaN)) = NaN", __imag__ result); | |
3711 | ||
3712 | result = FUNC(cacosh) (BUILD_COMPLEX (nan_value, plus_infty)); | |
3713 | check_isinfp ("real(cacosh(NaN + i Inf)) = +Inf", __real__ result); | |
3714 | check_isnan ("imag(cacosh(NaN + i Inf)) = NaN", __imag__ result); | |
3715 | result = FUNC(cacosh) (BUILD_COMPLEX (nan_value, minus_infty)); | |
3716 | check_isinfp ("real(cacosh(NaN - i Inf)) = +Inf", __real__ result); | |
3717 | check_isnan ("imag(cacosh(NaN - i Inf)) = NaN", __imag__ result); | |
3718 | ||
3719 | result = FUNC(cacosh) (BUILD_COMPLEX (10.5, nan_value)); | |
779ae82e | 3720 | check_isnan_maybe_exc ("real(cacosh(10.5 + i NaN)) = NaN plus maybe invalid exception", |
51702635 | 3721 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3722 | check_isnan ("imag(cacosh(10.5 + i NaN)) = NaN plus maybe invalid exception", |
3723 | __imag__ result); | |
993b3242 | 3724 | result = FUNC(cacosh) (BUILD_COMPLEX (-10.5, nan_value)); |
779ae82e | 3725 | check_isnan_maybe_exc ("real(cacosh(-10.5 + i NaN)) = NaN plus maybe invalid exception", |
51702635 | 3726 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3727 | check_isnan ("imag(cacosh(-10.5 + i NaN)) = NaN plus maybe invalid exception", |
3728 | __imag__ result); | |
993b3242 UD |
3729 | |
3730 | result = FUNC(cacosh) (BUILD_COMPLEX (nan_value, 0.75)); | |
779ae82e | 3731 | check_isnan_maybe_exc ("real(cacosh(NaN + i0.75)) = NaN plus maybe invalid exception", |
51702635 | 3732 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3733 | check_isnan ("imag(cacosh(NaN + i0.75)) = NaN plus maybe invalid exception", |
3734 | __imag__ result); | |
993b3242 | 3735 | result = FUNC(cacosh) (BUILD_COMPLEX (-10.5, nan_value)); |
779ae82e | 3736 | check_isnan_maybe_exc ("real(cacosh(NaN - i0.75)) = NaN plus maybe invalid exception", |
51702635 | 3737 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3738 | check_isnan ("imag(cacosh(NaN - i0.75)) = NaN plus maybe invalid exception", |
3739 | __imag__ result); | |
993b3242 UD |
3740 | |
3741 | result = FUNC(cacosh) (BUILD_COMPLEX (nan_value, nan_value)); | |
3742 | check_isnan ("real(cacosh(NaN + i NaN)) = NaN", __real__ result); | |
3743 | check_isnan ("imag(cacosh(NaN + i NaN)) = NaN", __imag__ result); | |
bd355af0 UD |
3744 | |
3745 | result = FUNC(cacosh) (BUILD_COMPLEX (0.7, 1.2)); | |
3746 | check_eps ("real(cacosh(0.7 + i 1.2)) == 1.09276...", __real__ result, | |
66000494 | 3747 | 1.0927647857577371459L, CHOOSE(4e-17L, 3e-16, 2e-7)); |
bd355af0 | 3748 | check_eps ("imag(cacosh(0.7 + i 1.2)) == 1.13518...", __imag__ result, |
5edb9387 | 3749 | 1.1351827477151551089L, CHOOSE(2e-17L, 0, 1.2e-7)); |
bd355af0 UD |
3750 | |
3751 | result = FUNC(cacosh) (BUILD_COMPLEX (-2, -3)); | |
3752 | check_eps ("real(cacosh(-2 - i 3)) == -1.98338...", __real__ result, | |
74015205 | 3753 | -1.9833870299165354323L, CHOOSE (2e-18L, 3e-16, 9e-7)); |
bd355af0 | 3754 | check_eps ("imag(cacosh(-2 - i 3)) == 2.14144...", __imag__ result, |
5edb9387 | 3755 | 2.1414491111159960199L, CHOOSE (4.5e-19, 5e-16, 1e-6)); |
993b3242 UD |
3756 | } |
3757 | ||
3758 | ||
63551311 UD |
3759 | static void |
3760 | casin_test (void) | |
3761 | { | |
3762 | __complex__ MATHTYPE result; | |
3763 | ||
3764 | result = FUNC(casin) (BUILD_COMPLEX (0, 0)); | |
3765 | check ("real(casin(0 + i0)) = 0", __real__ result, 0); | |
3766 | check ("imag(casin(0 + i0)) = 0", __imag__ result, 0); | |
3767 | result = FUNC(casin) (BUILD_COMPLEX (minus_zero, 0)); | |
3768 | check ("real(casin(-0 + i0)) = -0", __real__ result, minus_zero); | |
3769 | check ("imag(casin(-0 + i0)) = 0", __imag__ result, 0); | |
3770 | result = FUNC(casin) (BUILD_COMPLEX (0, minus_zero)); | |
3771 | check ("real(casin(0 - i0)) = 0", __real__ result, 0); | |
3772 | check ("imag(casin(0 - i0)) = -0", __imag__ result, minus_zero); | |
3773 | result = FUNC(casin) (BUILD_COMPLEX (minus_zero, minus_zero)); | |
3774 | check ("real(casin(-0 - i0)) = -0", __real__ result, minus_zero); | |
3775 | check ("imag(casin(-0 - i0)) = -0", __imag__ result, minus_zero); | |
3776 | ||
3777 | result = FUNC(casin) (BUILD_COMPLEX (plus_infty, plus_infty)); | |
0a614877 | 3778 | check ("real(casin(+Inf + i Inf)) = pi/4", __real__ result, M_PI_4l); |
63551311 UD |
3779 | check_isinfp ("imag(casin(+Inf + i Inf)) = +Inf", __imag__ result); |
3780 | result = FUNC(casin) (BUILD_COMPLEX (plus_infty, minus_infty)); | |
0a614877 | 3781 | check ("real(casin(+Inf - i Inf)) = pi/4", __real__ result, M_PI_4l); |
63551311 UD |
3782 | check_isinfn ("imag(casin(+Inf - i Inf)) = -Inf", __imag__ result); |
3783 | result = FUNC(casin) (BUILD_COMPLEX (minus_infty, plus_infty)); | |
0a614877 | 3784 | check ("real(casin(-Inf + i Inf)) = -pi/4", __real__ result, -M_PI_4l); |
63551311 UD |
3785 | check_isinfp ("imag(casin(-Inf + i Inf)) = +Inf", __imag__ result); |
3786 | result = FUNC(casin) (BUILD_COMPLEX (minus_infty, minus_infty)); | |
0a614877 | 3787 | check ("real(casin(-Inf - i Inf)) = -pi/4", __real__ result, -M_PI_4l); |
63551311 UD |
3788 | check_isinfn ("imag(casin(-Inf - i Inf)) = -Inf", __imag__ result); |
3789 | ||
3790 | result = FUNC(casin) (BUILD_COMPLEX (-10.0, plus_infty)); | |
3791 | check ("real(casin(-10.0 + i Inf)) = -0", __real__ result, minus_zero); | |
3792 | check_isinfp ("imag(casin(-10.0 + i Inf)) = +Inf", __imag__ result); | |
3793 | result = FUNC(casin) (BUILD_COMPLEX (-10.0, minus_infty)); | |
3794 | check ("real(casin(-10.0 - i Inf)) = -0", __real__ result, minus_zero); | |
3795 | check_isinfn ("imag(casin(-10.0 - i Inf)) = -Inf", __imag__ result); | |
3796 | result = FUNC(casin) (BUILD_COMPLEX (0, plus_infty)); | |
3797 | check ("real(casin(0 + i Inf)) = 0", __real__ result, 0.0); | |
3798 | check_isinfp ("imag(casin(0 + i Inf)) = +Inf", __imag__ result); | |
3799 | result = FUNC(casin) (BUILD_COMPLEX (0, minus_infty)); | |
3800 | check ("real(casin(0 - i Inf)) = 0", __real__ result, 0.0); | |
3801 | check_isinfn ("imag(casin(0 - i Inf)) = -Inf", __imag__ result); | |
3802 | result = FUNC(casin) (BUILD_COMPLEX (minus_zero, plus_infty)); | |
3803 | check ("real(casin(-0 + i Inf)) = -0", __real__ result, minus_zero); | |
3804 | check_isinfp ("imag(casin(-0 + i Inf)) = +Inf", __imag__ result); | |
3805 | result = FUNC(casin) (BUILD_COMPLEX (minus_zero, minus_infty)); | |
3806 | check ("real(casin(-0 - i Inf)) = -0", __real__ result, minus_zero); | |
3807 | check_isinfn ("imag(casin(-0 - i Inf)) = -Inf", __imag__ result); | |
3808 | result = FUNC(casin) (BUILD_COMPLEX (0.1, plus_infty)); | |
3809 | check ("real(casin(0.1 + i Inf)) = 0", __real__ result, 0); | |
3810 | check_isinfp ("imag(casin(0.1 + i Inf)) = +Inf", __imag__ result); | |
3811 | result = FUNC(casin) (BUILD_COMPLEX (0.1, minus_infty)); | |
3812 | check ("real(casin(0.1 - i Inf)) = 0", __real__ result, 0); | |
3813 | check_isinfn ("imag(casin(0.1 - i Inf)) = -Inf", __imag__ result); | |
3814 | ||
3815 | result = FUNC(casin) (BUILD_COMPLEX (minus_infty, 0)); | |
0a614877 | 3816 | check ("real(casin(-Inf + i0)) = -pi/2", __real__ result, -M_PI_2l); |
63551311 UD |
3817 | check_isinfp ("imag(casin(-Inf + i0)) = +Inf", __imag__ result); |
3818 | result = FUNC(casin) (BUILD_COMPLEX (minus_infty, minus_zero)); | |
0a614877 | 3819 | check ("real(casin(-Inf - i0)) = -pi/2", __real__ result, -M_PI_2l); |
63551311 UD |
3820 | check_isinfn ("imag(casin(-Inf - i0)) = -Inf", __imag__ result); |
3821 | result = FUNC(casin) (BUILD_COMPLEX (minus_infty, 100)); | |
0a614877 | 3822 | check ("real(casin(-Inf + i100)) = -pi/2", __real__ result, -M_PI_2l); |
63551311 UD |
3823 | check_isinfp ("imag(casin(-Inf + i100)) = +Inf", __imag__ result); |
3824 | result = FUNC(casin) (BUILD_COMPLEX (minus_infty, -100)); | |
0a614877 | 3825 | check ("real(casin(-Inf - i100)) = -pi/2", __real__ result, -M_PI_2l); |
63551311 UD |
3826 | check_isinfn ("imag(casin(-Inf - i100)) = -Inf", __imag__ result); |
3827 | ||
3828 | result = FUNC(casin) (BUILD_COMPLEX (plus_infty, 0)); | |
0a614877 | 3829 | check ("real(casin(+Inf + i0)) = pi/2", __real__ result, M_PI_2l); |
63551311 UD |
3830 | check_isinfp ("imag(casin(+Inf + i0)) = +Inf", __imag__ result); |
3831 | result = FUNC(casin) (BUILD_COMPLEX (plus_infty, minus_zero)); | |
0a614877 | 3832 | check ("real(casin(+Inf - i0)) = pi/2", __real__ result, M_PI_2l); |
63551311 UD |
3833 | check_isinfn ("imag(casin(+Inf - i0)) = -Inf", __imag__ result); |
3834 | result = FUNC(casin) (BUILD_COMPLEX (plus_infty, 0.5)); | |
0a614877 | 3835 | check ("real(casin(+Inf + i0.5)) = pi/2", __real__ result, M_PI_2l); |
63551311 UD |
3836 | check_isinfp ("imag(casin(+Inf + i0.5)) = +Inf", __imag__ result); |
3837 | result = FUNC(casin) (BUILD_COMPLEX (plus_infty, -0.5)); | |
0a614877 | 3838 | check ("real(casin(+Inf - i0.5)) = pi/2", __real__ result, M_PI_2l); |
63551311 UD |
3839 | check_isinfn ("imag(casin(+Inf - i0.5)) = -Inf", __imag__ result); |
3840 | ||
3841 | result = FUNC(casin) (BUILD_COMPLEX (nan_value, plus_infty)); | |
3842 | check_isnan ("real(casin(NaN + i Inf)) = NaN", __real__ result); | |
3843 | check_isinfp ("imag(casin(NaN + i Inf)) = +Inf", __imag__ result); | |
3844 | result = FUNC(casin) (BUILD_COMPLEX (nan_value, minus_infty)); | |
3845 | check_isnan ("real(casin(NaN - i Inf)) = NaN", __real__ result); | |
3846 | check_isinfn ("imag(casin(NaN - i Inf)) = -Inf", __imag__ result); | |
3847 | ||
3848 | result = FUNC(casin) (BUILD_COMPLEX (0.0, nan_value)); | |
3849 | check ("real(casin(0 + i NaN)) = 0", __real__ result, 0.0); | |
3850 | check_isnan ("imag(casin(0 + i NaN)) = NaN", __imag__ result); | |
3851 | result = FUNC(casin) (BUILD_COMPLEX (minus_zero, nan_value)); | |
3852 | check ("real(casin(-0 + i NaN)) = -0", __real__ result, minus_zero); | |
3853 | check_isnan ("imag(casin(-0 + i NaN)) = NaN", __imag__ result); | |
3854 | ||
3855 | result = FUNC(casin) (BUILD_COMPLEX (plus_infty, nan_value)); | |
3856 | check_isnan ("real(casin(+Inf + i NaN)) = NaN", __real__ result); | |
3857 | check_isinfp ("imag(casin(+Inf + i NaN)) = +-Inf", | |
3858 | FUNC(fabs) (__imag__ result)); | |
3859 | result = FUNC(casin) (BUILD_COMPLEX (minus_infty, nan_value)); | |
3860 | check_isnan ("real(casin(-Inf + i NaN)) = NaN", __real__ result); | |
3861 | check_isinfp ("imag(casin(-Inf + NaN)) = +-Inf", | |
3862 | FUNC(fabs) (__imag__ result)); | |
3863 | ||
3864 | result = FUNC(casin) (BUILD_COMPLEX (nan_value, 10.5)); | |
779ae82e | 3865 | check_isnan_maybe_exc ("real(casin(NaN + i10.5)) = NaN plus maybe invalid exception", |
51702635 | 3866 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3867 | check_isnan ("imag(casin(NaN + i10.5)) = NaN plus maybe invalid exception", |
3868 | __imag__ result); | |
63551311 | 3869 | result = FUNC(casin) (BUILD_COMPLEX (nan_value, -10.5)); |
779ae82e | 3870 | check_isnan_maybe_exc ("real(casin(NaN - i10.5)) = NaN plus maybe invalid exception", |
51702635 | 3871 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3872 | check_isnan ("imag(casin(NaN - i10.5)) = NaN plus maybe invalid exception", |
3873 | __imag__ result); | |
63551311 UD |
3874 | |
3875 | result = FUNC(casin) (BUILD_COMPLEX (0.75, nan_value)); | |
779ae82e | 3876 | check_isnan_maybe_exc ("real(casin(0.75 + i NaN)) = NaN plus maybe invalid exception", |
51702635 | 3877 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3878 | check_isnan ("imag(casin(0.75 + i NaN)) = NaN plus maybe invalid exception", |
3879 | __imag__ result); | |
63551311 | 3880 | result = FUNC(casin) (BUILD_COMPLEX (-0.75, nan_value)); |
779ae82e | 3881 | check_isnan_maybe_exc ("real(casin(-0.75 + i NaN)) = NaN plus maybe invalid exception", |
51702635 | 3882 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
3883 | check_isnan ("imag(casin(-0.75 + i NaN)) = NaN plus maybe invalid exception", |
3884 | __imag__ result); | |
63551311 UD |
3885 | |
3886 | result = FUNC(casin) (BUILD_COMPLEX (nan_value, nan_value)); | |
3887 | check_isnan ("real(casin(NaN + i NaN)) = NaN", __real__ result); | |
3888 | check_isnan ("imag(casin(NaN + i NaN)) = NaN", __imag__ result); | |
bd355af0 UD |
3889 | |
3890 | result = FUNC(casin) (BUILD_COMPLEX (0.7, 1.2)); | |
3891 | check_eps ("real(casin(0.7 + i 1.2)) == 0.43561...", __real__ result, | |
3892 | 0.4356135790797415103L, CHOOSE(2e-17L, 2e-16, 2e-7)); | |
3893 | check_eps ("imag(casin(0.7 + i 1.2)) == 1.09276...", __imag__ result, | |
66000494 | 3894 | 1.0927647857577371459L, CHOOSE(4e-17L, 3e-16, 3e-7)); |
bd355af0 UD |
3895 | |
3896 | result = FUNC(casin) (BUILD_COMPLEX (-2, -3)); | |
74015205 UD |
3897 | check_eps ("real(casin(-2 - i 3)) == -0.57065...", __real__ result, |
3898 | -0.5706527843210994007L, CHOOSE(4e-19L, 0, 0)); | |
bd355af0 | 3899 | check_eps ("imag(casin(-2 - i 3)) == -1.98338...", __imag__ result, |
74015205 | 3900 | -1.9833870299165354323L, CHOOSE(3e-19L, 0, 0)); |
63551311 UD |
3901 | } |
3902 | ||
3903 | ||
993b3242 UD |
3904 | static void |
3905 | casinh_test (void) | |
3906 | { | |
3907 | __complex__ MATHTYPE result; | |
3908 | ||
3909 | result = FUNC(casinh) (BUILD_COMPLEX (0, 0)); | |
3910 | check ("real(casinh(0 + i0)) = 0", __real__ result, 0); | |
3911 | check ("imag(casinh(0 + i0)) = 0", __imag__ result, 0); | |
3912 | result = FUNC(casinh) (BUILD_COMPLEX (minus_zero, 0)); | |
3913 | check ("real(casinh(-0 + i0)) = -0", __real__ result, minus_zero); | |
3914 | check ("imag(casinh(-0 + i0)) = 0", __imag__ result, 0); | |
3915 | result = FUNC(casinh) (BUILD_COMPLEX (0, minus_zero)); | |
3916 | check ("real(casinh(0 - i0)) = 0", __real__ result, 0); | |
3917 | check ("imag(casinh(0 - i0)) = -0", __imag__ result, minus_zero); | |
3918 | result = FUNC(casinh) (BUILD_COMPLEX (minus_zero, minus_zero)); | |
3919 | check ("real(casinh(-0 - i0)) = -0", __real__ result, minus_zero); | |
3920 | check ("imag(casinh(-0 - i0)) = -0", __imag__ result, minus_zero); | |
3921 | ||
3922 | result = FUNC(casinh) (BUILD_COMPLEX (plus_infty, plus_infty)); | |
3923 | check_isinfp ("real(casinh(+Inf + i Inf)) = +Inf", __real__ result); | |
0a614877 | 3924 | check ("imag(casinh(+Inf + i Inf)) = pi/4", __imag__ result, M_PI_4l); |
993b3242 UD |
3925 | result = FUNC(casinh) (BUILD_COMPLEX (plus_infty, minus_infty)); |
3926 | check_isinfp ("real(casinh(+Inf - i Inf)) = +Inf", __real__ result); | |
0a614877 | 3927 | check ("imag(casinh(+Inf - i Inf)) = -pi/4", __imag__ result, -M_PI_4l); |
993b3242 UD |
3928 | result = FUNC(casinh) (BUILD_COMPLEX (minus_infty, plus_infty)); |
3929 | check_isinfn ("real(casinh(-Inf + i Inf)) = -Inf", __real__ result); | |
0a614877 | 3930 | check ("imag(casinh(-Inf + i Inf)) = pi/4", __imag__ result, M_PI_4l); |
993b3242 UD |
3931 | result = FUNC(casinh) (BUILD_COMPLEX (minus_infty, minus_infty)); |
3932 | check_isinfn ("real(casinh(-Inf - i Inf)) = -Inf", __real__ result); | |
0a614877 | 3933 | check ("imag(casinh(-Inf - i Inf)) = -pi/4", __imag__ result, -M_PI_4l); |
993b3242 UD |
3934 | |
3935 | result = FUNC(casinh) (BUILD_COMPLEX (-10.0, plus_infty)); | |
3936 | check_isinfn ("real(casinh(-10.0 + i Inf)) = -Inf", __real__ result); | |
0a614877 | 3937 | check ("imag(casinh(-10.0 + i Inf)) = pi/2", __imag__ result, M_PI_2l); |
993b3242 UD |
3938 | result = FUNC(casinh) (BUILD_COMPLEX (-10.0, minus_infty)); |
3939 | check_isinfn ("real(casinh(-10.0 - i Inf)) = -Inf", __real__ result); | |
0a614877 | 3940 | check ("imag(casinh(-10.0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2l); |
993b3242 UD |
3941 | result = FUNC(casinh) (BUILD_COMPLEX (0, plus_infty)); |
3942 | check_isinfp ("real(casinh(0 + i Inf)) = +Inf", __real__ result); | |
0a614877 | 3943 | check ("imag(casinh(0 + i Inf)) = pi/2", __imag__ result, M_PI_2l); |
993b3242 UD |
3944 | result = FUNC(casinh) (BUILD_COMPLEX (0, minus_infty)); |
3945 | check_isinfp ("real(casinh(0 - i Inf)) = +Inf", __real__ result); | |
0a614877 | 3946 | check ("imag(casinh(0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2l); |
63551311 UD |
3947 | result = FUNC(casinh) (BUILD_COMPLEX (minus_zero, plus_infty)); |
3948 | check_isinfn ("real(casinh(-0 + i Inf)) = -Inf", __real__ result); | |
0a614877 | 3949 | check ("imag(casinh(-0 + i Inf)) = pi/2", __imag__ result, M_PI_2l); |
63551311 UD |
3950 | result = FUNC(casinh) (BUILD_COMPLEX (minus_zero, minus_infty)); |
3951 | check_isinfn ("real(casinh(-0 - i Inf)) = -Inf", __real__ result); | |
0a614877 | 3952 | check ("imag(casinh(-0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2l); |
993b3242 UD |
3953 | result = FUNC(casinh) (BUILD_COMPLEX (0.1, plus_infty)); |
3954 | check_isinfp ("real(casinh(0.1 + i Inf)) = +Inf", __real__ result); | |
0a614877 | 3955 | check ("imag(casinh(0.1 + i Inf)) = pi/2", __imag__ result, M_PI_2l); |
993b3242 UD |
3956 | result = FUNC(casinh) (BUILD_COMPLEX (0.1, minus_infty)); |
3957 | check_isinfp ("real(casinh(0.1 - i Inf)) = +Inf", __real__ result); | |
0a614877 | 3958 | check ("imag(casinh(0.1 - i Inf)) = -pi/2", __imag__ result, -M_PI_2l); |
993b3242 UD |
3959 | |
3960 | result = FUNC(casinh) (BUILD_COMPLEX (minus_infty, 0)); | |
3961 | check_isinfn ("real(casinh(-Inf + i0)) = -Inf", __real__ result); | |
3962 | check ("imag(casinh(-Inf + i0)) = 0", __imag__ result, 0); | |
3963 | result = FUNC(casinh) (BUILD_COMPLEX (minus_infty, minus_zero)); | |
3964 | check_isinfn ("real(casinh(-Inf - i0)) = -Inf", __real__ result); | |
3965 | check ("imag(casinh(-Inf - i0)) = -0", __imag__ result, minus_zero); | |
3966 | result = FUNC(casinh) (BUILD_COMPLEX (minus_infty, 100)); | |
3967 | check_isinfn ("real(casinh(-Inf + i100)) = -Inf", __real__ result); | |
3968 | check ("imag(casinh(-Inf + i100)) = 0", __imag__ result, 0); | |
3969 | result = FUNC(casinh) (BUILD_COMPLEX (minus_infty, -100)); | |
3970 | check_isinfn ("real(casinh(-Inf - i100)) = -Inf", __real__ result); | |
3971 | check ("imag(casinh(-Inf - i100)) = -0", __imag__ result, minus_zero); | |
3972 | ||
3973 | result = FUNC(casinh) (BUILD_COMPLEX (plus_infty, 0)); | |
3974 | check_isinfp ("real(casinh(+Inf + i0)) = +Inf", __real__ result); | |
3975 | check ("imag(casinh(+Inf + i0)) = 0", __imag__ result, 0); | |
3976 | result = FUNC(casinh) (BUILD_COMPLEX (plus_infty, minus_zero)); | |
3977 | check_isinfp ("real(casinh(+Inf - i0)) = +Inf", __real__ result); | |
3978 | check ("imag(casinh(+Inf - i0)) = -0", __imag__ result, minus_zero); | |
3979 | result = FUNC(casinh) (BUILD_COMPLEX (plus_infty, 0.5)); | |
3980 | check_isinfp ("real(casinh(+Inf + i0.5)) = +Inf", __real__ result); | |
3981 | check ("imag(casinh(+Inf + i0.5)) = 0", __imag__ result, 0); | |
3982 | result = FUNC(casinh) (BUILD_COMPLEX (plus_infty, -0.5)); | |
3983 | check_isinfp ("real(casinh(+Inf - i0.5)) = +Inf", __real__ result); | |
3984 | check ("imag(casinh(+Inf - i0.5)) = -0", __imag__ result, minus_zero); | |
3985 | ||
3986 | result = FUNC(casinh) (BUILD_COMPLEX (plus_infty, nan_value)); | |
3987 | check_isinfp ("real(casinh(+Inf + i NaN)) = +Inf", __real__ result); | |
3988 | check_isnan ("imag(casinh(+Inf + i NaN)) = NaN", __imag__ result); | |
3989 | result = FUNC(casinh) (BUILD_COMPLEX (minus_infty, nan_value)); | |
3990 | check_isinfn ("real(casinh(-Inf + i NaN)) = -Inf", __real__ result); | |
3991 | check_isnan ("imag(casinh(-Inf + i NaN)) = NaN", __imag__ result); | |
3992 | ||
3993 | result = FUNC(casinh) (BUILD_COMPLEX (nan_value, 0)); | |
3994 | check_isnan ("real(casinh(NaN + i0)) = NaN", __real__ result); | |
63551311 UD |
3995 | check ("imag(casinh(NaN + i0)) = 0", __imag__ result, 0); |
3996 | result = FUNC(casinh) (BUILD_COMPLEX (nan_value, minus_zero)); | |
993b3242 UD |
3997 | check_isnan ("real(casinh(NaN - i0)) = NaN", __real__ result); |
3998 | check ("imag(casinh(NaN - i0)) = -0", __imag__ result, minus_zero); | |
3999 | ||
4000 | result = FUNC(casinh) (BUILD_COMPLEX (nan_value, plus_infty)); | |
63551311 | 4001 | check_isinfp ("real(casinh(NaN + i Inf)) = +-Inf", |
993b3242 UD |
4002 | FUNC(fabs) (__real__ result)); |
4003 | check_isnan ("imag(casinh(NaN + i Inf)) = NaN", __imag__ result); | |
4004 | result = FUNC(casinh) (BUILD_COMPLEX (nan_value, minus_infty)); | |
63551311 | 4005 | check_isinfp ("real(casinh(NaN - i Inf)) = +-Inf", |
993b3242 UD |
4006 | FUNC(fabs) (__real__ result)); |
4007 | check_isnan ("imag(casinh(NaN - i Inf)) = NaN", __imag__ result); | |
4008 | ||
4009 | result = FUNC(casinh) (BUILD_COMPLEX (10.5, nan_value)); | |
779ae82e | 4010 | check_isnan_maybe_exc ("real(casinh(10.5 + i NaN)) = NaN plus maybe invalid exception", |
51702635 | 4011 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
4012 | check_isnan ("imag(casinh(10.5 + i NaN)) = NaN plus maybe invalid exception", |
4013 | __imag__ result); | |
993b3242 | 4014 | result = FUNC(casinh) (BUILD_COMPLEX (-10.5, nan_value)); |
779ae82e | 4015 | check_isnan_maybe_exc ("real(casinh(-10.5 + i NaN)) = NaN plus maybe invalid exception", |
51702635 | 4016 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
4017 | check_isnan ("imag(casinh(-10.5 + i NaN)) = NaN plus maybe invalid exception", |
4018 | __imag__ result); | |
993b3242 UD |
4019 | |
4020 | result = FUNC(casinh) (BUILD_COMPLEX (nan_value, 0.75)); | |
779ae82e | 4021 | check_isnan_maybe_exc ("real(casinh(NaN + i0.75)) = NaN plus maybe invalid exception", |
51702635 | 4022 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
4023 | check_isnan ("imag(casinh(NaN + i0.75)) = NaN plus maybe invalid exception", |
4024 | __imag__ result); | |
63551311 | 4025 | result = FUNC(casinh) (BUILD_COMPLEX (-0.75, nan_value)); |
779ae82e | 4026 | check_isnan_maybe_exc ("real(casinh(NaN - i0.75)) = NaN plus maybe invalid exception", |
51702635 | 4027 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
4028 | check_isnan ("imag(casinh(NaN - i0.75)) = NaN plus maybe invalid exception", |
4029 | __imag__ result); | |
993b3242 UD |
4030 | |
4031 | result = FUNC(casinh) (BUILD_COMPLEX (nan_value, nan_value)); | |
4032 | check_isnan ("real(casinh(NaN + i NaN)) = NaN", __real__ result); | |
4033 | check_isnan ("imag(casinh(NaN + i NaN)) = NaN", __imag__ result); | |
bd355af0 UD |
4034 | |
4035 | result = FUNC(casinh) (BUILD_COMPLEX (0.7, 1.2)); | |
4036 | check_eps ("real(casinh(0.7 + i 1.2)) == 0.97865...", __real__ result, | |
4037 | 0.9786545955936738768L, CHOOSE(5e-17L, 2e-16, 0)); | |
4038 | check_eps ("imag(casinh(0.7 + i 1.2)) == 0.91135...", __imag__ result, | |
7ce241a0 | 4039 | 0.9113541895315601156L, CHOOSE(7e-19L, 2e-16, 2e-7)); |
bd355af0 UD |
4040 | |
4041 | result = FUNC(casinh) (BUILD_COMPLEX (-2, -3)); | |
74015205 | 4042 | check_eps ("real(casinh(-2 - i 3)) == -1.96863...", __real__ result, |
7ce241a0 | 4043 | -1.9686379257930962917L, CHOOSE(7e-19L, 2e-15, 3e-6)); |
bd355af0 | 4044 | check_eps ("imag(casinh(-2 - i 3)) == -0.96465...", __imag__ result, |
5edb9387 | 4045 | -0.9646585044076027920L, CHOOSE(4e-19L, 2e-15, 4.5e-7)); |
993b3242 UD |
4046 | } |
4047 | ||
4048 | ||
63551311 UD |
4049 | static void |
4050 | catan_test (void) | |
4051 | { | |
4052 | __complex__ MATHTYPE result; | |
4053 | ||
4054 | result = FUNC(catan) (BUILD_COMPLEX (0, 0)); | |
4055 | check ("real(catan(0 + i0)) = 0", __real__ result, 0); | |
4056 | check ("imag(catan(0 + i0)) = 0", __imag__ result, 0); | |
4057 | result = FUNC(catan) (BUILD_COMPLEX (minus_zero, 0)); | |
4058 | check ("real(catan(-0 + i0)) = -0", __real__ result, minus_zero); | |
4059 | check ("imag(catan(-0 + i0)) = 0", __imag__ result, 0); | |
4060 | result = FUNC(catan) (BUILD_COMPLEX (0, minus_zero)); | |
4061 | check ("real(catan(0 - i0)) = 0", __real__ result, 0); | |
4062 | check ("imag(catan(0 - i0)) = -0", __imag__ result, minus_zero); | |
4063 | result = FUNC(catan) (BUILD_COMPLEX (minus_zero, minus_zero)); | |
4064 | check ("real(catan(-0 - i0)) = -0", __real__ result, minus_zero); | |
4065 | check ("imag(catan(-0 - i0)) = -0", __imag__ result, minus_zero); | |
4066 | ||
4067 | result = FUNC(catan) (BUILD_COMPLEX (plus_infty, plus_infty)); | |
0a614877 | 4068 | check ("real(catan(+Inf + i Inf)) = pi/2", __real__ result, M_PI_2l); |
63551311 UD |
4069 | check ("imag(catan(+Inf + i Inf)) = 0", __imag__ result, 0); |
4070 | result = FUNC(catan) (BUILD_COMPLEX (plus_infty, minus_infty)); | |
0a614877 | 4071 | check ("real(catan(+Inf - i Inf)) = pi/2", __real__ result, M_PI_2l); |
63551311 UD |
4072 | check ("imag(catan(+Inf - i Inf)) = -0", __imag__ result, minus_zero); |
4073 | result = FUNC(catan) (BUILD_COMPLEX (minus_infty, plus_infty)); | |
0a614877 | 4074 | check ("real(catan(-Inf + i Inf)) = -pi/2", __real__ result, -M_PI_2l); |
63551311 UD |
4075 | check ("imag(catan(-Inf + i Inf)) = 0", __imag__ result, 0.0); |
4076 | result = FUNC(catan) (BUILD_COMPLEX (minus_infty, minus_infty)); | |
0a614877 | 4077 | check ("real(catan(-Inf - i Inf)) = -pi/2", __real__ result, -M_PI_2l); |
63551311 UD |
4078 | check ("imag(catan(-Inf - i Inf)) = -0", __imag__ result, minus_zero); |
4079 | ||
4080 | result = FUNC(catan) (BUILD_COMPLEX (plus_infty, -10.0)); | |
0a614877 | 4081 | check ("real(catan(+Inf - i10.0)) = pi/2", __real__ result, M_PI_2l); |
63551311 UD |
4082 | check ("imag(catan(+Inf - i10.0)) = -0", __imag__ result, minus_zero); |
4083 | result = FUNC(catan) (BUILD_COMPLEX (minus_infty, -10.0)); | |
0a614877 | 4084 | check ("real(catan(-Inf - i10.0)) = -pi/2", __real__ result, -M_PI_2l); |
63551311 UD |
4085 | check ("imag(catan(-Inf - i10.0)) = -0", __imag__ result, minus_zero); |
4086 | result = FUNC(catan) (BUILD_COMPLEX (plus_infty, minus_zero)); | |
0a614877 | 4087 | check ("real(catan(Inf - i0)) = pi/2", __real__ result, M_PI_2l); |
63551311 UD |
4088 | check ("imag(catan(Inf - i0)) = -0", __imag__ result, minus_zero); |
4089 | result = FUNC(catan) (BUILD_COMPLEX (minus_infty, minus_zero)); | |
0a614877 | 4090 | check ("real(catan(-Inf - i0)) = -pi/2", __real__ result, -M_PI_2l); |
63551311 UD |
4091 | check ("imag(catan(-Inf - i0)) = -0", __imag__ result, minus_zero); |
4092 | result = FUNC(catan) (BUILD_COMPLEX (plus_infty, 0.0)); | |
0a614877 | 4093 | check ("real(catan(Inf + i0)) = pi/2", __real__ result, M_PI_2l); |
63551311 UD |
4094 | check ("imag(catan(Inf + i0)) = 0", __imag__ result, 0.0); |
4095 | result = FUNC(catan) (BUILD_COMPLEX (minus_infty, 0.0)); | |
0a614877 | 4096 | check ("real(catan(-Inf + i0)) = -pi/2", __real__ result, -M_PI_2l); |
63551311 UD |
4097 | check ("imag(catan(-Inf + i0)) = 0", __imag__ result, 0.0); |
4098 | result = FUNC(catan) (BUILD_COMPLEX (plus_infty, 0.1)); | |
0a614877 | 4099 | check ("real(catan(+Inf + i0.1)) = pi/2", __real__ result, M_PI_2l); |
63551311 UD |
4100 | check ("imag(catan(+Inf + i0.1)) = 0", __imag__ result, 0); |
4101 | result = FUNC(catan) (BUILD_COMPLEX (minus_infty, 0.1)); | |
0a614877 | 4102 | check ("real(catan(-Inf + i0.1)) = -pi/2", __real__ result, -M_PI_2l); |
63551311 UD |
4103 | check ("imag(catan(-Inf + i0.1)) = 0", __imag__ result, 0); |
4104 | ||
4105 | result = FUNC(catan) (BUILD_COMPLEX (0.0, minus_infty)); | |
0a614877 | 4106 | check ("real(catan(0 - i Inf)) = pi/2", __real__ result, M_PI_2l); |
63551311 UD |
4107 | check ("imag(catan(0 - i Inf)) = -0", __imag__ result, minus_zero); |
4108 | result = FUNC(catan) (BUILD_COMPLEX (minus_zero, minus_infty)); | |
0a614877 | 4109 | check ("real(catan(-0 - i Inf)) = -pi/2", __real__ result, -M_PI_2l); |
63551311 UD |
4110 | check ("imag(catan(-0 - i Inf)) = -0", __imag__ result, minus_zero); |
4111 | result = FUNC(catan) (BUILD_COMPLEX (100.0, minus_infty)); | |
0a614877 | 4112 | check ("real(catan(100 - i Inf)) = pi/2", __real__ result, M_PI_2l); |
63551311 UD |
4113 | check ("imag(catan(100 - i Inf)) = -0", __imag__ result, minus_zero); |
4114 | result = FUNC(catan) (BUILD_COMPLEX (-100.0, minus_infty)); | |
0a614877 | 4115 | check ("real(catan(-100 - i Inf)) = -pi/2", __real__ result, -M_PI_2l); |
63551311 UD |
4116 | check ("imag(catan(-100 - i Inf)) = -0", __imag__ result, minus_zero); |
4117 | ||
4118 | result = FUNC(catan) (BUILD_COMPLEX (0.0, plus_infty)); | |
0a614877 | 4119 | check ("real(catan(0 + i Inf)) = pi/2", __real__ result, M_PI_2l); |
63551311 UD |
4120 | check ("imag(catan(0 + i Inf)) = 0", __imag__ result, 0); |
4121 | result = FUNC(catan) (BUILD_COMPLEX (minus_zero, plus_infty)); | |
0a614877 | 4122 | check ("real(catan(-0 + i Inf)) = -pi/2", __real__ result, -M_PI_2l); |
63551311 UD |
4123 | check ("imag(catan(-0 + i Inf)) = 0", __imag__ result, 0); |
4124 | result = FUNC(catan) (BUILD_COMPLEX (0.5, plus_infty)); | |
0a614877 | 4125 | check ("real(catan(0.5 + i Inf)) = pi/2", __real__ result, M_PI_2l); |
63551311 UD |
4126 | check ("imag(catan(0.5 + i Inf)) = 0", __imag__ result, 0); |
4127 | result = FUNC(catan) (BUILD_COMPLEX (-0.5, plus_infty)); | |
0a614877 | 4128 | check ("real(catan(-0.5 + i Inf)) = -pi/2", __real__ result, -M_PI_2l); |
63551311 UD |
4129 | check ("imag(catan(-0.5 + i Inf)) = 0", __imag__ result, 0); |
4130 | ||
4131 | result = FUNC(catan) (BUILD_COMPLEX (nan_value, 0.0)); | |
4132 | check_isnan ("real(catan(NaN + i0)) = NaN", __real__ result); | |
4133 | check ("imag(catan(NaN + i0)) = 0", __imag__ result, 0.0); | |
4134 | result = FUNC(catan) (BUILD_COMPLEX (nan_value, minus_zero)); | |
4135 | check_isnan ("real(catan(NaN - i0)) = NaN", __real__ result); | |
4136 | check ("imag(catan(NaN - i0)) = -0", __imag__ result, minus_zero); | |
4137 | ||
4138 | result = FUNC(catan) (BUILD_COMPLEX (nan_value, plus_infty)); | |
4139 | check_isnan ("real(catan(NaN + i Inf)) = NaN", __real__ result); | |
4140 | check ("imag(catan(NaN + i Inf)) = 0", __imag__ result, 0); | |
4141 | result = FUNC(catan) (BUILD_COMPLEX (nan_value, minus_infty)); | |
4142 | check_isnan ("real(catan(NaN - i Inf)) = NaN", __real__ result); | |
4143 | check ("imag(catan(NaN - i Inf)) = -0", __imag__ result, minus_zero); | |
4144 | ||
4145 | result = FUNC(catan) (BUILD_COMPLEX (0.0, nan_value)); | |
4146 | check_isnan ("real(catan(0 + i NaN)) = NaN", __real__ result); | |
4147 | check_isnan ("imag(catan(0 + i NaN)) = NaN", __imag__ result); | |
4148 | result = FUNC(catan) (BUILD_COMPLEX (minus_zero, nan_value)); | |
4149 | check_isnan ("real(catan(-0 + i NaN)) = NaN", __real__ result); | |
4150 | check_isnan ("imag(catan(-0 + i NaN)) = NaN", __imag__ result); | |
4151 | ||
4152 | result = FUNC(catan) (BUILD_COMPLEX (plus_infty, nan_value)); | |
0a614877 | 4153 | check ("real(catan(+Inf + i NaN)) = pi/2", __real__ result, M_PI_2l); |
63551311 UD |
4154 | check ("imag(catan(+Inf + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0); |
4155 | result = FUNC(catan) (BUILD_COMPLEX (minus_infty, nan_value)); | |
0a614877 | 4156 | check ("real(catan(-Inf + i NaN)) = -pi/2", __real__ result, -M_PI_2l); |
63551311 UD |
4157 | check ("imag(catan(-Inf + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0); |
4158 | ||
4159 | result = FUNC(catan) (BUILD_COMPLEX (nan_value, 10.5)); | |
779ae82e | 4160 | check_isnan_maybe_exc ("real(catan(NaN + i10.5)) = NaN plus maybe invalid exception", |
51702635 | 4161 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
4162 | check_isnan ("imag(catan(NaN + i10.5)) = NaN plus maybe invalid exception", |
4163 | __imag__ result); | |
63551311 | 4164 | result = FUNC(catan) (BUILD_COMPLEX (nan_value, -10.5)); |
779ae82e | 4165 | check_isnan_maybe_exc ("real(catan(NaN - i10.5)) = NaN plus maybe invalid exception", |
51702635 | 4166 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
4167 | check_isnan ("imag(catan(NaN - i10.5)) = NaN plus maybe invalid exception", |
4168 | __imag__ result); | |
63551311 UD |
4169 | |
4170 | result = FUNC(catan) (BUILD_COMPLEX (0.75, nan_value)); | |
779ae82e | 4171 | check_isnan_maybe_exc ("real(catan(0.75 + i NaN)) = NaN plus maybe invalid exception", |
51702635 | 4172 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
4173 | check_isnan ("imag(catan(0.75 + i NaN)) = NaN plus maybe invalid exception", |
4174 | __imag__ result); | |
63551311 | 4175 | result = FUNC(catan) (BUILD_COMPLEX (-0.75, nan_value)); |
779ae82e | 4176 | check_isnan_maybe_exc ("real(catan(-0.75 + i NaN)) = NaN plus maybe invalid exception", |
51702635 | 4177 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
4178 | check_isnan ("imag(catan(-0.75 + i NaN)) = NaN plus maybe invalid exception", |
4179 | __imag__ result); | |
63551311 UD |
4180 | |
4181 | result = FUNC(catan) (BUILD_COMPLEX (nan_value, nan_value)); | |
4182 | check_isnan ("real(catan(NaN + i NaN)) = NaN", __real__ result); | |
4183 | check_isnan ("imag(catan(NaN + i NaN)) = NaN", __imag__ result); | |
bd355af0 UD |
4184 | |
4185 | result = FUNC(catan) (BUILD_COMPLEX (0.7, 1.2)); | |
4186 | check_eps ("real(catan(0.7 + i 1.2)) == 1.07857...", __real__ result, | |
66000494 | 4187 | 1.0785743834118921877L, CHOOSE (3e-17, 0, 5e-7)); |
bd355af0 | 4188 | check_eps ("imag(catan(0.7 + i 1.2)) == 0.57705...", __imag__ result, |
66000494 | 4189 | 0.5770573776534306764L, CHOOSE(3e-17L, 2e-16, 6e-8)); |
bd355af0 UD |
4190 | |
4191 | result = FUNC(catan) (BUILD_COMPLEX (-2, -3)); | |
66000494 UD |
4192 | check_eps ("real(catan(-2 - i 3)) == -1.40992...", __real__ result, |
4193 | -1.4099210495965755225L, CHOOSE(0, 0, 4e-7)); | |
bd355af0 | 4194 | check_eps ("imag(catan(-2 - i 3)) == -0.22907...", __imag__ result, |
74015205 | 4195 | -0.2290726829685387662L, CHOOSE(1.1e-19L, 3e-17, 2e-8)); |
63551311 UD |
4196 | } |
4197 | ||
4198 | ||
993b3242 UD |
4199 | static void |
4200 | catanh_test (void) | |
4201 | { | |
4202 | __complex__ MATHTYPE result; | |
4203 | ||
4204 | result = FUNC(catanh) (BUILD_COMPLEX (0, 0)); | |
4205 | check ("real(catanh(0 + i0)) = 0", __real__ result, 0); | |
4206 | check ("imag(catanh(0 + i0)) = 0", __imag__ result, 0); | |
4207 | result = FUNC(catanh) (BUILD_COMPLEX (minus_zero, 0)); | |
4208 | check ("real(catanh(-0 + i0)) = -0", __real__ result, minus_zero); | |
4209 | check ("imag(catanh(-0 + i0)) = 0", __imag__ result, 0); | |
4210 | result = FUNC(catanh) (BUILD_COMPLEX (0, minus_zero)); | |
4211 | check ("real(catanh(0 - i0)) = 0", __real__ result, 0); | |
4212 | check ("imag(catanh(0 - i0)) = -0", __imag__ result, minus_zero); | |
4213 | result = FUNC(catanh) (BUILD_COMPLEX (minus_zero, minus_zero)); | |
4214 | check ("real(catanh(-0 - i0)) = -0", __real__ result, minus_zero); | |
4215 | check ("imag(catanh(-0 - i0)) = -0", __imag__ result, minus_zero); | |
4216 | ||
4217 | result = FUNC(catanh) (BUILD_COMPLEX (plus_infty, plus_infty)); | |
4218 | check ("real(catanh(+Inf + i Inf)) = 0", __real__ result, 0); | |
0a614877 | 4219 | check ("imag(catanh(+Inf + i Inf)) = pi/2", __imag__ result, M_PI_2l); |
993b3242 UD |
4220 | result = FUNC(catanh) (BUILD_COMPLEX (plus_infty, minus_infty)); |
4221 | check ("real(catanh(+Inf - i Inf)) = 0", __real__ result, 0); | |
0a614877 | 4222 | check ("imag(catanh(+Inf - i Inf)) = -pi/2", __imag__ result, -M_PI_2l); |
993b3242 UD |
4223 | result = FUNC(catanh) (BUILD_COMPLEX (minus_infty, plus_infty)); |
4224 | check ("real(catanh(-Inf + i Inf)) = -0", __real__ result, minus_zero); | |
0a614877 | 4225 | check ("imag(catanh(-Inf + i Inf)) = pi/2", __imag__ result, M_PI_2l); |
993b3242 UD |
4226 | result = FUNC(catanh) (BUILD_COMPLEX (minus_infty, minus_infty)); |
4227 | check ("real(catanh(-Inf - i Inf)) = -0", __real__ result, minus_zero); | |
0a614877 | 4228 | check ("imag(catanh(-Inf - i Inf)) = -pi/2", __imag__ result, -M_PI_2l); |
993b3242 UD |
4229 | |
4230 | result = FUNC(catanh) (BUILD_COMPLEX (-10.0, plus_infty)); | |
63551311 | 4231 | check ("real(catanh(-10.0 + i Inf)) = -0", __real__ result, minus_zero); |
0a614877 | 4232 | check ("imag(catanh(-10.0 + i Inf)) = pi/2", __imag__ result, M_PI_2l); |
993b3242 | 4233 | result = FUNC(catanh) (BUILD_COMPLEX (-10.0, minus_infty)); |
63551311 | 4234 | check ("real(catanh(-10.0 - i Inf)) = -0", __real__ result, minus_zero); |
0a614877 | 4235 | check ("imag(catanh(-10.0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2l); |
63551311 UD |
4236 | result = FUNC(catanh) (BUILD_COMPLEX (minus_zero, plus_infty)); |
4237 | check ("real(catanh(-0 + i Inf)) = -0", __real__ result, minus_zero); | |
0a614877 | 4238 | check ("imag(catanh(-0 + i Inf)) = pi/2", __imag__ result, M_PI_2l); |
63551311 UD |
4239 | result = FUNC(catanh) (BUILD_COMPLEX (minus_zero, minus_infty)); |
4240 | check ("real(catanh(-0 - i Inf)) = -0", __real__ result, minus_zero); | |
0a614877 | 4241 | check ("imag(catanh(-0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2l); |
993b3242 UD |
4242 | result = FUNC(catanh) (BUILD_COMPLEX (0, plus_infty)); |
4243 | check ("real(catanh(0 + i Inf)) = 0", __real__ result, 0); | |
0a614877 | 4244 | check ("imag(catanh(0 + i Inf)) = pi/2", __imag__ result, M_PI_2l); |
993b3242 UD |
4245 | result = FUNC(catanh) (BUILD_COMPLEX (0, minus_infty)); |
4246 | check ("real(catanh(0 - i Inf)) = 0", __real__ result, 0); | |
0a614877 | 4247 | check ("imag(catanh(0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2l); |
993b3242 UD |
4248 | result = FUNC(catanh) (BUILD_COMPLEX (0.1, plus_infty)); |
4249 | check ("real(catanh(0.1 + i Inf)) = 0", __real__ result, 0); | |
0a614877 | 4250 | check ("imag(catanh(0.1 + i Inf)) = pi/2", __imag__ result, M_PI_2l); |
993b3242 UD |
4251 | result = FUNC(catanh) (BUILD_COMPLEX (0.1, minus_infty)); |
4252 | check ("real(catanh(0.1 - i Inf)) = 0", __real__ result, 0); | |
0a614877 | 4253 | check ("imag(catanh(0.1 - i Inf)) = -pi/2", __imag__ result, -M_PI_2l); |
993b3242 UD |
4254 | |
4255 | result = FUNC(catanh) (BUILD_COMPLEX (minus_infty, 0)); | |
4256 | check ("real(catanh(-Inf + i0)) = -0", __real__ result, minus_zero); | |
0a614877 | 4257 | check ("imag(catanh(-Inf + i0)) = pi/2", __imag__ result, M_PI_2l); |
993b3242 UD |
4258 | result = FUNC(catanh) (BUILD_COMPLEX (minus_infty, minus_zero)); |
4259 | check ("real(catanh(-Inf - i0)) = -0", __real__ result, minus_zero); | |
0a614877 | 4260 | check ("imag(catanh(-Inf - i0)) = -pi/2", __imag__ result, -M_PI_2l); |
993b3242 UD |
4261 | result = FUNC(catanh) (BUILD_COMPLEX (minus_infty, 100)); |
4262 | check ("real(catanh(-Inf + i100)) = -0", __real__ result, minus_zero); | |
0a614877 | 4263 | check ("imag(catanh(-Inf + i100)) = pi/2", __imag__ result, M_PI_2l); |
993b3242 UD |
4264 | result = FUNC(catanh) (BUILD_COMPLEX (minus_infty, -100)); |
4265 | check ("real(catanh(-Inf - i100)) = -0", __real__ result, minus_zero); | |
0a614877 | 4266 | check ("imag(catanh(-Inf - i100)) = -pi/2", __imag__ result, -M_PI_2l); |
993b3242 UD |
4267 | |
4268 | result = FUNC(catanh) (BUILD_COMPLEX (plus_infty, 0)); | |
4269 | check ("real(catanh(+Inf + i0)) = 0", __real__ result, 0); | |
0a614877 | 4270 | check ("imag(catanh(+Inf + i0)) = pi/2", __imag__ result, M_PI_2l); |
993b3242 UD |
4271 | result = FUNC(catanh) (BUILD_COMPLEX (plus_infty, minus_zero)); |
4272 | check ("real(catanh(+Inf - i0)) = 0", __real__ result, 0); | |
0a614877 | 4273 | check ("imag(catanh(+Inf - i0)) = -pi/2", __imag__ result, -M_PI_2l); |
993b3242 UD |
4274 | result = FUNC(catanh) (BUILD_COMPLEX (plus_infty, 0.5)); |
4275 | check ("real(catanh(+Inf + i0.5)) = 0", __real__ result, 0); | |
0a614877 | 4276 | check ("imag(catanh(+Inf + i0.5)) = pi/2", __imag__ result, M_PI_2l); |
993b3242 UD |
4277 | result = FUNC(catanh) (BUILD_COMPLEX (plus_infty, -0.5)); |
4278 | check ("real(catanh(+Inf - i0.5)) = 0", __real__ result, 0); | |
0a614877 | 4279 | check ("imag(catanh(+Inf - i0.5)) = -pi/2", __imag__ result, -M_PI_2l); |
993b3242 UD |
4280 | |
4281 | result = FUNC(catanh) (BUILD_COMPLEX (0, nan_value)); | |
4282 | check ("real(catanh(0 + i NaN)) = 0", __real__ result, 0); | |
63551311 | 4283 | check_isnan ("imag(catanh(0 + i NaN)) = NaN", __imag__ result); |
993b3242 UD |
4284 | result = FUNC(catanh) (BUILD_COMPLEX (minus_zero, nan_value)); |
4285 | check ("real(catanh(-0 + i NaN)) = -0", __real__ result, minus_zero); | |
63551311 | 4286 | check_isnan ("imag(catanh(-0 + i NaN)) = NaN", __imag__ result); |
993b3242 UD |
4287 | |
4288 | result = FUNC(catanh) (BUILD_COMPLEX (plus_infty, nan_value)); | |
4289 | check ("real(catanh(+Inf + i NaN)) = 0", __real__ result, 0); | |
4290 | check_isnan ("imag(catanh(+Inf + i NaN)) = NaN", __imag__ result); | |
4291 | result = FUNC(catanh) (BUILD_COMPLEX (minus_infty, nan_value)); | |
4292 | check ("real(catanh(-Inf + i NaN)) = -0", __real__ result, minus_zero); | |
4293 | check_isnan ("imag(catanh(-Inf + i NaN)) = NaN", __imag__ result); | |
4294 | ||
4295 | result = FUNC(catanh) (BUILD_COMPLEX (nan_value, 0)); | |
4296 | check_isnan ("real(catanh(NaN + i0)) = NaN", __real__ result); | |
63551311 UD |
4297 | check_isnan ("imag(catanh(NaN + i0)) = NaN", __imag__ result); |
4298 | result = FUNC(catanh) (BUILD_COMPLEX (nan_value, minus_zero)); | |
993b3242 UD |
4299 | check_isnan ("real(catanh(NaN - i0)) = NaN", __real__ result); |
4300 | check_isnan ("imag(catanh(NaN - i0)) = NaN", __imag__ result); | |
4301 | ||
4302 | result = FUNC(catanh) (BUILD_COMPLEX (nan_value, plus_infty)); | |
4303 | check ("real(catanh(NaN + i Inf)) = +-0", FUNC(fabs) (__real__ result), 0); | |
0a614877 | 4304 | check ("imag(catanh(NaN + i Inf)) = pi/2", __imag__ result, M_PI_2l); |
993b3242 UD |
4305 | result = FUNC(catanh) (BUILD_COMPLEX (nan_value, minus_infty)); |
4306 | check ("real(catanh(NaN - i Inf)) = +-0", FUNC(fabs) (__real__ result), 0); | |
0a614877 | 4307 | check ("imag(catanh(NaN - i Inf)) = -pi/2", __imag__ result, -M_PI_2l); |
993b3242 UD |
4308 | |
4309 | result = FUNC(catanh) (BUILD_COMPLEX (10.5, nan_value)); | |
779ae82e | 4310 | check_isnan_maybe_exc ("real(catanh(10.5 + i NaN)) = NaN plus maybe invalid exception", |
51702635 | 4311 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
4312 | check_isnan ("imag(catanh(10.5 + i NaN)) = NaN plus maybe invalid exception", |
4313 | __imag__ result); | |
993b3242 | 4314 | result = FUNC(catanh) (BUILD_COMPLEX (-10.5, nan_value)); |
779ae82e | 4315 | check_isnan_maybe_exc ("real(catanh(-10.5 + i NaN)) = NaN plus maybe invalid exception", |
51702635 | 4316 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
4317 | check_isnan ("imag(catanh(-10.5 + i NaN)) = NaN plus maybe invalid exception", |
4318 | __imag__ result); | |
993b3242 UD |
4319 | |
4320 | result = FUNC(catanh) (BUILD_COMPLEX (nan_value, 0.75)); | |
779ae82e | 4321 | check_isnan_maybe_exc ("real(catanh(NaN + i0.75)) = NaN plus maybe invalid exception", |
51702635 | 4322 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
4323 | check_isnan ("imag(catanh(NaN + i0.75)) = NaN plus maybe invalid exception", |
4324 | __imag__ result); | |
63551311 | 4325 | result = FUNC(catanh) (BUILD_COMPLEX (nan_value, -0.75)); |
779ae82e | 4326 | check_isnan_maybe_exc ("real(catanh(NaN - i0.75)) = NaN plus maybe invalid exception", |
51702635 | 4327 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
4328 | check_isnan ("imag(catanh(NaN - i0.75)) = NaN plus maybe invalid exception", |
4329 | __imag__ result); | |
993b3242 UD |
4330 | |
4331 | result = FUNC(catanh) (BUILD_COMPLEX (nan_value, nan_value)); | |
4332 | check_isnan ("real(catanh(NaN + i NaN)) = NaN", __real__ result); | |
4333 | check_isnan ("imag(catanh(NaN + i NaN)) = NaN", __imag__ result); | |
bd355af0 UD |
4334 | |
4335 | result = FUNC(catanh) (BUILD_COMPLEX (0.7, 1.2)); | |
4336 | check_eps ("real(catanh(0.7 + i 1.2)) == 0.26007...", __real__ result, | |
5edb9387 | 4337 | 0.2600749516525135959L, CHOOSE (2e-18, 6e-17, 3e-8)); |
bd355af0 | 4338 | check_eps ("imag(catanh(0.7 + i 1.2)) == 0.97024...", __imag__ result, |
66000494 | 4339 | 0.9702403077950989849L, CHOOSE (3e-17, 2e-16, 4e-7)); |
bd355af0 UD |
4340 | |
4341 | result = FUNC(catanh) (BUILD_COMPLEX (-2, -3)); | |
4342 | check_eps ("real(catanh(-2 - i 3)) == -0.14694...", __real__ result, | |
66000494 | 4343 | -0.1469466662255297520L, CHOOSE (9e-20L, 2e-16, 2e-8)); |
74015205 | 4344 | check_eps ("imag(catanh(-2 - i 3)) == -1.33897...", __imag__ result, |
66000494 | 4345 | -1.3389725222944935611L, CHOOSE (7e-19L, 0, 5e-7)); |
993b3242 | 4346 | } |
3075e0e3 UD |
4347 | |
4348 | ||
04be94a8 UD |
4349 | static void |
4350 | ctan_test (void) | |
4351 | { | |
4352 | __complex__ MATHTYPE result; | |
4353 | ||
4354 | result = FUNC(ctan) (BUILD_COMPLEX (0, 0)); | |
4355 | check ("real(ctan(0 + i0)) = 0", __real__ result, 0); | |
4356 | check ("imag(ctan(0 + i0)) = 0", __imag__ result, 0); | |
4357 | result = FUNC(ctan) (BUILD_COMPLEX (0, minus_zero)); | |
4358 | check ("real(ctan(0 - i0)) = 0", __real__ result, 0); | |
4359 | check ("imag(ctan(0 - i0)) = -0", __imag__ result, minus_zero); | |
4360 | result = FUNC(ctan) (BUILD_COMPLEX (minus_zero, 0)); | |
4361 | check ("real(ctan(-0 + i0)) = -0", __real__ result, minus_zero); | |
4362 | check ("imag(ctan(-0 + i0)) = 0", __imag__ result, 0); | |
4363 | result = FUNC(ctan) (BUILD_COMPLEX (minus_zero, minus_zero)); | |
4364 | check ("real(ctan(-0 - i0)) = -0", __real__ result, minus_zero); | |
4365 | check ("imag(ctan(-0 - i0)) = -0", __imag__ result, minus_zero); | |
4366 | ||
4367 | ||
4368 | result = FUNC(ctan) (BUILD_COMPLEX (0, plus_infty)); | |
4369 | check ("real(ctan(0 + i Inf)) = 0", __real__ result, 0); | |
4370 | check ("imag(ctan(0 + i Inf)) = 1", __imag__ result, 1); | |
4371 | result = FUNC(ctan) (BUILD_COMPLEX (1, plus_infty)); | |
4372 | check ("real(ctan(1 + i Inf)) = 0", __real__ result, 0); | |
4373 | check ("imag(ctan(1 + i Inf)) = 1", __imag__ result, 1); | |
4374 | result = FUNC(ctan) (BUILD_COMPLEX (minus_zero, plus_infty)); | |
4375 | check ("real(ctan(-0 + i Inf)) = -0", __real__ result, minus_zero); | |
4376 | check ("imag(ctan(-0 + i Inf)) = 1", __imag__ result, 1); | |
4377 | result = FUNC(ctan) (BUILD_COMPLEX (-1, plus_infty)); | |
4378 | check ("real(ctan(-1 + i Inf)) = -0", __real__ result, minus_zero); | |
4379 | check ("imag(ctan(-1 + i Inf)) = 1", __imag__ result, 1); | |
4380 | ||
4381 | result = FUNC(ctan) (BUILD_COMPLEX (0, minus_infty)); | |
4382 | check ("real(ctan(0 - i Inf)) = 0", __real__ result, 0); | |
4383 | check ("imag(ctan(0 - i Inf)) = -1", __imag__ result, -1); | |
4384 | result = FUNC(ctan) (BUILD_COMPLEX (1, minus_infty)); | |
4385 | check ("real(ctan(1 - i Inf)) = 0", __real__ result, 0); | |
4386 | check ("imag(ctan(1 - i Inf)) = -1", __imag__ result, -1); | |
4387 | result = FUNC(ctan) (BUILD_COMPLEX (minus_zero, minus_infty)); | |
4388 | check ("real(ctan(-0 - i Inf)) = -0", __real__ result, minus_zero); | |
4389 | check ("imag(ctan(-0 - i Inf)) = -1", __imag__ result, -1); | |
4390 | result = FUNC(ctan) (BUILD_COMPLEX (-1, minus_infty)); | |
4391 | check ("real(ctan(-1 - i Inf)) = -0", __real__ result, minus_zero); | |
4392 | check ("imag(ctan(-1 - i Inf)) = -1", __imag__ result, -1); | |
4393 | ||
4394 | result = FUNC(ctan) (BUILD_COMPLEX (plus_infty, 0)); | |
4395 | check_isnan_exc ("real(ctan(Inf + i 0)) = NaN plus invalid exception", | |
4396 | __real__ result, INVALID_EXCEPTION); | |
4397 | check_isnan ("imag(ctan(Inf + i 0)) = NaN plus invalid exception", | |
4398 | __imag__ result); | |
4399 | result = FUNC(ctan) (BUILD_COMPLEX (plus_infty, 2)); | |
4400 | check_isnan_exc ("real(ctan(Inf + i 2)) = NaN plus invalid exception", | |
4401 | __real__ result, INVALID_EXCEPTION); | |
4402 | check_isnan ("imag(ctan(Inf + i 2)) = NaN plus invalid exception", | |
4403 | __imag__ result); | |
4404 | result = FUNC(ctan) (BUILD_COMPLEX (minus_infty, 0)); | |
4405 | check_isnan_exc ("real(ctan(-Inf + i 0)) = NaN plus invalid exception", | |
4406 | __real__ result, INVALID_EXCEPTION); | |
4407 | check_isnan ("imag(ctan(-Inf + i 0)) = NaN plus invalid exception", | |
4408 | __imag__ result); | |
4409 | result = FUNC(ctan) (BUILD_COMPLEX (minus_infty, 2)); | |
4410 | check_isnan_exc ("real(ctan(- Inf + i 2)) = NaN plus invalid exception", | |
4411 | __real__ result, INVALID_EXCEPTION); | |
4412 | check_isnan ("imag(ctan(- Inf + i 2)) = NaN plus invalid exception", | |
4413 | __imag__ result); | |
4414 | result = FUNC(ctan) (BUILD_COMPLEX (plus_infty, minus_zero)); | |
4415 | check_isnan_exc ("real(ctan(Inf - i 0)) = NaN plus invalid exception", | |
4416 | __real__ result, INVALID_EXCEPTION); | |
4417 | check_isnan ("imag(ctan(Inf - i 0)) = NaN plus invalid exception", | |
4418 | __imag__ result); | |
4419 | result = FUNC(ctan) (BUILD_COMPLEX (plus_infty, -2)); | |
4420 | check_isnan_exc ("real(ctan(Inf - i 2)) = NaN plus invalid exception", | |
4421 | __real__ result, INVALID_EXCEPTION); | |
4422 | check_isnan ("imag(ctan(Inf - i 2)) = NaN plus invalid exception", | |
4423 | __imag__ result); | |
4424 | result = FUNC(ctan) (BUILD_COMPLEX (minus_infty, minus_zero)); | |
4425 | check_isnan_exc ("real(ctan(-Inf - i 0)) = NaN plus invalid exception", | |
4426 | __real__ result, INVALID_EXCEPTION); | |
4427 | check_isnan ("imag(ctan(-Inf - i 0)) = NaN plus invalid exception", | |
4428 | __imag__ result); | |
4429 | result = FUNC(ctan) (BUILD_COMPLEX (minus_infty, -2)); | |
4430 | check_isnan_exc ("real(ctan(-Inf - i 2)) = NaN plus invalid exception", | |
4431 | __real__ result, INVALID_EXCEPTION); | |
4432 | check_isnan ("imag(ctan(-Inf - i 2)) = NaN plus invalid exception", | |
4433 | __imag__ result); | |
4434 | ||
4435 | result = FUNC(ctan) (BUILD_COMPLEX (nan_value, plus_infty)); | |
4436 | check ("real(ctan(NaN + i Inf)) = +-0", FUNC(fabs) (__real__ result), 0); | |
4437 | check ("imag(ctan(NaN + i Inf)) = 1", __imag__ result, 1); | |
4438 | result = FUNC(ctan) (BUILD_COMPLEX (nan_value, minus_infty)); | |
4439 | check ("real(ctan(NaN - i Inf)) = +-0", FUNC(fabs) (__real__ result), 0); | |
4440 | check ("imag(ctan(NaN - i Inf)) = -1", __imag__ result, -1); | |
4441 | ||
4442 | result = FUNC(ctan) (BUILD_COMPLEX (0, nan_value)); | |
4443 | check ("real(ctan(0 + i NaN)) = 0", __real__ result, 0); | |
4444 | check_isnan ("imag(ctan(0 + i NaN)) = NaN", __imag__ result); | |
4445 | result = FUNC(ctan) (BUILD_COMPLEX (minus_zero, nan_value)); | |
4446 | check ("real(ctan(-0 + i NaN)) = -0", __real__ result, minus_zero); | |
4447 | check_isnan ("imag(ctan(-0 + i NaN)) = NaN", __imag__ result); | |
4448 | ||
4449 | result = FUNC(ctan) (BUILD_COMPLEX (0.5, nan_value)); | |
4450 | check_isnan_maybe_exc ("real(ctan(0.5 + i NaN)) = NaN plus maybe invalid exception", | |
4451 | __real__ result, INVALID_EXCEPTION); | |
4452 | check_isnan ("imag(ctan(0.5 + i NaN)) = NaN plus maybe invalid exception", | |
4453 | __imag__ result); | |
4454 | result = FUNC(ctan) (BUILD_COMPLEX (-4.5, nan_value)); | |
4455 | check_isnan_maybe_exc ("real(ctan(-4.5 + i NaN)) = NaN plus maybe invalid exception", | |
4456 | __real__ result, INVALID_EXCEPTION); | |
4457 | check_isnan ("imag(ctan(-4.5 + i NaN)) = NaN plus maybe invalid exception", | |
4458 | __imag__ result); | |
4459 | ||
4460 | result = FUNC(ctan) (BUILD_COMPLEX (nan_value, 0)); | |
4461 | check_isnan_maybe_exc ("real(ctan(NaN + i 0)) = NaN plus maybe invalid exception", | |
4462 | __real__ result, INVALID_EXCEPTION); | |
4463 | check_isnan ("imag(ctan(NaN + i 0)) = NaN plus maybe invalid exception", | |
4464 | __imag__ result); | |
4465 | result = FUNC(ctan) (BUILD_COMPLEX (nan_value, 5)); | |
4466 | check_isnan_maybe_exc ("real(ctan(NaN + i 5)) = NaN plus maybe invalid exception", | |
4467 | __real__ result, INVALID_EXCEPTION); | |
4468 | check_isnan ("imag(ctan(NaN + i 5)) = NaN plus maybe invalid exception", | |
4469 | __imag__ result); | |
4470 | result = FUNC(ctan) (BUILD_COMPLEX (nan_value, minus_zero)); | |
4471 | check_isnan_maybe_exc ("real(ctan(NaN - i 0)) = NaN plus maybe invalid exception", | |
4472 | __real__ result, INVALID_EXCEPTION); | |
4473 | check_isnan ("imag(ctan(NaN - i 0)) = NaN plus maybe invalid exception", | |
4474 | __imag__ result); | |
4475 | result = FUNC(ctan) (BUILD_COMPLEX (nan_value, -0.25)); | |
4476 | check_isnan_maybe_exc ("real(ctan(NaN -i 0.25)) = NaN plus maybe invalid exception", | |
4477 | __real__ result, INVALID_EXCEPTION); | |
bd355af0 | 4478 | check_isnan ("imag(ctan(NaN -i 0.25)) = NaN plus maybe invalid exception", |
04be94a8 UD |
4479 | __imag__ result); |
4480 | ||
4481 | result = FUNC(ctan) (BUILD_COMPLEX (nan_value, nan_value)); | |
4482 | check_isnan ("real(ctan(NaN + i NaN)) = NaN", __real__ result); | |
4483 | check_isnan ("imag(ctan(NaN + i NaN)) = NaN", __imag__ result); | |
4484 | ||
bd355af0 UD |
4485 | result = FUNC(ctan) (BUILD_COMPLEX (0.7, 1.2)); |
4486 | check_eps ("real(ctan(0.7 + i 1.2)) == 0.17207...", __real__ result, | |
4487 | 0.1720734197630349001L, CHOOSE(1e-17L, 3e-17, 2e-8)); | |
4488 | check_eps ("imag(ctan(0.7 + i 1.2)) == 0.95448...", __imag__ result, | |
66000494 | 4489 | 0.9544807059989405538L, CHOOSE(2e-17L, 2e-16, 6e-8)); |
bd355af0 UD |
4490 | |
4491 | result = FUNC(ctan) (BUILD_COMPLEX (-2, -3)); | |
4492 | check_eps ("real(ctan(-2 - i 3)) == -0.00376...", __real__ result, | |
66000494 | 4493 | 0.0037640256415042482L, CHOOSE(1e-19L, 5e-19, 0)); |
bd355af0 UD |
4494 | check_eps ("imag(ctan(-2 - i 3)) == -1.00323...", __imag__ result, |
4495 | -1.0032386273536098014L, CHOOSE(2e-19L, 0, 2e-7)); | |
04be94a8 UD |
4496 | } |
4497 | ||
4498 | ||
3075e0e3 UD |
4499 | static void |
4500 | ctanh_test (void) | |
4501 | { | |
4502 | __complex__ MATHTYPE result; | |
4503 | ||
4504 | result = FUNC(ctanh) (BUILD_COMPLEX (0, 0)); | |
4505 | check ("real(ctanh(0 + i0)) = 0", __real__ result, 0); | |
4506 | check ("imag(ctanh(0 + i0)) = 0", __imag__ result, 0); | |
4507 | result = FUNC(ctanh) (BUILD_COMPLEX (0, minus_zero)); | |
4508 | check ("real(ctanh(0 - i0)) = 0", __real__ result, 0); | |
4509 | check ("imag(ctanh(0 - i0)) = -0", __imag__ result, minus_zero); | |
4510 | result = FUNC(ctanh) (BUILD_COMPLEX (minus_zero, 0)); | |
4511 | check ("real(ctanh(-0 + i0)) = -0", __real__ result, minus_zero); | |
63551311 | 4512 | check ("imag(ctanh(-0 + i0)) = 0", __imag__ result, 0); |
3075e0e3 UD |
4513 | result = FUNC(ctanh) (BUILD_COMPLEX (minus_zero, minus_zero)); |
4514 | check ("real(ctanh(-0 - i0)) = -0", __real__ result, minus_zero); | |
4515 | check ("imag(ctanh(-0 - i0)) = -0", __imag__ result, minus_zero); | |
4516 | ||
4517 | result = FUNC(ctanh) (BUILD_COMPLEX (plus_infty, 0)); | |
4518 | check ("real(ctanh(+Inf + i0)) = 1", __real__ result, 1); | |
4519 | check ("imag(ctanh(+Inf + i0)) = 0", __imag__ result, 0); | |
4520 | result = FUNC(ctanh) (BUILD_COMPLEX (plus_infty, 1)); | |
4521 | check ("real(ctanh(+Inf + i1)) = 1", __real__ result, 1); | |
4522 | check ("imag(ctanh(+Inf + i1)) = 0", __imag__ result, 0); | |
4523 | result = FUNC(ctanh) (BUILD_COMPLEX (plus_infty, minus_zero)); | |
4524 | check ("real(ctanh(+Inf - i0)) = 1", __real__ result, 1); | |
4525 | check ("imag(ctanh(+Inf - i0)) = -0", __imag__ result, minus_zero); | |
4526 | result = FUNC(ctanh) (BUILD_COMPLEX (plus_infty, -1)); | |
4527 | check ("real(ctanh(+Inf - i1)) = 1", __real__ result, 1); | |
4528 | check ("imag(ctanh(+Inf - i1)) = -0", __imag__ result, minus_zero); | |
4529 | result = FUNC(ctanh) (BUILD_COMPLEX (minus_infty, 0)); | |
4530 | check ("real(ctanh(-Inf + i0)) = -1", __real__ result, -1); | |
4531 | check ("imag(ctanh(-Inf + i0)) = 0", __imag__ result, 0); | |
4532 | result = FUNC(ctanh) (BUILD_COMPLEX (minus_infty, 1)); | |
4533 | check ("real(ctanh(-Inf + i1)) = -1", __real__ result, -1); | |
4534 | check ("imag(ctanh(-Inf + i1)) = 0", __imag__ result, 0); | |
63551311 | 4535 | result = FUNC(ctanh) (BUILD_COMPLEX (minus_infty, minus_zero)); |
3075e0e3 UD |
4536 | check ("real(ctanh(-Inf - i0)) = -1", __real__ result, -1); |
4537 | check ("imag(ctanh(-Inf - i0)) = -0", __imag__ result, minus_zero); | |
4538 | result = FUNC(ctanh) (BUILD_COMPLEX (minus_infty, -1)); | |
4539 | check ("real(ctanh(-Inf - i1)) = -1", __real__ result, -1); | |
4540 | check ("imag(ctanh(-Inf - i1)) = -0", __imag__ result, minus_zero); | |
4541 | ||
4542 | result = FUNC(ctanh) (BUILD_COMPLEX (0, plus_infty)); | |
779ae82e | 4543 | check_isnan_exc ("real(ctanh(0 + i Inf)) = NaN plus invalid exception", |
51702635 | 4544 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
4545 | check_isnan ("imag(ctanh(0 + i Inf)) = NaN plus invalid exception", |
4546 | __imag__ result); | |
3075e0e3 | 4547 | result = FUNC(ctanh) (BUILD_COMPLEX (2, plus_infty)); |
779ae82e | 4548 | check_isnan_exc ("real(ctanh(2 + i Inf)) = NaN plus invalid exception", |
51702635 | 4549 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
4550 | check_isnan ("imag(ctanh(2 + i Inf)) = NaN plus invalid exception", |
4551 | __imag__ result); | |
3075e0e3 | 4552 | result = FUNC(ctanh) (BUILD_COMPLEX (0, minus_infty)); |
779ae82e | 4553 | check_isnan_exc ("real(ctanh(0 - i Inf)) = NaN plus invalid exception", |
51702635 | 4554 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
4555 | check_isnan ("imag(ctanh(0 - i Inf)) = NaN plus invalid exception", |
4556 | __imag__ result); | |
3075e0e3 | 4557 | result = FUNC(ctanh) (BUILD_COMPLEX (2, minus_infty)); |
779ae82e | 4558 | check_isnan_exc ("real(ctanh(2 - i Inf)) = NaN plus invalid exception", |
51702635 | 4559 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
4560 | check_isnan ("imag(ctanh(2 - i Inf)) = NaN plus invalid exception", |
4561 | __imag__ result); | |
3075e0e3 | 4562 | result = FUNC(ctanh) (BUILD_COMPLEX (minus_zero, plus_infty)); |
779ae82e | 4563 | check_isnan_exc ("real(ctanh(-0 + i Inf)) = NaN plus invalid exception", |
51702635 | 4564 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
4565 | check_isnan ("imag(ctanh(-0 + i Inf)) = NaN plus invalid exception", |
4566 | __imag__ result); | |
3075e0e3 | 4567 | result = FUNC(ctanh) (BUILD_COMPLEX (-2, plus_infty)); |
779ae82e | 4568 | check_isnan_exc ("real(ctanh(-2 + i Inf)) = NaN plus invalid exception", |
51702635 | 4569 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
4570 | check_isnan ("imag(ctanh(-2 + i Inf)) = NaN plus invalid exception", |
4571 | __imag__ result); | |
3075e0e3 | 4572 | result = FUNC(ctanh) (BUILD_COMPLEX (minus_zero, minus_infty)); |
779ae82e | 4573 | check_isnan_exc ("real(ctanh(-0 - i Inf)) = NaN plus invalid exception", |
51702635 | 4574 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
4575 | check_isnan ("imag(ctanh(-0 - i Inf)) = NaN plus invalid exception", |
4576 | __imag__ result); | |
3075e0e3 | 4577 | result = FUNC(ctanh) (BUILD_COMPLEX (-2, minus_infty)); |
779ae82e | 4578 | check_isnan_exc ("real(ctanh(-2 - i Inf)) = NaN plus invalid exception", |
51702635 | 4579 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
4580 | check_isnan ("imag(ctanh(-2 - i Inf)) = NaN plus invalid exception", |
4581 | __imag__ result); | |
3075e0e3 UD |
4582 | |
4583 | result = FUNC(ctanh) (BUILD_COMPLEX (plus_infty, nan_value)); | |
4584 | check ("real(ctanh(+Inf + i NaN)) = 1", __real__ result, 1); | |
4585 | check ("imag(ctanh(+Inf + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0); | |
4586 | result = FUNC(ctanh) (BUILD_COMPLEX (minus_infty, nan_value)); | |
4587 | check ("real(ctanh(-Inf + i NaN)) = -1", __real__ result, -1); | |
4588 | check ("imag(ctanh(-Inf + i NaN)) = +-0", FUNC(fabs) (__imag__ result), 0); | |
4589 | ||
4590 | result = FUNC(ctanh) (BUILD_COMPLEX (nan_value, 0)); | |
4591 | check_isnan ("real(ctanh(NaN + i0)) = NaN", __real__ result); | |
4592 | check ("imag(ctanh(NaN + i0)) = 0", __imag__ result, 0); | |
63551311 | 4593 | result = FUNC(ctanh) (BUILD_COMPLEX (nan_value, minus_zero)); |
3075e0e3 | 4594 | check_isnan ("real(ctanh(NaN - i0)) = NaN", __real__ result); |
63551311 | 4595 | check ("imag(ctanh(NaN - i0)) = -0", __imag__ result, minus_zero); |
3075e0e3 UD |
4596 | |
4597 | result = FUNC(ctanh) (BUILD_COMPLEX (nan_value, 0.5)); | |
779ae82e | 4598 | check_isnan_maybe_exc ("real(ctanh(NaN + i0.5)) = NaN plus maybe invalid exception", |
51702635 | 4599 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
4600 | check_isnan ("imag(ctanh(NaN + i0.5)) = NaN plus maybe invalid exception", |
4601 | __imag__ result); | |
3075e0e3 | 4602 | result = FUNC(ctanh) (BUILD_COMPLEX (nan_value, -4.5)); |
779ae82e | 4603 | check_isnan_maybe_exc ("real(ctanh(NaN - i4.5)) = NaN plus maybe invalid exception", |
51702635 | 4604 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
4605 | check_isnan ("imag(ctanh(NaN - i4.5)) = NaN plus maybe invalid exception", |
4606 | __imag__ result); | |
3075e0e3 UD |
4607 | |
4608 | result = FUNC(ctanh) (BUILD_COMPLEX (0, nan_value)); | |
779ae82e | 4609 | check_isnan_maybe_exc ("real(ctanh(0 + i NaN)) = NaN plus maybe invalid exception", |
51702635 | 4610 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
4611 | check_isnan ("imag(ctanh(0 + i NaN)) = NaN plus maybe invalid exception", |
4612 | __imag__ result); | |
3075e0e3 | 4613 | result = FUNC(ctanh) (BUILD_COMPLEX (5, nan_value)); |
779ae82e | 4614 | check_isnan_maybe_exc ("real(ctanh(5 + i NaN)) = NaN plus maybe invalid exception", |
51702635 | 4615 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
4616 | check_isnan ("imag(ctanh(5 + i NaN)) = NaN plus maybe invalid exception", |
4617 | __imag__ result); | |
3075e0e3 | 4618 | result = FUNC(ctanh) (BUILD_COMPLEX (minus_zero, nan_value)); |
779ae82e | 4619 | check_isnan_maybe_exc ("real(ctanh(-0 + i NaN)) = NaN plus maybe invalid exception", |
51702635 | 4620 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
4621 | check_isnan ("imag(ctanh(-0 + i NaN)) = NaN plus maybe invalid exception", |
4622 | __imag__ result); | |
3075e0e3 | 4623 | result = FUNC(ctanh) (BUILD_COMPLEX (-0.25, nan_value)); |
779ae82e | 4624 | check_isnan_maybe_exc ("real(ctanh(-0.25 + i NaN)) = NaN plus maybe invalid exception", |
51702635 | 4625 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
4626 | check_isnan ("imag(ctanh(-0.25 + i NaN)) = NaN plus maybe invalid exception", |
4627 | __imag__ result); | |
3075e0e3 UD |
4628 | |
4629 | result = FUNC(ctanh) (BUILD_COMPLEX (nan_value, nan_value)); | |
4630 | check_isnan ("real(ctanh(NaN + i NaN)) = NaN", __real__ result); | |
4631 | check_isnan ("imag(ctanh(NaN + i NaN)) = NaN", __imag__ result); | |
04be94a8 | 4632 | |
0a614877 | 4633 | result = FUNC(ctanh) (BUILD_COMPLEX (0, M_PI_4l)); |
04be94a8 UD |
4634 | check ("real(ctanh (0 + i pi/4)) == 0", __real__ result, 0); |
4635 | check_eps ("imag(ctanh (0 + i pi/4)) == 1", __imag__ result, 1, | |
9756dfe1 | 4636 | CHOOSE (0, 2e-16, 2e-7)); |
bd355af0 UD |
4637 | |
4638 | result = FUNC(ctanh) (BUILD_COMPLEX (0.7, 1.2)); | |
4639 | check_eps ("real(ctanh(0.7 + i 1.2)) == 1.34721...", __real__ result, | |
66000494 | 4640 | 1.3472197399061191630L, CHOOSE(4e-17L, 5e-16, 2e-7)); |
bd355af0 | 4641 | check_eps ("imag(ctanh(0.7 + i 1.2)) == -0.47786...", __imag__ result, |
66000494 | 4642 | 0.4778641038326365540L, CHOOSE(9e-17L, 2e-16, 9e-8)); |
bd355af0 UD |
4643 | |
4644 | result = FUNC(ctanh) (BUILD_COMPLEX (-2, -3)); | |
74015205 | 4645 | check_eps ("real(ctanh(-2 - i 3)) == -0.96538...", __real__ result, |
66000494 | 4646 | -0.9653858790221331242L, CHOOSE(2e-19L, 2e-16, 2e-7)); |
74015205 | 4647 | check_eps ("imag(ctanh(-2 - i 3)) == 0.00988...", __imag__ result, |
66000494 | 4648 | 0.0098843750383224937L, CHOOSE(7e-20L, 2e-16, 1e-9)); |
3075e0e3 UD |
4649 | } |
4650 | ||
4651 | ||
4652 | static void | |
4653 | clog_test (void) | |
4654 | { | |
4655 | __complex__ MATHTYPE result; | |
4656 | ||
4657 | result = FUNC(clog) (BUILD_COMPLEX (minus_zero, 0)); | |
779ae82e UD |
4658 | check_isinfn_exc ("real(clog(-0 + i0)) = -Inf plus divide-by-zero exception", |
4659 | __real__ result, DIVIDE_BY_ZERO_EXCEPTION); | |
4660 | check ("imag(clog(-0 + i0)) = pi plus divide-by-zero exception", | |
0a614877 | 4661 | __imag__ result, M_PIl); |
3075e0e3 | 4662 | result = FUNC(clog) (BUILD_COMPLEX (minus_zero, minus_zero)); |
779ae82e UD |
4663 | check_isinfn_exc ("real(clog(-0 - i0)) = -Inf plus divide-by-zero exception", |
4664 | __real__ result, DIVIDE_BY_ZERO_EXCEPTION); | |
4665 | check ("imag(clog(-0 - i0)) = -pi plus divide-by-zero exception", | |
0a614877 | 4666 | __imag__ result, -M_PIl); |
3075e0e3 UD |
4667 | |
4668 | result = FUNC(clog) (BUILD_COMPLEX (0, 0)); | |
779ae82e UD |
4669 | check_isinfn_exc ("real(clog(0 + i0)) = -Inf plus divide-by-zero exception", |
4670 | __real__ result, DIVIDE_BY_ZERO_EXCEPTION); | |
4671 | check ("imag(clog(0 + i0)) = 0 plus divide-by-zero exception", | |
4672 | __imag__ result, 0); | |
3075e0e3 | 4673 | result = FUNC(clog) (BUILD_COMPLEX (0, minus_zero)); |
779ae82e UD |
4674 | check_isinfn_exc ("real(clog(0 - i0)) = -Inf plus divide-by-zero exception", |
4675 | __real__ result, DIVIDE_BY_ZERO_EXCEPTION); | |
4676 | check ("imag(clog(0 - i0)) = -0 plus divide-by-zero exception", | |
4677 | __imag__ result, minus_zero); | |
3075e0e3 UD |
4678 | |
4679 | result = FUNC(clog) (BUILD_COMPLEX (minus_infty, plus_infty)); | |
4680 | check_isinfp ("real(clog(-Inf + i Inf)) = +Inf", __real__ result); | |
0a614877 UD |
4681 | check ("imag(clog(-Inf + i Inf)) = 3*pi/4", __imag__ result, |
4682 | M_PIl - M_PI_4l); | |
3075e0e3 UD |
4683 | result = FUNC(clog) (BUILD_COMPLEX (minus_infty, minus_infty)); |
4684 | check_isinfp ("real(clog(-Inf - i Inf)) = +Inf", __real__ result); | |
0a614877 UD |
4685 | check ("imag(clog(-Inf - i Inf)) = -3*pi/4", __imag__ result, |
4686 | M_PI_4l - M_PIl); | |
3075e0e3 UD |
4687 | |
4688 | result = FUNC(clog) (BUILD_COMPLEX (plus_infty, plus_infty)); | |
4689 | check_isinfp ("real(clog(+Inf + i Inf)) = +Inf", __real__ result); | |
0a614877 | 4690 | check ("imag(clog(+Inf + i Inf)) = pi/4", __imag__ result, M_PI_4l); |
3075e0e3 UD |
4691 | result = FUNC(clog) (BUILD_COMPLEX (plus_infty, minus_infty)); |
4692 | check_isinfp ("real(clog(+Inf - i Inf)) = +Inf", __real__ result); | |
0a614877 | 4693 | check ("imag(clog(+Inf - i Inf)) = -pi/4", __imag__ result, -M_PI_4l); |
3075e0e3 UD |
4694 | |
4695 | result = FUNC(clog) (BUILD_COMPLEX (0, plus_infty)); | |
4696 | check_isinfp ("real(clog(0 + i Inf)) = +Inf", __real__ result); | |
0a614877 | 4697 | check ("imag(clog(0 + i Inf)) = pi/2", __imag__ result, M_PI_2l); |
3075e0e3 UD |
4698 | result = FUNC(clog) (BUILD_COMPLEX (3, plus_infty)); |
4699 | check_isinfp ("real(clog(3 + i Inf)) = +Inf", __real__ result); | |
0a614877 | 4700 | check ("imag(clog(3 + i Inf)) = pi/2", __imag__ result, M_PI_2l); |
3075e0e3 UD |
4701 | result = FUNC(clog) (BUILD_COMPLEX (minus_zero, plus_infty)); |
4702 | check_isinfp ("real(clog(-0 + i Inf)) = +Inf", __real__ result); | |
0a614877 | 4703 | check ("imag(clog(-0 + i Inf)) = pi/2", __imag__ result, M_PI_2l); |
3075e0e3 UD |
4704 | result = FUNC(clog) (BUILD_COMPLEX (-3, plus_infty)); |
4705 | check_isinfp ("real(clog(-3 + i Inf)) = +Inf", __real__ result); | |
0a614877 | 4706 | check ("imag(clog(-3 + i Inf)) = pi/2", __imag__ result, M_PI_2l); |
3075e0e3 UD |
4707 | result = FUNC(clog) (BUILD_COMPLEX (0, minus_infty)); |
4708 | check_isinfp ("real(clog(0 - i Inf)) = +Inf", __real__ result); | |
0a614877 | 4709 | check ("imag(clog(0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2l); |
3075e0e3 UD |
4710 | result = FUNC(clog) (BUILD_COMPLEX (3, minus_infty)); |
4711 | check_isinfp ("real(clog(3 - i Inf)) = +Inf", __real__ result); | |
0a614877 | 4712 | check ("imag(clog(3 - i Inf)) = -pi/2", __imag__ result, -M_PI_2l); |
3075e0e3 UD |
4713 | result = FUNC(clog) (BUILD_COMPLEX (minus_zero, minus_infty)); |
4714 | check_isinfp ("real(clog(-0 - i Inf)) = +Inf", __real__ result); | |
0a614877 | 4715 | check ("imag(clog(-0 - i Inf)) = -pi/2", __imag__ result, -M_PI_2l); |
3075e0e3 UD |
4716 | result = FUNC(clog) (BUILD_COMPLEX (-3, minus_infty)); |
4717 | check_isinfp ("real(clog(-3 - i Inf)) = +Inf", __real__ result); | |
0a614877 | 4718 | check ("imag(clog(-3 - i Inf)) = -pi/2", __imag__ result, -M_PI_2l); |
3075e0e3 UD |
4719 | |
4720 | result = FUNC(clog) (BUILD_COMPLEX (minus_infty, 0)); | |
4721 | check_isinfp ("real(clog(-Inf + i0)) = +Inf", __real__ result); | |
0a614877 | 4722 | check ("imag(clog(-Inf + i0)) = pi", __imag__ result, M_PIl); |
3075e0e3 UD |
4723 | result = FUNC(clog) (BUILD_COMPLEX (minus_infty, 1)); |
4724 | check_isinfp ("real(clog(-Inf + i1)) = +Inf", __real__ result); | |
0a614877 | 4725 | check ("imag(clog(-Inf + i1)) = pi", __imag__ result, M_PIl); |
3075e0e3 UD |
4726 | result = FUNC(clog) (BUILD_COMPLEX (minus_infty, minus_zero)); |
4727 | check_isinfp ("real(clog(-Inf - i0)) = +Inf", __real__ result); | |
0a614877 | 4728 | check ("imag(clog(-Inf - i0)) = -pi", __imag__ result, -M_PIl); |
3075e0e3 UD |
4729 | result = FUNC(clog) (BUILD_COMPLEX (minus_infty, -1)); |
4730 | check_isinfp ("real(clog(-Inf - i1)) = +Inf", __real__ result); | |
0a614877 | 4731 | check ("imag(clog(-Inf - i1)) = -pi", __imag__ result, -M_PIl); |
3075e0e3 UD |
4732 | |
4733 | result = FUNC(clog) (BUILD_COMPLEX (plus_infty, 0)); | |
4734 | check_isinfp ("real(clog(+Inf + i0)) = +Inf", __real__ result); | |
4735 | check ("imag(clog(+Inf + i0)) = 0", __imag__ result, 0); | |
4736 | result = FUNC(clog) (BUILD_COMPLEX (plus_infty, 1)); | |
4737 | check_isinfp ("real(clog(+Inf + i1)) = +Inf", __real__ result); | |
4738 | check ("imag(clog(+Inf + i1)) = 0", __imag__ result, 0); | |
4739 | result = FUNC(clog) (BUILD_COMPLEX (plus_infty, minus_zero)); | |
4740 | check_isinfp ("real(clog(+Inf - i0)) = +Inf", __real__ result); | |
c131718c | 4741 | check ("imag(clog(+Inf - i0)) = -0", __imag__ result, minus_zero); |
3075e0e3 UD |
4742 | result = FUNC(clog) (BUILD_COMPLEX (plus_infty, -1)); |
4743 | check_isinfp ("real(clog(+Inf - i1)) = +Inf", __real__ result); | |
c131718c | 4744 | check ("imag(clog(+Inf - i1)) = -0", __imag__ result, minus_zero); |
3075e0e3 UD |
4745 | |
4746 | result = FUNC(clog) (BUILD_COMPLEX (plus_infty, nan_value)); | |
4747 | check_isinfp ("real(clog(+Inf + i NaN)) = +Inf", __real__ result); | |
4748 | check_isnan ("imag(clog(+Inf + i NaN)) = NaN", __imag__ result); | |
4749 | result = FUNC(clog) (BUILD_COMPLEX (minus_infty, nan_value)); | |
4750 | check_isinfp ("real(clog(-Inf + i NaN)) = +Inf", __real__ result); | |
4751 | check_isnan ("imag(clog(-Inf + i NaN)) = NaN", __imag__ result); | |
4752 | ||
4753 | result = FUNC(clog) (BUILD_COMPLEX (nan_value, plus_infty)); | |
4754 | check_isinfp ("real(clog(NaN + i Inf)) = +Inf", __real__ result); | |
4755 | check_isnan ("imag(clog(NaN + i Inf)) = NaN", __imag__ result); | |
63551311 | 4756 | result = FUNC(clog) (BUILD_COMPLEX (nan_value, minus_infty)); |
3075e0e3 UD |
4757 | check_isinfp ("real(clog(NaN - i Inf)) = +Inf", __real__ result); |
4758 | check_isnan ("imag(clog(NaN - i Inf)) = NaN", __imag__ result); | |
4759 | ||
4760 | result = FUNC(clog) (BUILD_COMPLEX (0, nan_value)); | |
779ae82e | 4761 | check_isnan_maybe_exc ("real(clog(0 + i NaN)) = NaN plus maybe invalid exception", |
51702635 | 4762 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
4763 | check_isnan ("imag(clog(0 + i NaN)) = NaN plus maybe invalid exception", |
4764 | __imag__ result); | |
3075e0e3 | 4765 | result = FUNC(clog) (BUILD_COMPLEX (3, nan_value)); |
779ae82e | 4766 | check_isnan_maybe_exc ("real(clog(3 + i NaN)) = NaN plus maybe invalid exception", |
51702635 | 4767 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
4768 | check_isnan ("imag(clog(3 + i NaN)) = NaN plus maybe invalid exception", |
4769 | __imag__ result); | |
3075e0e3 | 4770 | result = FUNC(clog) (BUILD_COMPLEX (minus_zero, nan_value)); |
779ae82e | 4771 | check_isnan_maybe_exc ("real(clog(-0 + i NaN)) = NaN plus maybe invalid exception", |
51702635 | 4772 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
4773 | check_isnan ("imag(clog(-0 + i NaN)) = NaN plus maybe invalid exception", |
4774 | __imag__ result); | |
3075e0e3 | 4775 | result = FUNC(clog) (BUILD_COMPLEX (-3, nan_value)); |
779ae82e | 4776 | check_isnan_maybe_exc ("real(clog(-3 + i NaN)) = NaN plus maybe invalid exception", |
51702635 | 4777 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
4778 | check_isnan ("imag(clog(-3 + i NaN)) = NaN plus maybe invalid exception", |
4779 | __imag__ result); | |
3075e0e3 UD |
4780 | |
4781 | result = FUNC(clog) (BUILD_COMPLEX (nan_value, 0)); | |
779ae82e | 4782 | check_isnan_maybe_exc ("real(clog(NaN + i0)) = NaN plus maybe invalid exception", |
51702635 | 4783 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
4784 | check_isnan ("imag(clog(NaN + i0)) = NaN plus maybe invalid exception", |
4785 | __imag__ result); | |
3075e0e3 | 4786 | result = FUNC(clog) (BUILD_COMPLEX (nan_value, 5)); |
779ae82e | 4787 | check_isnan_maybe_exc ("real(clog(NaN + i5)) = NaN plus maybe invalid exception", |
51702635 | 4788 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
4789 | check_isnan ("imag(clog(NaN + i5)) = NaN plus maybe invalid exception", |
4790 | __imag__ result); | |
3075e0e3 | 4791 | result = FUNC(clog) (BUILD_COMPLEX (nan_value, minus_zero)); |
779ae82e | 4792 | check_isnan_maybe_exc ("real(clog(NaN - i0)) = NaN plus maybe invalid exception", |
51702635 | 4793 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
4794 | check_isnan ("imag(clog(NaN - i0)) = NaN plus maybe invalid exception", |
4795 | __imag__ result); | |
3075e0e3 | 4796 | result = FUNC(clog) (BUILD_COMPLEX (nan_value, -5)); |
779ae82e | 4797 | check_isnan_maybe_exc ("real(clog(NaN - i5)) = NaN plus maybe invalid exception", |
51702635 | 4798 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
4799 | check_isnan ("imag(clog(NaN - i5)) = NaN plus maybe invalid exception", |
4800 | __imag__ result); | |
3075e0e3 UD |
4801 | |
4802 | result = FUNC(clog) (BUILD_COMPLEX (nan_value, nan_value)); | |
4803 | check_isnan ("real(clog(NaN + i NaN)) = NaN", __real__ result); | |
4804 | check_isnan ("imag(clog(NaN + i NaN)) = NaN", __imag__ result); | |
bd355af0 UD |
4805 | |
4806 | result = FUNC(clog) (BUILD_COMPLEX (0.7, 1.2)); | |
4807 | check_eps ("real(clog(0.7 + i 1.2)) == 0.32876...", __real__ result, | |
4808 | 0.3287600014583970919L, CHOOSE(5e-17L, 6e-17, 3e-8)); | |
4809 | check_eps ("imag(clog(0.7 + i 1.2)) == 1.04272...", __imag__ result, | |
5edb9387 | 4810 | 1.0427218783685369524L, CHOOSE(2e-17L, 2.5e-16, 1.2e-7)); |
bd355af0 UD |
4811 | |
4812 | result = FUNC(clog) (BUILD_COMPLEX (-2, -3)); | |
74015205 UD |
4813 | check_eps ("real(clog(-2 - i 3)) == 1.28247...", __real__ result, |
4814 | 1.2824746787307683680L, CHOOSE(3e-19L, 0, 0)); | |
bd355af0 | 4815 | check_eps ("imag(clog(-2 - i 3)) == -2.15879...", __imag__ result, |
66000494 | 4816 | -2.1587989303424641704L, CHOOSE(2e-18L, 5e-16, 8e-7)); |
3075e0e3 UD |
4817 | } |
4818 | ||
4819 | ||
dfd2257a UD |
4820 | static void |
4821 | clog10_test (void) | |
4822 | { | |
4823 | __complex__ MATHTYPE result; | |
4824 | ||
4825 | result = FUNC(clog10) (BUILD_COMPLEX (minus_zero, 0)); | |
4826 | check_isinfn_exc ("real(clog10(-0 + i0)) = -Inf plus divide-by-zero exception", | |
4827 | __real__ result, DIVIDE_BY_ZERO_EXCEPTION); | |
4828 | check ("imag(clog10(-0 + i0)) = pi plus divide-by-zero exception", | |
0a614877 | 4829 | __imag__ result, M_PIl); |
dfd2257a UD |
4830 | result = FUNC(clog10) (BUILD_COMPLEX (minus_zero, minus_zero)); |
4831 | check_isinfn_exc ("real(clog10(-0 - i0)) = -Inf plus divide-by-zero exception", | |
4832 | __real__ result, DIVIDE_BY_ZERO_EXCEPTION); | |
4833 | check ("imag(clog10(-0 - i0)) = -pi plus divide-by-zero exception", | |
0a614877 | 4834 | __imag__ result, -M_PIl); |
dfd2257a UD |
4835 | |
4836 | result = FUNC(clog10) (BUILD_COMPLEX (0, 0)); | |
4837 | check_isinfn_exc ("real(clog10(0 + i0)) = -Inf plus divide-by-zero exception", | |
4838 | __real__ result, DIVIDE_BY_ZERO_EXCEPTION); | |
4839 | check ("imag(clog10(0 + i0)) = 0 plus divide-by-zero exception", | |
4840 | __imag__ result, 0); | |
4841 | result = FUNC(clog10) (BUILD_COMPLEX (0, minus_zero)); | |
4842 | check_isinfn_exc ("real(clog10(0 - i0)) = -Inf plus divide-by-zero exception", | |
4843 | __real__ result, DIVIDE_BY_ZERO_EXCEPTION); | |
4844 | check ("imag(clog10(0 - i0)) = -0 plus divide-by-zero exception", | |
4845 | __imag__ result, minus_zero); | |
4846 | ||
4847 | result = FUNC(clog10) (BUILD_COMPLEX (minus_infty, plus_infty)); | |
4848 | check_isinfp ("real(clog10(-Inf + i Inf)) = +Inf", __real__ result); | |
bd355af0 | 4849 | check_eps ("imag(clog10(-Inf + i Inf)) = 3*pi/4*M_LOG10E", __imag__ result, |
0a614877 | 4850 | (M_PIl - M_PI_4l) * M_LOG10El, CHOOSE (0, 3e-16, 0)); |
dfd2257a UD |
4851 | result = FUNC(clog10) (BUILD_COMPLEX (minus_infty, minus_infty)); |
4852 | check_isinfp ("real(clog10(-Inf - i Inf)) = +Inf", __real__ result); | |
bd355af0 | 4853 | check_eps ("imag(clog10(-Inf - i Inf)) = -3*pi/4*M_LOG10E", __imag__ result, |
0a614877 | 4854 | (M_PI_4l - M_PIl) * M_LOG10El, CHOOSE (0, 3e-16, 0)); |
dfd2257a UD |
4855 | |
4856 | result = FUNC(clog10) (BUILD_COMPLEX (plus_infty, plus_infty)); | |
4857 | check_isinfp ("real(clog10(+Inf + i Inf)) = +Inf", __real__ result); | |
bd355af0 | 4858 | check_eps ("imag(clog10(+Inf + i Inf)) = pi/4*M_LOG10E", __imag__ result, |
0a614877 | 4859 | M_PI_4l * M_LOG10El, CHOOSE (0, 6e-17, 3e-8)); |
dfd2257a UD |
4860 | result = FUNC(clog10) (BUILD_COMPLEX (plus_infty, minus_infty)); |
4861 | check_isinfp ("real(clog10(+Inf - i Inf)) = +Inf", __real__ result); | |
bd355af0 | 4862 | check_eps ("imag(clog10(+Inf - i Inf)) = -pi/4*M_LOG10E", __imag__ result, |
0a614877 | 4863 | -M_PI_4l * M_LOG10El, CHOOSE (0, 6e-17, 3e-8)); |
dfd2257a UD |
4864 | |
4865 | result = FUNC(clog10) (BUILD_COMPLEX (0, plus_infty)); | |
4866 | check_isinfp ("real(clog10(0 + i Inf)) = +Inf", __real__ result); | |
bd355af0 | 4867 | check_eps ("imag(clog10(0 + i Inf)) = pi/2*M_LOG10E", __imag__ result, |
0a614877 | 4868 | M_PI_2l * M_LOG10El, CHOOSE (0, 2e-16, 6e-8)); |
dfd2257a UD |
4869 | result = FUNC(clog10) (BUILD_COMPLEX (3, plus_infty)); |
4870 | check_isinfp ("real(clog10(3 + i Inf)) = +Inf", __real__ result); | |
bd355af0 | 4871 | check_eps ("imag(clog10(3 + i Inf)) = pi/2*M_LOG10E", __imag__ result, |
0a614877 | 4872 | M_PI_2l * M_LOG10El, CHOOSE (0, 2e-16, 6e-8)); |
dfd2257a UD |
4873 | result = FUNC(clog10) (BUILD_COMPLEX (minus_zero, plus_infty)); |
4874 | check_isinfp ("real(clog10(-0 + i Inf)) = +Inf", __real__ result); | |
bd355af0 | 4875 | check_eps ("imag(clog10(-0 + i Inf)) = pi/2*M_LOG10E", __imag__ result, |
0a614877 | 4876 | M_PI_2l * M_LOG10El, CHOOSE (0, 2e-16, 6e-8)); |
dfd2257a UD |
4877 | result = FUNC(clog10) (BUILD_COMPLEX (-3, plus_infty)); |
4878 | check_isinfp ("real(clog10(-3 + i Inf)) = +Inf", __real__ result); | |
bd355af0 | 4879 | check_eps ("imag(clog10(-3 + i Inf)) = pi/2*M_LOG10E", __imag__ result, |
0a614877 | 4880 | M_PI_2l * M_LOG10El, CHOOSE (0, 2e-16, 6e-8)); |
dfd2257a UD |
4881 | result = FUNC(clog10) (BUILD_COMPLEX (0, minus_infty)); |
4882 | check_isinfp ("real(clog10(0 - i Inf)) = +Inf", __real__ result); | |
bd355af0 | 4883 | check_eps ("imag(clog10(0 - i Inf)) = -pi/2*M_LOG10E", __imag__ result, |
0a614877 | 4884 | -M_PI_2l * M_LOG10El, CHOOSE (0, 2e-16, 6e-8)); |
dfd2257a UD |
4885 | result = FUNC(clog10) (BUILD_COMPLEX (3, minus_infty)); |
4886 | check_isinfp ("real(clog10(3 - i Inf)) = +Inf", __real__ result); | |
bd355af0 | 4887 | check_eps ("imag(clog10(3 - i Inf)) = -pi/2*M_LOG10E", __imag__ result, |
0a614877 | 4888 | -M_PI_2l * M_LOG10El, CHOOSE (0, 2e-16, 6e-8)); |
dfd2257a UD |
4889 | result = FUNC(clog10) (BUILD_COMPLEX (minus_zero, minus_infty)); |
4890 | check_isinfp ("real(clog10(-0 - i Inf)) = +Inf", __real__ result); | |
bd355af0 | 4891 | check_eps ("imag(clog10(-0 - i Inf)) = -pi/2*M_LOG10E", __imag__ result, |
0a614877 | 4892 | -M_PI_2l * M_LOG10El, CHOOSE (0, 2e-16, 6e-8)); |
dfd2257a UD |
4893 | result = FUNC(clog10) (BUILD_COMPLEX (-3, minus_infty)); |
4894 | check_isinfp ("real(clog10(-3 - i Inf)) = +Inf", __real__ result); | |
bd355af0 | 4895 | check_eps ("imag(clog10(-3 - i Inf)) = -pi/2*M_LOG10E", __imag__ result, |
0a614877 | 4896 | -M_PI_2l * M_LOG10El, CHOOSE (0, 2e-16, 6e-8)); |
dfd2257a UD |
4897 | |
4898 | result = FUNC(clog10) (BUILD_COMPLEX (minus_infty, 0)); | |
4899 | check_isinfp ("real(clog10(-Inf + i0)) = +Inf", __real__ result); | |
bd355af0 | 4900 | check_eps ("imag(clog10(-Inf + i0)) = pi*M_LOG10E", __imag__ result, |
0a614877 | 4901 | M_PIl * M_LOG10El, CHOOSE (0, 3e-16, 2e-7)); |
dfd2257a UD |
4902 | result = FUNC(clog10) (BUILD_COMPLEX (minus_infty, 1)); |
4903 | check_isinfp ("real(clog10(-Inf + i1)) = +Inf", __real__ result); | |
bd355af0 | 4904 | check_eps ("imag(clog10(-Inf + i1)) = pi*M_LOG10E", __imag__ result, |
0a614877 | 4905 | M_PIl * M_LOG10El, CHOOSE (0, 3e-16, 2e-7)); |
dfd2257a UD |
4906 | result = FUNC(clog10) (BUILD_COMPLEX (minus_infty, minus_zero)); |
4907 | check_isinfp ("real(clog10(-Inf - i0)) = +Inf", __real__ result); | |
bd355af0 | 4908 | check_eps ("imag(clog10(-Inf - i0)) = -pi*M_LOG10E", __imag__ result, |
0a614877 | 4909 | -M_PIl * M_LOG10El, CHOOSE (0, 3e-16, 2e-7)); |
dfd2257a UD |
4910 | result = FUNC(clog10) (BUILD_COMPLEX (minus_infty, -1)); |
4911 | check_isinfp ("real(clog10(-Inf - i1)) = +Inf", __real__ result); | |
bd355af0 | 4912 | check_eps ("imag(clog10(-Inf - i1)) = -pi*M_LOG10E", __imag__ result, |
0a614877 | 4913 | -M_PIl * M_LOG10El, CHOOSE (0, 3e-16, 2e-7)); |
dfd2257a UD |
4914 | |
4915 | result = FUNC(clog10) (BUILD_COMPLEX (plus_infty, 0)); | |
4916 | check_isinfp ("real(clog10(+Inf + i0)) = +Inf", __real__ result); | |
4917 | check ("imag(clog10(+Inf + i0)) = 0", __imag__ result, 0); | |
4918 | result = FUNC(clog10) (BUILD_COMPLEX (plus_infty, 1)); | |
4919 | check_isinfp ("real(clog10(+Inf + i1)) = +Inf", __real__ result); | |
4920 | check ("imag(clog10(+Inf + i1)) = 0", __imag__ result, 0); | |
4921 | result = FUNC(clog10) (BUILD_COMPLEX (plus_infty, minus_zero)); | |
4922 | check_isinfp ("real(clog10(+Inf - i0)) = +Inf", __real__ result); | |
4923 | check ("imag(clog10(+Inf - i0)) = -0", __imag__ result, minus_zero); | |
4924 | result = FUNC(clog10) (BUILD_COMPLEX (plus_infty, -1)); | |
4925 | check_isinfp ("real(clog10(+Inf - i1)) = +Inf", __real__ result); | |
4926 | check ("imag(clog10(+Inf - i1)) = -0", __imag__ result, minus_zero); | |
4927 | ||
4928 | result = FUNC(clog10) (BUILD_COMPLEX (plus_infty, nan_value)); | |
4929 | check_isinfp ("real(clog10(+Inf + i NaN)) = +Inf", __real__ result); | |
4930 | check_isnan ("imag(clog10(+Inf + i NaN)) = NaN", __imag__ result); | |
4931 | result = FUNC(clog10) (BUILD_COMPLEX (minus_infty, nan_value)); | |
4932 | check_isinfp ("real(clog10(-Inf + i NaN)) = +Inf", __real__ result); | |
4933 | check_isnan ("imag(clog10(-Inf + i NaN)) = NaN", __imag__ result); | |
4934 | ||
4935 | result = FUNC(clog10) (BUILD_COMPLEX (nan_value, plus_infty)); | |
4936 | check_isinfp ("real(clog10(NaN + i Inf)) = +Inf", __real__ result); | |
4937 | check_isnan ("imag(clog10(NaN + i Inf)) = NaN", __imag__ result); | |
4938 | result = FUNC(clog10) (BUILD_COMPLEX (nan_value, minus_infty)); | |
4939 | check_isinfp ("real(clog10(NaN - i Inf)) = +Inf", __real__ result); | |
4940 | check_isnan ("imag(clog10(NaN - i Inf)) = NaN", __imag__ result); | |
4941 | ||
4942 | result = FUNC(clog10) (BUILD_COMPLEX (0, nan_value)); | |
4943 | check_isnan_maybe_exc ("real(clog10(0 + i NaN)) = NaN plus maybe invalid exception", | |
4944 | __real__ result, INVALID_EXCEPTION); | |
4945 | check_isnan ("imag(clog10(0 + i NaN)) = NaN plus maybe invalid exception", | |
4946 | __imag__ result); | |
4947 | result = FUNC(clog10) (BUILD_COMPLEX (3, nan_value)); | |
4948 | check_isnan_maybe_exc ("real(clog10(3 + i NaN)) = NaN plus maybe invalid exception", | |
4949 | __real__ result, INVALID_EXCEPTION); | |
4950 | check_isnan ("imag(clog10(3 + i NaN)) = NaN plus maybe invalid exception", | |
4951 | __imag__ result); | |
4952 | result = FUNC(clog10) (BUILD_COMPLEX (minus_zero, nan_value)); | |
4953 | check_isnan_maybe_exc ("real(clog10(-0 + i NaN)) = NaN plus maybe invalid exception", | |
4954 | __real__ result, INVALID_EXCEPTION); | |
4955 | check_isnan ("imag(clog10(-0 + i NaN)) = NaN plus maybe invalid exception", | |
4956 | __imag__ result); | |
4957 | result = FUNC(clog10) (BUILD_COMPLEX (-3, nan_value)); | |
4958 | check_isnan_maybe_exc ("real(clog10(-3 + i NaN)) = NaN plus maybe invalid exception", | |
4959 | __real__ result, INVALID_EXCEPTION); | |
4960 | check_isnan ("imag(clog10(-3 + i NaN)) = NaN plus maybe invalid exception", | |
4961 | __imag__ result); | |
4962 | ||
4963 | result = FUNC(clog10) (BUILD_COMPLEX (nan_value, 0)); | |
4964 | check_isnan_maybe_exc ("real(clog10(NaN + i0)) = NaN plus maybe invalid exception", | |
4965 | __real__ result, INVALID_EXCEPTION); | |
4966 | check_isnan ("imag(clog10(NaN + i0)) = NaN plus maybe invalid exception", | |
4967 | __imag__ result); | |
4968 | result = FUNC(clog10) (BUILD_COMPLEX (nan_value, 5)); | |
4969 | check_isnan_maybe_exc ("real(clog10(NaN + i5)) = NaN plus maybe invalid exception", | |
4970 | __real__ result, INVALID_EXCEPTION); | |
4971 | check_isnan ("imag(clog10(NaN + i5)) = NaN plus maybe invalid exception", | |
4972 | __imag__ result); | |
4973 | result = FUNC(clog10) (BUILD_COMPLEX (nan_value, minus_zero)); | |
4974 | check_isnan_maybe_exc ("real(clog10(NaN - i0)) = NaN plus maybe invalid exception", | |
4975 | __real__ result, INVALID_EXCEPTION); | |
4976 | check_isnan ("imag(clog10(NaN - i0)) = NaN plus maybe invalid exception", | |
4977 | __imag__ result); | |
4978 | result = FUNC(clog10) (BUILD_COMPLEX (nan_value, -5)); | |
4979 | check_isnan_maybe_exc ("real(clog10(NaN - i5)) = NaN plus maybe invalid exception", | |
4980 | __real__ result, INVALID_EXCEPTION); | |
4981 | check_isnan ("imag(clog10(NaN - i5)) = NaN plus maybe invalid exception", | |
4982 | __imag__ result); | |
4983 | ||
4984 | result = FUNC(clog10) (BUILD_COMPLEX (nan_value, nan_value)); | |
4985 | check_isnan ("real(clog10(NaN + i NaN)) = NaN", __real__ result); | |
4986 | check_isnan ("imag(clog10(NaN + i NaN)) = NaN", __imag__ result); | |
bd355af0 UD |
4987 | |
4988 | result = FUNC(clog10) (BUILD_COMPLEX (0.7, 1.2)); | |
4989 | check_eps ("real(clog10(0.7 + i 1.2)) == 0.14277...", __real__ result, | |
4990 | 0.1427786545038868803L, CHOOSE(2e-17L, 6e-17, 2e-8)); | |
4991 | check_eps ("imag(clog10(0.7 + i 1.2)) == 0.45284...", __imag__ result, | |
5edb9387 | 4992 | 0.4528483579352493248L, CHOOSE(6e-18, 6e-17, 6e-8)); |
bd355af0 UD |
4993 | |
4994 | result = FUNC(clog10) (BUILD_COMPLEX (-2, -3)); | |
74015205 UD |
4995 | check_eps ("real(clog10(-2 - i 3)) == 0.55697...", __real__ result, |
4996 | 0.5569716761534183846L, CHOOSE(6e-20L, 0, 0)); | |
bd355af0 | 4997 | check_eps ("imag(clog10(-2 - i 3)) == -0.93755...", __imag__ result, |
66000494 | 4998 | -0.9375544629863747085L, CHOOSE (7e-19L, 2e-16, 3e-7)); |
dfd2257a UD |
4999 | } |
5000 | ||
5001 | ||
3075e0e3 UD |
5002 | static void |
5003 | csqrt_test (void) | |
5004 | { | |
5005 | __complex__ MATHTYPE result; | |
5006 | ||
5007 | result = FUNC(csqrt) (BUILD_COMPLEX (0, 0)); | |
5008 | check ("real(csqrt(0 + i0)) = 0", __real__ result, 0); | |
5009 | check ("imag(csqrt(0 + i0)) = 0", __imag__ result, 0); | |
5010 | result = FUNC(csqrt) (BUILD_COMPLEX (0, minus_zero)); | |
5011 | check ("real(csqrt(0 - i0)) = 0", __real__ result, 0); | |
5012 | check ("imag(csqrt(0 - i0)) = -0", __imag__ result, minus_zero); | |
5013 | result = FUNC(csqrt) (BUILD_COMPLEX (minus_zero, 0)); | |
5014 | check ("real(csqrt(-0 + i0)) = 0", __real__ result, 0); | |
5015 | check ("imag(csqrt(-0 + i0)) = 0", __imag__ result, 0); | |
5016 | result = FUNC(csqrt) (BUILD_COMPLEX (minus_zero, minus_zero)); | |
5017 | check ("real(csqrt(-0 - i0)) = 0", __real__ result, 0); | |
5018 | check ("imag(csqrt(-0 - i0)) = -0", __imag__ result, minus_zero); | |
5019 | ||
5020 | result = FUNC(csqrt) (BUILD_COMPLEX (minus_infty, 0)); | |
5021 | check ("real(csqrt(-Inf + i0)) = 0", __real__ result, 0); | |
5022 | check_isinfp ("imag(csqrt(-Inf + i0)) = +Inf", __imag__ result); | |
5023 | result = FUNC(csqrt) (BUILD_COMPLEX (minus_infty, 6)); | |
5024 | check ("real(csqrt(-Inf + i6)) = 0", __real__ result, 0); | |
5025 | check_isinfp ("imag(csqrt(-Inf + i6)) = +Inf", __imag__ result); | |
5026 | result = FUNC(csqrt) (BUILD_COMPLEX (minus_infty, minus_zero)); | |
5027 | check ("real(csqrt(-Inf - i0)) = 0", __real__ result, 0); | |
5028 | check_isinfn ("imag(csqrt(-Inf - i0)) = -Inf", __imag__ result); | |
5029 | result = FUNC(csqrt) (BUILD_COMPLEX (minus_infty, -6)); | |
5030 | check ("real(csqrt(-Inf - i6)) = 0", __real__ result, 0); | |
5031 | check_isinfn ("imag(csqrt(-Inf - i6)) = -Inf", __imag__ result); | |
5032 | ||
5033 | result = FUNC(csqrt) (BUILD_COMPLEX (plus_infty, 0)); | |
5034 | check_isinfp ("real(csqrt(+Inf + i0)) = +Inf", __real__ result); | |
63551311 | 5035 | check ("imag(csqrt(+Inf + i0)) = 0", __imag__ result, 0); |
3075e0e3 UD |
5036 | result = FUNC(csqrt) (BUILD_COMPLEX (plus_infty, 6)); |
5037 | check_isinfp ("real(csqrt(+Inf + i6)) = +Inf", __real__ result); | |
63551311 | 5038 | check ("imag(csqrt(+Inf + i6)) = 0", __imag__ result, 0); |
3075e0e3 UD |
5039 | result = FUNC(csqrt) (BUILD_COMPLEX (plus_infty, minus_zero)); |
5040 | check_isinfp ("real(csqrt(+Inf - i0)) = +Inf", __real__ result); | |
63551311 | 5041 | check ("imag(csqrt(+Inf - i0)) = -0", __imag__ result, minus_zero); |
3075e0e3 UD |
5042 | result = FUNC(csqrt) (BUILD_COMPLEX (plus_infty, -6)); |
5043 | check_isinfp ("real(csqrt(+Inf - i6)) = +Inf", __real__ result); | |
63551311 | 5044 | check ("imag(csqrt(+Inf - i6)) = -0", __imag__ result, minus_zero); |
3075e0e3 UD |
5045 | |
5046 | result = FUNC(csqrt) (BUILD_COMPLEX (0, plus_infty)); | |
5047 | check_isinfp ("real(csqrt(0 + i Inf)) = +Inf", __real__ result); | |
5048 | check_isinfp ("imag(csqrt(0 + i Inf)) = +Inf", __imag__ result); | |
5049 | result = FUNC(csqrt) (BUILD_COMPLEX (4, plus_infty)); | |
5050 | check_isinfp ("real(csqrt(4 + i Inf)) = +Inf", __real__ result); | |
5051 | check_isinfp ("imag(csqrt(4 + i Inf)) = +Inf", __imag__ result); | |
5052 | result = FUNC(csqrt) (BUILD_COMPLEX (plus_infty, plus_infty)); | |
5053 | check_isinfp ("real(csqrt(+Inf + i Inf)) = +Inf", __real__ result); | |
5054 | check_isinfp ("imag(csqrt(+Inf + i Inf)) = +Inf", __imag__ result); | |
5055 | result = FUNC(csqrt) (BUILD_COMPLEX (minus_zero, plus_infty)); | |
5056 | check_isinfp ("real(csqrt(-0 + i Inf)) = +Inf", __real__ result); | |
5057 | check_isinfp ("imag(csqrt(-0 + i Inf)) = +Inf", __imag__ result); | |
5058 | result = FUNC(csqrt) (BUILD_COMPLEX (-4, plus_infty)); | |
5059 | check_isinfp ("real(csqrt(-4 + i Inf)) = +Inf", __real__ result); | |
5060 | check_isinfp ("imag(csqrt(-4 + i Inf)) = +Inf", __imag__ result); | |
5061 | result = FUNC(csqrt) (BUILD_COMPLEX (minus_infty, plus_infty)); | |
5062 | check_isinfp ("real(csqrt(-Inf + i Inf)) = +Inf", __real__ result); | |
5063 | check_isinfp ("imag(csqrt(-Inf + i Inf)) = +Inf", __imag__ result); | |
5064 | result = FUNC(csqrt) (BUILD_COMPLEX (0, minus_infty)); | |
5065 | check_isinfp ("real(csqrt(0 - i Inf)) = +Inf", __real__ result); | |
5066 | check_isinfn ("imag(csqrt(0 - i Inf)) = -Inf", __imag__ result); | |
5067 | result = FUNC(csqrt) (BUILD_COMPLEX (4, minus_infty)); | |
5068 | check_isinfp ("real(csqrt(4 - i Inf)) = +Inf", __real__ result); | |
5069 | check_isinfn ("imag(csqrt(4 - i Inf)) = -Inf", __imag__ result); | |
5070 | result = FUNC(csqrt) (BUILD_COMPLEX (plus_infty, minus_infty)); | |
5071 | check_isinfp ("real(csqrt(+Inf - i Inf)) = +Inf", __real__ result); | |
5072 | check_isinfn ("imag(csqrt(+Inf - i Inf)) = -Inf", __imag__ result); | |
5073 | result = FUNC(csqrt) (BUILD_COMPLEX (minus_zero, minus_infty)); | |
5074 | check_isinfp ("real(csqrt(-0 - i Inf)) = +Inf", __real__ result); | |
5075 | check_isinfn ("imag(csqrt(-0 - i Inf)) = -Inf", __imag__ result); | |
5076 | result = FUNC(csqrt) (BUILD_COMPLEX (-4, minus_infty)); | |
5077 | check_isinfp ("real(csqrt(-4 - i Inf)) = +Inf", __real__ result); | |
5078 | check_isinfn ("imag(csqrt(-4 - i Inf)) = -Inf", __imag__ result); | |
5079 | result = FUNC(csqrt) (BUILD_COMPLEX (minus_infty, minus_infty)); | |
5080 | check_isinfp ("real(csqrt(-Inf - i Inf)) = +Inf", __real__ result); | |
5081 | check_isinfn ("imag(csqrt(-Inf - i Inf)) = -Inf", __imag__ result); | |
5082 | ||
5083 | result = FUNC(csqrt) (BUILD_COMPLEX (minus_infty, nan_value)); | |
5084 | check_isnan ("real(csqrt(-Inf + i NaN)) = NaN", __real__ result); | |
5085 | check_isinfp ("imag(csqrt(-Inf + i NaN)) = +-Inf", | |
5086 | FUNC(fabs) (__imag__ result)); | |
5087 | ||
5088 | result = FUNC(csqrt) (BUILD_COMPLEX (plus_infty, nan_value)); | |
5089 | check_isinfp ("real(csqrt(+Inf + i NaN)) = +Inf", __real__ result); | |
5090 | check_isnan ("imag(csqrt(+Inf + i NaN)) = NaN", __imag__ result); | |
5091 | ||
5092 | result = FUNC(csqrt) (BUILD_COMPLEX (0, nan_value)); | |
779ae82e | 5093 | check_isnan_maybe_exc ("real(csqrt(0 + i NaN)) = NaN plus maybe invalid exception", |
51702635 | 5094 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
5095 | check_isnan ("imag(csqrt(0 + i NaN)) = NaN plus maybe invalid exception", |
5096 | __imag__ result); | |
3075e0e3 | 5097 | result = FUNC(csqrt) (BUILD_COMPLEX (1, nan_value)); |
779ae82e | 5098 | check_isnan_maybe_exc ("real(csqrt(1 + i NaN)) = NaN plus maybe invalid exception", |
51702635 | 5099 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
5100 | check_isnan ("imag(csqrt(1 + i NaN)) = NaN plus maybe invalid exception", |
5101 | __imag__ result); | |
3075e0e3 | 5102 | result = FUNC(csqrt) (BUILD_COMPLEX (minus_zero, nan_value)); |
779ae82e | 5103 | check_isnan_maybe_exc ("real(csqrt(-0 + i NaN)) = NaN plus maybe invalid exception", |
51702635 | 5104 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
5105 | check_isnan ("imag(csqrt(-0 + i NaN)) = NaN plus maybe invalid exception", |
5106 | __imag__ result); | |
3075e0e3 | 5107 | result = FUNC(csqrt) (BUILD_COMPLEX (-1, nan_value)); |
779ae82e | 5108 | check_isnan_maybe_exc ("real(csqrt(-1 + i NaN)) = NaN plus maybe invalid exception", |
51702635 | 5109 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
5110 | check_isnan ("imag(csqrt(-1 + i NaN)) = NaN plus maybe invalid exception", |
5111 | __imag__ result); | |
3075e0e3 UD |
5112 | |
5113 | result = FUNC(csqrt) (BUILD_COMPLEX (nan_value, 0)); | |
779ae82e | 5114 | check_isnan_maybe_exc ("real(csqrt(NaN + i0)) = NaN plus maybe invalid exception", |
51702635 | 5115 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
5116 | check_isnan ("imag(csqrt(NaN + i0)) = NaN plus maybe invalid exception", |
5117 | __imag__ result); | |
3075e0e3 | 5118 | result = FUNC(csqrt) (BUILD_COMPLEX (nan_value, 8)); |
779ae82e | 5119 | check_isnan_maybe_exc ("real(csqrt(NaN + i8)) = NaN plus maybe invalid exception", |
51702635 | 5120 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
5121 | check_isnan ("imag(csqrt(NaN + i8)) = NaN plus maybe invalid exception", |
5122 | __imag__ result); | |
3075e0e3 | 5123 | result = FUNC(csqrt) (BUILD_COMPLEX (nan_value, minus_zero)); |
779ae82e | 5124 | check_isnan_maybe_exc ("real(csqrt(NaN - i0)) = NaN plus maybe invalid exception", |
51702635 | 5125 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
5126 | check_isnan ("imag(csqrt(NaN - i0)) = NaN plus maybe invalid exception", |
5127 | __imag__ result); | |
3075e0e3 | 5128 | result = FUNC(csqrt) (BUILD_COMPLEX (nan_value, -8)); |
779ae82e | 5129 | check_isnan_maybe_exc ("real(csqrt(NaN - i8)) = NaN plus maybe invalid exception", |
51702635 | 5130 | __real__ result, INVALID_EXCEPTION); |
779ae82e UD |
5131 | check_isnan ("imag(csqrt(NaN - i8)) = NaN plus maybe invalid exception", |
5132 | __imag__ result); | |
3075e0e3 UD |
5133 | |
5134 | result = FUNC(csqrt) (BUILD_COMPLEX (nan_value, nan_value)); | |
5135 | check_isnan ("real(csqrt(NaN + i NaN)) = NaN", __real__ result); | |
5136 | check_isnan ("imag(csqrt(NaN + i NaN)) = NaN", __imag__ result); | |
04be94a8 | 5137 | |
cbdee279 UD |
5138 | result = FUNC(csqrt) (BUILD_COMPLEX (16.0, -30.0)); |
5139 | check ("real(csqrt(16 - 30i)) = 5", __real__ result, 5.0); | |
5140 | check ("imag(csqrt(16 - 30i)) = -3", __imag__ result, -3.0); | |
5141 | ||
04be94a8 UD |
5142 | result = FUNC(csqrt) (BUILD_COMPLEX (-1, 0)); |
5143 | check ("real(csqrt(1 + i0) = 0", __real__ result, 0); | |
5144 | check ("imag(csqrt(1 + i0) = 1", __imag__ result, 1); | |
cbdee279 UD |
5145 | |
5146 | result = FUNC(csqrt) (BUILD_COMPLEX (0, 2)); | |
5147 | check ("real(csqrt(0 + i 2) = 1", __real__ result, 1); | |
5148 | check ("imag(csqrt(0 + i 2) = 1", __imag__ result, 1); | |
5149 | ||
5150 | result = FUNC(csqrt) (BUILD_COMPLEX (119, 120)); | |
5151 | check ("real(csqrt(119 + i 120) = 12", __real__ result, 12); | |
5152 | check ("imag(csqrt(119 + i 120) = 5", __imag__ result, 5); | |
bd355af0 UD |
5153 | |
5154 | result = FUNC(csqrt) (BUILD_COMPLEX (0.7, 1.2)); | |
5155 | check_eps ("real(csqrt(0.7 + i 1.2)) == 1.02206...", __real__ result, | |
5156 | 1.0220676100300264507L, CHOOSE(3e-17L, 3e-16, 2e-7)); | |
5157 | check_eps ("imag(csqrt(0.7 + i 1.2)) == 0.58704...", __imag__ result, | |
adac8450 | 5158 | 0.5870453129635652115L, CHOOSE(7e-18L, 0, 6e-8)); |
bd355af0 UD |
5159 | |
5160 | result = FUNC(csqrt) (BUILD_COMPLEX (-2, -3)); | |
ec986e23 | 5161 | check_eps ("real(csqrt(-2 - i 3)) == 0.89597...", __real__ result, |
7ce241a0 | 5162 | 0.8959774761298381247L, CHOOSE(6e-16L, 4e-16, 6e-8)); |
74015205 UD |
5163 | check_eps ("imag(csqrt(-2 - i 3)) == -1.67414...", __imag__ result, |
5164 | -1.6741492280355400404L, CHOOSE(0, 5e-16, 0)); | |
ec986e23 UD |
5165 | |
5166 | result = FUNC(csqrt) (BUILD_COMPLEX (-2, 3)); | |
5167 | check_eps ("real(csqrt(-2 + i 3)) == 0.89597...", __real__ result, | |
7ce241a0 | 5168 | 0.8959774761298381247L, CHOOSE(6e-20L, 4e-16, 6e-8)); |
ec986e23 UD |
5169 | check_eps ("imag(csqrt(-2 + i 3)) == 1.67414...", __imag__ result, |
5170 | 1.6741492280355400404L, CHOOSE(0, 5e-16, 0)); | |
3075e0e3 | 5171 | } |
63551311 UD |
5172 | |
5173 | ||
5174 | static void | |
5175 | cpow_test (void) | |
5176 | { | |
5177 | __complex__ MATHTYPE result; | |
76b87c03 UD |
5178 | |
5179 | result = FUNC (cpow) (BUILD_COMPLEX (1, 0), BUILD_COMPLEX (0, 0)); | |
cbdee279 UD |
5180 | check ("real(cpow (1 + i0), (0 + i0)) == 0", __real__ result, 1); |
5181 | check ("imag(cpow (1 + i0), (0 + i0)) == 0", __imag__ result, 0); | |
76b87c03 UD |
5182 | |
5183 | result = FUNC (cpow) (BUILD_COMPLEX (2, 0), BUILD_COMPLEX (10, 0)); | |
cbdee279 | 5184 | check_eps ("real(cpow (2 + i0), (10 + i0)) == 1024", __real__ result, 1024, |
5edb9387 | 5185 | CHOOSE (6e-16L, 0, 0)); |
cbdee279 UD |
5186 | check ("imag(cpow (2 + i0), (10 + i0)) == 0", __imag__ result, 0); |
5187 | ||
0a614877 | 5188 | result = FUNC (cpow) (BUILD_COMPLEX (M_El, 0), BUILD_COMPLEX (0, 2 * M_PIl)); |
9756dfe1 UD |
5189 | check_eps ("real(cpow (e + i0), (0 + i 2*PI)) == 1", __real__ result, 1, |
5190 | CHOOSE (0, 0, 6e-8)); | |
cbdee279 | 5191 | check_eps ("imag(cpow (e + i0), (0 + i 2*PI)) == 0", __imag__ result, 0, |
9756dfe1 | 5192 | CHOOSE (3e-18L, 3e-16, 4e-7)); |
cbdee279 UD |
5193 | |
5194 | result = FUNC (cpow) (BUILD_COMPLEX (2, 3), BUILD_COMPLEX (4, 0)); | |
5195 | check_eps ("real(cpow (2 + i3), (4 + i0)) == -119", __real__ result, -119, | |
9756dfe1 | 5196 | CHOOSE (9e-16L, 2e-14, 4e-5)); |
cbdee279 | 5197 | check_eps ("imag(cpow (2 + i3), (4 + i0)) == -120", __imag__ result, -120, |
9756dfe1 | 5198 | CHOOSE (1e-15L, 0, 5e-5)); |
63551311 UD |
5199 | } |
5200 | ||
5201 | ||
04be94a8 UD |
5202 | static void |
5203 | cabs_test (void) | |
5204 | { | |
5205 | /* cabs (x + iy) is specified as hypot (x,y) */ | |
5206 | MATHTYPE a; | |
5207 | a = random_greater (0); | |
5208 | check_isinfp_ext ("cabs (+inf + i x) == +inf", | |
5209 | FUNC(cabs) (BUILD_COMPLEX (plus_infty, a)), a); | |
5210 | check_isinfp_ext ("cabs (-inf + i x) == +inf", | |
5211 | FUNC(cabs) (BUILD_COMPLEX (minus_infty, a)), a); | |
5212 | ||
5213 | check_isinfp ("cabs (+inf+ iNaN) == +inf", | |
5214 | FUNC(cabs) (BUILD_COMPLEX(minus_infty, nan_value))); | |
5215 | check_isinfp ("cabs (-inf+ iNaN) == +inf", | |
5216 | FUNC(cabs) (BUILD_COMPLEX(minus_infty, nan_value))); | |
5217 | ||
5218 | check_isnan ("cabs (NaN+ iNaN) == NaN", | |
5219 | FUNC(cabs) (BUILD_COMPLEX(nan_value, nan_value))); | |
5220 | ||
5221 | a = FUNC(cabs) (BUILD_COMPLEX (12.4L, 0.7L)); | |
5222 | check ("cabs (x,y) == cabs (y,x)", | |
5223 | FUNC(cabs) (BUILD_COMPLEX(0.7L, 12.4L)), a); | |
5224 | check ("cabs (x,y) == cabs (-x,y)", | |
5225 | FUNC(cabs) (BUILD_COMPLEX(-12.4L, 0.7L)), a); | |
5226 | check ("cabs (x,y) == cabs (-y,x)", | |
5227 | FUNC(cabs) (BUILD_COMPLEX(-0.7L, 12.4L)), a); | |
5228 | check ("cabs (x,y) == cabs (-x,-y)", | |
5229 | FUNC(cabs) (BUILD_COMPLEX(-12.4L, -0.7L)), a); | |
5230 | check ("cabs (x,y) == cabs (-y,-x)", | |
5231 | FUNC(cabs) (BUILD_COMPLEX(-0.7L, -12.4L)), a); | |
5232 | check ("cabs (x,0) == fabs (x)", FUNC(cabs) (BUILD_COMPLEX(-0.7L, 0)), 0.7L); | |
5233 | check ("cabs (x,0) == fabs (x)", FUNC(cabs) (BUILD_COMPLEX(0.7L, 0)), 0.7L); | |
5234 | check ("cabs (x,0) == fabs (x)", FUNC(cabs) (BUILD_COMPLEX(-1.0L, 0)), 1.0L); | |
5235 | check ("cabs (x,0) == fabs (x)", FUNC(cabs) (BUILD_COMPLEX(1.0L, 0)), 1.0L); | |
5236 | check ("cabs (x,0) == fabs (x)", FUNC(cabs) (BUILD_COMPLEX(-5.7e7L, 0)), | |
5237 | 5.7e7L); | |
5238 | check ("cabs (x,0) == fabs (x)", FUNC(cabs) (BUILD_COMPLEX(5.7e7L, 0)), | |
5239 | 5.7e7L); | |
5240 | ||
9756dfe1 UD |
5241 | check_eps ("cabs (0.7 + i 1.2) == 1.38924...", FUNC(cabs) (BUILD_COMPLEX(0.7, 1.2)), |
5242 | 1.3892443989449804508L, CHOOSE(7e-17L, 3e-16, 0)); | |
04be94a8 UD |
5243 | } |
5244 | ||
5245 | ||
5246 | static void | |
5247 | carg_test (void) | |
5248 | { | |
5249 | /* carg (x + iy) is specified as atan2 (y, x) */ | |
5250 | MATHTYPE x; | |
5251 | ||
5252 | x = random_greater (0); | |
5253 | check ("carg (x + i 0) == 0 for x > 0", | |
5254 | FUNC(carg) (BUILD_COMPLEX(x, 0)), 0); | |
5255 | x = random_greater (0); | |
5256 | check ("carg (x - i 0) == -0 for x > 0", | |
5257 | FUNC(carg) (BUILD_COMPLEX(x, minus_zero)), minus_zero); | |
5258 | ||
5259 | check ("carg (+0 + i 0) == +0", FUNC(carg) (BUILD_COMPLEX(0, 0)), 0); | |
5260 | check ("carg (+0 - i 0) == -0", FUNC(carg) (BUILD_COMPLEX(0, minus_zero)), | |
5261 | minus_zero); | |
5262 | ||
5263 | x = -random_greater (0); | |
5264 | check ("carg (x + i 0) == +pi for x < 0", FUNC(carg) (BUILD_COMPLEX(x, 0)), | |
0a614877 | 5265 | M_PIl); |
04be94a8 UD |
5266 | |
5267 | x = -random_greater (0); | |
5268 | check ("carg (x - i 0) == -pi for x < 0", | |
0a614877 | 5269 | FUNC(carg) (BUILD_COMPLEX(x, minus_zero)), -M_PIl); |
04be94a8 UD |
5270 | |
5271 | check ("carg (-0 + i 0) == +pi", FUNC(carg) (BUILD_COMPLEX(minus_zero, 0)), | |
0a614877 | 5272 | M_PIl); |
04be94a8 | 5273 | check ("carg (-0 - i 0) == -pi", |
0a614877 | 5274 | FUNC(carg) (BUILD_COMPLEX(minus_zero, minus_zero)), -M_PIl); |
04be94a8 UD |
5275 | |
5276 | x = random_greater (0); | |
5277 | check ("carg (+0 + i y) == pi/2 for y > 0", FUNC(carg) (BUILD_COMPLEX(0, x)), | |
0a614877 | 5278 | M_PI_2l); |
04be94a8 UD |
5279 | |
5280 | x = random_greater (0); | |
5281 | check ("carg (-0 + i y) == pi/2 for y > 0", | |
0a614877 | 5282 | FUNC(carg) (BUILD_COMPLEX(minus_zero, x)), M_PI_2l); |
04be94a8 UD |
5283 | |
5284 | x = random_less (0); | |
5285 | check ("carg (+0 + i y) == -pi/2 for y < 0", FUNC(carg) (BUILD_COMPLEX(0, x)), | |
0a614877 | 5286 | -M_PI_2l); |
04be94a8 UD |
5287 | |
5288 | x = random_less (0); | |
5289 | check ("carg (-0 + i y) == -pi/2 for y < 0", | |
0a614877 | 5290 | FUNC(carg) (BUILD_COMPLEX(minus_zero, x)), -M_PI_2l); |
04be94a8 UD |
5291 | |
5292 | x = random_greater (0); | |
5293 | check ("carg (inf + i y) == +0 for finite y > 0", | |
5294 | FUNC(carg) (BUILD_COMPLEX(plus_infty, x)), 0); | |
5295 | ||
5296 | x = -random_greater (0); | |
5297 | check ("carg (inf + i y) == -0 for finite y < 0", | |
5298 | FUNC(carg) (BUILD_COMPLEX(plus_infty, x)), minus_zero); | |
5299 | ||
5300 | x = random_value (-1e4, 1e4); | |
5301 | check ("carg(x + i inf) == pi/2 for finite x", | |
0a614877 | 5302 | FUNC(carg) (BUILD_COMPLEX(x, plus_infty)), M_PI_2l); |
04be94a8 UD |
5303 | |
5304 | x = random_value (-1e4, 1e4); | |
5305 | check ("carg(x - i inf) == -pi/2 for finite x", | |
0a614877 | 5306 | FUNC(carg) (BUILD_COMPLEX(x, minus_infty)), -M_PI_2l); |
04be94a8 UD |
5307 | |
5308 | x = random_greater (0); | |
5309 | check ("carg (-inf + i y) == +pi for finite y > 0", | |
0a614877 | 5310 | FUNC(carg) (BUILD_COMPLEX(minus_infty, x)), M_PIl); |
04be94a8 UD |
5311 | |
5312 | x = -random_greater (0); | |
5313 | check ("carg (-inf + i y) == -pi for finite y < 0", | |
0a614877 | 5314 | FUNC(carg) (BUILD_COMPLEX(minus_infty, x)), -M_PIl); |
04be94a8 UD |
5315 | |
5316 | check ("carg (+inf + i inf) == +pi/4", | |
0a614877 | 5317 | FUNC(carg) (BUILD_COMPLEX(plus_infty, plus_infty)), M_PI_4l); |
04be94a8 UD |
5318 | |
5319 | check ("carg (+inf -i inf) == -pi/4", | |
0a614877 | 5320 | FUNC(carg) (BUILD_COMPLEX(plus_infty, minus_infty)), -M_PI_4l); |
04be94a8 UD |
5321 | |
5322 | check ("carg (-inf +i inf) == +3*pi/4", | |
0a614877 | 5323 | FUNC(carg) (BUILD_COMPLEX(minus_infty, plus_infty)), 3 * M_PI_4l); |
04be94a8 UD |
5324 | |
5325 | check ("carg (-inf -i inf) == -3*pi/4", | |
0a614877 | 5326 | FUNC(carg) (BUILD_COMPLEX(minus_infty, minus_infty)), -3 * M_PI_4l); |
04be94a8 UD |
5327 | |
5328 | } | |
5329 | ||
5330 | ||
900bec85 UD |
5331 | static void |
5332 | nearbyint_test (void) | |
5333 | { | |
5334 | check ("nearbyint(+0) = 0", FUNC(nearbyint) (0.0), 0.0); | |
5335 | check ("nearbyint(-0) = -0", FUNC(nearbyint) (minus_zero), minus_zero); | |
5336 | check_isinfp ("nearbyint(+Inf) = +Inf", FUNC(nearbyint) (plus_infty)); | |
5337 | check_isinfn ("nearbyint(-Inf) = -Inf", FUNC(nearbyint) (minus_infty)); | |
5338 | } | |
5339 | ||
5340 | ||
63551311 UD |
5341 | static void |
5342 | rint_test (void) | |
5343 | { | |
5344 | check ("rint(0) = 0", FUNC(rint) (0.0), 0.0); | |
5345 | check ("rint(-0) = -0", FUNC(rint) (minus_zero), minus_zero); | |
5346 | check_isinfp ("rint(+Inf) = +Inf", FUNC(rint) (plus_infty)); | |
5347 | check_isinfn ("rint(-Inf) = -Inf", FUNC(rint) (minus_infty)); | |
5348 | } | |
993b3242 UD |
5349 | |
5350 | ||
c131718c | 5351 | static void |
d705269e | 5352 | lrint_test (void) |
c131718c UD |
5353 | { |
5354 | /* XXX this test is incomplete. We need to have a way to specifiy | |
5355 | the rounding method and test the critical cases. So far, only | |
5356 | unproblematic numbers are tested. */ | |
5357 | ||
cc3fa755 UD |
5358 | check_long ("lrint(0) = 0", FUNC(lrint) (0.0), 0); |
5359 | check_long ("lrint(-0) = 0", FUNC(lrint) (minus_zero), 0); | |
5360 | check_long ("lrint(0.2) = 0", FUNC(lrint) (0.2), 0); | |
5361 | check_long ("lrint(-0.2) = 0", FUNC(lrint) (-0.2), 0); | |
c131718c | 5362 | |
cc3fa755 UD |
5363 | check_long ("lrint(1.4) = 1", FUNC(lrint) (1.4), 1); |
5364 | check_long ("lrint(-1.4) = -1", FUNC(lrint) (-1.4), -1); | |
c131718c | 5365 | |
cc3fa755 UD |
5366 | check_long ("lrint(8388600.3) = 8388600", FUNC(lrint) (8388600.3), 8388600); |
5367 | check_long ("lrint(-8388600.3) = -8388600", FUNC(lrint) (-8388600.3), | |
63551311 | 5368 | -8388600); |
c131718c UD |
5369 | } |
5370 | ||
5371 | ||
5372 | static void | |
d705269e | 5373 | llrint_test (void) |
c131718c UD |
5374 | { |
5375 | /* XXX this test is incomplete. We need to have a way to specifiy | |
5376 | the rounding method and test the critical cases. So far, only | |
5377 | unproblematic numbers are tested. */ | |
5378 | ||
cc3fa755 UD |
5379 | check_longlong ("llrint(0) = 0", FUNC(llrint) (0.0), 0); |
5380 | check_longlong ("llrint(-0) = 0", FUNC(llrint) (minus_zero), 0); | |
5381 | check_longlong ("llrint(0.2) = 0", FUNC(llrint) (0.2), 0); | |
5382 | check_longlong ("llrint(-0.2) = 0", FUNC(llrint) (-0.2), 0); | |
c131718c | 5383 | |
cc3fa755 UD |
5384 | check_longlong ("llrint(1.4) = 1", FUNC(llrint) (1.4), 1); |
5385 | check_longlong ("llrint(-1.4) = -1", FUNC(llrint) (-1.4), -1); | |
c131718c | 5386 | |
cc3fa755 | 5387 | check_longlong ("llrint(8388600.3) = 8388600", FUNC(llrint) (8388600.3), |
63551311 | 5388 | 8388600); |
cc3fa755 | 5389 | check_longlong ("llrint(-8388600.3) = -8388600", FUNC(llrint) (-8388600.3), |
63551311 | 5390 | -8388600); |
cc3fa755 UD |
5391 | |
5392 | /* Test boundary conditions. */ | |
5393 | /* 0x1FFFFF */ | |
5394 | check_longlong ("llrint(2097151.0) = 2097151", FUNC(llrint) (2097151.0), | |
5395 | 2097151LL); | |
5396 | /* 0x800000 */ | |
5397 | check_longlong ("llrint(8388608.0) = 8388608", FUNC(llrint) (8388608.0), | |
5398 | 8388608LL); | |
5399 | /* 0x1000000 */ | |
5400 | check_longlong ("llrint(16777216.0) = 16777216", | |
5401 | FUNC(llrint) (16777216.0), 16777216LL); | |
5402 | /* 0x20000000000 */ | |
5403 | check_longlong ("llrint(2199023255552.0) = 2199023255552", | |
5404 | FUNC(llrint) (2199023255552.0), 2199023255552LL); | |
5405 | /* 0x40000000000 */ | |
5406 | check_longlong ("llrint(4398046511104.0) = 4398046511104", | |
5407 | FUNC(llrint) (4398046511104.0), 4398046511104LL); | |
5408 | /* 0x10000000000000 */ | |
5409 | check_longlong ("llrint(4503599627370496.0) = 4503599627370496", | |
5410 | FUNC(llrint) (4503599627370496.0), 4503599627370496LL); | |
5411 | /* 0x10000080000000 */ | |
5412 | check_longlong ("llrint(4503601774854144.0) = 4503601774854144", | |
5413 | FUNC(llrint) (4503601774854144.0), 4503601774854144LL); | |
5414 | /* 0x20000000000000 */ | |
5415 | check_longlong ("llrint(9007199254740992.0) = 9007199254740992", | |
5416 | FUNC(llrint) (9007199254740992.0), 9007199254740992LL); | |
5417 | /* 0x80000000000000 */ | |
5418 | check_longlong ("llrint(36028797018963968.0) = 36028797018963968", | |
5419 | FUNC(llrint) (36028797018963968.0), 36028797018963968LL); | |
5420 | /* 0x100000000000000 */ | |
5421 | check_longlong ("llrint(72057594037927936.0) = 72057594037927936", | |
5422 | FUNC(llrint) (72057594037927936.0), 72057594037927936LL); | |
63551311 UD |
5423 | } |
5424 | ||
5425 | ||
5426 | static void | |
5427 | round_test (void) | |
5428 | { | |
5429 | check ("round(0) = 0", FUNC(round) (0), 0); | |
5430 | check ("round(-0) = -0", FUNC(round) (minus_zero), minus_zero); | |
5431 | check ("round(0.2) = 0", FUNC(round) (0.2), 0.0); | |
5432 | check ("round(-0.2) = -0", FUNC(round) (-0.2), minus_zero); | |
5433 | check ("round(0.5) = 1", FUNC(round) (0.5), 1.0); | |
5434 | check ("round(-0.5) = -1", FUNC(round) (-0.5), -1.0); | |
5435 | check ("round(0.8) = 1", FUNC(round) (0.8), 1.0); | |
5436 | check ("round(-0.8) = -1", FUNC(round) (-0.8), -1.0); | |
5437 | check ("round(1.5) = 2", FUNC(round) (1.5), 2.0); | |
5438 | check ("round(-1.5) = -2", FUNC(round) (-1.5), -2.0); | |
5439 | check ("round(2097152.5) = 2097153", FUNC(round) (2097152.5), 2097153); | |
5440 | check ("round(-2097152.5) = -2097153", FUNC(round) (-2097152.5), -2097153); | |
5441 | } | |
5442 | ||
5443 | ||
5444 | static void | |
d705269e | 5445 | lround_test (void) |
63551311 | 5446 | { |
dfd2257a UD |
5447 | check_long ("lround(0) = 0", FUNC(lround) (0), 0); |
5448 | check_long ("lround(-0) = 0", FUNC(lround) (minus_zero), 0); | |
5449 | check_long ("lround(0.2) = 0", FUNC(lround) (0.2), 0.0); | |
5450 | check_long ("lround(-0.2) = 0", FUNC(lround) (-0.2), 0); | |
5451 | check_long ("lround(0.5) = 1", FUNC(lround) (0.5), 1); | |
5452 | check_long ("lround(-0.5) = -1", FUNC(lround) (-0.5), -1); | |
5453 | check_long ("lround(0.8) = 1", FUNC(lround) (0.8), 1); | |
5454 | check_long ("lround(-0.8) = -1", FUNC(lround) (-0.8), -1); | |
5455 | check_long ("lround(1.5) = 2", FUNC(lround) (1.5), 2); | |
5456 | check_long ("lround(-1.5) = -2", FUNC(lround) (-1.5), -2); | |
cc3fa755 UD |
5457 | check_long ("lround(22514.5) = 22515", FUNC(lround) (22514.5), 22515); |
5458 | check_long ("lround(-22514.5) = -22515", FUNC(lround) (-22514.5), -22515); | |
dfd2257a UD |
5459 | #ifndef TEST_FLOAT |
5460 | check_long ("lround(2097152.5) = 2097153", FUNC(lround) (2097152.5), | |
5461 | 2097153); | |
5462 | check_long ("lround(-2097152.5) = -2097153", FUNC(lround) (-2097152.5), | |
63551311 | 5463 | -2097153); |
dfd2257a | 5464 | #endif |
63551311 UD |
5465 | } |
5466 | ||
5467 | ||
5468 | static void | |
d705269e | 5469 | llround_test (void) |
63551311 | 5470 | { |
dfd2257a UD |
5471 | check_longlong ("llround(0) = 0", FUNC(llround) (0), 0); |
5472 | check_longlong ("llround(-0) = 0", FUNC(llround) (minus_zero), 0); | |
5473 | check_longlong ("llround(0.2) = 0", FUNC(llround) (0.2), 0.0); | |
5474 | check_longlong ("llround(-0.2) = 0", FUNC(llround) (-0.2), 0); | |
5475 | check_longlong ("llround(0.5) = 1", FUNC(llround) (0.5), 1); | |
5476 | check_longlong ("llround(-0.5) = -1", FUNC(llround) (-0.5), -1); | |
5477 | check_longlong ("llround(0.8) = 1", FUNC(llround) (0.8), 1); | |
5478 | check_longlong ("llround(-0.8) = -1", FUNC(llround) (-0.8), -1); | |
5479 | check_longlong ("llround(1.5) = 2", FUNC(llround) (1.5), 2); | |
5480 | check_longlong ("llround(-1.5) = -2", FUNC(llround) (-1.5), -2); | |
cc3fa755 UD |
5481 | check_longlong ("llround(22514.5) = 22515", FUNC(llround) (22514.5), 22515); |
5482 | check_longlong ("llround(-22514.5) = -22515", FUNC(llround) (-22514.5), | |
5483 | -22515); | |
dfd2257a | 5484 | #ifndef TEST_FLOAT |
d705269e | 5485 | check_longlong ("llround(2097152.5) = 2097153", |
dfd2257a | 5486 | FUNC(llround) (2097152.5), 2097153); |
d705269e | 5487 | check_longlong ("llround(-2097152.5) = -2097153", |
dfd2257a | 5488 | FUNC(llround) (-2097152.5), -2097153); |
d705269e | 5489 | check_longlong ("llround(34359738368.5) = 34359738369", |
dfd2257a | 5490 | FUNC(llround) (34359738368.5), 34359738369ll); |
d705269e | 5491 | check_longlong ("llround(-34359738368.5) = -34359738369", |
dfd2257a UD |
5492 | FUNC(llround) (-34359738368.5), -34359738369ll); |
5493 | #endif | |
cc3fa755 UD |
5494 | |
5495 | /* Test boundary conditions. */ | |
5496 | /* 0x1FFFFF */ | |
5497 | check_longlong ("llround(2097151.0) = 2097151", FUNC(llround) (2097151.0), | |
5498 | 2097151LL); | |
5499 | /* 0x800000 */ | |
5500 | check_longlong ("llround(8388608.0) = 8388608", FUNC(llround) (8388608.0), | |
5501 | 8388608LL); | |
5502 | /* 0x1000000 */ | |
5503 | check_longlong ("llround(16777216.0) = 16777216", | |
5504 | FUNC(llround) (16777216.0), 16777216LL); | |
5505 | /* 0x20000000000 */ | |
5506 | check_longlong ("llround(2199023255552.0) = 2199023255552", | |
5507 | FUNC(llround) (2199023255552.0), 2199023255552LL); | |
5508 | /* 0x40000000000 */ | |
5509 | check_longlong ("llround(4398046511104.0) = 4398046511104", | |
5510 | FUNC(llround) (4398046511104.0), 4398046511104LL); | |
5511 | /* 0x10000000000000 */ | |
5512 | check_longlong ("llround(4503599627370496.0) = 4503599627370496", | |
5513 | FUNC(llround) (4503599627370496.0), 4503599627370496LL); | |
5514 | /* 0x10000080000000 */ | |
5515 | check_longlong ("llrint(4503601774854144.0) = 4503601774854144", | |
5516 | FUNC(llrint) (4503601774854144.0), 4503601774854144LL); | |
5517 | /* 0x20000000000000 */ | |
5518 | check_longlong ("llround(9007199254740992.0) = 9007199254740992", | |
5519 | FUNC(llround) (9007199254740992.0), 9007199254740992LL); | |
5520 | /* 0x80000000000000 */ | |
5521 | check_longlong ("llround(36028797018963968.0) = 36028797018963968", | |
5522 | FUNC(llround) (36028797018963968.0), 36028797018963968LL); | |
5523 | /* 0x100000000000000 */ | |
5524 | check_longlong ("llround(72057594037927936.0) = 72057594037927936", | |
5525 | FUNC(llround) (72057594037927936.0), 72057594037927936LL); | |
c131718c UD |
5526 | } |
5527 | ||
5528 | ||
fe0ec73e UD |
5529 | static void |
5530 | fma_test (void) | |
5531 | { | |
5532 | check ("fma(1.0, 2.0, 3.0) = 5.0", FUNC(fma) (1.0, 2.0, 3.0), 5.0); | |
5533 | check_isnan ("fma(NaN, 2.0, 3.0) = NaN", FUNC(fma) (nan_value, 2.0, 3.0)); | |
5534 | check_isnan ("fma(1.0, NaN, 3.0) = NaN", FUNC(fma) (1.0, nan_value, 3.0)); | |
5535 | check_isnan_maybe_exc ("fma(1.0, 2.0, NaN) = NaN", | |
5536 | FUNC(fma) (1.0, 2.0, nan_value), INVALID_EXCEPTION); | |
5537 | check_isnan_maybe_exc ("fma(+Inf, 0.0, NaN) = NaN", | |
5538 | FUNC(fma) (plus_infty, 0.0, nan_value), | |
5539 | INVALID_EXCEPTION); | |
5540 | check_isnan_maybe_exc ("fma(-Inf, 0.0, NaN) = NaN", | |
5541 | FUNC(fma) (minus_infty, 0.0, nan_value), | |
5542 | INVALID_EXCEPTION); | |
5543 | check_isnan_maybe_exc ("fma(0.0, +Inf, NaN) = NaN", | |
5544 | FUNC(fma) (0.0, plus_infty, nan_value), | |
5545 | INVALID_EXCEPTION); | |
5546 | check_isnan_maybe_exc ("fma(0.0, -Inf, NaN) = NaN", | |
5547 | FUNC(fma) (0.0, minus_infty, nan_value), | |
5548 | INVALID_EXCEPTION); | |
5549 | check_isnan_exc ("fma(+Inf, 0.0, 1.0) = NaN", | |
5550 | FUNC(fma) (plus_infty, 0.0, 1.0), INVALID_EXCEPTION); | |
5551 | check_isnan_exc ("fma(-Inf, 0.0, 1.0) = NaN", | |
5552 | FUNC(fma) (minus_infty, 0.0, 1.0), INVALID_EXCEPTION); | |
5553 | check_isnan_exc ("fma(0.0, +Inf, 1.0) = NaN", | |
5554 | FUNC(fma) (0.0, plus_infty, 1.0), INVALID_EXCEPTION); | |
5555 | check_isnan_exc ("fma(0.0, -Inf, 1.0) = NaN", | |
5556 | FUNC(fma) (0.0, minus_infty, 1.0), INVALID_EXCEPTION); | |
5557 | ||
5558 | check_isnan_exc ("fma(+Inf, +Inf, -Inf) = NaN", | |
5559 | FUNC(fma) (plus_infty, plus_infty, minus_infty), | |
5560 | INVALID_EXCEPTION); | |
5561 | check_isnan_exc ("fma(-Inf, +Inf, +Inf) = NaN", | |
5562 | FUNC(fma) (minus_infty, plus_infty, plus_infty), | |
5563 | INVALID_EXCEPTION); | |
5564 | check_isnan_exc ("fma(+Inf, -Inf, +Inf) = NaN", | |
5565 | FUNC(fma) (plus_infty, minus_infty, plus_infty), | |
5566 | INVALID_EXCEPTION); | |
5567 | check_isnan_exc ("fma(-Inf, -Inf, -Inf) = NaN", | |
5568 | FUNC(fma) (minus_infty, minus_infty, minus_infty), | |
5569 | INVALID_EXCEPTION); | |
5570 | } | |
5571 | ||
5572 | ||
d111572f UD |
5573 | /* |
5574 | Tests for the comparison macros | |
5575 | */ | |
5576 | typedef enum {is_less, is_equal, is_greater, is_unordered} comp_result; | |
5577 | ||
5578 | ||
5579 | static void | |
5580 | comparison2_test (MATHTYPE x, MATHTYPE y, comp_result comp) | |
5581 | { | |
5582 | char buf[255]; | |
5583 | int result; | |
5584 | int expected; | |
5585 | ||
5586 | expected = (comp == is_greater); | |
5587 | sprintf (buf, "isgreater (%" PRINTF_EXPR ", %" PRINTF_EXPR ") == %d", x, y, | |
5588 | expected); | |
5589 | result = (isgreater (x, y) == expected); | |
5590 | check_bool (buf, result); | |
5591 | ||
5592 | expected = (comp == is_greater || comp == is_equal); | |
5593 | sprintf (buf, "isgreaterequal (%" PRINTF_EXPR ", %" PRINTF_EXPR ") == %d", x, y, | |
5594 | expected); | |
5595 | result = (isgreaterequal (x, y) == expected); | |
5596 | check_bool (buf, result); | |
5597 | ||
5598 | expected = (comp == is_less); | |
5599 | sprintf (buf, "isless (%" PRINTF_EXPR ", %" PRINTF_EXPR ") == %d", x, y, | |
5600 | expected); | |
5601 | result = (isless (x, y) == expected); | |
5602 | check_bool (buf, result); | |
5603 | ||
5604 | expected = (comp == is_less || comp == is_equal); | |
5605 | sprintf (buf, "islessequal (%" PRINTF_EXPR ", %" PRINTF_EXPR ") == %d", x, y, | |
5606 | expected); | |
5607 | result = (islessequal (x, y) == expected); | |
5608 | check_bool (buf, result); | |
5609 | ||
5610 | expected = (comp == is_greater || comp == is_less); | |
5611 | sprintf (buf, "islessgreater (%" PRINTF_EXPR ", %" PRINTF_EXPR ") == %d", x, y, | |
5612 | expected); | |
5613 | result = (islessgreater (x, y) == expected); | |
5614 | check_bool (buf, result); | |
5615 | ||
5616 | expected = (comp == is_unordered); | |
5617 | sprintf (buf, "isunordered (%" PRINTF_EXPR ", %" PRINTF_EXPR ") == %d", x, y, | |
5618 | expected); | |
5619 | result = (isunordered (x, y) == expected); | |
5620 | check_bool (buf, result); | |
5621 | ||
5622 | } | |
5623 | ||
5624 | ||
5625 | static void | |
5626 | comparison1_test (MATHTYPE x, MATHTYPE y, comp_result comp) | |
5627 | { | |
5628 | comp_result comp_swap; | |
5629 | switch (comp) | |
5630 | { | |
5631 | case is_less: | |
5632 | comp_swap = is_greater; | |
5633 | break; | |
5634 | case is_greater: | |
5635 | comp_swap = is_less; | |
5636 | break; | |
5637 | default: | |
5638 | comp_swap = comp; | |
5639 | break; | |
5640 | } | |
5641 | comparison2_test (x, y, comp); | |
5642 | comparison2_test (y, x, comp_swap); | |
5643 | } | |
5644 | ||
5645 | ||
5646 | static void | |
5647 | comparisons_test (void) | |
5648 | { | |
5649 | comparison1_test (1, 2, is_less); | |
5650 | comparison1_test (-30, 30, is_less); | |
5651 | comparison1_test (42, 42, is_equal); | |
5652 | comparison1_test (1, plus_infty, is_less); | |
5653 | comparison1_test (35, minus_infty, is_greater); | |
5654 | comparison1_test (1, nan_value, is_unordered); | |
5655 | comparison1_test (nan_value, nan_value, is_unordered); | |
5656 | comparison1_test (plus_infty, nan_value, is_unordered); | |
5657 | comparison1_test (minus_infty, nan_value, is_unordered); | |
5658 | comparison1_test (plus_infty, minus_infty, is_greater); | |
5659 | } | |
5660 | ||
5661 | ||
0d8733c4 UD |
5662 | static void |
5663 | inverse_func_pair_test (const char *test_name, | |
5664 | mathfunc f1, mathfunc inverse, | |
5665 | MATHTYPE x, MATHTYPE epsilon) | |
5666 | { | |
5667 | MATHTYPE a, b, difference; | |
5668 | int result; | |
5669 | ||
5670 | a = f1 (x); | |
e7fd8a39 | 5671 | (void) &a; |
0d8733c4 | 5672 | b = inverse (a); |
e7fd8a39 | 5673 | (void) &b; |
0d8733c4 | 5674 | |
76b87c03 | 5675 | output_new_test (test_name); |
0d8733c4 UD |
5676 | result = check_equal (b, x, epsilon, &difference); |
5677 | output_result (test_name, result, | |
5678 | b, x, difference, PRINT, PRINT); | |
5679 | } | |
5680 | ||
5681 | ||
5682 | static void | |
5683 | inverse_functions (void) | |
5684 | { | |
bc9f6000 | 5685 | inverse_func_pair_test ("asin(sin(x)) == x", |
6973fc01 UD |
5686 | FUNC(sin), FUNC(asin), 1.0, |
5687 | CHOOSE (2e-18L, 0, 3e-7L)); | |
bc9f6000 | 5688 | inverse_func_pair_test ("sin(asin(x)) == x", |
0d8733c4 UD |
5689 | FUNC(asin), FUNC(sin), 1.0, 0.0); |
5690 | ||
bc9f6000 | 5691 | inverse_func_pair_test ("acos(cos(x)) == x", |
6973fc01 UD |
5692 | FUNC(cos), FUNC(acos), 1.0, |
5693 | CHOOSE (4e-18L, 1e-15L, 0)); | |
bc9f6000 | 5694 | inverse_func_pair_test ("cos(acos(x)) == x", |
0d8733c4 | 5695 | FUNC(acos), FUNC(cos), 1.0, 0.0); |
bc9f6000 | 5696 | inverse_func_pair_test ("atan(tan(x)) == x", |
3e5f5557 | 5697 | FUNC(tan), FUNC(atan), 1.0, CHOOSE (2e-18L, 0, 0)); |
bc9f6000 | 5698 | inverse_func_pair_test ("tan(atan(x)) == x", |
6973fc01 UD |
5699 | FUNC(atan), FUNC(tan), 1.0, |
5700 | CHOOSE (2e-18L, 1e-15L, 2e-7)); | |
0d8733c4 | 5701 | |
bc9f6000 | 5702 | inverse_func_pair_test ("asinh(sinh(x)) == x", |
3e5f5557 | 5703 | FUNC(sinh), FUNC(asinh), 1.0, CHOOSE (1e-18L, 0, 1e-7)); |
bc9f6000 | 5704 | inverse_func_pair_test ("sinh(asinh(x)) == x", |
6973fc01 UD |
5705 | FUNC(asinh), FUNC(sinh), 1.0, |
5706 | CHOOSE (2e-18L, 2e-16L, 2e-7)); | |
0d8733c4 | 5707 | |
bc9f6000 | 5708 | inverse_func_pair_test ("acosh(cosh(x)) == x", |
6973fc01 UD |
5709 | FUNC(cosh), FUNC(acosh), 1.0, |
5710 | CHOOSE (1e-18L, 1e-15L, 6e-8)); | |
bc9f6000 | 5711 | inverse_func_pair_test ("cosh(acosh(x)) == x", |
0d8733c4 UD |
5712 | FUNC(acosh), FUNC(cosh), 1.0, 0.0); |
5713 | ||
bc9f6000 | 5714 | inverse_func_pair_test ("atanh(tanh(x)) == x", |
3e5f5557 | 5715 | FUNC(tanh), FUNC(atanh), 1.0, CHOOSE (1e-18L, 1e-15L, 0)); |
bc9f6000 | 5716 | inverse_func_pair_test ("tanh(atanh(x)) == x", |
0d8733c4 UD |
5717 | FUNC(atanh), FUNC(tanh), 1.0, 0.0); |
5718 | ||
5719 | } | |
5720 | ||
5721 | /* Test sin and cos with the identity: sin(x)^2 + cos(x)^2 = 1. */ | |
5722 | static void | |
5723 | identities1_test (MATHTYPE x, MATHTYPE epsilon) | |
5724 | { | |
5725 | MATHTYPE res1, res2, res3, diff; | |
5726 | int result; | |
5727 | ||
5728 | res1 = FUNC(sin) (x); | |
e7fd8a39 | 5729 | (void) &res1; |
0d8733c4 | 5730 | res2 = FUNC(cos) (x); |
e7fd8a39 | 5731 | (void) &res2; |
0d8733c4 | 5732 | res3 = res1 * res1 + res2 * res2; |
e7fd8a39 | 5733 | (void) &res3; |
0d8733c4 | 5734 | |
76b87c03 | 5735 | output_new_test ("sin^2 + cos^2 == 1"); |
0d8733c4 UD |
5736 | result = check_equal (res3, 1.0, epsilon, &diff); |
5737 | output_result_ext ("sin^2 + cos^2 == 1", result, | |
5738 | res3, 1.0, diff, x, PRINT, PRINT); | |
5739 | } | |
5740 | ||
5741 | ||
5742 | /* Test sin, cos, tan with the following relation: tan = sin/cos. */ | |
5743 | static void | |
5744 | identities2_test (MATHTYPE x, MATHTYPE epsilon) | |
5745 | { | |
ca34d7a7 | 5746 | #ifndef TEST_INLINE |
0d8733c4 UD |
5747 | MATHTYPE res1, res2, res3, res4, diff; |
5748 | int result; | |
5749 | ||
5750 | res1 = FUNC(sin) (x); | |
e7fd8a39 | 5751 | (void) &res1; |
0d8733c4 | 5752 | res2 = FUNC(cos) (x); |
e7fd8a39 | 5753 | (void) &res2; |
0d8733c4 | 5754 | res3 = FUNC(tan) (x); |
e7fd8a39 | 5755 | (void) &res3; |
0d8733c4 | 5756 | res4 = res1 / res2; |
e7fd8a39 | 5757 | (void) &res4; |
0d8733c4 | 5758 | |
76b87c03 | 5759 | output_new_test ("sin/cos == tan"); |
0d8733c4 UD |
5760 | result = check_equal (res4, res3, epsilon, &diff); |
5761 | output_result_ext ("sin/cos == tan", result, | |
5762 | res4, res3, diff, x, PRINT, PRINT); | |
ca34d7a7 | 5763 | #endif |
0d8733c4 UD |
5764 | } |
5765 | ||
5766 | ||
5767 | /* Test cosh and sinh with the identity cosh^2 - sinh^2 = 1. */ | |
5768 | static void | |
5769 | identities3_test (MATHTYPE x, MATHTYPE epsilon) | |
5770 | { | |
5771 | MATHTYPE res1, res2, res3, diff; | |
5772 | int result; | |
5773 | ||
5774 | res1 = FUNC(sinh) (x); | |
e7fd8a39 | 5775 | (void) &res1; |
0d8733c4 | 5776 | res2 = FUNC(cosh) (x); |
e7fd8a39 | 5777 | (void) &res2; |
0d8733c4 | 5778 | res3 = res2 * res2 - res1 * res1; |
e7fd8a39 | 5779 | (void) &res3; |
0d8733c4 | 5780 | |
76b87c03 | 5781 | output_new_test ("cosh^2 - sinh^2 == 1"); |
0d8733c4 UD |
5782 | result = check_equal (res3, 1.0, epsilon, &diff); |
5783 | output_result_ext ("cosh^2 - sinh^2 == 1", result, | |
5784 | res3, 1.0, diff, x, PRINT, PRINT); | |
5785 | } | |
5786 | ||
5787 | ||
5788 | static void | |
5789 | identities (void) | |
5790 | { | |
3e5f5557 | 5791 | identities1_test (0.2L, CHOOSE (1e-18L, 0, 2e-7)); |
d4f4d1ca | 5792 | identities1_test (0.9L, CHOOSE (1e-18L, 2e-16, 2e-7)); |
0d8733c4 | 5793 | identities1_test (0, 0); |
3e5f5557 | 5794 | identities1_test (-1, CHOOSE (1e-18L, 0, 1e-7)); |
0d8733c4 | 5795 | |
f41c8091 | 5796 | identities2_test (0.2L, CHOOSE (1e-19L, 1e-16, 0)); |
74015205 | 5797 | identities2_test (0.9L, CHOOSE (3e-19L, 1e-15, 2e-7)); |
0d8733c4 | 5798 | identities2_test (0, 0); |
9a0a462c | 5799 | identities2_test (-1, CHOOSE (1e-18L, 1e-15, 2e-7)); |
0d8733c4 | 5800 | |
3e5f5557 | 5801 | identities3_test (0.2L, CHOOSE (1e-18L, 0, 1e-7)); |
0d8733c4 UD |
5802 | identities3_test (0.9L, CHOOSE (1e-18L, 1e-15, 1e-6)); |
5803 | identities3_test (0, CHOOSE (0, 0, 1e-6)); | |
9a0a462c | 5804 | identities3_test (-1, CHOOSE (1e-18L, 7e-16, 1e-6)); |
0d8733c4 UD |
5805 | } |
5806 | ||
5807 | ||
5808 | /* | |
5809 | Let's test that basic arithmetic is working | |
5810 | tests: Infinity and NaN | |
5811 | */ | |
5812 | static void | |
5813 | basic_tests (void) | |
5814 | { | |
5815 | /* variables are declared volatile to forbid some compiler | |
5816 | optimizations */ | |
5817 | volatile MATHTYPE Inf_var, NaN_var, zero_var, one_var; | |
5818 | MATHTYPE x1, x2; | |
5819 | ||
5820 | zero_var = 0.0; | |
5821 | one_var = 1.0; | |
5822 | NaN_var = nan_value; | |
5823 | Inf_var = one_var / zero_var; | |
5824 | ||
e7fd8a39 UD |
5825 | (void) &zero_var; |
5826 | (void) &one_var; | |
5827 | (void) &NaN_var; | |
5828 | (void) &Inf_var; | |
0d8733c4 | 5829 | |
779ae82e UD |
5830 | /* Clear all exceptions. The previous computations raised exceptions. */ |
5831 | feclearexcept (FE_ALL_EXCEPT); | |
5832 | ||
3e5f5557 UD |
5833 | check_isinfp ("isinf (inf) == +1", Inf_var); |
5834 | check_isinfn ("isinf (-inf) == -1", -Inf_var); | |
0d8733c4 | 5835 | check_bool ("!isinf (1)", !(FUNC(isinf) (one_var))); |
3e5f5557 | 5836 | check_bool ("!isinf (NaN)", !(FUNC(isinf) (NaN_var))); |
0d8733c4 | 5837 | |
3e5f5557 UD |
5838 | check_isnan ("isnan (NaN)", NaN_var); |
5839 | check_isnan ("isnan (-NaN)", -NaN_var); | |
0d8733c4 | 5840 | check_bool ("!isnan (1)", !(FUNC(isnan) (one_var))); |
3e5f5557 | 5841 | check_bool ("!isnan (inf)", !(FUNC(isnan) (Inf_var))); |
0d8733c4 UD |
5842 | |
5843 | check_bool ("inf == inf", Inf_var == Inf_var); | |
5844 | check_bool ("-inf == -inf", -Inf_var == -Inf_var); | |
5845 | check_bool ("inf != -inf", Inf_var != -Inf_var); | |
5846 | check_bool ("NaN != NaN", NaN_var != NaN_var); | |
5847 | ||
5848 | /* | |
5107cf1d | 5849 | the same tests but this time with NAN from <bits/nan.h> |
0d8733c4 UD |
5850 | NAN is a double const |
5851 | */ | |
5852 | check_bool ("isnan (NAN)", isnan (NAN)); | |
5853 | check_bool ("isnan (-NAN)", isnan (-NAN)); | |
5854 | check_bool ("!isinf (NAN)", !(isinf (NAN))); | |
5855 | check_bool ("!isinf (-NAN)", !(isinf (-NAN))); | |
5856 | check_bool ("NAN != NAN", NAN != NAN); | |
5857 | ||
bc9f6000 UD |
5858 | /* |
5859 | And again with the value returned by the `nan' function. | |
5860 | */ | |
dd33e89f UD |
5861 | check_bool ("isnan (NAN)", FUNC(isnan) (FUNC(nan) (""))); |
5862 | check_bool ("isnan (-NAN)", FUNC(isnan) (-FUNC(nan) (""))); | |
5863 | check_bool ("!isinf (NAN)", !(FUNC(isinf) (FUNC(nan) ("")))); | |
5864 | check_bool ("!isinf (-NAN)", !(FUNC(isinf) (-FUNC(nan) ("")))); | |
bc9f6000 UD |
5865 | check_bool ("NAN != NAN", FUNC(nan) ("") != FUNC(nan) ("")); |
5866 | ||
0d8733c4 UD |
5867 | /* test if EPSILON is ok */ |
5868 | x1 = MATHCONST (1.0); | |
5869 | x2 = x1 + CHOOSE (LDBL_EPSILON, DBL_EPSILON, FLT_EPSILON); | |
5870 | check_bool ("1 != 1+EPSILON", x1 != x2); | |
5871 | ||
5872 | x1 = MATHCONST (1.0); | |
5873 | x2 = x1 - CHOOSE (LDBL_EPSILON, DBL_EPSILON, FLT_EPSILON); | |
5874 | check_bool ("1 != 1-EPSILON", x1 != x2); | |
5875 | ||
5876 | /* test if HUGE_VALx is ok */ | |
5877 | x1 = CHOOSE (HUGE_VALL, HUGE_VAL, HUGE_VALF); | |
5878 | check_bool ("isinf (HUGE_VALx) == +1", ISINF (x1) == +1); | |
5879 | x1 = -CHOOSE (HUGE_VALL, HUGE_VAL, HUGE_VALF); | |
5880 | check_bool ("isinf (-HUGE_VALx) == -1", ISINF (x1) == -1); | |
5881 | ||
5882 | } | |
5883 | ||
5884 | ||
5885 | static void | |
5886 | initialize (void) | |
5887 | { | |
5929563f | 5888 | fpstack_test ("start *init*"); |
0d8733c4 UD |
5889 | plus_zero = 0.0; |
5890 | nan_value = plus_zero / plus_zero; /* Suppress GCC warning */ | |
5891 | ||
3e5f5557 | 5892 | minus_zero = FUNC (copysign) (0.0, -1.0); |
0d8733c4 UD |
5893 | plus_infty = CHOOSE (HUGE_VALL, HUGE_VAL, HUGE_VALF); |
5894 | minus_infty = -CHOOSE (HUGE_VALL, HUGE_VAL, HUGE_VALF); | |
5895 | ||
5929563f UD |
5896 | (void) &plus_zero; |
5897 | (void) &nan_value; | |
5898 | (void) &minus_zero; | |
5899 | (void) &plus_infty; | |
5900 | (void) &minus_infty; | |
5901 | ||
779ae82e UD |
5902 | /* Clear all exceptions. From now on we must not get random exceptions. */ |
5903 | feclearexcept (FE_ALL_EXCEPT); | |
5904 | ||
0d8733c4 | 5905 | /* Test to make sure we start correctly. */ |
5929563f | 5906 | fpstack_test ("end *init*"); |
0d8733c4 UD |
5907 | } |
5908 | ||
5909 | ||
5910 | static struct option long_options[] = | |
5911 | { | |
5912 | {"verbose", optional_argument, NULL, 'v'}, | |
5913 | {"silent", no_argument, NULL, 's'}, | |
5914 | {0, 0, 0, 0} | |
5915 | }; | |
5916 | ||
5917 | ||
5918 | static void | |
5919 | parse_options (int argc, char *argv[]) | |
5920 | { | |
5921 | int c; | |
5922 | int option_index; | |
5923 | ||
5924 | verbose = 1; | |
5925 | ||
5926 | while (1) | |
5927 | { | |
3e5f5557 | 5928 | c = getopt_long (argc, argv, "v::s", |
0d8733c4 UD |
5929 | long_options, &option_index); |
5930 | ||
5931 | /* Detect the end of the options. */ | |
5932 | if (c == -1) | |
5933 | break; | |
5934 | ||
5935 | switch (c) | |
5936 | { | |
5937 | case 'v': | |
5938 | if (optarg) | |
5939 | verbose = (unsigned int) strtoul (optarg, NULL, 0); | |
5940 | else | |
76b87c03 | 5941 | verbose = 4; |
0d8733c4 UD |
5942 | break; |
5943 | case 's': | |
5944 | verbose = 0; | |
5945 | default: | |
5946 | break; | |
5947 | } | |
5948 | } | |
5949 | } | |
5950 | ||
5951 | ||
5952 | int | |
5953 | main (int argc, char *argv[]) | |
5954 | { | |
76b87c03 | 5955 | |
0d8733c4 UD |
5956 | parse_options (argc, argv); |
5957 | ||
5958 | initialize (); | |
5959 | printf (TEST_MSG); | |
76b87c03 | 5960 | |
0d8733c4 UD |
5961 | basic_tests (); |
5962 | ||
900bec85 UD |
5963 | /* keep the tests a wee bit ordered (according to ISO 9X) */ |
5964 | /* classification functions */ | |
5965 | fpclassify_test (); | |
5966 | isfinite_test (); | |
5967 | isnormal_test (); | |
5968 | signbit_test (); | |
e7f1f046 | 5969 | |
d111572f UD |
5970 | comparisons_test (); |
5971 | ||
900bec85 | 5972 | /* trigonometric functions */ |
0d8733c4 | 5973 | acos_test (); |
0d8733c4 | 5974 | asin_test (); |
0d8733c4 | 5975 | atan_test (); |
0d8733c4 | 5976 | atan2_test (); |
0d8733c4 | 5977 | cos_test (); |
900bec85 UD |
5978 | sin_test (); |
5979 | sincos_test (); | |
5980 | tan_test (); | |
5981 | ||
5982 | /* hyperbolic functions */ | |
5983 | acosh_test (); | |
5984 | asinh_test (); | |
5985 | atanh_test (); | |
0d8733c4 | 5986 | cosh_test (); |
900bec85 UD |
5987 | sinh_test (); |
5988 | tanh_test (); | |
5989 | ||
5990 | /* exponential and logarithmic functions */ | |
0d8733c4 | 5991 | exp_test (); |
36ecfe56 | 5992 | exp10_test (); |
0d8733c4 | 5993 | exp2_test (); |
0d8733c4 UD |
5994 | expm1_test (); |
5995 | frexp_test (); | |
5996 | ldexp_test (); | |
5997 | log_test (); | |
5998 | log10_test (); | |
5999 | log1p_test (); | |
0d8733c4 | 6000 | log2_test (); |
0d8733c4 | 6001 | logb_test (); |
c57abfa7 | 6002 | modf_test (); |
900bec85 | 6003 | ilogb_test (); |
3e5f5557 UD |
6004 | scalb_test (); |
6005 | scalbn_test (); | |
900bec85 UD |
6006 | |
6007 | /* power and absolute value functions */ | |
6008 | cbrt_test (); | |
0d8733c4 | 6009 | fabs_test (); |
0d8733c4 UD |
6010 | hypot_test (); |
6011 | pow_test (); | |
3e5f5557 | 6012 | sqrt_test (); |
900bec85 UD |
6013 | |
6014 | /* error and gamma functions */ | |
6015 | erf_test (); | |
6016 | erfc_test (); | |
6017 | gamma_test (); | |
e852e889 | 6018 | tgamma_test (); |
900bec85 UD |
6019 | lgamma_test (); |
6020 | ||
6021 | /* nearest integer functions */ | |
6022 | ceil_test (); | |
6023 | floor_test (); | |
6024 | nearbyint_test (); | |
6025 | rint_test (); | |
d705269e UD |
6026 | lrint_test (); |
6027 | llrint_test (); | |
900bec85 | 6028 | round_test (); |
d705269e UD |
6029 | lround_test (); |
6030 | llround_test (); | |
bc9f6000 | 6031 | trunc_test (); |
900bec85 UD |
6032 | |
6033 | /* remainder functions */ | |
6034 | fmod_test (); | |
6035 | remainder_test (); | |
bc9f6000 | 6036 | remquo_test (); |
900bec85 UD |
6037 | |
6038 | /* manipulation functions */ | |
6039 | copysign_test (); | |
6040 | nextafter_test (); | |
6041 | ||
6042 | /* maximum, minimum and positive difference functions */ | |
6043 | fdim_test (); | |
6044 | fmin_test (); | |
6045 | fmax_test (); | |
6046 | ||
6047 | /* complex functions */ | |
04be94a8 UD |
6048 | cabs_test (); |
6049 | carg_test (); | |
3e5f5557 | 6050 | cexp_test (); |
779ae82e | 6051 | csin_test (); |
993b3242 | 6052 | csinh_test (); |
63551311 | 6053 | ccos_test (); |
993b3242 | 6054 | ccosh_test (); |
c131718c | 6055 | clog_test (); |
dfd2257a | 6056 | clog10_test (); |
63551311 UD |
6057 | cacos_test (); |
6058 | cacosh_test (); | |
6059 | casin_test (); | |
6060 | casinh_test (); | |
6061 | catan_test (); | |
6062 | catanh_test (); | |
04be94a8 | 6063 | ctan_test (); |
63551311 UD |
6064 | ctanh_test (); |
6065 | csqrt_test (); | |
6066 | cpow_test (); | |
04be94a8 UD |
6067 | |
6068 | /* multiply and add */ | |
fe0ec73e | 6069 | fma_test (); |
63551311 | 6070 | |
900bec85 | 6071 | /* special tests */ |
0d8733c4 UD |
6072 | identities (); |
6073 | inverse_functions (); | |
6074 | ||
f43ce637 UD |
6075 | printf ("\nTest suite completed:\n"); |
6076 | printf (" %d test cases plus %d tests for exception flags executed.\n", | |
6077 | noTests, noExcTests); | |
0d8733c4 UD |
6078 | if (noErrors) |
6079 | { | |
f43ce637 | 6080 | printf (" %d errors occured.\n", noErrors); |
0d8733c4 UD |
6081 | exit (1); |
6082 | } | |
f43ce637 | 6083 | printf (" All tests passed successfully.\n"); |
0d8733c4 UD |
6084 | exit (0); |
6085 | } |