OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [uClibc/] [test/] [math/] [libm-test.inc] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1325 phoenix
/* Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
2
   This file is part of the GNU C Library.
3
   Contributed by Andreas Jaeger , 1997.
4
 
5
   The GNU C Library is free software; you can redistribute it and/or
6
   modify it under the terms of the GNU Lesser General Public
7
   License as published by the Free Software Foundation; either
8
   version 2.1 of the 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
   Lesser General Public License for more details.
14
 
15
   You should have received a copy of the GNU Lesser General Public
16
   License along with the GNU C Library; if not, write to the Free
17
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18
   02111-1307 USA.  */
19
 
20
/* Part of testsuite for libm.
21
 
22
   This file is processed by a perl script.  The resulting file has to
23
   be included by a master file that defines:
24
 
25
   Makros:
26
   FUNC(function): converts general function name (like cos) to
27
   name with correct suffix (e.g. cosl or cosf)
28
   MATHCONST(x):   like FUNC but for constants (e.g convert 0.0 to 0.0L)
29
   FLOAT:          floating point type to test
30
   - TEST_MSG:     informal message to be displayed
31
   CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat):
32
   chooses one of the parameters as delta for testing
33
   equality
34
   PRINTF_EXPR     Floating point conversion specification to print a variable
35
   of type FLOAT with printf.  PRINTF_EXPR just contains
36
   the specifier, not the percent and width arguments,
37
   e.g. "f".
38
   PRINTF_XEXPR    Like PRINTF_EXPR, but print in hexadecimal format.
39
   PRINTF_NEXPR Like PRINTF_EXPR, but print nice.  */
40
 
41
/* This testsuite has currently tests for:
42
   acos, acosh, asin, asinh, atan, atan2, atanh,
43
   cbrt, ceil, copysign, cos, cosh, erf, erfc, exp, exp10, exp2, expm1,
44
   fabs, fdim, floor, fma, fmax, fmin, fmod, fpclassify,
45
   frexp, gamma, hypot,
46
   ilogb, isfinite, isinf, isnan, isnormal,
47
   isless, islessequal, isgreater, isgreaterequal, islessgreater, isunordered,
48
   j0, j1, jn,
49
   ldexp, lgamma, log, log10, log1p, log2, logb,
50
   modf, nearbyint, nextafter,
51
   pow, remainder, remquo, rint, lrint, llrint,
52
   round, lround, llround,
53
   scalb, scalbn, scalbln, signbit, sin, sincos, sinh, sqrt, tan, tanh, tgamma, trunc,
54
   y0, y1, yn
55
 
56
   and for the following complex math functions:
57
   cabs, cacos, cacosh, carg, casin, casinh, catan, catanh,
58
   ccos, ccosh, cexp, clog, cpow, cproj, csin, csinh, csqrt, ctan, ctanh.
59
 
60
   At the moment the following functions aren't tested:
61
   drem, significand, nan
62
 
63
   Parameter handling is primitive in the moment:
64
   --verbose=[0..3] for different levels of output:
65
   0: only error count
66
   1: basic report on failed tests (default)
67
   2: full report on all tests
68
   -v for full output (equals --verbose=3)
69
   -u for generation of an ULPs file
70
 */
71
 
72
/* "Philosophy":
73
 
74
   This suite tests some aspects of the correct implementation of
75
   mathematical functions in libm.  Some simple, specific parameters
76
   are tested for correctness but there's no exhaustive
77
   testing.  Handling of specific inputs (e.g. infinity, not-a-number)
78
   is also tested.  Correct handling of exceptions is checked
79
   against.  These implemented tests should check all cases that are
80
   specified in ISO C99.
81
 
82
   Exception testing: At the moment only divide-by-zero and invalid
83
   exceptions are tested.  Overflow/underflow and inexact exceptions
84
   aren't checked at the moment.
85
 
86
   NaN values: There exist signalling and quiet NaNs.  This implementation
87
   only uses signalling NaN as parameter but does not differenciate
88
   between the two kinds of NaNs as result.
89
 
90
   Inline functions: Inlining functions should give an improvement in
91
   speed - but not in precission.  The inlined functions return
92
   reasonable values for a reasonable range of input values.  The
93
   result is not necessarily correct for all values and exceptions are
94
   not correctly raised in all cases.  Problematic input and return
95
   values are infinity, not-a-number and minus zero.  This suite
96
   therefore does not check these specific inputs and the exception
97
   handling for inlined mathematical functions - just the "reasonable"
98
   values are checked.
99
 
100
   Beware: The tests might fail for any of the following reasons:
101
   - Tests are wrong
102
   - Functions are wrong
103
   - Floating Point Unit not working properly
104
   - Compiler has errors
105
 
106
   With e.g. gcc 2.7.2.2 the test for cexp fails because of a compiler error.
107
 
108
 
109
   To Do: All parameter should be numbers that can be represented as
110
   exact floating point values.  Currently some values cannot be represented
111
   exactly and therefore the result is not the expected result.
112
*/
113
 
114
#ifndef _GNU_SOURCE
115
# define _GNU_SOURCE
116
#endif
117
 
118
#include "libm-test-ulps.h"
119
#include 
120
#include 
121
#include 
122
#include 
123
 
124
#include 
125
#include 
126
#include 
127
#include 
128
#include 
129
 
130
//#include 
131
#define feclearexcept(X)
132
#define fetestexcept(X)     0
133
 
134
/* Possible exceptions */
135
#define NO_EXCEPTION                    0x0
136
#define INVALID_EXCEPTION               0x1
137
#define DIVIDE_BY_ZERO_EXCEPTION        0x2
138
/* The next flags signals that those exceptions are allowed but not required.   */
139
#define INVALID_EXCEPTION_OK            0x4
140
#define DIVIDE_BY_ZERO_EXCEPTION_OK     0x8
141
#define EXCEPTIONS_OK INVALID_EXCEPTION_OK+DIVIDE_BY_ZERO_EXCEPTION_OK
142
/* Some special test flags, passed togther with exceptions.  */
143
#define IGNORE_ZERO_INF_SIGN            0x10
144
 
145
/* Various constants (we must supply them precalculated for accuracy).  */
146
#define M_PI_6l                 .52359877559829887307710723054658383L
147
#define M_E2l                   7.389056098930650227230427460575008L
148
#define M_E3l                   20.085536923187667740928529654581719L
149
#define M_2_SQRT_PIl            3.5449077018110320545963349666822903L   /* 2 sqrt (M_PIl)  */
150
#define M_SQRT_PIl              1.7724538509055160272981674833411451L   /* sqrt (M_PIl)  */
151
#define M_LOG_SQRT_PIl          0.57236494292470008707171367567652933L  /* log(sqrt(M_PIl))  */
152
#define M_LOG_2_SQRT_PIl        1.265512123484645396488945797134706L    /* log(2*sqrt(M_PIl))  */
153
#define M_PI_34l                (M_PIl - M_PI_4l)               /* 3*pi/4 */
154
#define M_PI_34_LOG10El         (M_PIl - M_PI_4l) * M_LOG10El
155
#define M_PI2_LOG10El           M_PI_2l * M_LOG10El
156
#define M_PI4_LOG10El           M_PI_4l * M_LOG10El
157
#define M_PI_LOG10El            M_PIl * M_LOG10El
158
 
159
static FILE *ulps_file; /* File to document difference.  */
160
static int output_ulps; /* Should ulps printed?  */
161
 
162
static int noErrors;    /* number of errors */
163
static int noTests;     /* number of tests (without testing exceptions) */
164
static int noExcTests;  /* number of tests for exception flags */
165
static int noXFails;    /* number of expected failures.  */
166
static int noXPasses;   /* number of unexpected passes.  */
167
 
168
static int verbose;
169
static int output_max_error;    /* Should the maximal errors printed?  */
170
static int output_points;       /* Should the single function results printed?  */
171
static int ignore_max_ulp;      /* Should we ignore max_ulp?  */
172
 
173
static FLOAT minus_zero, plus_zero;
174
static FLOAT plus_infty, minus_infty, nan_value;
175
 
176
static FLOAT max_error, real_max_error, imag_max_error;
177
 
178
 
179
#define BUILD_COMPLEX(real, imag) \
180
  ({ __complex__ FLOAT __retval;                                              \
181
     __real__ __retval = (real);                                              \
182
     __imag__ __retval = (imag);                                              \
183
     __retval; })
184
 
185
#define BUILD_COMPLEX_INT(real, imag) \
186
  ({ __complex__ int __retval;                                                \
187
     __real__ __retval = (real);                                              \
188
     __imag__ __retval = (imag);                                              \
189
     __retval; })
190
 
191
 
192
#define MANT_DIG CHOOSE ((LDBL_MANT_DIG-1), (DBL_MANT_DIG-1), (FLT_MANT_DIG-1),  \
193
                         (LDBL_MANT_DIG-1), (DBL_MANT_DIG-1), (FLT_MANT_DIG-1))
194
 
195
static void
196
init_max_error (void)
197
{
198
  max_error = 0;
199
  real_max_error = 0;
200
  imag_max_error = 0;
201
  feclearexcept (FE_ALL_EXCEPT);
202
}
203
 
204
static void
205
set_max_error (FLOAT current, FLOAT *curr_max_error)
206
{
207
  if (current > *curr_max_error)
208
    *curr_max_error = current;
209
}
210
 
211
 
212
/* Should the message print to screen?  This depends on the verbose flag,
213
   and the test status.  */
214
static int
215
print_screen (int ok, int xfail)
216
{
217
  if (output_points
218
      && (verbose > 1
219
          || (verbose == 1 && ok == xfail)))
220
    return 1;
221
  return 0;
222
}
223
 
224
 
225
/* Should the message print to screen?  This depends on the verbose flag,
226
   and the test status.  */
227
static int
228
print_screen_max_error (int ok, int xfail)
229
{
230
  if (output_max_error
231
      && (verbose > 1
232
          || ((verbose == 1) && (ok == xfail))))
233
    return 1;
234
  return 0;
235
}
236
 
237
/* Update statistic counters.  */
238
static void
239
update_stats (int ok, int xfail)
240
{
241
  ++noTests;
242
  if (ok && xfail)
243
    ++noXPasses;
244
  else if (!ok && xfail)
245
    ++noXFails;
246
  else if (!ok && !xfail)
247
    ++noErrors;
248
}
249
 
250
static void
251
print_ulps (const char *test_name, FLOAT ulp)
252
{
253
  if (output_ulps)
254
    {
255
      fprintf (ulps_file, "Test \"%s\":\n", test_name);
256
      fprintf (ulps_file, "%s: %.0" PRINTF_NEXPR "\n",
257
               CHOOSE("ldouble", "double", "float",
258
                      "ildouble", "idouble", "ifloat"),
259
               FUNC(ceil) (ulp));
260
    }
261
}
262
 
263
static void
264
print_function_ulps (const char *function_name, FLOAT ulp)
265
{
266
  if (output_ulps)
267
    {
268
      fprintf (ulps_file, "Function: \"%s\":\n", function_name);
269
      fprintf (ulps_file, "%s: %.0" PRINTF_NEXPR "\n",
270
               CHOOSE("ldouble", "double", "float",
271
                      "ildouble", "idouble", "ifloat"),
272
               FUNC(ceil) (ulp));
273
    }
274
}
275
 
276
 
277
static void
278
print_complex_function_ulps (const char *function_name, FLOAT real_ulp,
279
                             FLOAT imag_ulp)
280
{
281
  if (output_ulps)
282
    {
283
      if (real_ulp != 0.0)
284
        {
285
          fprintf (ulps_file, "Function: Real part of \"%s\":\n", function_name);
286
          fprintf (ulps_file, "%s: %.0" PRINTF_NEXPR "\n",
287
                   CHOOSE("ldouble", "double", "float",
288
                          "ildouble", "idouble", "ifloat"),
289
                   FUNC(ceil) (real_ulp));
290
        }
291
      if (imag_ulp != 0.0)
292
        {
293
          fprintf (ulps_file, "Function: Imaginary part of \"%s\":\n", function_name);
294
          fprintf (ulps_file, "%s: %.0" PRINTF_NEXPR "\n",
295
                   CHOOSE("ldouble", "double", "float",
296
                          "ildouble", "idouble", "ifloat"),
297
                   FUNC(ceil) (imag_ulp));
298
        }
299
 
300
 
301
    }
302
}
303
 
304
 
305
 
306
/* Test if Floating-Point stack hasn't changed */
307
static void
308
fpstack_test (const char *test_name)
309
{
310
#ifdef i386
311
  static int old_stack;
312
  int sw;
313
 
314
  asm ("fnstsw" : "=a" (sw));
315
  sw >>= 11;
316
  sw &= 7;
317
 
318
  if (sw != old_stack)
319
    {
320
      printf ("FP-Stack wrong after test %s (%d, should be %d)\n",
321
              test_name, sw, old_stack);
322
      ++noErrors;
323
      old_stack = sw;
324
    }
325
#endif
326
}
327
 
328
 
329
static void
330
print_max_error (const char *func_name, FLOAT allowed, int xfail)
331
{
332
  int ok = 0;
333
 
334
  if (max_error == 0.0 || (max_error <= allowed && !ignore_max_ulp))
335
    {
336
      ok = 1;
337
    }
338
 
339
  if (!ok)
340
    print_function_ulps (func_name, max_error);
341
 
342
 
343
  if (print_screen_max_error (ok, xfail))
344
    {
345
      printf ("Maximal error of `%s'\n", func_name);
346
      printf (" is      : %.0" PRINTF_NEXPR " ulp\n", FUNC(ceil) (max_error));
347
      printf (" accepted: %.0" PRINTF_NEXPR " ulp\n", FUNC(ceil) (allowed));
348
    }
349
 
350
  update_stats (ok, xfail);
351
}
352
 
353
 
354
static void
355
print_complex_max_error (const char *func_name, __complex__ FLOAT allowed,
356
                         __complex__ int xfail)
357
{
358
  int ok = 0;
359
 
360
  if ((real_max_error == 0 && imag_max_error == 0)
361
      || (real_max_error <= __real__ allowed
362
          && imag_max_error <= __imag__ allowed
363
          && !ignore_max_ulp))
364
    {
365
      ok = 1;
366
    }
367
 
368
  if (!ok)
369
    print_complex_function_ulps (func_name, real_max_error, imag_max_error);
370
 
371
 
372
  if (print_screen_max_error (ok, xfail))
373
    {
374
      printf ("Maximal error of real part of: %s\n", func_name);
375
      printf (" is      : %.0" PRINTF_NEXPR " ulp\n",
376
              FUNC(ceil) (real_max_error));
377
      printf (" accepted: %.0" PRINTF_NEXPR " ulp\n",
378
              FUNC(ceil) (__real__ allowed));
379
      printf ("Maximal error of imaginary part of: %s\n", func_name);
380
      printf (" is      : %.0" PRINTF_NEXPR " ulp\n",
381
              FUNC(ceil) (imag_max_error));
382
      printf (" accepted: %.0" PRINTF_NEXPR " ulp\n",
383
              FUNC(ceil) (__imag__ allowed));
384
    }
385
 
386
  update_stats (ok, xfail);
387
}
388
 
389
 
390
/* Test whether a given exception was raised.  */
391
static void
392
test_single_exception (const char *test_name,
393
                       int exception,
394
                       int exc_flag,
395
                       int fe_flag,
396
                       const char *flag_name)
397
{
398
#ifndef TEST_INLINE
399
  int ok = 1;
400
  if (exception & exc_flag)
401
    {
402
      if (fetestexcept (fe_flag))
403
        {
404
          if (print_screen (1, 0))
405
            printf ("Pass: %s: Exception \"%s\" set\n", test_name, flag_name);
406
        }
407
      else
408
        {
409
          ok = 0;
410
          if (print_screen (0, 0))
411
            printf ("Failure: %s: Exception \"%s\" not set\n",
412
                    test_name, flag_name);
413
        }
414
    }
415
  else
416
    {
417
      if (fetestexcept (fe_flag))
418
        {
419
          ok = 0;
420
          if (print_screen (0, 0))
421
            printf ("Failure: %s: Exception \"%s\" set\n",
422
                    test_name, flag_name);
423
        }
424
      else
425
        {
426
          if (print_screen (1, 0))
427
            printf ("%s: Exception \"%s\" not set\n", test_name,
428
                    flag_name);
429
        }
430
    }
431
  if (!ok)
432
    ++noErrors;
433
 
434
#endif
435
}
436
 
437
 
438
/* Test whether exceptions given by EXCEPTION are raised.  Ignore thereby
439
   allowed but not required exceptions.
440
*/
441
static void
442
test_exceptions (const char *test_name, int exception)
443
{
444
  ++noExcTests;
445
#ifdef FE_DIVBYZERO
446
  if ((exception & DIVIDE_BY_ZERO_EXCEPTION_OK) == 0)
447
    test_single_exception (test_name, exception,
448
                           DIVIDE_BY_ZERO_EXCEPTION, FE_DIVBYZERO,
449
                           "Divide by zero");
450
#endif
451
#ifdef FE_INVALID
452
  if ((exception & INVALID_EXCEPTION_OK) == 0)
453
    test_single_exception (test_name, exception, INVALID_EXCEPTION, FE_INVALID,
454
                         "Invalid operation");
455
#endif
456
  feclearexcept (FE_ALL_EXCEPT);
457
}
458
 
459
 
460
static void
461
check_float_internal (const char *test_name, FLOAT computed, FLOAT expected,
462
                      FLOAT max_ulp, int xfail, int exceptions,
463
                      FLOAT *curr_max_error)
464
{
465
  int ok = 0;
466
  int print_diff = 0;
467
  FLOAT diff = 0;
468
  FLOAT ulp = 0;
469
 
470
  test_exceptions (test_name, exceptions);
471
  if (isnan (computed) && isnan (expected))
472
    ok = 1;
473
  else if (isinf (computed) && isinf (expected))
474
    {
475
      /* Test for sign of infinities.  */
476
      if ((exceptions & IGNORE_ZERO_INF_SIGN) == 0
477
          && signbit (computed) != signbit (expected))
478
        {
479
          ok = 0;
480
          printf ("infinity has wrong sign.\n");
481
        }
482
      else
483
        ok = 1;
484
    }
485
  /* Don't calc ulp for NaNs or infinities.  */
486
  else if (isinf (computed) || isnan (computed) || isinf (expected) || isnan (expected))
487
    ok = 0;
488
  else
489
    {
490
      diff = FUNC(fabs) (computed - expected);
491
      /* ilogb (0) isn't allowed.  */
492
      if (expected == 0.0)
493
        ulp = diff / FUNC(ldexp) (1.0, - MANT_DIG);
494
      else
495
        ulp = diff / FUNC(ldexp) (1.0, FUNC(ilogb) (expected) - MANT_DIG);
496
      set_max_error (ulp, curr_max_error);
497
      print_diff = 1;
498
      if ((exceptions & IGNORE_ZERO_INF_SIGN) == 0
499
          && computed == 0.0 && expected == 0.0
500
          && signbit(computed) != signbit (expected))
501
        ok = 0;
502
      else if (ulp == 0.0 || (ulp <= max_ulp && !ignore_max_ulp))
503
        ok = 1;
504
      else
505
        {
506
          ok = 0;
507
          print_ulps (test_name, ulp);
508
        }
509
 
510
    }
511
  if (print_screen (ok, xfail))
512
    {
513
      if (!ok)
514
        printf ("Failure: ");
515
      printf ("Test: %s\n", test_name);
516
      printf ("Result:\n");
517
      printf (" is:         % .20" PRINTF_EXPR "  % .20" PRINTF_XEXPR "\n",
518
              computed, computed);
519
      printf (" should be:  % .20" PRINTF_EXPR "  % .20" PRINTF_XEXPR "\n",
520
              expected, expected);
521
      if (print_diff)
522
        {
523
          printf (" difference: % .20" PRINTF_EXPR "  % .20" PRINTF_XEXPR
524
                  "\n", diff, diff);
525
          printf (" ulp       : % .4" PRINTF_NEXPR "\n", ulp);
526
          printf (" max.ulp   : % .4" PRINTF_NEXPR "\n", max_ulp);
527
        }
528
    }
529
  update_stats (ok, xfail);
530
 
531
  fpstack_test (test_name);
532
}
533
 
534
 
535
static void
536
check_float (const char *test_name, FLOAT computed, FLOAT expected,
537
             FLOAT max_ulp, int xfail, int exceptions)
538
{
539
  check_float_internal (test_name, computed, expected, max_ulp, xfail,
540
                        exceptions, &max_error);
541
}
542
 
543
 
544
static void
545
check_complex (const char *test_name, __complex__ FLOAT computed,
546
               __complex__ FLOAT expected,
547
               __complex__ FLOAT max_ulp, __complex__ int xfail,
548
               int exception)
549
{
550
  FLOAT part_comp, part_exp, part_max_ulp;
551
  int part_xfail;
552
  char str[200];
553
 
554
  sprintf (str, "Real part of: %s", test_name);
555
  part_comp = __real__ computed;
556
  part_exp = __real__ expected;
557
  part_max_ulp = __real__ max_ulp;
558
  part_xfail = __real__ xfail;
559
 
560
  check_float_internal (str, part_comp, part_exp, part_max_ulp, part_xfail,
561
                        exception, &real_max_error);
562
 
563
  sprintf (str, "Imaginary part of: %s", test_name);
564
  part_comp = __imag__ computed;
565
  part_exp = __imag__ expected;
566
  part_max_ulp = __imag__ max_ulp;
567
  part_xfail = __imag__ xfail;
568
 
569
  /* Don't check again for exceptions, just pass through the
570
     zero/inf sign test.  */
571
  check_float_internal (str, part_comp, part_exp, part_max_ulp, part_xfail,
572
                        exception & IGNORE_ZERO_INF_SIGN,
573
                        &imag_max_error);
574
}
575
 
576
 
577
/* Check that computed and expected values are equal (int values).  */
578
static void
579
check_int (const char *test_name, int computed, int expected, int max_ulp,
580
           int xfail, int exceptions)
581
{
582
  int diff = computed - expected;
583
  int ok = 0;
584
 
585
  test_exceptions (test_name, exceptions);
586
  noTests++;
587
  if (abs (diff) <= max_ulp)
588
    ok = 1;
589
 
590
  if (!ok)
591
    print_ulps (test_name, diff);
592
 
593
  if (print_screen (ok, xfail))
594
    {
595
      if (!ok)
596
        printf ("Failure: ");
597
      printf ("Test: %s\n", test_name);
598
      printf ("Result:\n");
599
      printf (" is:         %d\n", computed);
600
      printf (" should be:  %d\n", expected);
601
    }
602
 
603
  update_stats (ok, xfail);
604
  fpstack_test (test_name);
605
}
606
 
607
 
608
/* Check that computed and expected values are equal (long int values).  */
609
static void
610
check_long (const char *test_name, long int computed, long int expected,
611
            long int max_ulp, int xfail, int exceptions)
612
{
613
  long int diff = computed - expected;
614
  int ok = 0;
615
 
616
  test_exceptions (test_name, exceptions);
617
  noTests++;
618
  if (labs (diff) <= max_ulp)
619
    ok = 1;
620
 
621
  if (!ok)
622
    print_ulps (test_name, diff);
623
 
624
  if (print_screen (ok, xfail))
625
    {
626
      if (!ok)
627
        printf ("Failure: ");
628
      printf ("Test: %s\n", test_name);
629
      printf ("Result:\n");
630
      printf (" is:         %ld\n", computed);
631
      printf (" should be:  %ld\n", expected);
632
    }
633
 
634
  update_stats (ok, xfail);
635
  fpstack_test (test_name);
636
}
637
 
638
 
639
/* Check that computed value is true/false.  */
640
static void
641
check_bool (const char *test_name, int computed, int expected,
642
            long int max_ulp, int xfail, int exceptions)
643
{
644
  int ok = 0;
645
 
646
  test_exceptions (test_name, exceptions);
647
  noTests++;
648
  if ((computed == 0) == (expected == 0))
649
    ok = 1;
650
 
651
  if (print_screen (ok, xfail))
652
    {
653
      if (!ok)
654
        printf ("Failure: ");
655
      printf ("Test: %s\n", test_name);
656
      printf ("Result:\n");
657
      printf (" is:         %d\n", computed);
658
      printf (" should be:  %d\n", expected);
659
    }
660
 
661
  update_stats (ok, xfail);
662
  fpstack_test (test_name);
663
}
664
 
665
 
666
/* check that computed and expected values are equal (long int values) */
667
static void
668
check_longlong (const char *test_name, long long int computed,
669
                long long int expected,
670
                long long int max_ulp, int xfail,
671
                int exceptions)
672
{
673
  long long int diff = computed - expected;
674
  int ok = 0;
675
 
676
  test_exceptions (test_name, exceptions);
677
  noTests++;
678
  if (llabs (diff) <= max_ulp)
679
    ok = 1;
680
 
681
  if (!ok)
682
    print_ulps (test_name, diff);
683
 
684
  if (print_screen (ok, xfail))
685
    {
686
      if (!ok)
687
        printf ("Failure:");
688
      printf ("Test: %s\n", test_name);
689
      printf ("Result:\n");
690
      printf (" is:         %lld\n", computed);
691
      printf (" should be:  %lld\n", expected);
692
    }
693
 
694
  update_stats (ok, xfail);
695
  fpstack_test (test_name);
696
}
697
 
698
 
699
 
700
/* This is to prevent messages from the SVID libm emulation.  */
701
int
702
matherr (struct exception *x __attribute__ ((unused)))
703
{
704
  return 1;
705
}
706
 
707
 
708
/****************************************************************************
709
  Tests for single functions of libm.
710
  Please keep them alphabetically sorted!
711
****************************************************************************/
712
 
713
static void
714
acos_test (void)
715
{
716
  errno = 0;
717
  FUNC(acos) (0);
718
  if (errno == ENOSYS)
719
    /* Function not implemented.  */
720
    return;
721
 
722
  START (acos);
723
 
724
  TEST_f_f (acos, plus_infty, nan_value, INVALID_EXCEPTION);
725
  TEST_f_f (acos, minus_infty, nan_value, INVALID_EXCEPTION);
726
  TEST_f_f (acos, nan_value, nan_value);
727
 
728
  /* |x| > 1: */
729
  TEST_f_f (acos, 1.1L, nan_value, INVALID_EXCEPTION);
730
  TEST_f_f (acos, -1.1L, nan_value, INVALID_EXCEPTION);
731
 
732
  TEST_f_f (acos, 0, M_PI_2l);
733
  TEST_f_f (acos, minus_zero, M_PI_2l);
734
  TEST_f_f (acos, 1, 0);
735
  TEST_f_f (acos, -1, M_PIl);
736
  TEST_f_f (acos, 0.5, M_PI_6l*2.0);
737
  TEST_f_f (acos, -0.5, M_PI_6l*4.0);
738
  TEST_f_f (acos, 0.7L, 0.79539883018414355549096833892476432L);
739
 
740
  END (acos);
741
}
742
 
743
static void
744
acosh_test (void)
745
{
746
  errno = 0;
747
  FUNC(acosh) (7);
748
  if (errno == ENOSYS)
749
    /* Function not implemented.  */
750
    return;
751
 
752
  START (acosh);
753
 
754
  TEST_f_f (acosh, plus_infty, plus_infty);
755
  TEST_f_f (acosh, minus_infty, nan_value, INVALID_EXCEPTION);
756
 
757
  /* x < 1:  */
758
  TEST_f_f (acosh, -1.1L, nan_value, INVALID_EXCEPTION);
759
 
760
  TEST_f_f (acosh, 1, 0);
761
  TEST_f_f (acosh, 7, 2.633915793849633417250092694615937L);
762
 
763
  END (acosh);
764
}
765
 
766
static void
767
asin_test (void)
768
{
769
  errno = 0;
770
  FUNC(asin) (0);
771
  if (errno == ENOSYS)
772
    /* Function not implemented.  */
773
    return;
774
 
775
  START (asin);
776
 
777
  TEST_f_f (asin, plus_infty, nan_value, INVALID_EXCEPTION);
778
  TEST_f_f (asin, minus_infty, nan_value, INVALID_EXCEPTION);
779
  TEST_f_f (asin, nan_value, nan_value);
780
 
781
  /* asin x == NaN plus invalid exception for |x| > 1.  */
782
  TEST_f_f (asin, 1.1L, nan_value, INVALID_EXCEPTION);
783
  TEST_f_f (asin, -1.1L, nan_value, INVALID_EXCEPTION);
784
 
785
  TEST_f_f (asin, 0, 0);
786
  TEST_f_f (asin, minus_zero, minus_zero);
787
  TEST_f_f (asin, 0.5, M_PI_6l);
788
  TEST_f_f (asin, -0.5, -M_PI_6l);
789
  TEST_f_f (asin, 1.0, M_PI_2l);
790
  TEST_f_f (asin, -1.0, -M_PI_2l);
791
  TEST_f_f (asin, 0.7L, 0.77539749661075306374035335271498708L);
792
 
793
  END (asin);
794
}
795
 
796
static void
797
asinh_test (void)
798
{
799
  errno = 0;
800
  FUNC(asinh) (0.7L);
801
  if (errno == ENOSYS)
802
    /* Function not implemented.  */
803
    return;
804
 
805
  START (asinh);
806
 
807
  TEST_f_f (asinh, 0, 0);
808
  TEST_f_f (asinh, minus_zero, minus_zero);
809
#ifndef TEST_INLINE
810
  TEST_f_f (asinh, plus_infty, plus_infty);
811
  TEST_f_f (asinh, minus_infty, minus_infty);
812
#endif
813
  TEST_f_f (asinh, nan_value, nan_value);
814
  TEST_f_f (asinh, 0.7L, 0.652666566082355786L);
815
 
816
  END (asinh);
817
}
818
 
819
static void
820
atan_test (void)
821
{
822
  errno = 0;
823
  FUNC(atan) (0);
824
  if (errno == ENOSYS)
825
    /* Function not implemented.  */
826
    return;
827
 
828
  START (atan);
829
 
830
  TEST_f_f (atan, 0, 0);
831
  TEST_f_f (atan, minus_zero, minus_zero);
832
 
833
  TEST_f_f (atan, plus_infty, M_PI_2l);
834
  TEST_f_f (atan, minus_infty, -M_PI_2l);
835
  TEST_f_f (atan, nan_value, nan_value);
836
 
837
  TEST_f_f (atan, 1, M_PI_4l);
838
  TEST_f_f (atan, -1, -M_PI_4l);
839
 
840
  TEST_f_f (atan, 0.7L, 0.61072596438920861654375887649023613L);
841
 
842
  END (atan);
843
}
844
 
845
 
846
 
847
static void
848
atanh_test (void)
849
{
850
  errno = 0;
851
  FUNC(atanh) (0.7L);
852
  if (errno == ENOSYS)
853
    /* Function not implemented.  */
854
    return;
855
 
856
  START (atanh);
857
 
858
 
859
  TEST_f_f (atanh, 0, 0);
860
  TEST_f_f (atanh, minus_zero, minus_zero);
861
 
862
  TEST_f_f (atanh, 1, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
863
  TEST_f_f (atanh, -1, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
864
  TEST_f_f (atanh, nan_value, nan_value);
865
 
866
  /* atanh (x) == NaN plus invalid exception if |x| > 1.  */
867
  TEST_f_f (atanh, 1.1L, nan_value, INVALID_EXCEPTION);
868
  TEST_f_f (atanh, -1.1L, nan_value, INVALID_EXCEPTION);
869
 
870
  TEST_f_f (atanh, 0.7L, 0.8673005276940531944L);
871
 
872
  END (atanh);
873
}
874
 
875
static void
876
atan2_test (void)
877
{
878
  errno = 0;
879
  FUNC(atan2) (-0, 1);
880
  if (errno == ENOSYS)
881
    /* Function not implemented.  */
882
    return;
883
 
884
  START (atan2);
885
 
886
  /* atan2 (0,x) == 0 for x > 0.  */
887
  TEST_ff_f (atan2, 0, 1, 0);
888
 
889
  /* atan2 (-0,x) == -0 for x > 0.  */
890
  TEST_ff_f (atan2, minus_zero, 1, minus_zero);
891
 
892
  TEST_ff_f (atan2, 0, 0, 0);
893
  TEST_ff_f (atan2, minus_zero, 0, minus_zero);
894
 
895
  /* atan2 (+0,x) == +pi for x < 0.  */
896
  TEST_ff_f (atan2, 0, -1, M_PIl);
897
 
898
  /* atan2 (-0,x) == -pi for x < 0.  */
899
  TEST_ff_f (atan2, minus_zero, -1, -M_PIl);
900
 
901
  TEST_ff_f (atan2, 0, minus_zero, M_PIl);
902
  TEST_ff_f (atan2, minus_zero, minus_zero, -M_PIl);
903
 
904
  /* atan2 (y,+0) == pi/2 for y > 0.  */
905
  TEST_ff_f (atan2, 1, 0, M_PI_2l);
906
 
907
  /* atan2 (y,-0) == pi/2 for y > 0.  */
908
  TEST_ff_f (atan2, 1, minus_zero, M_PI_2l);
909
 
910
  /* atan2 (y,+0) == -pi/2 for y < 0.  */
911
  TEST_ff_f (atan2, -1, 0, -M_PI_2l);
912
 
913
  /* atan2 (y,-0) == -pi/2 for y < 0.  */
914
  TEST_ff_f (atan2, -1, minus_zero, -M_PI_2l);
915
 
916
  /* atan2 (y,inf) == +0 for finite y > 0.  */
917
  TEST_ff_f (atan2, 1, plus_infty, 0);
918
 
919
  /* atan2 (y,inf) == -0 for finite y < 0.  */
920
  TEST_ff_f (atan2, -1, plus_infty, minus_zero);
921
 
922
  /* atan2(+inf, x) == pi/2 for finite x.  */
923
  TEST_ff_f (atan2, plus_infty, -1, M_PI_2l);
924
 
925
  /* atan2(-inf, x) == -pi/2 for finite x.  */
926
  TEST_ff_f (atan2, minus_infty, 1, -M_PI_2l);
927
 
928
  /* atan2 (y,-inf) == +pi for finite y > 0.  */
929
  TEST_ff_f (atan2, 1, minus_infty, M_PIl);
930
 
931
  /* atan2 (y,-inf) == -pi for finite y < 0.  */
932
  TEST_ff_f (atan2, -1, minus_infty, -M_PIl);
933
 
934
  TEST_ff_f (atan2, plus_infty, plus_infty, M_PI_4l);
935
  TEST_ff_f (atan2, minus_infty, plus_infty, -M_PI_4l);
936
  TEST_ff_f (atan2, plus_infty, minus_infty, M_PI_34l);
937
  TEST_ff_f (atan2, minus_infty, minus_infty, -M_PI_34l);
938
  TEST_ff_f (atan2, nan_value, nan_value, nan_value);
939
 
940
  TEST_ff_f (atan2, 0.7L, 1, 0.61072596438920861654375887649023613L);
941
  TEST_ff_f (atan2, -0.7L, 1.0L, -0.61072596438920861654375887649023613L);
942
  TEST_ff_f (atan2, 0.7L, -1.0L, 2.530866689200584621918884506789267L);
943
  TEST_ff_f (atan2, -0.7L, -1.0L, -2.530866689200584621918884506789267L);
944
  TEST_ff_f (atan2, 0.4L, 0.0003L, 1.5700463269355215717704032607580829L);
945
  TEST_ff_f (atan2, 1.4L, -0.93L, 2.1571487668237843754887415992772736L);
946
 
947
  END (atan2);
948
}
949
 
950
 
951
static void
952
cabs_test (void)
953
{
954
  errno = 0;
955
  FUNC(cabs) (BUILD_COMPLEX (0.7L, 12.4L));
956
  if (errno == ENOSYS)
957
    /* Function not implemented.  */
958
    return;
959
 
960
  START (cabs);
961
 
962
  /* cabs (x + iy) is specified as hypot (x,y) */
963
 
964
  /* cabs (+inf + i x) == +inf.  */
965
  TEST_c_f (cabs, plus_infty, 1.0, plus_infty);
966
  /* cabs (-inf + i x) == +inf.  */
967
  TEST_c_f (cabs, minus_infty, 1.0, plus_infty);
968
 
969
  TEST_c_f (cabs, minus_infty, nan_value, plus_infty);
970
  TEST_c_f (cabs, minus_infty, nan_value, plus_infty);
971
 
972
  TEST_c_f (cabs, nan_value, nan_value, nan_value);
973
 
974
  /* cabs (x,y) == cabs (y,x).  */
975
  TEST_c_f (cabs, 0.7L, 12.4L, 12.419742348374220601176836866763271L);
976
  /* cabs (x,y) == cabs (-x,y).  */
977
  TEST_c_f (cabs, -12.4L, 0.7L, 12.419742348374220601176836866763271L);
978
  /* cabs (x,y) == cabs (-y,x).  */
979
  TEST_c_f (cabs, -0.7L, 12.4L, 12.419742348374220601176836866763271L);
980
  /* cabs (x,y) == cabs (-x,-y).  */
981
  TEST_c_f (cabs, -12.4L, -0.7L, 12.419742348374220601176836866763271L);
982
  /* cabs (x,y) == cabs (-y,-x).  */
983
  TEST_c_f (cabs, -0.7L, -12.4L, 12.419742348374220601176836866763271L);
984
  /* cabs (x,0) == fabs (x).  */
985
  TEST_c_f (cabs, -0.7L, 0, 0.7L);
986
  TEST_c_f (cabs, 0.7L, 0, 0.7L);
987
  TEST_c_f (cabs, -1.0L, 0, 1.0L);
988
  TEST_c_f (cabs, 1.0L, 0, 1.0L);
989
  TEST_c_f (cabs, -5.7e7L, 0, 5.7e7L);
990
  TEST_c_f (cabs, 5.7e7L, 0, 5.7e7L);
991
 
992
  TEST_c_f (cabs, 0.7L, 1.2L, 1.3892443989449804508432547041028554L);
993
 
994
  END (cabs);
995
}
996
 
997
#if 0
998
static void
999
cacos_test (void)
1000
{
1001
  errno = 0;
1002
  FUNC(cacos) (BUILD_COMPLEX (0.7L, 1.2L));
1003
  if (errno == ENOSYS)
1004
    /* Function not implemented.  */
1005
    return;
1006
 
1007
  START (cacos);
1008
 
1009
 
1010
  TEST_c_c (cacos, 0, 0, M_PI_2l, minus_zero);
1011
  TEST_c_c (cacos, minus_zero, 0, M_PI_2l, minus_zero);
1012
  TEST_c_c (cacos, minus_zero, minus_zero, M_PI_2l, 0.0);
1013
  TEST_c_c (cacos, 0, minus_zero, M_PI_2l, 0.0);
1014
 
1015
  TEST_c_c (cacos, minus_infty, plus_infty, M_PI_34l, minus_infty);
1016
  TEST_c_c (cacos, minus_infty, minus_infty, M_PI_34l, plus_infty);
1017
 
1018
  TEST_c_c (cacos, plus_infty, plus_infty, M_PI_4l, minus_infty);
1019
  TEST_c_c (cacos, plus_infty, minus_infty, M_PI_4l, plus_infty);
1020
 
1021
  TEST_c_c (cacos, -10.0, plus_infty, M_PI_2l, minus_infty);
1022
  TEST_c_c (cacos, -10.0, minus_infty, M_PI_2l, plus_infty);
1023
  TEST_c_c (cacos, 0, plus_infty, M_PI_2l, minus_infty);
1024
  TEST_c_c (cacos, 0, minus_infty, M_PI_2l, plus_infty);
1025
  TEST_c_c (cacos, 0.1L, plus_infty, M_PI_2l, minus_infty);
1026
  TEST_c_c (cacos, 0.1L, minus_infty, M_PI_2l, plus_infty);
1027
 
1028
  TEST_c_c (cacos, minus_infty, 0, M_PIl, minus_infty);
1029
  TEST_c_c (cacos, minus_infty, minus_zero, M_PIl, plus_infty);
1030
  TEST_c_c (cacos, minus_infty, 100, M_PIl, minus_infty);
1031
  TEST_c_c (cacos, minus_infty, -100, M_PIl, plus_infty);
1032
 
1033
  TEST_c_c (cacos, plus_infty, 0, 0.0, minus_infty);
1034
  TEST_c_c (cacos, plus_infty, minus_zero, 0.0, plus_infty);
1035
  TEST_c_c (cacos, plus_infty, 0.5, 0.0, minus_infty);
1036
  TEST_c_c (cacos, plus_infty, -0.5, 0.0, plus_infty);
1037
 
1038
  TEST_c_c (cacos, plus_infty, nan_value, nan_value, plus_infty, IGNORE_ZERO_INF_SIGN);
1039
  TEST_c_c (cacos, minus_infty, nan_value, nan_value, plus_infty, IGNORE_ZERO_INF_SIGN);
1040
 
1041
  TEST_c_c (cacos, 0, nan_value, M_PI_2l, nan_value);
1042
  TEST_c_c (cacos, minus_zero, nan_value, M_PI_2l, nan_value);
1043
 
1044
  TEST_c_c (cacos, nan_value, plus_infty, nan_value, minus_infty);
1045
  TEST_c_c (cacos, nan_value, minus_infty, nan_value, plus_infty);
1046
 
1047
  TEST_c_c (cacos, 10.5, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
1048
  TEST_c_c (cacos, -10.5, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
1049
 
1050
  TEST_c_c (cacos, nan_value, 0.75, nan_value, nan_value, INVALID_EXCEPTION_OK);
1051
  TEST_c_c (cacos, nan_value, -0.75, nan_value, nan_value, INVALID_EXCEPTION_OK);
1052
 
1053
  TEST_c_c (cacos, nan_value, nan_value, nan_value, nan_value);
1054
 
1055
  TEST_c_c (cacos, 0.7L, 1.2L, 1.1351827477151551088992008271819053L, -1.0927647857577371459105272080819308L);
1056
  TEST_c_c (cacos, -2, -3, 2.1414491111159960199416055713254211L, 1.9833870299165354323470769028940395L);
1057
 
1058
  END (cacos, complex);
1059
}
1060
 
1061
 
1062
static void
1063
cacosh_test (void)
1064
{
1065
  errno = 0;
1066
  FUNC(cacosh) (BUILD_COMPLEX (0.7L, 1.2L));
1067
  if (errno == ENOSYS)
1068
    /* Function not implemented.  */
1069
    return;
1070
 
1071
  START (cacosh);
1072
 
1073
 
1074
  TEST_c_c (cacosh, 0, 0, 0.0, M_PI_2l);
1075
  TEST_c_c (cacosh, minus_zero, 0, 0.0, M_PI_2l);
1076
  TEST_c_c (cacosh, 0, minus_zero, 0.0, -M_PI_2l);
1077
  TEST_c_c (cacosh, minus_zero, minus_zero, 0.0, -M_PI_2l);
1078
  TEST_c_c (cacosh, minus_infty, plus_infty, plus_infty, M_PI_34l);
1079
  TEST_c_c (cacosh, minus_infty, minus_infty, plus_infty, -M_PI_34l);
1080
 
1081
  TEST_c_c (cacosh, plus_infty, plus_infty, plus_infty, M_PI_4l);
1082
  TEST_c_c (cacosh, plus_infty, minus_infty, plus_infty, -M_PI_4l);
1083
 
1084
  TEST_c_c (cacosh, -10.0, plus_infty, plus_infty, M_PI_2l);
1085
  TEST_c_c (cacosh, -10.0, minus_infty, plus_infty, -M_PI_2l);
1086
  TEST_c_c (cacosh, 0, plus_infty, plus_infty, M_PI_2l);
1087
  TEST_c_c (cacosh, 0, minus_infty, plus_infty, -M_PI_2l);
1088
  TEST_c_c (cacosh, 0.1L, plus_infty, plus_infty, M_PI_2l);
1089
  TEST_c_c (cacosh, 0.1L, minus_infty, plus_infty, -M_PI_2l);
1090
 
1091
  TEST_c_c (cacosh, minus_infty, 0, plus_infty, M_PIl);
1092
  TEST_c_c (cacosh, minus_infty, minus_zero, plus_infty, -M_PIl);
1093
  TEST_c_c (cacosh, minus_infty, 100, plus_infty, M_PIl);
1094
  TEST_c_c (cacosh, minus_infty, -100, plus_infty, -M_PIl);
1095
 
1096
  TEST_c_c (cacosh, plus_infty, 0, plus_infty, 0.0);
1097
  TEST_c_c (cacosh, plus_infty, minus_zero, plus_infty, minus_zero);
1098
  TEST_c_c (cacosh, plus_infty, 0.5, plus_infty, 0.0);
1099
  TEST_c_c (cacosh, plus_infty, -0.5, plus_infty, minus_zero);
1100
 
1101
  TEST_c_c (cacosh, plus_infty, nan_value, plus_infty, nan_value);
1102
  TEST_c_c (cacosh, minus_infty, nan_value, plus_infty, nan_value);
1103
 
1104
  TEST_c_c (cacosh, 0, nan_value, nan_value, nan_value);
1105
  TEST_c_c (cacosh, minus_zero, nan_value, nan_value, nan_value);
1106
 
1107
  TEST_c_c (cacosh, nan_value, plus_infty, plus_infty, nan_value);
1108
  TEST_c_c (cacosh, nan_value, minus_infty, plus_infty, nan_value);
1109
 
1110
  TEST_c_c (cacosh, 10.5, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
1111
  TEST_c_c (cacosh, -10.5, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
1112
 
1113
  TEST_c_c (cacosh, nan_value, 0.75, nan_value, nan_value, INVALID_EXCEPTION_OK);
1114
  TEST_c_c (cacosh, nan_value, -0.75, nan_value, nan_value, INVALID_EXCEPTION_OK);
1115
 
1116
  TEST_c_c (cacosh, nan_value, nan_value, nan_value, nan_value);
1117
 
1118
  TEST_c_c (cacosh, 0.7L, 1.2L, 1.0927647857577371459105272080819308L, 1.1351827477151551088992008271819053L);
1119
  TEST_c_c (cacosh, -2, -3, -1.9833870299165354323470769028940395L, 2.1414491111159960199416055713254211L);
1120
 
1121
  END (cacosh, complex);
1122
}
1123
 
1124
static void
1125
carg_test (void)
1126
{
1127
  START (carg);
1128
 
1129
  /* carg (x + iy) is specified as atan2 (y, x) */
1130
 
1131
  /* carg (x + i 0) == 0 for x > 0.  */
1132
  TEST_c_f (carg, 2.0, 0, 0);
1133
  /* carg (x - i 0) == -0 for x > 0.  */
1134
  TEST_c_f (carg, 2.0, minus_zero, minus_zero);
1135
 
1136
  TEST_c_f (carg, 0, 0, 0);
1137
  TEST_c_f (carg, 0, minus_zero, minus_zero);
1138
 
1139
  /* carg (x + i 0) == +pi for x < 0.  */
1140
  TEST_c_f (carg, -2.0, 0, M_PIl);
1141
 
1142
  /* carg (x - i 0) == -pi for x < 0.  */
1143
  TEST_c_f (carg, -2.0, minus_zero, -M_PIl);
1144
 
1145
  TEST_c_f (carg, minus_zero, 0, M_PIl);
1146
  TEST_c_f (carg, minus_zero, minus_zero, -M_PIl);
1147
 
1148
  /* carg (+0 + i y) == pi/2 for y > 0.  */
1149
  TEST_c_f (carg, 0, 2.0, M_PI_2l);
1150
 
1151
  /* carg (-0 + i y) == pi/2 for y > 0.  */
1152
  TEST_c_f (carg, minus_zero, 2.0, M_PI_2l);
1153
 
1154
  /* carg (+0 + i y) == -pi/2 for y < 0.  */
1155
  TEST_c_f (carg, 0, -2.0, -M_PI_2l);
1156
 
1157
  /* carg (-0 + i y) == -pi/2 for y < 0.  */
1158
  TEST_c_f (carg, minus_zero, -2.0, -M_PI_2l);
1159
 
1160
  /* carg (inf + i y) == +0 for finite y > 0.  */
1161
  TEST_c_f (carg, plus_infty, 2.0, 0);
1162
 
1163
  /* carg (inf + i y) == -0 for finite y < 0.  */
1164
  TEST_c_f (carg, plus_infty, -2.0, minus_zero);
1165
 
1166
  /* carg(x + i inf) == pi/2 for finite x.  */
1167
  TEST_c_f (carg, 10.0, plus_infty, M_PI_2l);
1168
 
1169
  /* carg(x - i inf) == -pi/2 for finite x.  */
1170
  TEST_c_f (carg, 10.0, minus_infty, -M_PI_2l);
1171
 
1172
  /* carg (-inf + i y) == +pi for finite y > 0.  */
1173
  TEST_c_f (carg, minus_infty, 10.0, M_PIl);
1174
 
1175
  /* carg (-inf + i y) == -pi for finite y < 0.  */
1176
  TEST_c_f (carg, minus_infty, -10.0, -M_PIl);
1177
 
1178
  TEST_c_f (carg, plus_infty, plus_infty, M_PI_4l);
1179
 
1180
  TEST_c_f (carg, plus_infty, minus_infty, -M_PI_4l);
1181
 
1182
  TEST_c_f (carg, minus_infty, plus_infty, 3 * M_PI_4l);
1183
 
1184
  TEST_c_f (carg, minus_infty, minus_infty, -3 * M_PI_4l);
1185
 
1186
  TEST_c_f (carg, nan_value, nan_value, nan_value);
1187
 
1188
  END (carg);
1189
}
1190
 
1191
static void
1192
casin_test (void)
1193
{
1194
  errno = 0;
1195
  FUNC(casin) (BUILD_COMPLEX (0.7L, 1.2L));
1196
  if (errno == ENOSYS)
1197
    /* Function not implemented.  */
1198
    return;
1199
 
1200
  START (casin);
1201
 
1202
  TEST_c_c (casin, 0, 0, 0.0, 0.0);
1203
  TEST_c_c (casin, minus_zero, 0, minus_zero, 0.0);
1204
  TEST_c_c (casin, 0, minus_zero, 0.0, minus_zero);
1205
  TEST_c_c (casin, minus_zero, minus_zero, minus_zero, minus_zero);
1206
 
1207
  TEST_c_c (casin, plus_infty, plus_infty, M_PI_4l, plus_infty);
1208
  TEST_c_c (casin, plus_infty, minus_infty, M_PI_4l, minus_infty);
1209
  TEST_c_c (casin, minus_infty, plus_infty, -M_PI_4l, plus_infty);
1210
  TEST_c_c (casin, minus_infty, minus_infty, -M_PI_4l, minus_infty);
1211
 
1212
  TEST_c_c (casin, -10.0, plus_infty, minus_zero, plus_infty);
1213
  TEST_c_c (casin, -10.0, minus_infty, minus_zero, minus_infty);
1214
  TEST_c_c (casin, 0, plus_infty, 0.0, plus_infty);
1215
  TEST_c_c (casin, 0, minus_infty, 0.0, minus_infty);
1216
  TEST_c_c (casin, minus_zero, plus_infty, minus_zero, plus_infty);
1217
  TEST_c_c (casin, minus_zero, minus_infty, minus_zero, minus_infty);
1218
  TEST_c_c (casin, 0.1L, plus_infty, 0.0, plus_infty);
1219
  TEST_c_c (casin, 0.1L, minus_infty, 0.0, minus_infty);
1220
 
1221
  TEST_c_c (casin, minus_infty, 0, -M_PI_2l, plus_infty);
1222
  TEST_c_c (casin, minus_infty, minus_zero, -M_PI_2l, minus_infty);
1223
  TEST_c_c (casin, minus_infty, 100, -M_PI_2l, plus_infty);
1224
  TEST_c_c (casin, minus_infty, -100, -M_PI_2l, minus_infty);
1225
 
1226
  TEST_c_c (casin, plus_infty, 0, M_PI_2l, plus_infty);
1227
  TEST_c_c (casin, plus_infty, minus_zero, M_PI_2l, minus_infty);
1228
  TEST_c_c (casin, plus_infty, 0.5, M_PI_2l, plus_infty);
1229
  TEST_c_c (casin, plus_infty, -0.5, M_PI_2l, minus_infty);
1230
 
1231
  TEST_c_c (casin, nan_value, plus_infty, nan_value, plus_infty);
1232
  TEST_c_c (casin, nan_value, minus_infty, nan_value, minus_infty);
1233
 
1234
  TEST_c_c (casin, 0.0, nan_value, 0.0, nan_value);
1235
  TEST_c_c (casin, minus_zero, nan_value, minus_zero, nan_value);
1236
 
1237
  TEST_c_c (casin, plus_infty, nan_value, nan_value, plus_infty, IGNORE_ZERO_INF_SIGN);
1238
  TEST_c_c (casin, minus_infty, nan_value, nan_value, plus_infty, IGNORE_ZERO_INF_SIGN);
1239
 
1240
  TEST_c_c (casin, nan_value, 10.5, nan_value, nan_value, INVALID_EXCEPTION_OK);
1241
  TEST_c_c (casin, nan_value, -10.5, nan_value, nan_value, INVALID_EXCEPTION_OK);
1242
 
1243
  TEST_c_c (casin, 0.75, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
1244
  TEST_c_c (casin, -0.75, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
1245
 
1246
  TEST_c_c (casin, nan_value, nan_value, nan_value, nan_value);
1247
 
1248
  TEST_c_c (casin, 0.7L, 1.2L, 0.4356135790797415103321208644578462L, 1.0927647857577371459105272080819308L);
1249
  TEST_c_c (casin, -2, -3, -0.57065278432109940071028387968566963L, -1.9833870299165354323470769028940395L);
1250
 
1251
  END (casin, complex);
1252
}
1253
 
1254
 
1255
static void
1256
casinh_test (void)
1257
{
1258
  errno = 0;
1259
  FUNC(casinh) (BUILD_COMPLEX (0.7L, 1.2L));
1260
  if (errno == ENOSYS)
1261
    /* Function not implemented.  */
1262
    return;
1263
 
1264
  START (casinh);
1265
 
1266
  TEST_c_c (casinh, 0, 0, 0.0, 0.0);
1267
  TEST_c_c (casinh, minus_zero, 0, minus_zero, 0);
1268
  TEST_c_c (casinh, 0, minus_zero, 0.0, minus_zero);
1269
  TEST_c_c (casinh, minus_zero, minus_zero, minus_zero, minus_zero);
1270
 
1271
  TEST_c_c (casinh, plus_infty, plus_infty, plus_infty, M_PI_4l);
1272
  TEST_c_c (casinh, plus_infty, minus_infty, plus_infty, -M_PI_4l);
1273
  TEST_c_c (casinh, minus_infty, plus_infty, minus_infty, M_PI_4l);
1274
  TEST_c_c (casinh, minus_infty, minus_infty, minus_infty, -M_PI_4l);
1275
 
1276
  TEST_c_c (casinh, -10.0, plus_infty, minus_infty, M_PI_2l);
1277
  TEST_c_c (casinh, -10.0, minus_infty, minus_infty, -M_PI_2l);
1278
  TEST_c_c (casinh, 0, plus_infty, plus_infty, M_PI_2l);
1279
  TEST_c_c (casinh, 0, minus_infty, plus_infty, -M_PI_2l);
1280
  TEST_c_c (casinh, minus_zero, plus_infty, minus_infty, M_PI_2l);
1281
  TEST_c_c (casinh, minus_zero, minus_infty, minus_infty, -M_PI_2l);
1282
  TEST_c_c (casinh, 0.1L, plus_infty, plus_infty, M_PI_2l);
1283
  TEST_c_c (casinh, 0.1L, minus_infty, plus_infty, -M_PI_2l);
1284
 
1285
  TEST_c_c (casinh, minus_infty, 0, minus_infty, 0.0);
1286
  TEST_c_c (casinh, minus_infty, minus_zero, minus_infty, minus_zero);
1287
  TEST_c_c (casinh, minus_infty, 100, minus_infty, 0.0);
1288
  TEST_c_c (casinh, minus_infty, -100, minus_infty, minus_zero);
1289
 
1290
  TEST_c_c (casinh, plus_infty, 0, plus_infty, 0.0);
1291
  TEST_c_c (casinh, plus_infty, minus_zero, plus_infty, minus_zero);
1292
  TEST_c_c (casinh, plus_infty, 0.5, plus_infty, 0.0);
1293
  TEST_c_c (casinh, plus_infty, -0.5, plus_infty, minus_zero);
1294
 
1295
  TEST_c_c (casinh, plus_infty, nan_value, plus_infty, nan_value);
1296
  TEST_c_c (casinh, minus_infty, nan_value, minus_infty, nan_value);
1297
 
1298
  TEST_c_c (casinh, nan_value, 0, nan_value, 0.0);
1299
  TEST_c_c (casinh, nan_value, minus_zero, nan_value, minus_zero);
1300
 
1301
  TEST_c_c (casinh, nan_value, plus_infty, plus_infty, nan_value, IGNORE_ZERO_INF_SIGN);
1302
  TEST_c_c (casinh, nan_value, minus_infty, plus_infty, nan_value, IGNORE_ZERO_INF_SIGN);
1303
 
1304
  TEST_c_c (casinh, 10.5, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
1305
  TEST_c_c (casinh, -10.5, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
1306
 
1307
  TEST_c_c (casinh, nan_value, 0.75, nan_value, nan_value, INVALID_EXCEPTION_OK);
1308
  TEST_c_c (casinh, -0.75, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
1309
 
1310
  TEST_c_c (casinh, nan_value, nan_value, nan_value, nan_value);
1311
 
1312
  TEST_c_c (casinh, 0.7L, 1.2L, 0.97865459559367387689317593222160964L, 0.91135418953156011567903546856170941L);
1313
  TEST_c_c (casinh, -2, -3, -1.9686379257930962917886650952454982L, -0.96465850440760279204541105949953237L);
1314
 
1315
  END (casinh, complex);
1316
}
1317
 
1318
 
1319
static void
1320
catan_test (void)
1321
{
1322
  errno = 0;
1323
  FUNC(catan) (BUILD_COMPLEX (0.7L, 1.2L));
1324
  if (errno == ENOSYS)
1325
    /* Function not implemented.  */
1326
    return;
1327
 
1328
  START (catan);
1329
 
1330
  TEST_c_c (catan, 0, 0, 0, 0);
1331
  TEST_c_c (catan, minus_zero, 0, minus_zero, 0);
1332
  TEST_c_c (catan, 0, minus_zero, 0, minus_zero);
1333
  TEST_c_c (catan, minus_zero, minus_zero, minus_zero, minus_zero);
1334
 
1335
  TEST_c_c (catan, plus_infty, plus_infty, M_PI_2l, 0);
1336
  TEST_c_c (catan, plus_infty, minus_infty, M_PI_2l, minus_zero);
1337
  TEST_c_c (catan, minus_infty, plus_infty, -M_PI_2l, 0);
1338
  TEST_c_c (catan, minus_infty, minus_infty, -M_PI_2l, minus_zero);
1339
 
1340
 
1341
  TEST_c_c (catan, plus_infty, -10.0, M_PI_2l, minus_zero);
1342
  TEST_c_c (catan, minus_infty, -10.0, -M_PI_2l, minus_zero);
1343
  TEST_c_c (catan, plus_infty, minus_zero, M_PI_2l, minus_zero);
1344
  TEST_c_c (catan, minus_infty, minus_zero, -M_PI_2l, minus_zero);
1345
  TEST_c_c (catan, plus_infty, 0.0, M_PI_2l, 0);
1346
  TEST_c_c (catan, minus_infty, 0.0, -M_PI_2l, 0);
1347
  TEST_c_c (catan, plus_infty, 0.1L, M_PI_2l, 0);
1348
  TEST_c_c (catan, minus_infty, 0.1L, -M_PI_2l, 0);
1349
 
1350
  TEST_c_c (catan, 0.0, minus_infty, M_PI_2l, minus_zero);
1351
  TEST_c_c (catan, minus_zero, minus_infty, -M_PI_2l, minus_zero);
1352
  TEST_c_c (catan, 100.0, minus_infty, M_PI_2l, minus_zero);
1353
  TEST_c_c (catan, -100.0, minus_infty, -M_PI_2l, minus_zero);
1354
 
1355
  TEST_c_c (catan, 0.0, plus_infty, M_PI_2l, 0);
1356
  TEST_c_c (catan, minus_zero, plus_infty, -M_PI_2l, 0);
1357
  TEST_c_c (catan, 0.5, plus_infty, M_PI_2l, 0);
1358
  TEST_c_c (catan, -0.5, plus_infty, -M_PI_2l, 0);
1359
 
1360
  TEST_c_c (catan, nan_value, 0.0, nan_value, 0);
1361
  TEST_c_c (catan, nan_value, minus_zero, nan_value, minus_zero);
1362
 
1363
  TEST_c_c (catan, nan_value, plus_infty, nan_value, 0);
1364
  TEST_c_c (catan, nan_value, minus_infty, nan_value, minus_zero);
1365
 
1366
  TEST_c_c (catan, 0.0, nan_value, nan_value, nan_value);
1367
  TEST_c_c (catan, minus_zero, nan_value, nan_value, nan_value);
1368
 
1369
  TEST_c_c (catan, plus_infty, nan_value, M_PI_2l, 0, IGNORE_ZERO_INF_SIGN);
1370
  TEST_c_c (catan, minus_infty, nan_value, -M_PI_2l, 0, IGNORE_ZERO_INF_SIGN);
1371
 
1372
  TEST_c_c (catan, nan_value, 10.5, nan_value, nan_value, INVALID_EXCEPTION_OK);
1373
  TEST_c_c (catan, nan_value, -10.5, nan_value, nan_value, INVALID_EXCEPTION_OK);
1374
 
1375
  TEST_c_c (catan, 0.75, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
1376
  TEST_c_c (catan, -0.75, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
1377
 
1378
  TEST_c_c (catan, nan_value, nan_value, nan_value, nan_value);
1379
 
1380
  TEST_c_c (catan, 0.7L, 1.2L, 1.0785743834118921877443707996386368L, 0.57705737765343067644394541889341712L);
1381
 
1382
  TEST_c_c (catan, -2, -3, -1.4099210495965755225306193844604208L, -0.22907268296853876629588180294200276L);
1383
 
1384
  END (catan, complex);
1385
}
1386
 
1387
static void
1388
catanh_test (void)
1389
{
1390
  errno = 0;
1391
  FUNC(catanh) (BUILD_COMPLEX (0.7L, 1.2L));
1392
  if (errno == ENOSYS)
1393
    /* Function not implemented.  */
1394
    return;
1395
 
1396
  START (catanh);
1397
 
1398
  TEST_c_c (catanh, 0, 0, 0.0, 0.0);
1399
  TEST_c_c (catanh, minus_zero, 0, minus_zero, 0.0);
1400
  TEST_c_c (catanh, 0, minus_zero, 0.0, minus_zero);
1401
  TEST_c_c (catanh, minus_zero, minus_zero, minus_zero, minus_zero);
1402
 
1403
  TEST_c_c (catanh, plus_infty, plus_infty, 0.0, M_PI_2l);
1404
  TEST_c_c (catanh, plus_infty, minus_infty, 0.0, -M_PI_2l);
1405
  TEST_c_c (catanh, minus_infty, plus_infty, minus_zero, M_PI_2l);
1406
  TEST_c_c (catanh, minus_infty, minus_infty, minus_zero, -M_PI_2l);
1407
 
1408
  TEST_c_c (catanh, -10.0, plus_infty, minus_zero, M_PI_2l);
1409
  TEST_c_c (catanh, -10.0, minus_infty, minus_zero, -M_PI_2l);
1410
  TEST_c_c (catanh, minus_zero, plus_infty, minus_zero, M_PI_2l);
1411
  TEST_c_c (catanh, minus_zero, minus_infty, minus_zero, -M_PI_2l);
1412
  TEST_c_c (catanh, 0, plus_infty, 0.0, M_PI_2l);
1413
  TEST_c_c (catanh, 0, minus_infty, 0.0, -M_PI_2l);
1414
  TEST_c_c (catanh, 0.1L, plus_infty, 0.0, M_PI_2l);
1415
  TEST_c_c (catanh, 0.1L, minus_infty, 0.0, -M_PI_2l);
1416
 
1417
  TEST_c_c (catanh, minus_infty, 0, minus_zero, M_PI_2l);
1418
  TEST_c_c (catanh, minus_infty, minus_zero, minus_zero, -M_PI_2l);
1419
  TEST_c_c (catanh, minus_infty, 100, minus_zero, M_PI_2l);
1420
  TEST_c_c (catanh, minus_infty, -100, minus_zero, -M_PI_2l);
1421
 
1422
  TEST_c_c (catanh, plus_infty, 0, 0.0, M_PI_2l);
1423
  TEST_c_c (catanh, plus_infty, minus_zero, 0.0, -M_PI_2l);
1424
  TEST_c_c (catanh, plus_infty, 0.5, 0.0, M_PI_2l);
1425
  TEST_c_c (catanh, plus_infty, -0.5, 0.0, -M_PI_2l);
1426
 
1427
  TEST_c_c (catanh, 0, nan_value, 0.0, nan_value);
1428
  TEST_c_c (catanh, minus_zero, nan_value, minus_zero, nan_value);
1429
 
1430
  TEST_c_c (catanh, plus_infty, nan_value, 0.0, nan_value);
1431
  TEST_c_c (catanh, minus_infty, nan_value, minus_zero, nan_value);
1432
 
1433
  TEST_c_c (catanh, nan_value, 0, nan_value, nan_value);
1434
  TEST_c_c (catanh, nan_value, minus_zero, nan_value, nan_value);
1435
 
1436
  TEST_c_c (catanh, nan_value, plus_infty, 0.0, M_PI_2l, IGNORE_ZERO_INF_SIGN);
1437
  TEST_c_c (catanh, nan_value, minus_infty, 0.0, -M_PI_2l, IGNORE_ZERO_INF_SIGN);
1438
 
1439
  TEST_c_c (catanh, 10.5, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
1440
  TEST_c_c (catanh, -10.5, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
1441
 
1442
  TEST_c_c (catanh, nan_value, 0.75, nan_value, nan_value, INVALID_EXCEPTION_OK);
1443
  TEST_c_c (catanh, nan_value, -0.75, nan_value, nan_value, INVALID_EXCEPTION_OK);
1444
 
1445
  TEST_c_c (catanh, nan_value, nan_value, nan_value, nan_value);
1446
 
1447
  TEST_c_c (catanh, 0.7L, 1.2L, 0.2600749516525135959200648705635915L, 0.97024030779509898497385130162655963L);
1448
  TEST_c_c (catanh, -2, -3, -0.14694666622552975204743278515471595L, -1.3389725222944935611241935759091443L);
1449
 
1450
  END (catanh, complex);
1451
}
1452
#endif
1453
 
1454
static void
1455
cbrt_test (void)
1456
{
1457
  errno = 0;
1458
  FUNC(cbrt) (8);
1459
  if (errno == ENOSYS)
1460
    /* Function not implemented.  */
1461
    return;
1462
 
1463
  START (cbrt);
1464
 
1465
  TEST_f_f (cbrt, 0.0, 0.0);
1466
  TEST_f_f (cbrt, minus_zero, minus_zero);
1467
 
1468
  TEST_f_f (cbrt, plus_infty, plus_infty);
1469
  TEST_f_f (cbrt, minus_infty, minus_infty);
1470
  TEST_f_f (cbrt, nan_value, nan_value);
1471
 
1472
  TEST_f_f (cbrt, -0.001L, -0.1L);
1473
  TEST_f_f (cbrt, 8, 2);
1474
  TEST_f_f (cbrt, -27.0, -3.0);
1475
  TEST_f_f (cbrt, 0.970299L, 0.99L);
1476
  TEST_f_f (cbrt, 0.7L, 0.8879040017426007084L);
1477
 
1478
  END (cbrt);
1479
}
1480
 
1481
#if 0
1482
static void
1483
ccos_test (void)
1484
{
1485
  errno = 0;
1486
  FUNC(ccos) (BUILD_COMPLEX (0, 0));
1487
  if (errno == ENOSYS)
1488
    /* Function not implemented.  */
1489
    return;
1490
 
1491
  START (ccos);
1492
 
1493
  TEST_c_c (ccos, 0.0, 0.0, 1.0, minus_zero);
1494
  TEST_c_c (ccos, minus_zero, 0.0, 1.0, 0.0);
1495
  TEST_c_c (ccos, 0.0, minus_zero, 1.0, 0.0);
1496
  TEST_c_c (ccos, minus_zero, minus_zero, 1.0, minus_zero);
1497
 
1498
  TEST_c_c (ccos, plus_infty, 0.0, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
1499
  TEST_c_c (ccos, plus_infty, minus_zero, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
1500
  TEST_c_c (ccos, minus_infty, 0.0, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
1501
  TEST_c_c (ccos, minus_infty, minus_zero, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
1502
 
1503
  TEST_c_c (ccos, 0.0, plus_infty, plus_infty, minus_zero);
1504
  TEST_c_c (ccos, 0.0, minus_infty, plus_infty, 0.0);
1505
  TEST_c_c (ccos, minus_zero, plus_infty, plus_infty, 0.0);
1506
  TEST_c_c (ccos, minus_zero, minus_infty, plus_infty, minus_zero);
1507
 
1508
  TEST_c_c (ccos, plus_infty, plus_infty, plus_infty, nan_value, INVALID_EXCEPTION);
1509
  TEST_c_c (ccos, minus_infty, plus_infty, plus_infty, nan_value, INVALID_EXCEPTION);
1510
  TEST_c_c (ccos, plus_infty, minus_infty, plus_infty, nan_value, INVALID_EXCEPTION);
1511
  TEST_c_c (ccos, minus_infty, minus_infty, plus_infty, nan_value, INVALID_EXCEPTION);
1512
 
1513
  TEST_c_c (ccos, 4.625, plus_infty, minus_infty, plus_infty);
1514
  TEST_c_c (ccos, 4.625, minus_infty, minus_infty, minus_infty);
1515
  TEST_c_c (ccos, -4.625, plus_infty, minus_infty, minus_infty);
1516
  TEST_c_c (ccos, -4.625, minus_infty, minus_infty, plus_infty);
1517
 
1518
  TEST_c_c (ccos, plus_infty, 6.75, nan_value, nan_value, INVALID_EXCEPTION);
1519
  TEST_c_c (ccos, plus_infty, -6.75, nan_value, nan_value, INVALID_EXCEPTION);
1520
  TEST_c_c (ccos, minus_infty, 6.75, nan_value, nan_value, INVALID_EXCEPTION);
1521
  TEST_c_c (ccos, minus_infty, -6.75, nan_value, nan_value, INVALID_EXCEPTION);
1522
 
1523
  TEST_c_c (ccos, nan_value, 0.0, nan_value, 0.0, IGNORE_ZERO_INF_SIGN);
1524
  TEST_c_c (ccos, nan_value, minus_zero, nan_value, 0.0, IGNORE_ZERO_INF_SIGN);
1525
 
1526
  TEST_c_c (ccos, nan_value, plus_infty, plus_infty, nan_value);
1527
  TEST_c_c (ccos, nan_value, minus_infty, plus_infty, nan_value);
1528
 
1529
  TEST_c_c (ccos, nan_value, 9.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
1530
  TEST_c_c (ccos, nan_value, -9.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
1531
 
1532
  TEST_c_c (ccos, 0.0, nan_value, nan_value, 0.0, IGNORE_ZERO_INF_SIGN);
1533
  TEST_c_c (ccos, minus_zero, nan_value, nan_value, 0.0, IGNORE_ZERO_INF_SIGN);
1534
 
1535
  TEST_c_c (ccos, 10.0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
1536
  TEST_c_c (ccos, -10.0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
1537
 
1538
  TEST_c_c (ccos, plus_infty, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
1539
  TEST_c_c (ccos, minus_infty, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
1540
 
1541
  TEST_c_c (ccos, nan_value, nan_value, nan_value, nan_value);
1542
 
1543
  TEST_c_c (ccos, 0.7L, 1.2L, 1.3848657645312111080L, -0.97242170335830028619L);
1544
 
1545
  TEST_c_c (ccos, -2, -3, -4.1896256909688072301L, -9.1092278937553365979L);
1546
 
1547
  END (ccos, complex);
1548
}
1549
 
1550
 
1551
static void
1552
ccosh_test (void)
1553
{
1554
  errno = 0;
1555
  FUNC(ccosh) (BUILD_COMPLEX (0.7L, 1.2L));
1556
  if (errno == ENOSYS)
1557
    /* Function not implemented.  */
1558
    return;
1559
 
1560
  START (ccosh);
1561
 
1562
  TEST_c_c (ccosh, 0.0, 0.0, 1.0, 0.0);
1563
  TEST_c_c (ccosh, minus_zero, 0.0, 1.0, minus_zero);
1564
  TEST_c_c (ccosh, 0.0, minus_zero, 1.0, minus_zero);
1565
  TEST_c_c (ccosh, minus_zero, minus_zero, 1.0, 0.0);
1566
 
1567
  TEST_c_c (ccosh, 0.0, plus_infty, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
1568
  TEST_c_c (ccosh, minus_zero, plus_infty, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
1569
  TEST_c_c (ccosh, 0.0, minus_infty, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
1570
  TEST_c_c (ccosh, minus_zero, minus_infty, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
1571
 
1572
  TEST_c_c (ccosh, plus_infty, 0.0, plus_infty, 0.0);
1573
  TEST_c_c (ccosh, minus_infty, 0.0, plus_infty, minus_zero);
1574
  TEST_c_c (ccosh, plus_infty, minus_zero, plus_infty, minus_zero);
1575
  TEST_c_c (ccosh, minus_infty, minus_zero, plus_infty, 0.0);
1576
 
1577
  TEST_c_c (ccosh, plus_infty, plus_infty, plus_infty, nan_value, INVALID_EXCEPTION);
1578
  TEST_c_c (ccosh, minus_infty, plus_infty, plus_infty, nan_value, INVALID_EXCEPTION);
1579
  TEST_c_c (ccosh, plus_infty, minus_infty, plus_infty, nan_value, INVALID_EXCEPTION);
1580
  TEST_c_c (ccosh, minus_infty, minus_infty, plus_infty, nan_value, INVALID_EXCEPTION);
1581
 
1582
  TEST_c_c (ccosh, plus_infty, 4.625, minus_infty, minus_infty);
1583
  TEST_c_c (ccosh, minus_infty, 4.625, minus_infty, plus_infty);
1584
  TEST_c_c (ccosh, plus_infty, -4.625, minus_infty, plus_infty);
1585
  TEST_c_c (ccosh, minus_infty, -4.625, minus_infty, minus_infty);
1586
 
1587
  TEST_c_c (ccosh, 6.75, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
1588
  TEST_c_c (ccosh, -6.75, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
1589
  TEST_c_c (ccosh, 6.75, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
1590
  TEST_c_c (ccosh, -6.75, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
1591
 
1592
  TEST_c_c (ccosh, 0.0, nan_value, nan_value, 0.0, IGNORE_ZERO_INF_SIGN);
1593
  TEST_c_c (ccosh, minus_zero, nan_value, nan_value, 0.0, IGNORE_ZERO_INF_SIGN);
1594
 
1595
  TEST_c_c (ccosh, plus_infty, nan_value, plus_infty, nan_value);
1596
  TEST_c_c (ccosh, minus_infty, nan_value, plus_infty, nan_value);
1597
 
1598
  TEST_c_c (ccosh, 9.0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
1599
  TEST_c_c (ccosh, -9.0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
1600
 
1601
  TEST_c_c (ccosh, nan_value, 0.0, nan_value, 0.0, IGNORE_ZERO_INF_SIGN);
1602
  TEST_c_c (ccosh, nan_value, minus_zero, nan_value, 0.0, IGNORE_ZERO_INF_SIGN);
1603
 
1604
  TEST_c_c (ccosh, nan_value, 10.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
1605
  TEST_c_c (ccosh, nan_value, -10.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
1606
 
1607
  TEST_c_c (ccosh, nan_value, plus_infty, nan_value, nan_value, INVALID_EXCEPTION_OK);
1608
  TEST_c_c (ccosh, nan_value, minus_infty, nan_value, nan_value, INVALID_EXCEPTION_OK);
1609
 
1610
  TEST_c_c (ccosh, nan_value, nan_value, nan_value, nan_value);
1611
 
1612
  TEST_c_c (ccosh, 0.7L, 1.2L, 0.4548202223691477654L, 0.7070296600921537682L);
1613
 
1614
  TEST_c_c (ccosh, -2, -3, -3.7245455049153225654L, 0.5118225699873846088L);
1615
 
1616
  END (ccosh, complex);
1617
}
1618
#endif
1619
 
1620
static void
1621
ceil_test (void)
1622
{
1623
  START (ceil);
1624
 
1625
  TEST_f_f (ceil, 0.0, 0.0);
1626
  TEST_f_f (ceil, minus_zero, minus_zero);
1627
  TEST_f_f (ceil, plus_infty, plus_infty);
1628
  TEST_f_f (ceil, minus_infty, minus_infty);
1629
  TEST_f_f (ceil, nan_value, nan_value);
1630
 
1631
  TEST_f_f (ceil, M_PIl, 4.0);
1632
  TEST_f_f (ceil, -M_PIl, -3.0);
1633
 
1634
  END (ceil);
1635
}
1636
 
1637
#if 0
1638
static void
1639
cexp_test (void)
1640
{
1641
  errno = 0;
1642
  FUNC(cexp) (BUILD_COMPLEX (0, 0));
1643
  if (errno == ENOSYS)
1644
    /* Function not implemented.  */
1645
    return;
1646
 
1647
  START (cexp);
1648
 
1649
  TEST_c_c (cexp, plus_zero, plus_zero, 1, 0.0);
1650
  TEST_c_c (cexp, minus_zero, plus_zero, 1, 0.0);
1651
  TEST_c_c (cexp, plus_zero, minus_zero, 1, minus_zero);
1652
  TEST_c_c (cexp, minus_zero, minus_zero, 1, minus_zero);
1653
 
1654
  TEST_c_c (cexp, plus_infty, plus_zero, plus_infty, 0.0);
1655
  TEST_c_c (cexp, plus_infty, minus_zero, plus_infty, minus_zero);
1656
 
1657
  TEST_c_c (cexp, minus_infty, plus_zero, 0.0, 0.0);
1658
  TEST_c_c (cexp, minus_infty, minus_zero, 0.0, minus_zero);
1659
 
1660
  TEST_c_c (cexp, 0.0, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
1661
  TEST_c_c (cexp, minus_zero, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
1662
 
1663
  TEST_c_c (cexp, 0.0, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
1664
  TEST_c_c (cexp, minus_zero, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
1665
 
1666
  TEST_c_c (cexp, 100.0, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
1667
  TEST_c_c (cexp, -100.0, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
1668
 
1669
  TEST_c_c (cexp, 100.0, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
1670
  TEST_c_c (cexp, -100.0, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
1671
 
1672
  TEST_c_c (cexp, minus_infty, 2.0, minus_zero, 0.0);
1673
  TEST_c_c (cexp, minus_infty, 4.0, minus_zero, minus_zero);
1674
  TEST_c_c (cexp, plus_infty, 2.0, minus_infty, plus_infty);
1675
  TEST_c_c (cexp, plus_infty, 4.0, minus_infty, minus_infty);
1676
 
1677
  TEST_c_c (cexp, plus_infty, plus_infty, plus_infty, nan_value, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
1678
  TEST_c_c (cexp, plus_infty, minus_infty, plus_infty, nan_value, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
1679
 
1680
  TEST_c_c (cexp, minus_infty, plus_infty, 0.0, 0.0, IGNORE_ZERO_INF_SIGN);
1681
  TEST_c_c (cexp, minus_infty, minus_infty, 0.0, minus_zero, IGNORE_ZERO_INF_SIGN);
1682
 
1683
  TEST_c_c (cexp, minus_infty, nan_value, 0, 0, IGNORE_ZERO_INF_SIGN);
1684
 
1685
  TEST_c_c (cexp, plus_infty, nan_value, plus_infty, nan_value);
1686
 
1687
  TEST_c_c (cexp, nan_value, 0.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
1688
  TEST_c_c (cexp, nan_value, 1.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
1689
 
1690
  TEST_c_c (cexp, nan_value, plus_infty, nan_value, nan_value, INVALID_EXCEPTION_OK);
1691
  TEST_c_c (cexp, 0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
1692
  TEST_c_c (cexp, 1, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
1693
  TEST_c_c (cexp, nan_value, nan_value, nan_value, nan_value);
1694
 
1695
  TEST_c_c (cexp, 0.7L, 1.2L, 0.72969890915032360123451688642930727L, 1.8768962328348102821139467908203072L);
1696
  TEST_c_c (cexp, -2.0, -3.0, -0.13398091492954261346140525546115575L, -0.019098516261135196432576240858800925L);
1697
 
1698
  END (cexp, complex);
1699
}
1700
 
1701
static void
1702
cimag_test (void)
1703
{
1704
  START (cimag);
1705
  TEST_c_f (cimag, 1.0, 0.0, 0.0);
1706
  TEST_c_f (cimag, 1.0, minus_zero, minus_zero);
1707
  TEST_c_f (cimag, 1.0, nan_value, nan_value);
1708
  TEST_c_f (cimag, nan_value, nan_value, nan_value);
1709
  TEST_c_f (cimag, 1.0, plus_infty, plus_infty);
1710
  TEST_c_f (cimag, 1.0, minus_infty, minus_infty);
1711
  TEST_c_f (cimag, 2.0, 3.0, 3.0);
1712
 
1713
  END (cimag);
1714
}
1715
 
1716
static void
1717
clog_test (void)
1718
{
1719
  errno = 0;
1720
  FUNC(clog) (BUILD_COMPLEX (-2, -3));
1721
  if (errno == ENOSYS)
1722
    /* Function not implemented.  */
1723
    return;
1724
 
1725
  START (clog);
1726
 
1727
  TEST_c_c (clog, minus_zero, 0, minus_infty, M_PIl, DIVIDE_BY_ZERO_EXCEPTION);
1728
  TEST_c_c (clog, minus_zero, minus_zero, minus_infty, -M_PIl, DIVIDE_BY_ZERO_EXCEPTION);
1729
 
1730
  TEST_c_c (clog, 0, 0, minus_infty, 0.0, DIVIDE_BY_ZERO_EXCEPTION);
1731
  TEST_c_c (clog, 0, minus_zero, minus_infty, minus_zero, DIVIDE_BY_ZERO_EXCEPTION);
1732
 
1733
  TEST_c_c (clog, minus_infty, plus_infty, plus_infty, M_PI_34l);
1734
  TEST_c_c (clog, minus_infty, minus_infty, plus_infty, -M_PI_34l);
1735
 
1736
  TEST_c_c (clog, plus_infty, plus_infty, plus_infty, M_PI_4l);
1737
  TEST_c_c (clog, plus_infty, minus_infty, plus_infty, -M_PI_4l);
1738
 
1739
  TEST_c_c (clog, 0, plus_infty, plus_infty, M_PI_2l);
1740
  TEST_c_c (clog, 3, plus_infty, plus_infty, M_PI_2l);
1741
  TEST_c_c (clog, minus_zero, plus_infty, plus_infty, M_PI_2l);
1742
  TEST_c_c (clog, -3, plus_infty, plus_infty, M_PI_2l);
1743
  TEST_c_c (clog, 0, minus_infty, plus_infty, -M_PI_2l);
1744
  TEST_c_c (clog, 3, minus_infty, plus_infty, -M_PI_2l);
1745
  TEST_c_c (clog, minus_zero, minus_infty, plus_infty, -M_PI_2l);
1746
  TEST_c_c (clog, -3, minus_infty, plus_infty, -M_PI_2l);
1747
 
1748
  TEST_c_c (clog, minus_infty, 0, plus_infty, M_PIl);
1749
  TEST_c_c (clog, minus_infty, 1, plus_infty, M_PIl);
1750
  TEST_c_c (clog, minus_infty, minus_zero, plus_infty, -M_PIl);
1751
  TEST_c_c (clog, minus_infty, -1, plus_infty, -M_PIl);
1752
 
1753
  TEST_c_c (clog, plus_infty, 0, plus_infty, 0.0);
1754
  TEST_c_c (clog, plus_infty, 1, plus_infty, 0.0);
1755
  TEST_c_c (clog, plus_infty, minus_zero, plus_infty, minus_zero);
1756
  TEST_c_c (clog, plus_infty, -1, plus_infty, minus_zero);
1757
 
1758
  TEST_c_c (clog, plus_infty, nan_value, plus_infty, nan_value);
1759
  TEST_c_c (clog, minus_infty, nan_value, plus_infty, nan_value);
1760
 
1761
  TEST_c_c (clog, nan_value, plus_infty, plus_infty, nan_value);
1762
  TEST_c_c (clog, nan_value, minus_infty, plus_infty, nan_value);
1763
 
1764
  TEST_c_c (clog, 0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
1765
  TEST_c_c (clog, 3, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
1766
  TEST_c_c (clog, minus_zero, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
1767
  TEST_c_c (clog, -3, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
1768
 
1769
  TEST_c_c (clog, nan_value, 0, nan_value, nan_value, INVALID_EXCEPTION_OK);
1770
  TEST_c_c (clog, nan_value, 5, nan_value, nan_value, INVALID_EXCEPTION_OK);
1771
  TEST_c_c (clog, nan_value, minus_zero, nan_value, nan_value, INVALID_EXCEPTION_OK);
1772
  TEST_c_c (clog, nan_value, -5, nan_value, nan_value, INVALID_EXCEPTION_OK);
1773
 
1774
  TEST_c_c (clog, nan_value, nan_value, nan_value, nan_value);
1775
  TEST_c_c (clog, -2, -3, 1.2824746787307683680267437207826593L, -2.1587989303424641704769327722648368L);
1776
 
1777
  END (clog, complex);
1778
}
1779
 
1780
 
1781
static void
1782
clog10_test (void)
1783
{
1784
  errno = 0;
1785
  FUNC(clog10) (BUILD_COMPLEX (0.7L, 1.2L));
1786
  if (errno == ENOSYS)
1787
    /* Function not implemented.  */
1788
    return;
1789
 
1790
  START (clog10);
1791
 
1792
  TEST_c_c (clog10, minus_zero, 0, minus_infty, M_PIl, DIVIDE_BY_ZERO_EXCEPTION);
1793
  TEST_c_c (clog10, minus_zero, minus_zero, minus_infty, -M_PIl, DIVIDE_BY_ZERO_EXCEPTION);
1794
 
1795
  TEST_c_c (clog10, 0, 0, minus_infty, 0.0, DIVIDE_BY_ZERO_EXCEPTION);
1796
  TEST_c_c (clog10, 0, minus_zero, minus_infty, minus_zero, DIVIDE_BY_ZERO_EXCEPTION);
1797
 
1798
  TEST_c_c (clog10, minus_infty, plus_infty, plus_infty, M_PI_34_LOG10El);
1799
 
1800
  TEST_c_c (clog10, plus_infty, plus_infty, plus_infty, M_PI4_LOG10El);
1801
  TEST_c_c (clog10, plus_infty, minus_infty, plus_infty, -M_PI4_LOG10El);
1802
 
1803
  TEST_c_c (clog10, 0, plus_infty, plus_infty, M_PI2_LOG10El);
1804
  TEST_c_c (clog10, 3, plus_infty, plus_infty, M_PI2_LOG10El);
1805
  TEST_c_c (clog10, minus_zero, plus_infty, plus_infty, M_PI2_LOG10El);
1806
  TEST_c_c (clog10, -3, plus_infty, plus_infty, M_PI2_LOG10El);
1807
  TEST_c_c (clog10, 0, minus_infty, plus_infty, -M_PI2_LOG10El);
1808
  TEST_c_c (clog10, 3, minus_infty, plus_infty, -M_PI2_LOG10El);
1809
  TEST_c_c (clog10, minus_zero, minus_infty, plus_infty, -M_PI2_LOG10El);
1810
  TEST_c_c (clog10, -3, minus_infty, plus_infty, -M_PI2_LOG10El);
1811
 
1812
  TEST_c_c (clog10, minus_infty, 0, plus_infty, M_PI_LOG10El);
1813
  TEST_c_c (clog10, minus_infty, 1, plus_infty, M_PI_LOG10El);
1814
  TEST_c_c (clog10, minus_infty, minus_zero, plus_infty, -M_PI_LOG10El);
1815
  TEST_c_c (clog10, minus_infty, -1, plus_infty, -M_PI_LOG10El);
1816
 
1817
  TEST_c_c (clog10, plus_infty, 0, plus_infty, 0.0);
1818
  TEST_c_c (clog10, plus_infty, 1, plus_infty, 0.0);
1819
  TEST_c_c (clog10, plus_infty, minus_zero, plus_infty, minus_zero);
1820
  TEST_c_c (clog10, plus_infty, -1, plus_infty, minus_zero);
1821
 
1822
  TEST_c_c (clog10, plus_infty, nan_value, plus_infty, nan_value);
1823
  TEST_c_c (clog10, minus_infty, nan_value, plus_infty, nan_value);
1824
 
1825
  TEST_c_c (clog10, nan_value, plus_infty, plus_infty, nan_value);
1826
  TEST_c_c (clog10, nan_value, minus_infty, plus_infty, nan_value);
1827
 
1828
  TEST_c_c (clog10, 0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
1829
  TEST_c_c (clog10, 3, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
1830
  TEST_c_c (clog10, minus_zero, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
1831
  TEST_c_c (clog10, -3, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
1832
 
1833
  TEST_c_c (clog10, nan_value, 0, nan_value, nan_value, INVALID_EXCEPTION_OK);
1834
  TEST_c_c (clog10, nan_value, 5, nan_value, nan_value, INVALID_EXCEPTION_OK);
1835
  TEST_c_c (clog10, nan_value, minus_zero, nan_value, nan_value, INVALID_EXCEPTION_OK);
1836
  TEST_c_c (clog10, nan_value, -5, nan_value, nan_value, INVALID_EXCEPTION_OK);
1837
 
1838
  TEST_c_c (clog10, nan_value, nan_value, nan_value, nan_value);
1839
 
1840
  TEST_c_c (clog10, 0.7L, 1.2L, 0.1427786545038868803L, 0.4528483579352493248L);
1841
  TEST_c_c (clog10, -2, -3, 0.5569716761534183846L, -0.9375544629863747085L);
1842
 
1843
  END (clog10, complex);
1844
}
1845
#endif
1846
 
1847
static void
1848
conj_test (void)
1849
{
1850
  START (conj);
1851
  TEST_c_c (conj, 0.0, 0.0, 0.0, minus_zero);
1852
  TEST_c_c (conj, 0.0, minus_zero, 0.0, 0.0);
1853
  TEST_c_c (conj, nan_value, nan_value, nan_value, nan_value);
1854
  TEST_c_c (conj, plus_infty, minus_infty, plus_infty, plus_infty);
1855
  TEST_c_c (conj, plus_infty, plus_infty, plus_infty, minus_infty);
1856
  TEST_c_c (conj, 1.0, 2.0, 1.0, -2.0);
1857
  TEST_c_c (conj, 3.0, -4.0, 3.0, 4.0);
1858
 
1859
  END (conj, complex);
1860
}
1861
 
1862
 
1863
static void
1864
copysign_test (void)
1865
{
1866
  START (copysign);
1867
 
1868
  TEST_ff_f (copysign, 0, 4, 0);
1869
  TEST_ff_f (copysign, 0, -4, minus_zero);
1870
  TEST_ff_f (copysign, minus_zero, 4, 0);
1871
  TEST_ff_f (copysign, minus_zero, -4, minus_zero);
1872
 
1873
  TEST_ff_f (copysign, plus_infty, 0, plus_infty);
1874
  TEST_ff_f (copysign, plus_infty, minus_zero, minus_infty);
1875
  TEST_ff_f (copysign, minus_infty, 0, plus_infty);
1876
  TEST_ff_f (copysign, minus_infty, minus_zero, minus_infty);
1877
 
1878
  TEST_ff_f (copysign, 0, plus_infty, 0);
1879
  TEST_ff_f (copysign, 0, minus_zero, minus_zero);
1880
  TEST_ff_f (copysign, minus_zero, plus_infty, 0);
1881
  TEST_ff_f (copysign, minus_zero, minus_zero, minus_zero);
1882
 
1883
  /* XXX More correctly we would have to check the sign of the NaN.  */
1884
  TEST_ff_f (copysign, nan_value, 0, nan_value);
1885
  TEST_ff_f (copysign, nan_value, minus_zero, nan_value);
1886
  TEST_ff_f (copysign, -nan_value, 0, nan_value);
1887
  TEST_ff_f (copysign, -nan_value, minus_zero, nan_value);
1888
 
1889
  END (copysign);
1890
}
1891
 
1892
static void
1893
cos_test (void)
1894
{
1895
  errno = 0;
1896
  FUNC(cos) (0);
1897
  if (errno == ENOSYS)
1898
    /* Function not implemented.  */
1899
    return;
1900
 
1901
  START (cos);
1902
 
1903
  TEST_f_f (cos, 0, 1);
1904
  TEST_f_f (cos, minus_zero, 1);
1905
  TEST_f_f (cos, plus_infty, nan_value, INVALID_EXCEPTION);
1906
  TEST_f_f (cos, minus_infty, nan_value, INVALID_EXCEPTION);
1907
  TEST_f_f (cos, nan_value, nan_value);
1908
 
1909
  TEST_f_f (cos, M_PI_6l * 2.0, 0.5);
1910
  TEST_f_f (cos, M_PI_6l * 4.0, -0.5);
1911
  TEST_f_f (cos, M_PI_2l, 0);
1912
 
1913
  TEST_f_f (cos, 0.7L, 0.76484218728448842625585999019186495L);
1914
 
1915
  END (cos);
1916
}
1917
 
1918
static void
1919
cosh_test (void)
1920
{
1921
  errno = 0;
1922
  FUNC(cosh) (0.7L);
1923
  if (errno == ENOSYS)
1924
    /* Function not implemented.  */
1925
    return;
1926
 
1927
  START (cosh);
1928
  TEST_f_f (cosh, 0, 1);
1929
  TEST_f_f (cosh, minus_zero, 1);
1930
 
1931
#ifndef TEST_INLINE
1932
  TEST_f_f (cosh, plus_infty, plus_infty);
1933
  TEST_f_f (cosh, minus_infty, plus_infty);
1934
#endif
1935
  TEST_f_f (cosh, nan_value, nan_value);
1936
 
1937
  TEST_f_f (cosh, 0.7L, 1.255169005630943018L);
1938
  END (cosh);
1939
}
1940
 
1941
#if 0
1942
static void
1943
cpow_test (void)
1944
{
1945
  errno = 0;
1946
  FUNC(cpow) (BUILD_COMPLEX (1, 0), BUILD_COMPLEX (0, 0));
1947
  if (errno == ENOSYS)
1948
    /* Function not implemented.  */
1949
    return;
1950
 
1951
  START (cpow);
1952
 
1953
  TEST_cc_c (cpow, 1, 0, 0, 0, 1.0, 0.0);
1954
  TEST_cc_c (cpow, 2, 0, 10, 0, 1024.0, 0.0);
1955
 
1956
  TEST_cc_c (cpow, M_El, 0, 0, 2 * M_PIl, 1.0, 0.0);
1957
  TEST_cc_c (cpow, 2, 3, 4, 0, -119.0, -120.0);
1958
 
1959
  TEST_cc_c (cpow, nan_value, nan_value, nan_value, nan_value, nan_value, nan_value);
1960
 
1961
  END (cpow, complex);
1962
}
1963
 
1964
static void
1965
cproj_test (void)
1966
{
1967
  START (cproj);
1968
  TEST_c_c (cproj, 0.0, 0.0, 0.0, 0.0);
1969
  TEST_c_c (cproj, minus_zero, minus_zero, minus_zero, minus_zero);
1970
  TEST_c_c (cproj, 0.0, minus_zero, 0.0, minus_zero);
1971
  TEST_c_c (cproj, minus_zero, 0.0, minus_zero, 0.0);
1972
 
1973
  TEST_c_c (cproj, nan_value, nan_value, nan_value, nan_value);
1974
 
1975
  TEST_c_c (cproj, plus_infty, plus_infty, plus_infty, 0.0);
1976
  TEST_c_c (cproj, plus_infty, minus_infty, plus_infty, minus_zero);
1977
  TEST_c_c (cproj, minus_infty, plus_infty, plus_infty, 0.0);
1978
  TEST_c_c (cproj, minus_infty, minus_infty, plus_infty, minus_zero);
1979
 
1980
  TEST_c_c (cproj, 1.0, 0.0, 1.0, 0.0);
1981
  TEST_c_c (cproj, 2.0, 3.0, 0.2857142857142857142857142857142857L, 0.42857142857142857142857142857142855L);
1982
 
1983
  END (cproj, complex);
1984
}
1985
 
1986
static void
1987
creal_test (void)
1988
{
1989
  START (creal);
1990
  TEST_c_f (creal, 0.0, 1.0, 0.0);
1991
  TEST_c_f (creal, minus_zero, 1.0, minus_zero);
1992
  TEST_c_f (creal, nan_value, 1.0, nan_value);
1993
  TEST_c_f (creal, nan_value, nan_value, nan_value);
1994
  TEST_c_f (creal, plus_infty, 1.0, plus_infty);
1995
  TEST_c_f (creal, minus_infty, 1.0, minus_infty);
1996
  TEST_c_f (creal, 2.0, 3.0, 2.0);
1997
 
1998
  END (creal);
1999
}
2000
 
2001
static void
2002
csin_test (void)
2003
{
2004
  errno = 0;
2005
  FUNC(csin) (BUILD_COMPLEX (0.7L, 1.2L));
2006
  if (errno == ENOSYS)
2007
    /* Function not implemented.  */
2008
    return;
2009
 
2010
  START (csin);
2011
 
2012
  TEST_c_c (csin, 0.0, 0.0, 0.0, 0.0);
2013
  TEST_c_c (csin, minus_zero, 0.0, minus_zero, 0.0);
2014
  TEST_c_c (csin, 0.0, minus_zero, 0, minus_zero);
2015
  TEST_c_c (csin, minus_zero, minus_zero, minus_zero, minus_zero);
2016
 
2017
  TEST_c_c (csin, 0.0, plus_infty, 0.0, plus_infty);
2018
  TEST_c_c (csin, minus_zero, plus_infty, minus_zero, plus_infty);
2019
  TEST_c_c (csin, 0.0, minus_infty, 0.0, minus_infty);
2020
  TEST_c_c (csin, minus_zero, minus_infty, minus_zero, minus_infty);
2021
 
2022
  TEST_c_c (csin, plus_infty, 0.0, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
2023
  TEST_c_c (csin, minus_infty, 0.0, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
2024
  TEST_c_c (csin, plus_infty, minus_zero, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
2025
  TEST_c_c (csin, minus_infty, minus_zero, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
2026
 
2027
  TEST_c_c (csin, plus_infty, plus_infty, nan_value, plus_infty, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
2028
  TEST_c_c (csin, minus_infty, plus_infty, nan_value, plus_infty, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
2029
  TEST_c_c (csin, plus_infty, minus_infty, nan_value, plus_infty, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
2030
  TEST_c_c (csin, minus_infty, minus_infty, nan_value, plus_infty, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
2031
 
2032
  TEST_c_c (csin, plus_infty, 6.75, nan_value, nan_value, INVALID_EXCEPTION);
2033
  TEST_c_c (csin, plus_infty, -6.75, nan_value, nan_value, INVALID_EXCEPTION);
2034
  TEST_c_c (csin, minus_infty, 6.75, nan_value, nan_value, INVALID_EXCEPTION);
2035
  TEST_c_c (csin, minus_infty, -6.75,  nan_value, nan_value, INVALID_EXCEPTION);
2036
 
2037
  TEST_c_c (csin, 4.625, plus_infty, minus_infty, minus_infty);
2038
  TEST_c_c (csin, 4.625, minus_infty, minus_infty, plus_infty);
2039
  TEST_c_c (csin, -4.625, plus_infty, plus_infty, minus_infty);
2040
  TEST_c_c (csin, -4.625, minus_infty, plus_infty, plus_infty);
2041
 
2042
  TEST_c_c (csin, nan_value, 0.0, nan_value, 0.0, IGNORE_ZERO_INF_SIGN);
2043
  TEST_c_c (csin, nan_value, minus_zero, nan_value, 0.0, IGNORE_ZERO_INF_SIGN);
2044
 
2045
  TEST_c_c (csin, nan_value, plus_infty, nan_value, plus_infty, IGNORE_ZERO_INF_SIGN);
2046
  TEST_c_c (csin, nan_value, minus_infty, nan_value, plus_infty, IGNORE_ZERO_INF_SIGN);
2047
 
2048
  TEST_c_c (csin, nan_value, 9.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
2049
  TEST_c_c (csin, nan_value, -9.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
2050
 
2051
  TEST_c_c (csin, 0.0, nan_value, 0.0, nan_value);
2052
  TEST_c_c (csin, minus_zero, nan_value, minus_zero, nan_value);
2053
 
2054
  TEST_c_c (csin, 10.0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
2055
  TEST_c_c (csin, nan_value, -10.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
2056
 
2057
  TEST_c_c (csin, plus_infty, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
2058
  TEST_c_c (csin, minus_infty, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
2059
 
2060
  TEST_c_c (csin, nan_value, nan_value, nan_value, nan_value);
2061
 
2062
  TEST_c_c (csin, 0.7L, 1.2L, 1.1664563419657581376L, 1.1544997246948547371L);
2063
 
2064
  TEST_c_c (csin, -2, -3, -9.1544991469114295734L, 4.1689069599665643507L);
2065
 
2066
  END (csin, complex);
2067
}
2068
 
2069
 
2070
static void
2071
csinh_test (void)
2072
{
2073
  errno = 0;
2074
  FUNC(csinh) (BUILD_COMPLEX (0.7L, 1.2L));
2075
  if (errno == ENOSYS)
2076
    /* Function not implemented.  */
2077
    return;
2078
 
2079
  START (csinh);
2080
 
2081
  TEST_c_c (csinh, 0.0, 0.0, 0.0, 0.0);
2082
  TEST_c_c (csinh, minus_zero, 0.0, minus_zero, 0.0);
2083
  TEST_c_c (csinh, 0.0, minus_zero, 0.0, minus_zero);
2084
  TEST_c_c (csinh, minus_zero, minus_zero, minus_zero, minus_zero);
2085
 
2086
  TEST_c_c (csinh, 0.0, plus_infty, 0.0, nan_value, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
2087
  TEST_c_c (csinh, minus_zero, plus_infty, 0.0, nan_value, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
2088
  TEST_c_c (csinh, 0.0, minus_infty, 0.0, nan_value, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
2089
  TEST_c_c (csinh, minus_zero, minus_infty, 0.0, nan_value, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
2090
 
2091
  TEST_c_c (csinh, plus_infty, 0.0, plus_infty, 0.0);
2092
  TEST_c_c (csinh, minus_infty, 0.0, minus_infty, 0.0);
2093
  TEST_c_c (csinh, plus_infty, minus_zero, plus_infty, minus_zero);
2094
  TEST_c_c (csinh, minus_infty, minus_zero, minus_infty, minus_zero);
2095
 
2096
  TEST_c_c (csinh, plus_infty, plus_infty, plus_infty, nan_value, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
2097
  TEST_c_c (csinh, minus_infty, plus_infty, plus_infty, nan_value, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
2098
  TEST_c_c (csinh, plus_infty, minus_infty, plus_infty, nan_value, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
2099
  TEST_c_c (csinh, minus_infty, minus_infty, plus_infty, nan_value, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
2100
 
2101
  TEST_c_c (csinh, plus_infty, 4.625, minus_infty, minus_infty);
2102
  TEST_c_c (csinh, minus_infty, 4.625, plus_infty, minus_infty);
2103
  TEST_c_c (csinh, plus_infty, -4.625, minus_infty, plus_infty);
2104
  TEST_c_c (csinh, minus_infty, -4.625, plus_infty, plus_infty);
2105
 
2106
  TEST_c_c (csinh, 6.75, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
2107
  TEST_c_c (csinh, -6.75, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
2108
  TEST_c_c (csinh, 6.75, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
2109
  TEST_c_c (csinh, -6.75, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
2110
 
2111
  TEST_c_c (csinh, 0.0, nan_value, 0.0, nan_value, IGNORE_ZERO_INF_SIGN);
2112
  TEST_c_c (csinh, minus_zero, nan_value, 0.0, nan_value, IGNORE_ZERO_INF_SIGN);
2113
 
2114
  TEST_c_c (csinh, plus_infty, nan_value, plus_infty, nan_value, IGNORE_ZERO_INF_SIGN);
2115
  TEST_c_c (csinh, minus_infty, nan_value, plus_infty, nan_value, IGNORE_ZERO_INF_SIGN);
2116
 
2117
  TEST_c_c (csinh, 9.0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
2118
  TEST_c_c (csinh, -9.0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
2119
 
2120
  TEST_c_c (csinh, nan_value, 0.0, nan_value, 0.0);
2121
  TEST_c_c (csinh, nan_value, minus_zero, nan_value, minus_zero);
2122
 
2123
  TEST_c_c (csinh, nan_value, 10.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
2124
  TEST_c_c (csinh, nan_value, -10.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
2125
 
2126
  TEST_c_c (csinh, nan_value, plus_infty, nan_value, nan_value, INVALID_EXCEPTION_OK);
2127
  TEST_c_c (csinh, nan_value, minus_infty, nan_value, nan_value, INVALID_EXCEPTION_OK);
2128
 
2129
  TEST_c_c (csinh, nan_value, nan_value, nan_value, nan_value);
2130
 
2131
  TEST_c_c (csinh, 0.7L, 1.2L, 0.27487868678117583582L, 1.1698665727426565139L);
2132
  TEST_c_c (csinh, -2, -3, 3.5905645899857799520L, -0.5309210862485198052L);
2133
 
2134
  END (csinh, complex);
2135
}
2136
 
2137
static void
2138
csqrt_test (void)
2139
{
2140
  errno = 0;
2141
  FUNC(csqrt) (BUILD_COMPLEX (-1, 0));
2142
  if (errno == ENOSYS)
2143
    /* Function not implemented.  */
2144
    return;
2145
 
2146
  START (csqrt);
2147
 
2148
  TEST_c_c (csqrt, 0, 0, 0.0, 0.0);
2149
  TEST_c_c (csqrt, 0, minus_zero, 0, minus_zero);
2150
  TEST_c_c (csqrt, minus_zero, 0, 0.0, 0.0);
2151
  TEST_c_c (csqrt, minus_zero, minus_zero, 0.0, minus_zero);
2152
 
2153
  TEST_c_c (csqrt, minus_infty, 0, 0.0, plus_infty);
2154
  TEST_c_c (csqrt, minus_infty, 6, 0.0, plus_infty);
2155
  TEST_c_c (csqrt, minus_infty, minus_zero, 0.0, minus_infty);
2156
  TEST_c_c (csqrt, minus_infty, -6, 0.0, minus_infty);
2157
 
2158
  TEST_c_c (csqrt, plus_infty, 0, plus_infty, 0.0);
2159
  TEST_c_c (csqrt, plus_infty, 6, plus_infty, 0.0);
2160
  TEST_c_c (csqrt, plus_infty, minus_zero, plus_infty, minus_zero);
2161
  TEST_c_c (csqrt, plus_infty, -6, plus_infty, minus_zero);
2162
 
2163
  TEST_c_c (csqrt, 0, plus_infty, plus_infty, plus_infty);
2164
  TEST_c_c (csqrt, 4, plus_infty, plus_infty, plus_infty);
2165
  TEST_c_c (csqrt, plus_infty, plus_infty, plus_infty, plus_infty);
2166
  TEST_c_c (csqrt, minus_zero, plus_infty, plus_infty, plus_infty);
2167
  TEST_c_c (csqrt, -4, plus_infty, plus_infty, plus_infty);
2168
  TEST_c_c (csqrt, minus_infty, plus_infty, plus_infty, plus_infty);
2169
  TEST_c_c (csqrt, 0, minus_infty, plus_infty, minus_infty);
2170
  TEST_c_c (csqrt, 4, minus_infty, plus_infty, minus_infty);
2171
  TEST_c_c (csqrt, plus_infty, minus_infty, plus_infty, minus_infty);
2172
  TEST_c_c (csqrt, minus_zero, minus_infty, plus_infty, minus_infty);
2173
  TEST_c_c (csqrt, -4, minus_infty, plus_infty, minus_infty);
2174
  TEST_c_c (csqrt, minus_infty, minus_infty, plus_infty, minus_infty);
2175
 
2176
  TEST_c_c (csqrt, minus_infty, nan_value, nan_value, plus_infty, IGNORE_ZERO_INF_SIGN);
2177
 
2178
  TEST_c_c (csqrt, plus_infty, nan_value, plus_infty, nan_value);
2179
 
2180
  TEST_c_c (csqrt, 0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
2181
  TEST_c_c (csqrt, 1, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
2182
  TEST_c_c (csqrt, minus_zero, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
2183
  TEST_c_c (csqrt, -1, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
2184
 
2185
  TEST_c_c (csqrt, nan_value, 0, nan_value, nan_value, INVALID_EXCEPTION_OK);
2186
  TEST_c_c (csqrt, nan_value, 8, nan_value, nan_value, INVALID_EXCEPTION_OK);
2187
  TEST_c_c (csqrt, nan_value, minus_zero, nan_value, nan_value, INVALID_EXCEPTION_OK);
2188
  TEST_c_c (csqrt, nan_value, -8, nan_value, nan_value, INVALID_EXCEPTION_OK);
2189
 
2190
  TEST_c_c (csqrt, nan_value, nan_value, nan_value, nan_value);
2191
 
2192
  TEST_c_c (csqrt, 16.0, -30.0, 5.0, -3.0);
2193
  TEST_c_c (csqrt, -1, 0, 0.0, 1.0);
2194
  TEST_c_c (csqrt, 0, 2, 1.0, 1.0);
2195
  TEST_c_c (csqrt, 119, 120, 12.0, 5.0);
2196
  TEST_c_c (csqrt, 0.7L, 1.2L, 1.022067610030026450706487883081139L, 0.58704531296356521154977678719838035L);
2197
  TEST_c_c (csqrt, -2, -3, 0.89597747612983812471573375529004348L, -1.6741492280355400404480393008490519L);
2198
  TEST_c_c (csqrt, -2, 3, 0.89597747612983812471573375529004348L, 1.6741492280355400404480393008490519L);
2199
 
2200
  END (csqrt, complex);
2201
}
2202
 
2203
static void
2204
ctan_test (void)
2205
{
2206
  errno = 0;
2207
  FUNC(ctan) (BUILD_COMPLEX (0.7L, 1.2L));
2208
  if (errno == ENOSYS)
2209
    /* Function not implemented.  */
2210
    return;
2211
 
2212
  START (ctan);
2213
 
2214
  TEST_c_c (ctan, 0, 0, 0.0, 0.0);
2215
  TEST_c_c (ctan, 0, minus_zero, 0.0, minus_zero);
2216
  TEST_c_c (ctan, minus_zero, 0, minus_zero, 0.0);
2217
  TEST_c_c (ctan, minus_zero, minus_zero, minus_zero, minus_zero);
2218
 
2219
  TEST_c_c (ctan, 0, plus_infty, 0.0, 1.0);
2220
  TEST_c_c (ctan, 1, plus_infty, 0.0, 1.0);
2221
  TEST_c_c (ctan, minus_zero, plus_infty, minus_zero, 1.0);
2222
  TEST_c_c (ctan, -1, plus_infty, minus_zero, 1.0);
2223
 
2224
  TEST_c_c (ctan, 0, minus_infty, 0.0, -1.0);
2225
  TEST_c_c (ctan, 1, minus_infty, 0.0, -1.0);
2226
  TEST_c_c (ctan, minus_zero, minus_infty, minus_zero, -1.0);
2227
  TEST_c_c (ctan, -1, minus_infty, minus_zero, -1.0);
2228
 
2229
  TEST_c_c (ctan, plus_infty, 0, nan_value, nan_value, INVALID_EXCEPTION);
2230
  TEST_c_c (ctan, plus_infty, 2, nan_value, nan_value, INVALID_EXCEPTION);
2231
  TEST_c_c (ctan, minus_infty, 0, nan_value, nan_value, INVALID_EXCEPTION);
2232
  TEST_c_c (ctan, minus_infty, 2, nan_value, nan_value, INVALID_EXCEPTION);
2233
  TEST_c_c (ctan, plus_infty, minus_zero, nan_value, nan_value, INVALID_EXCEPTION);
2234
  TEST_c_c (ctan, plus_infty, -2, nan_value, nan_value, INVALID_EXCEPTION);
2235
  TEST_c_c (ctan, minus_infty, minus_zero, nan_value, nan_value, INVALID_EXCEPTION);
2236
  TEST_c_c (ctan, minus_infty, -2, nan_value, nan_value, INVALID_EXCEPTION);
2237
 
2238
  TEST_c_c (ctan, nan_value, plus_infty, 0.0, 1.0, IGNORE_ZERO_INF_SIGN);
2239
  TEST_c_c (ctan, nan_value, minus_infty, 0.0, -1.0, IGNORE_ZERO_INF_SIGN);
2240
 
2241
  TEST_c_c (ctan, 0, nan_value, 0.0, nan_value);
2242
  TEST_c_c (ctan, minus_zero, nan_value, minus_zero, nan_value);
2243
 
2244
  TEST_c_c (ctan, 0.5, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
2245
  TEST_c_c (ctan, -4.5, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
2246
 
2247
  TEST_c_c (ctan, nan_value, 0, nan_value, nan_value, INVALID_EXCEPTION_OK);
2248
  TEST_c_c (ctan, nan_value, 5, nan_value, nan_value, INVALID_EXCEPTION_OK);
2249
  TEST_c_c (ctan, nan_value, minus_zero, nan_value, nan_value, INVALID_EXCEPTION_OK);
2250
  TEST_c_c (ctan, nan_value, -0.25, nan_value, nan_value, INVALID_EXCEPTION_OK);
2251
 
2252
  TEST_c_c (ctan, nan_value, nan_value, nan_value, nan_value);
2253
 
2254
  TEST_c_c (ctan, 0.7L, 1.2L, 0.1720734197630349001L, 0.9544807059989405538L);
2255
  TEST_c_c (ctan, -2, -3, 0.0037640256415042482L, -1.0032386273536098014L);
2256
 
2257
  END (ctan, complex);
2258
}
2259
 
2260
 
2261
static void
2262
ctanh_test (void)
2263
{
2264
  errno = 0;
2265
  FUNC(ctanh) (BUILD_COMPLEX (0, 0));
2266
  if (errno == ENOSYS)
2267
    /* Function not implemented.  */
2268
    return;
2269
 
2270
  START (ctanh);
2271
 
2272
  TEST_c_c (ctanh, 0, 0, 0.0, 0.0);
2273
  TEST_c_c (ctanh, 0, minus_zero, 0.0, minus_zero);
2274
  TEST_c_c (ctanh, minus_zero, 0, minus_zero, 0.0);
2275
  TEST_c_c (ctanh, minus_zero, minus_zero, minus_zero, minus_zero);
2276
 
2277
  TEST_c_c (ctanh, plus_infty, 0, 1.0, 0.0);
2278
  TEST_c_c (ctanh, plus_infty, 1, 1.0, 0.0);
2279
  TEST_c_c (ctanh, plus_infty, minus_zero, 1.0, minus_zero);
2280
  TEST_c_c (ctanh, plus_infty, -1, 1.0, minus_zero);
2281
  TEST_c_c (ctanh, minus_infty, 0, -1.0, 0.0);
2282
  TEST_c_c (ctanh, minus_infty, 1, -1.0, 0.0);
2283
  TEST_c_c (ctanh, minus_infty, minus_zero, -1.0, minus_zero);
2284
  TEST_c_c (ctanh, minus_infty, -1, -1.0, minus_zero);
2285
 
2286
  TEST_c_c (ctanh, 0, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
2287
  TEST_c_c (ctanh, 2, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
2288
  TEST_c_c (ctanh, 0, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
2289
  TEST_c_c (ctanh, 2, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
2290
  TEST_c_c (ctanh, minus_zero, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
2291
  TEST_c_c (ctanh, -2, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
2292
  TEST_c_c (ctanh, minus_zero, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
2293
  TEST_c_c (ctanh, -2, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
2294
 
2295
  TEST_c_c (ctanh, plus_infty, nan_value, 1.0, 0.0, IGNORE_ZERO_INF_SIGN);
2296
  TEST_c_c (ctanh, minus_infty, nan_value, -1.0, 0.0, IGNORE_ZERO_INF_SIGN);
2297
 
2298
  TEST_c_c (ctanh, nan_value, 0, nan_value, 0.0);
2299
  TEST_c_c (ctanh, nan_value, minus_zero, nan_value, minus_zero);
2300
 
2301
  TEST_c_c (ctanh, nan_value, 0.5, nan_value, nan_value, INVALID_EXCEPTION_OK);
2302
  TEST_c_c (ctanh, nan_value, -4.5, nan_value, nan_value, INVALID_EXCEPTION_OK);
2303
 
2304
  TEST_c_c (ctanh, 0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
2305
  TEST_c_c (ctanh, 5, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
2306
  TEST_c_c (ctanh, minus_zero, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
2307
  TEST_c_c (ctanh, -0.25, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
2308
 
2309
  TEST_c_c (ctanh, nan_value, nan_value, nan_value, nan_value);
2310
 
2311
  TEST_c_c (ctanh, 0, M_PI_4l, 0.0, 1.0);
2312
 
2313
  TEST_c_c (ctanh, 0.7L, 1.2L, 1.3472197399061191630L, 0.4778641038326365540L);
2314
  TEST_c_c (ctanh, -2, -3, -0.9653858790221331242L, 0.0098843750383224937L);
2315
 
2316
  END (ctanh, complex);
2317
}
2318
#endif
2319
 
2320
static void
2321
erf_test (void)
2322
{
2323
  errno = 0;
2324
  FUNC(erf) (0);
2325
  if (errno == ENOSYS)
2326
    /* Function not implemented.  */
2327
    return;
2328
 
2329
  START (erf);
2330
 
2331
  TEST_f_f (erf, 0, 0);
2332
  TEST_f_f (erf, minus_zero, minus_zero);
2333
  TEST_f_f (erf, plus_infty, 1);
2334
  TEST_f_f (erf, minus_infty, -1);
2335
  TEST_f_f (erf, nan_value, nan_value);
2336
 
2337
  TEST_f_f (erf, 0.7L, 0.67780119383741847297L);
2338
 
2339
  TEST_f_f (erf, 1.2L, 0.91031397822963538024L);
2340
  TEST_f_f (erf, 2.0, 0.99532226501895273416L);
2341
  TEST_f_f (erf, 4.1L, 0.99999999329997234592L);
2342
  TEST_f_f (erf, 27, 1.0L);
2343
 
2344
  END (erf);
2345
}
2346
 
2347
 
2348
static void
2349
erfc_test (void)
2350
{
2351
  errno = 0;
2352
  FUNC(erfc) (0);
2353
  if (errno == ENOSYS)
2354
    /* Function not implemented.  */
2355
    return;
2356
 
2357
  START (erfc);
2358
 
2359
  TEST_f_f (erfc, plus_infty, 0.0);
2360
  TEST_f_f (erfc, minus_infty, 2.0);
2361
  TEST_f_f (erfc, 0.0, 1.0);
2362
  TEST_f_f (erfc, minus_zero, 1.0);
2363
  TEST_f_f (erfc, nan_value, nan_value);
2364
 
2365
  TEST_f_f (erfc, 0.7L, 0.32219880616258152702L);
2366
 
2367
  TEST_f_f (erfc, 1.2L, 0.089686021770364619762L);
2368
  TEST_f_f (erfc, 2.0, 0.0046777349810472658379L);
2369
  TEST_f_f (erfc, 4.1L, 0.67000276540848983727e-8L);
2370
  TEST_f_f (erfc, 9, 0.41370317465138102381e-36L);
2371
 
2372
  END (erfc);
2373
}
2374
 
2375
static void
2376
exp_test (void)
2377
{
2378
  errno = 0;
2379
  FUNC(exp) (0);
2380
  if (errno == ENOSYS)
2381
    /* Function not implemented.  */
2382
    return;
2383
 
2384
  START (exp);
2385
 
2386
  TEST_f_f (exp, 0, 1);
2387
  TEST_f_f (exp, minus_zero, 1);
2388
 
2389
#ifndef TEST_INLINE
2390
  TEST_f_f (exp, plus_infty, plus_infty);
2391
  TEST_f_f (exp, minus_infty, 0);
2392
#endif
2393
  TEST_f_f (exp, nan_value, nan_value);
2394
  TEST_f_f (exp, 1, M_El);
2395
 
2396
  TEST_f_f (exp, 2, M_E2l);
2397
  TEST_f_f (exp, 3, M_E3l);
2398
  TEST_f_f (exp, 0.7L, 2.0137527074704765216L);
2399
  TEST_f_f (exp, 50.0L, 5184705528587072464087.45332293348538L);
2400
#ifdef TEST_LDOUBLE
2401
  /* The result can only be represented in long double.  */
2402
  TEST_f_f (exp, 1000.0L, 0.197007111401704699388887935224332313e435L);
2403
#endif
2404
  END (exp);
2405
}
2406
 
2407
 
2408
#if 0
2409
static void
2410
exp10_test (void)
2411
{
2412
  errno = 0;
2413
  FUNC(exp10) (0);
2414
  if (errno == ENOSYS)
2415
    /* Function not implemented.  */
2416
    return;
2417
 
2418
  START (exp10);
2419
 
2420
  TEST_f_f (exp10, 0, 1);
2421
  TEST_f_f (exp10, minus_zero, 1);
2422
 
2423
  TEST_f_f (exp10, plus_infty, plus_infty);
2424
  TEST_f_f (exp10, minus_infty, 0);
2425
  TEST_f_f (exp10, nan_value, nan_value);
2426
  TEST_f_f (exp10, 3, 1000);
2427
  TEST_f_f (exp10, -1, 0.1L);
2428
  TEST_f_f (exp10, 1e6, plus_infty);
2429
  TEST_f_f (exp10, -1e6, 0);
2430
  TEST_f_f (exp10, 0.7L, 5.0118723362727228500155418688494574L);
2431
 
2432
  END (exp10);
2433
}
2434
 
2435
static void
2436
exp2_test (void)
2437
{
2438
  errno = 0;
2439
  FUNC(exp2) (0);
2440
  if (errno == ENOSYS)
2441
    /* Function not implemented.  */
2442
    return;
2443
 
2444
  START (exp2);
2445
 
2446
  TEST_f_f (exp2, 0, 1);
2447
  TEST_f_f (exp2, minus_zero, 1);
2448
  TEST_f_f (exp2, plus_infty, plus_infty);
2449
  TEST_f_f (exp2, minus_infty, 0);
2450
  TEST_f_f (exp2, nan_value, nan_value);
2451
 
2452
  TEST_f_f (exp2, 10, 1024);
2453
  TEST_f_f (exp2, -1, 0.5);
2454
  TEST_f_f (exp2, 1e6, plus_infty);
2455
  TEST_f_f (exp2, -1e6, 0);
2456
  TEST_f_f (exp2, 0.7L, 1.6245047927124710452L);
2457
 
2458
  END (exp2);
2459
}
2460
#endif
2461
 
2462
static void
2463
expm1_test (void)
2464
{
2465
  errno = 0;
2466
  FUNC(expm1) (0);
2467
  if (errno == ENOSYS)
2468
    /* Function not implemented.  */
2469
    return;
2470
 
2471
  START (expm1);
2472
 
2473
  TEST_f_f (expm1, 0, 0);
2474
  TEST_f_f (expm1, minus_zero, minus_zero);
2475
 
2476
#ifndef TEST_INLINE
2477
  TEST_f_f (expm1, plus_infty, plus_infty);
2478
  TEST_f_f (expm1, minus_infty, -1);
2479
#endif
2480
  TEST_f_f (expm1, nan_value, nan_value);
2481
 
2482
  TEST_f_f (expm1, 1, M_El - 1.0);
2483
  TEST_f_f (expm1, 0.7L, 1.0137527074704765216L);
2484
 
2485
  END (expm1);
2486
}
2487
 
2488
static void
2489
fabs_test (void)
2490
{
2491
  START (fabs);
2492
 
2493
  TEST_f_f (fabs, 0, 0);
2494
  TEST_f_f (fabs, minus_zero, 0);
2495
 
2496
  TEST_f_f (fabs, plus_infty, plus_infty);
2497
  TEST_f_f (fabs, minus_infty, plus_infty);
2498
  TEST_f_f (fabs, nan_value, nan_value);
2499
 
2500
  TEST_f_f (fabs, 38.0, 38.0);
2501
  TEST_f_f (fabs, -M_El, M_El);
2502
 
2503
  END (fabs);
2504
}
2505
 
2506
#if 0
2507
static void
2508
fdim_test (void)
2509
{
2510
  START (fdim);
2511
 
2512
  TEST_ff_f (fdim, 0, 0, 0);
2513
  TEST_ff_f (fdim, 9, 0, 9);
2514
  TEST_ff_f (fdim, 0, 9, 0);
2515
  TEST_ff_f (fdim, -9, 0, 0);
2516
  TEST_ff_f (fdim, 0, -9, 9);
2517
 
2518
  TEST_ff_f (fdim, plus_infty, 9, plus_infty);
2519
  TEST_ff_f (fdim, plus_infty, -9, plus_infty);
2520
  TEST_ff_f (fdim, minus_infty, 9, 0);
2521
  TEST_ff_f (fdim, minus_infty, -9, 0);
2522
  TEST_ff_f (fdim, 9, minus_infty, plus_infty);
2523
  TEST_ff_f (fdim, -9, minus_infty, plus_infty);
2524
  TEST_ff_f (fdim, 9, plus_infty, 0);
2525
  TEST_ff_f (fdim, -9, plus_infty, 0);
2526
 
2527
  TEST_ff_f (fdim, 0, nan_value, nan_value);
2528
  TEST_ff_f (fdim, 9, nan_value, nan_value);
2529
  TEST_ff_f (fdim, -9, nan_value, nan_value);
2530
  TEST_ff_f (fdim, nan_value, 9, nan_value);
2531
  TEST_ff_f (fdim, nan_value, -9, nan_value);
2532
  TEST_ff_f (fdim, plus_infty, nan_value, nan_value);
2533
  TEST_ff_f (fdim, minus_infty, nan_value, nan_value);
2534
  TEST_ff_f (fdim, nan_value, plus_infty, nan_value);
2535
  TEST_ff_f (fdim, nan_value, minus_infty, nan_value);
2536
  TEST_ff_f (fdim, nan_value, nan_value, nan_value);
2537
 
2538
  END (fdim);
2539
}
2540
#endif
2541
 
2542
static void
2543
floor_test (void)
2544
{
2545
  START (floor);
2546
 
2547
  TEST_f_f (floor, 0.0, 0.0);
2548
  TEST_f_f (floor, minus_zero, minus_zero);
2549
  TEST_f_f (floor, plus_infty, plus_infty);
2550
  TEST_f_f (floor, minus_infty, minus_infty);
2551
  TEST_f_f (floor, nan_value, nan_value);
2552
 
2553
  TEST_f_f (floor, M_PIl, 3.0);
2554
  TEST_f_f (floor, -M_PIl, -4.0);
2555
 
2556
  END (floor);
2557
}
2558
 
2559
#if 0
2560
static void
2561
fma_test (void)
2562
{
2563
  START (fma);
2564
 
2565
  TEST_fff_f (fma, 1.0, 2.0, 3.0, 5.0);
2566
  TEST_fff_f (fma, nan_value, 2.0, 3.0, nan_value);
2567
  TEST_fff_f (fma, 1.0, nan_value, 3.0, nan_value);
2568
  TEST_fff_f (fma, 1.0, 2.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
2569
  TEST_fff_f (fma, plus_infty, 0.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
2570
  TEST_fff_f (fma, minus_infty, 0.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
2571
  TEST_fff_f (fma, 0.0, plus_infty, nan_value, nan_value, INVALID_EXCEPTION_OK);
2572
  TEST_fff_f (fma, 0.0, minus_infty, nan_value, nan_value, INVALID_EXCEPTION_OK);
2573
  TEST_fff_f (fma, plus_infty, 0.0, 1.0, nan_value, INVALID_EXCEPTION);
2574
  TEST_fff_f (fma, minus_infty, 0.0, 1.0, nan_value, INVALID_EXCEPTION);
2575
  TEST_fff_f (fma, 0.0, plus_infty, 1.0, nan_value, INVALID_EXCEPTION);
2576
  TEST_fff_f (fma, 0.0, minus_infty, 1.0, nan_value, INVALID_EXCEPTION);
2577
 
2578
  TEST_fff_f (fma, plus_infty, plus_infty, minus_infty, nan_value, INVALID_EXCEPTION);
2579
  TEST_fff_f (fma, minus_infty, plus_infty, plus_infty, nan_value, INVALID_EXCEPTION);
2580
  TEST_fff_f (fma, plus_infty, minus_infty, plus_infty, nan_value, INVALID_EXCEPTION);
2581
  TEST_fff_f (fma, minus_infty, minus_infty, minus_infty, nan_value, INVALID_EXCEPTION);
2582
 
2583
  END (fma);
2584
}
2585
 
2586
 
2587
static void
2588
fmax_test (void)
2589
{
2590
  START (fmax);
2591
 
2592
  TEST_ff_f (fmax, 0, 0, 0);
2593
  TEST_ff_f (fmax, minus_zero, minus_zero, minus_zero);
2594
  TEST_ff_f (fmax, 9, 0, 9);
2595
  TEST_ff_f (fmax, 0, 9, 9);
2596
  TEST_ff_f (fmax, -9, 0, 0);
2597
  TEST_ff_f (fmax, 0, -9, 0);
2598
 
2599
  TEST_ff_f (fmax, plus_infty, 9, plus_infty);
2600
  TEST_ff_f (fmax, 0, plus_infty, plus_infty);
2601
  TEST_ff_f (fmax, -9, plus_infty, plus_infty);
2602
  TEST_ff_f (fmax, plus_infty, -9, plus_infty);
2603
 
2604
  TEST_ff_f (fmax, minus_infty, 9, 9);
2605
  TEST_ff_f (fmax, minus_infty, -9, -9);
2606
  TEST_ff_f (fmax, 9, minus_infty, 9);
2607
  TEST_ff_f (fmax, -9, minus_infty, -9);
2608
 
2609
  TEST_ff_f (fmax, 0, nan_value, 0);
2610
  TEST_ff_f (fmax, 9, nan_value, 9);
2611
  TEST_ff_f (fmax, -9, nan_value, -9);
2612
  TEST_ff_f (fmax, nan_value, 0, 0);
2613
  TEST_ff_f (fmax, nan_value, 9, 9);
2614
  TEST_ff_f (fmax, nan_value, -9, -9);
2615
  TEST_ff_f (fmax, plus_infty, nan_value, plus_infty);
2616
  TEST_ff_f (fmax, minus_infty, nan_value, minus_infty);
2617
  TEST_ff_f (fmax, nan_value, plus_infty, plus_infty);
2618
  TEST_ff_f (fmax, nan_value, minus_infty, minus_infty);
2619
  TEST_ff_f (fmax, nan_value, nan_value, nan_value);
2620
 
2621
  END (fmax);
2622
}
2623
 
2624
 
2625
static void
2626
fmin_test (void)
2627
{
2628
  START (fmin);
2629
 
2630
  TEST_ff_f (fmin, 0, 0, 0);
2631
  TEST_ff_f (fmin, minus_zero, minus_zero, minus_zero);
2632
  TEST_ff_f (fmin, 9, 0, 0);
2633
  TEST_ff_f (fmin, 0, 9, 0);
2634
  TEST_ff_f (fmin, -9, 0, -9);
2635
  TEST_ff_f (fmin, 0, -9, -9);
2636
 
2637
  TEST_ff_f (fmin, plus_infty, 9, 9);
2638
  TEST_ff_f (fmin, 9, plus_infty, 9);
2639
  TEST_ff_f (fmin, plus_infty, -9, -9);
2640
  TEST_ff_f (fmin, -9, plus_infty, -9);
2641
  TEST_ff_f (fmin, minus_infty, 9, minus_infty);
2642
  TEST_ff_f (fmin, minus_infty, -9, minus_infty);
2643
  TEST_ff_f (fmin, 9, minus_infty, minus_infty);
2644
  TEST_ff_f (fmin, -9, minus_infty, minus_infty);
2645
 
2646
  TEST_ff_f (fmin, 0, nan_value, 0);
2647
  TEST_ff_f (fmin, 9, nan_value, 9);
2648
  TEST_ff_f (fmin, -9, nan_value, -9);
2649
  TEST_ff_f (fmin, nan_value, 0, 0);
2650
  TEST_ff_f (fmin, nan_value, 9, 9);
2651
  TEST_ff_f (fmin, nan_value, -9, -9);
2652
  TEST_ff_f (fmin, plus_infty, nan_value, plus_infty);
2653
  TEST_ff_f (fmin, minus_infty, nan_value, minus_infty);
2654
  TEST_ff_f (fmin, nan_value, plus_infty, plus_infty);
2655
  TEST_ff_f (fmin, nan_value, minus_infty, minus_infty);
2656
  TEST_ff_f (fmin, nan_value, nan_value, nan_value);
2657
 
2658
  END (fmin);
2659
}
2660
#endif
2661
 
2662
static void
2663
fmod_test (void)
2664
{
2665
  errno = 0;
2666
  FUNC(fmod) (6.5, 2.3L);
2667
  if (errno == ENOSYS)
2668
    /* Function not implemented.  */
2669
    return;
2670
 
2671
  START (fmod);
2672
 
2673
  /* fmod (+0, y) == +0 for y != 0.  */
2674
  TEST_ff_f (fmod, 0, 3, 0);
2675
 
2676
  /* fmod (-0, y) == -0 for y != 0.  */
2677
  TEST_ff_f (fmod, minus_zero, 3, minus_zero);
2678
 
2679
  /* fmod (+inf, y) == NaN plus invalid exception.  */
2680
  TEST_ff_f (fmod, plus_infty, 3, nan_value, INVALID_EXCEPTION);
2681
  /* fmod (-inf, y) == NaN plus invalid exception.  */
2682
  TEST_ff_f (fmod, minus_infty, 3, nan_value, INVALID_EXCEPTION);
2683
  /* fmod (x, +0) == NaN plus invalid exception.  */
2684
  TEST_ff_f (fmod, 3, 0, nan_value, INVALID_EXCEPTION);
2685
  /* fmod (x, -0) == NaN plus invalid exception.  */
2686
  TEST_ff_f (fmod, 3, minus_zero, nan_value, INVALID_EXCEPTION);
2687
 
2688
  /* fmod (x, +inf) == x for x not infinite.  */
2689
  TEST_ff_f (fmod, 3.0, plus_infty, 3.0);
2690
  /* fmod (x, -inf) == x for x not infinite.  */
2691
  TEST_ff_f (fmod, 3.0, minus_infty, 3.0);
2692
 
2693
  TEST_ff_f (fmod, nan_value, nan_value, nan_value);
2694
 
2695
  TEST_ff_f (fmod, 6.5, 2.3L, 1.9L);
2696
  TEST_ff_f (fmod, -6.5, 2.3L, -1.9L);
2697
  TEST_ff_f (fmod, 6.5, -2.3L, 1.9L);
2698
  TEST_ff_f (fmod, -6.5, -2.3L, -1.9L);
2699
 
2700
  END (fmod);
2701
}
2702
 
2703
static void
2704
fpclassify_test (void)
2705
{
2706
  START (fpclassify);
2707
 
2708
  TEST_f_i (fpclassify, nan_value, FP_NAN);
2709
  TEST_f_i (fpclassify, plus_infty, FP_INFINITE);
2710
  TEST_f_i (fpclassify, minus_infty, FP_INFINITE);
2711
  TEST_f_i (fpclassify, plus_zero, FP_ZERO);
2712
  TEST_f_i (fpclassify, minus_zero, FP_ZERO);
2713
  TEST_f_i (fpclassify, 1000, FP_NORMAL);
2714
 
2715
  END (fpclassify);
2716
}
2717
 
2718
 
2719
static void
2720
frexp_test (void)
2721
{
2722
  int x;
2723
 
2724
  START (frexp);
2725
 
2726
  TEST_fI_f1 (frexp, plus_infty, plus_infty, IGNORE);
2727
  TEST_fI_f1 (frexp, minus_infty, minus_infty, IGNORE);
2728
  TEST_fI_f1 (frexp, nan_value, nan_value, IGNORE);
2729
 
2730
  TEST_fI_f1 (frexp, 0.0, 0.0, 0.0);
2731
  TEST_fI_f1 (frexp, minus_zero, minus_zero, 0.0);
2732
 
2733
  TEST_fI_f1 (frexp, 12.8L, 0.8L, 4);
2734
  TEST_fI_f1 (frexp, -27.34L, -0.854375L, 5);
2735
 
2736
  END (frexp);
2737
}
2738
 
2739
 
2740
static void
2741
gamma_test (void)
2742
{
2743
  errno = 0;
2744
  FUNC(gamma) (1);
2745
 
2746
  if (errno == ENOSYS)
2747
    /* Function not implemented.  */
2748
    return;
2749
  feclearexcept (FE_ALL_EXCEPT);
2750
 
2751
  START (gamma);
2752
 
2753
  TEST_f_f (gamma, plus_infty, plus_infty);
2754
  TEST_f_f (gamma, 0, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
2755
  TEST_f_f (gamma, -3, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
2756
  TEST_f_f (gamma, minus_infty, plus_infty);
2757
  TEST_f_f (gamma, nan_value, nan_value);
2758
 
2759
  TEST_f_f1 (gamma, 1, 0, 1);
2760
  TEST_f_f1 (gamma, 3, M_LN2l, 1);
2761
 
2762
  TEST_f_f1 (gamma, 0.5, M_LOG_SQRT_PIl, 1);
2763
  TEST_f_f1 (gamma, -0.5, M_LOG_2_SQRT_PIl, -1);
2764
 
2765
  END (gamma);
2766
}
2767
 
2768
static void
2769
hypot_test (void)
2770
{
2771
  errno = 0;
2772
  FUNC(hypot) (0.7L, 12.4L);
2773
  if (errno == ENOSYS)
2774
    /* Function not implemented.  */
2775
    return;
2776
 
2777
  START (hypot);
2778
 
2779
  TEST_ff_f (hypot, plus_infty, 1, plus_infty, IGNORE_ZERO_INF_SIGN);
2780
  TEST_ff_f (hypot, minus_infty, 1, plus_infty, IGNORE_ZERO_INF_SIGN);
2781
 
2782
#ifndef TEST_INLINE
2783
  TEST_ff_f (hypot, plus_infty, nan_value, plus_infty);
2784
  TEST_ff_f (hypot, minus_infty, nan_value, plus_infty);
2785
  TEST_ff_f (hypot, nan_value, plus_infty, plus_infty);
2786
  TEST_ff_f (hypot, nan_value, minus_infty, plus_infty);
2787
#endif
2788
 
2789
  TEST_ff_f (hypot, nan_value, nan_value, nan_value);
2790
 
2791
  /* hypot (x,y) == hypot (+-x, +-y)  */
2792
  TEST_ff_f (hypot, 0.7L, 12.4L, 12.419742348374220601176836866763271L);
2793
  TEST_ff_f (hypot, -0.7L, 12.4L, 12.419742348374220601176836866763271L);
2794
  TEST_ff_f (hypot, 0.7L, -12.4L, 12.419742348374220601176836866763271L);
2795
  TEST_ff_f (hypot, -0.7L, -12.4L, 12.419742348374220601176836866763271L);
2796
  TEST_ff_f (hypot, 12.4L, 0.7L, 12.419742348374220601176836866763271L);
2797
  TEST_ff_f (hypot, -12.4L, 0.7L, 12.419742348374220601176836866763271L);
2798
  TEST_ff_f (hypot, 12.4L, -0.7L, 12.419742348374220601176836866763271L);
2799
  TEST_ff_f (hypot, -12.4L, -0.7L, 12.419742348374220601176836866763271L);
2800
 
2801
  /*  hypot (x,0) == fabs (x)  */
2802
  TEST_ff_f (hypot, 0.7L, 0, 0.7L);
2803
  TEST_ff_f (hypot, -0.7L, 0, 0.7L);
2804
  TEST_ff_f (hypot, -5.7e7, 0, 5.7e7L);
2805
 
2806
  TEST_ff_f (hypot, 0.7L, 1.2L, 1.3892443989449804508432547041028554L);
2807
 
2808
  END (hypot);
2809
}
2810
 
2811
 
2812
static void
2813
ilogb_test (void)
2814
{
2815
  START (ilogb);
2816
 
2817
  TEST_f_i (ilogb, 1, 0);
2818
  TEST_f_i (ilogb, M_El, 1);
2819
  TEST_f_i (ilogb, 1024, 10);
2820
  TEST_f_i (ilogb, -2000, 10);
2821
 
2822
  /* XXX We have a problem here: the standard does not tell us whether
2823
     exceptions are allowed/required.  ignore them for now.  */
2824
 
2825
  TEST_f_i (ilogb, 0.0, FP_ILOGB0, EXCEPTIONS_OK);
2826
  TEST_f_i (ilogb, nan_value, FP_ILOGBNAN, EXCEPTIONS_OK);
2827
  TEST_f_i (ilogb, plus_infty, INT_MAX, EXCEPTIONS_OK);
2828
  TEST_f_i (ilogb, minus_infty, INT_MAX, EXCEPTIONS_OK);
2829
 
2830
  END (ilogb);
2831
}
2832
 
2833
static void
2834
isfinite_test (void)
2835
{
2836
  START (isfinite);
2837
 
2838
  TEST_f_b (isfinite, 0, 1);
2839
  TEST_f_b (isfinite, minus_zero, 1);
2840
  TEST_f_b (isfinite, 10, 1);
2841
  TEST_f_b (isfinite, plus_infty, 0);
2842
  TEST_f_b (isfinite, minus_infty, 0);
2843
  TEST_f_b (isfinite, nan_value, 0);
2844
 
2845
  END (isfinite);
2846
}
2847
 
2848
static void
2849
isnormal_test (void)
2850
{
2851
  START (isnormal);
2852
 
2853
  TEST_f_b (isnormal, 0, 0);
2854
  TEST_f_b (isnormal, minus_zero, 0);
2855
  TEST_f_b (isnormal, 10, 1);
2856
  TEST_f_b (isnormal, plus_infty, 0);
2857
  TEST_f_b (isnormal, minus_infty, 0);
2858
  TEST_f_b (isnormal, nan_value, 0);
2859
 
2860
  END (isnormal);
2861
}
2862
 
2863
static void
2864
j0_test (void)
2865
{
2866
  errno = 0;
2867
#if 0
2868
  FLOAT s, c;
2869
  FUNC (sincos) (0, &s, &c);
2870
  if (errno == ENOSYS)
2871
    /* Required function not implemented.  */
2872
    return;
2873
#endif
2874
  FUNC(j0) (0);
2875
  if (errno == ENOSYS)
2876
    /* Function not implemented.  */
2877
    return;
2878
 
2879
  START (j0);
2880
 
2881
  /* j0 is the Bessel function of the first kind of order 0 */
2882
  TEST_f_f (j0, nan_value, nan_value);
2883
  TEST_f_f (j0, plus_infty, 0);
2884
  TEST_f_f (j0, -1.0, 0.76519768655796655145L);
2885
  TEST_f_f (j0, 0.0, 1.0);
2886
  TEST_f_f (j0, 0.1L, 0.99750156206604003228L);
2887
  TEST_f_f (j0, 0.7L, 0.88120088860740528084L);
2888
  TEST_f_f (j0, 1.0, 0.76519768655796655145L);
2889
  TEST_f_f (j0, 1.5, 0.51182767173591812875L);
2890
  TEST_f_f (j0, 2.0, 0.22389077914123566805L);
2891
  TEST_f_f (j0, 8.0, 0.17165080713755390609L);
2892
  TEST_f_f (j0, 10.0, -0.24593576445134833520L);
2893
  TEST_f_f (j0, 4.0, -3.9714980986384737228659076845169804197562E-1L);
2894
  TEST_f_f (j0, -4.0, -3.9714980986384737228659076845169804197562E-1L);
2895
 
2896
  END (j0);
2897
}
2898
 
2899
 
2900
static void
2901
j1_test (void)
2902
{
2903
  errno = 0;
2904
#if 0
2905
  FLOAT s, c;
2906
  FUNC (sincos) (0, &s, &c);
2907
  if (errno == ENOSYS)
2908
    /* Required function not implemented.  */
2909
    return;
2910
#endif
2911
  FUNC(j1) (0);
2912
  if (errno == ENOSYS)
2913
    /* Function not implemented.  */
2914
    return;
2915
 
2916
  /* j1 is the Bessel function of the first kind of order 1 */
2917
 
2918
  START (j1);
2919
 
2920
  TEST_f_f (j1, nan_value, nan_value);
2921
  TEST_f_f (j1, plus_infty, 0);
2922
 
2923
  TEST_f_f (j1, -1.0, -0.44005058574493351596L);
2924
  TEST_f_f (j1, 0.0, 0.0);
2925
  TEST_f_f (j1, 0.1L, 0.049937526036241997556L);
2926
  TEST_f_f (j1, 0.7L, 0.32899574154005894785L);
2927
  TEST_f_f (j1, 1.0, 0.44005058574493351596L);
2928
  TEST_f_f (j1, 1.5, 0.55793650791009964199L);
2929
  TEST_f_f (j1, 2.0, 0.57672480775687338720L);
2930
  TEST_f_f (j1, 8.0, 0.23463634685391462438L);
2931
  TEST_f_f (j1, 10.0, 0.043472746168861436670L);
2932
 
2933
  END (j1);
2934
}
2935
 
2936
static void
2937
jn_test (void)
2938
{
2939
  errno = 0;
2940
#if 0
2941
  FLOAT s, c;
2942
  FUNC (sincos) (0, &s, &c);
2943
  if (errno == ENOSYS)
2944
    /* Required function not implemented.  */
2945
    return;
2946
#endif
2947
  FUNC(jn) (1, 1);
2948
  if (errno == ENOSYS)
2949
    /* Function not implemented.  */
2950
    return;
2951
 
2952
  /* jn is the Bessel function of the first kind of order n.  */
2953
  START (jn);
2954
 
2955
  /* jn (0, x) == j0 (x)  */
2956
  TEST_ff_f (jn, 0, nan_value, nan_value);
2957
  TEST_ff_f (jn, 0, plus_infty, 0);
2958
  TEST_ff_f (jn, 0, -1.0, 0.76519768655796655145L);
2959
  TEST_ff_f (jn, 0, 0.0, 1.0);
2960
  TEST_ff_f (jn, 0, 0.1L, 0.99750156206604003228L);
2961
  TEST_ff_f (jn, 0, 0.7L, 0.88120088860740528084L);
2962
  TEST_ff_f (jn, 0, 1.0, 0.76519768655796655145L);
2963
  TEST_ff_f (jn, 0, 1.5, 0.51182767173591812875L);
2964
  TEST_ff_f (jn, 0, 2.0, 0.22389077914123566805L);
2965
  TEST_ff_f (jn, 0, 8.0, 0.17165080713755390609L);
2966
  TEST_ff_f (jn, 0, 10.0, -0.24593576445134833520L);
2967
 
2968
  /* jn (1, x) == j1 (x)  */
2969
  TEST_ff_f (jn, 1, nan_value, nan_value);
2970
  TEST_ff_f (jn, 1, plus_infty, 0);
2971
 
2972
  TEST_ff_f (jn, 1, -1.0, -0.44005058574493351596L);
2973
  TEST_ff_f (jn, 1, 0.0, 0.0);
2974
  TEST_ff_f (jn, 1, 0.1L, 0.049937526036241997556L);
2975
  TEST_ff_f (jn, 1, 0.7L, 0.32899574154005894785L);
2976
  TEST_ff_f (jn, 1, 1.0, 0.44005058574493351596L);
2977
  TEST_ff_f (jn, 1, 1.5, 0.55793650791009964199L);
2978
  TEST_ff_f (jn, 1, 2.0, 0.57672480775687338720L);
2979
  TEST_ff_f (jn, 1, 8.0, 0.23463634685391462438L);
2980
  TEST_ff_f (jn, 1, 10.0, 0.043472746168861436670L);
2981
 
2982
  /* jn (3, x)  */
2983
  TEST_ff_f (jn, 3, nan_value, nan_value);
2984
  TEST_ff_f (jn, 3, plus_infty, 0);
2985
 
2986
  TEST_ff_f (jn, 3, -1.0, -0.019563353982668405919L);
2987
  TEST_ff_f (jn, 3, 0.0, 0.0);
2988
  TEST_ff_f (jn, 3, 0.1L, 0.000020820315754756261429L);
2989
  TEST_ff_f (jn, 3, 0.7L, 0.0069296548267508408077L);
2990
  TEST_ff_f (jn, 3, 1.0, 0.019563353982668405919L);
2991
  TEST_ff_f (jn, 3, 2.0, 0.12894324947440205110L);
2992
  TEST_ff_f (jn, 3, 10.0, 0.058379379305186812343L);
2993
 
2994
  /*  jn (10, x)  */
2995
  TEST_ff_f (jn, 10, nan_value, nan_value);
2996
  TEST_ff_f (jn, 10, plus_infty, 0);
2997
 
2998
  TEST_ff_f (jn, 10, -1.0, 0.26306151236874532070e-9L);
2999
  TEST_ff_f (jn, 10, 0.0, 0.0);
3000
  TEST_ff_f (jn, 10, 0.1L, 0.26905328954342155795e-19L);
3001
  TEST_ff_f (jn, 10, 0.7L, 0.75175911502153953928e-11L);
3002
  TEST_ff_f (jn, 10, 1.0, 0.26306151236874532070e-9L);
3003
  TEST_ff_f (jn, 10, 2.0, 0.25153862827167367096e-6L);
3004
  TEST_ff_f (jn, 10, 10.0, 0.20748610663335885770L);
3005
 
3006
  END (jn);
3007
}
3008
 
3009
 
3010
static void
3011
ldexp_test (void)
3012
{
3013
  TEST_ff_f (ldexp, 0, 0, 0);
3014
  TEST_ff_f (ldexp, minus_zero, 0, minus_zero);
3015
 
3016
  TEST_ff_f (ldexp, plus_infty, 1, plus_infty);
3017
  TEST_ff_f (ldexp, minus_infty, 1, minus_infty);
3018
  TEST_ff_f (ldexp, nan_value, 1, nan_value);
3019
 
3020
  TEST_ff_f (ldexp, 0.8L, 4, 12.8L);
3021
  TEST_ff_f (ldexp, -0.854375L, 5, -27.34L);
3022
 
3023
  /* ldexp (x, 0) == x.  */
3024
  TEST_ff_f (ldexp, 1.0L, 0L, 1.0L);
3025
}
3026
 
3027
static void
3028
lgamma_test (void)
3029
{
3030
  errno = 0;
3031
  FUNC(lgamma) (0);
3032
  if (errno == ENOSYS)
3033
    /* Function not implemented.  */
3034
    return;
3035
  feclearexcept (FE_ALL_EXCEPT);
3036
 
3037
  START (lgamma);
3038
 
3039
  TEST_f_f (lgamma, plus_infty, plus_infty);
3040
  TEST_f_f (lgamma, 0, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
3041
  TEST_f_f (lgamma, nan_value, nan_value);
3042
 
3043
  /* lgamma (x) == +inf plus divide by zero exception for integer x <= 0.  */
3044
  TEST_f_f (lgamma, -3, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
3045
  TEST_f_f (lgamma, minus_infty, plus_infty);
3046
 
3047
  TEST_f_f1 (lgamma, 1, 0, 1);
3048
 
3049
  TEST_f_f1 (lgamma, 3, M_LN2l, 1);
3050
 
3051
  TEST_f_f1 (lgamma, 0.5, M_LOG_SQRT_PIl, 1);
3052
  TEST_f_f1 (lgamma, -0.5, M_LOG_2_SQRT_PIl, -1);
3053
  TEST_f_f1 (lgamma, 0.7L, 0.26086724653166651439L, 1);
3054
  TEST_f_f1 (lgamma, 1.2L, -0.853740900033158497197e-1L, 1);
3055
 
3056
  END (lgamma);
3057
}
3058
 
3059
#if 0
3060
static void
3061
lrint_test (void)
3062
{
3063
  /* XXX this test is incomplete.  We need to have a way to specifiy
3064
     the rounding method and test the critical cases.  So far, only
3065
     unproblematic numbers are tested.  */
3066
 
3067
  START (lrint);
3068
 
3069
  TEST_f_l (lrint, 0.0, 0);
3070
  TEST_f_l (lrint, minus_zero, 0);
3071
  TEST_f_l (lrint, 0.2L, 0);
3072
  TEST_f_l (lrint, -0.2L, 0);
3073
 
3074
  TEST_f_l (lrint, 1.4L, 1);
3075
  TEST_f_l (lrint, -1.4L, -1);
3076
 
3077
  TEST_f_l (lrint, 8388600.3L, 8388600);
3078
  TEST_f_l (lrint, -8388600.3L, -8388600);
3079
 
3080
  END (lrint);
3081
}
3082
 
3083
static void
3084
llrint_test (void)
3085
{
3086
  /* XXX this test is incomplete.  We need to have a way to specifiy
3087
     the rounding method and test the critical cases.  So far, only
3088
     unproblematic numbers are tested.  */
3089
 
3090
  START (llrint);
3091
 
3092
  TEST_f_L (llrint, 0.0, 0);
3093
  TEST_f_L (llrint, minus_zero, 0);
3094
  TEST_f_L (llrint, 0.2L, 0);
3095
  TEST_f_L (llrint, -0.2L, 0);
3096
 
3097
  TEST_f_L (llrint, 1.4L, 1);
3098
  TEST_f_L (llrint, -1.4L, -1);
3099
 
3100
  TEST_f_L (llrint, 8388600.3L, 8388600);
3101
  TEST_f_L (llrint, -8388600.3L, -8388600);
3102
 
3103
  /* Test boundary conditions.  */
3104
  /* 0x1FFFFF */
3105
  TEST_f_L (llrint, 2097151.0,2097151LL);
3106
  /* 0x800000 */
3107
  TEST_f_L (llrint, 8388608.0, 8388608LL);
3108
  /* 0x1000000 */
3109
  TEST_f_L (llrint, 16777216.0, 16777216LL);
3110
  /* 0x20000000000 */
3111
  TEST_f_L (llrint, 2199023255552.0, 2199023255552LL);
3112
  /* 0x40000000000 */
3113
  TEST_f_L (llrint, 4398046511104.0, 4398046511104LL);
3114
  /* 0x10000000000000 */
3115
  TEST_f_L (llrint, 4503599627370496.0, 4503599627370496LL);
3116
  /* 0x10000080000000 */
3117
  TEST_f_L (llrint, 4503601774854144.0, 4503601774854144LL);
3118
  /* 0x20000000000000 */
3119
  TEST_f_L (llrint, 9007199254740992.0, 9007199254740992LL);
3120
  /* 0x80000000000000 */
3121
  TEST_f_L (llrint, 36028797018963968.0, 36028797018963968LL);
3122
  /* 0x100000000000000 */
3123
  TEST_f_L (llrint, 72057594037927936.0, 72057594037927936LL);
3124
 
3125
  END (llrint);
3126
}
3127
#endif
3128
 
3129
static void
3130
log_test (void)
3131
{
3132
  errno = 0;
3133
  FUNC(log) (1);
3134
  if (errno == ENOSYS)
3135
    /* Function not implemented.  */
3136
    return;
3137
  START (log);
3138
 
3139
  TEST_f_f (log, 0, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
3140
  TEST_f_f (log, minus_zero, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
3141
 
3142
  TEST_f_f (log, 1, 0);
3143
 
3144
  TEST_f_f (log, -1, nan_value, INVALID_EXCEPTION);
3145
  TEST_f_f (log, plus_infty, plus_infty);
3146
 
3147
  TEST_f_f (log, M_El, 1);
3148
  TEST_f_f (log, 1.0 / M_El, -1);
3149
  TEST_f_f (log, 2, M_LN2l);
3150
  TEST_f_f (log, 10, M_LN10l);
3151
  TEST_f_f (log, 0.7L, -0.35667494393873237891263871124118447L);
3152
 
3153
  END (log);
3154
}
3155
 
3156
 
3157
static void
3158
log10_test (void)
3159
{
3160
  errno = 0;
3161
  FUNC(log10) (1);
3162
  if (errno == ENOSYS)
3163
    /* Function not implemented.  */
3164
    return;
3165
 
3166
  START (log10);
3167
 
3168
  TEST_f_f (log10, 0, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
3169
  TEST_f_f (log10, minus_zero, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
3170
 
3171
  TEST_f_f (log10, 1, 0);
3172
 
3173
  /* log10 (x) == NaN plus invalid exception if x < 0.  */
3174
  TEST_f_f (log10, -1, nan_value, INVALID_EXCEPTION);
3175
 
3176
  TEST_f_f (log10, plus_infty, plus_infty);
3177
  TEST_f_f (log10, nan_value, nan_value);
3178
 
3179
  TEST_f_f (log10, 0.1L, -1);
3180
  TEST_f_f (log10, 10.0, 1);
3181
  TEST_f_f (log10, 100.0, 2);
3182
  TEST_f_f (log10, 10000.0, 4);
3183
  TEST_f_f (log10, M_El, M_LOG10El);
3184
  TEST_f_f (log10, 0.7L, -0.15490195998574316929L);
3185
 
3186
  END (log10);
3187
}
3188
 
3189
 
3190
static void
3191
log1p_test (void)
3192
{
3193
  errno = 0;
3194
  FUNC(log1p) (0);
3195
  if (errno == ENOSYS)
3196
    /* Function not implemented.  */
3197
    return;
3198
 
3199
  START (log1p);
3200
 
3201
  TEST_f_f (log1p, 0, 0);
3202
  TEST_f_f (log1p, minus_zero, minus_zero);
3203
 
3204
  TEST_f_f (log1p, -1, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
3205
  TEST_f_f (log1p, -2, nan_value, INVALID_EXCEPTION);
3206
 
3207
  TEST_f_f (log1p, plus_infty, plus_infty);
3208
  TEST_f_f (log1p, nan_value, nan_value);
3209
 
3210
  TEST_f_f (log1p, M_El - 1.0, 1);
3211
 
3212
  TEST_f_f (log1p, -0.3L, -0.35667494393873237891263871124118447L);
3213
 
3214
  END (log1p);
3215
}
3216
 
3217
#if 0
3218
static void
3219
log2_test (void)
3220
{
3221
  errno = 0;
3222
  FUNC(log2) (1);
3223
  if (errno == ENOSYS)
3224
    /* Function not implemented.  */
3225
    return;
3226
 
3227
  START (log2);
3228
 
3229
  TEST_f_f (log2, 0, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
3230
  TEST_f_f (log2, minus_zero, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
3231
 
3232
  TEST_f_f (log2, 1, 0);
3233
 
3234
  TEST_f_f (log2, -1, nan_value, INVALID_EXCEPTION);
3235
 
3236
  TEST_f_f (log2, plus_infty, plus_infty);
3237
  TEST_f_f (log2, nan_value, nan_value);
3238
 
3239
  TEST_f_f (log2, M_El, M_LOG2El);
3240
  TEST_f_f (log2, 2.0, 1);
3241
  TEST_f_f (log2, 16.0, 4);
3242
  TEST_f_f (log2, 256.0, 8);
3243
  TEST_f_f (log2, 0.7L, -0.51457317282975824043L);
3244
 
3245
  END (log2);
3246
}
3247
#endif
3248
 
3249
 
3250
static void
3251
logb_test (void)
3252
{
3253
  START (logb);
3254
 
3255
  TEST_f_f (logb, plus_infty, plus_infty);
3256
  TEST_f_f (logb, minus_infty, plus_infty);
3257
 
3258
  TEST_f_f (logb, 0, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
3259
 
3260
  TEST_f_f (logb, minus_zero, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
3261
  TEST_f_f (logb, nan_value, nan_value);
3262
 
3263
  TEST_f_f (logb, 1, 0);
3264
  TEST_f_f (logb, M_El, 1);
3265
  TEST_f_f (logb, 1024, 10);
3266
  TEST_f_f (logb, -2000, 10);
3267
 
3268
  END (logb);
3269
}
3270
 
3271
#if 0
3272
static void
3273
lround_test (void)
3274
{
3275
  START (lround);
3276
 
3277
  TEST_f_l (lround, 0, 0);
3278
  TEST_f_l (lround, minus_zero, 0);
3279
  TEST_f_l (lround, 0.2L, 0.0);
3280
  TEST_f_l (lround, -0.2L, 0);
3281
  TEST_f_l (lround, 0.5, 1);
3282
  TEST_f_l (lround, -0.5, -1);
3283
  TEST_f_l (lround, 0.8L, 1);
3284
  TEST_f_l (lround, -0.8L, -1);
3285
  TEST_f_l (lround, 1.5, 2);
3286
  TEST_f_l (lround, -1.5, -2);
3287
  TEST_f_l (lround, 22514.5, 22515);
3288
  TEST_f_l (lround, -22514.5, -22515);
3289
#ifndef TEST_FLOAT
3290
  TEST_f_l (lround, 2097152.5, 2097153);
3291
  TEST_f_l (lround, -2097152.5, -2097153);
3292
#endif
3293
  END (lround);
3294
}
3295
 
3296
 
3297
static void
3298
llround_test (void)
3299
{
3300
  START (llround);
3301
 
3302
  TEST_f_L (llround, 0, 0);
3303
  TEST_f_L (llround, minus_zero, 0);
3304
  TEST_f_L (llround, 0.2L, 0.0);
3305
  TEST_f_L (llround, -0.2L, 0);
3306
  TEST_f_L (llround, 0.5, 1);
3307
  TEST_f_L (llround, -0.5, -1);
3308
  TEST_f_L (llround, 0.8L, 1);
3309
  TEST_f_L (llround, -0.8L, -1);
3310
  TEST_f_L (llround, 1.5, 2);
3311
  TEST_f_L (llround, -1.5, -2);
3312
  TEST_f_L (llround, 22514.5, 22515);
3313
  TEST_f_L (llround, -22514.5, -22515);
3314
#ifndef TEST_FLOAT
3315
  TEST_f_L (llround, 2097152.5, 2097153);
3316
  TEST_f_L (llround, -2097152.5, -2097153);
3317
  TEST_f_L (llround, 34359738368.5, 34359738369ll);
3318
  TEST_f_L (llround, -34359738368.5, -34359738369ll);
3319
#endif
3320
 
3321
  /* Test boundary conditions.  */
3322
  /* 0x1FFFFF */
3323
  TEST_f_L (llround, 2097151.0, 2097151LL);
3324
  /* 0x800000 */
3325
  TEST_f_L (llround, 8388608.0, 8388608LL);
3326
  /* 0x1000000 */
3327
  TEST_f_L (llround, 16777216.0, 16777216LL);
3328
  /* 0x20000000000 */
3329
  TEST_f_L (llround, 2199023255552.0, 2199023255552LL);
3330
  /* 0x40000000000 */
3331
  TEST_f_L (llround, 4398046511104.0, 4398046511104LL);
3332
  /* 0x10000000000000 */
3333
  TEST_f_L (llround, 4503599627370496.0, 4503599627370496LL);
3334
  /* 0x10000080000000 */
3335
  TEST_f_L (llrint, 4503601774854144.0, 4503601774854144LL);
3336
  /* 0x20000000000000 */
3337
  TEST_f_L (llround, 9007199254740992.0, 9007199254740992LL);
3338
  /* 0x80000000000000 */
3339
  TEST_f_L (llround, 36028797018963968.0, 36028797018963968LL);
3340
  /* 0x100000000000000 */
3341
  TEST_f_L (llround, 72057594037927936.0, 72057594037927936LL);
3342
 
3343
#ifndef TEST_FLOAT
3344
  /* 0x100000000 */
3345
  TEST_f_L (llround, 4294967295.5, 4294967296LL);
3346
  /* 0x200000000 */
3347
  TEST_f_L (llround, 8589934591.5, 8589934592LL);
3348
#endif
3349
 
3350
  END (llround);
3351
}
3352
#endif
3353
 
3354
static void
3355
modf_test (void)
3356
{
3357
  FLOAT x;
3358
 
3359
  START (modf);
3360
 
3361
  TEST_fF_f1 (modf, plus_infty, 0, plus_infty);
3362
  TEST_fF_f1 (modf, minus_infty, minus_zero, minus_infty);
3363
  TEST_fF_f1 (modf, nan_value, nan_value, nan_value);
3364
  TEST_fF_f1 (modf, 0, 0, 0);
3365
  TEST_fF_f1 (modf, 1.5, 0.5, 1);
3366
  TEST_fF_f1 (modf, 2.5, 0.5, 2);
3367
  TEST_fF_f1 (modf, -2.5, -0.5, -2);
3368
  TEST_fF_f1 (modf, 20, 0, 20);
3369
  TEST_fF_f1 (modf, 21, 0, 21);
3370
  TEST_fF_f1 (modf, 89.5, 0.5, 89);
3371
 
3372
  END (modf);
3373
}
3374
 
3375
 
3376
#if 0
3377
static void
3378
nearbyint_test (void)
3379
{
3380
  START (nearbyint);
3381
 
3382
  TEST_f_f (nearbyint, 0.0, 0.0);
3383
  TEST_f_f (nearbyint, minus_zero, minus_zero);
3384
  TEST_f_f (nearbyint, plus_infty, plus_infty);
3385
  TEST_f_f (nearbyint, minus_infty, minus_infty);
3386
  TEST_f_f (nearbyint, nan_value, nan_value);
3387
 
3388
  /* Default rounding mode is round to nearest.  */
3389
  TEST_f_f (nearbyint, 0.5, 0.0);
3390
  TEST_f_f (nearbyint, 1.5, 2.0);
3391
  TEST_f_f (nearbyint, -0.5, minus_zero);
3392
  TEST_f_f (nearbyint, -1.5, -2.0);
3393
 
3394
  END (nearbyint);
3395
}
3396
 
3397
static void
3398
nextafter_test (void)
3399
{
3400
 
3401
  START (nextafter);
3402
 
3403
  TEST_ff_f (nextafter, 0, 0, 0);
3404
  TEST_ff_f (nextafter, minus_zero, 0, 0);
3405
  TEST_ff_f (nextafter, 0, minus_zero, minus_zero);
3406
  TEST_ff_f (nextafter, minus_zero, minus_zero, minus_zero);
3407
 
3408
  TEST_ff_f (nextafter, 9, 9, 9);
3409
  TEST_ff_f (nextafter, -9, -9, -9);
3410
  TEST_ff_f (nextafter, plus_infty, plus_infty, plus_infty);
3411
  TEST_ff_f (nextafter, minus_infty, minus_infty, minus_infty);
3412
 
3413
  TEST_ff_f (nextafter, nan_value, 1.1L, nan_value);
3414
  TEST_ff_f (nextafter, 1.1L, nan_value, nan_value);
3415
  TEST_ff_f (nextafter, nan_value, nan_value, nan_value);
3416
 
3417
  /* XXX We need the hexadecimal FP number representation here for further
3418
     tests.  */
3419
 
3420
  END (nextafter);
3421
}
3422
 
3423
 
3424
static void
3425
nexttoward_test (void)
3426
{
3427
  START (nexttoward);
3428
  TEST_ff_f (nexttoward, 0, 0, 0);
3429
  TEST_ff_f (nexttoward, minus_zero, 0, 0);
3430
  TEST_ff_f (nexttoward, 0, minus_zero, minus_zero);
3431
  TEST_ff_f (nexttoward, minus_zero, minus_zero, minus_zero);
3432
 
3433
  TEST_ff_f (nexttoward, 9, 9, 9);
3434
  TEST_ff_f (nexttoward, -9, -9, -9);
3435
  TEST_ff_f (nexttoward, plus_infty, plus_infty, plus_infty);
3436
  TEST_ff_f (nexttoward, minus_infty, minus_infty, minus_infty);
3437
 
3438
  TEST_ff_f (nexttoward, nan_value, 1.1L, nan_value);
3439
  TEST_ff_f (nexttoward, 1.1L, nan_value, nan_value);
3440
  TEST_ff_f (nexttoward, nan_value, nan_value, nan_value);
3441
 
3442
  /* XXX We need the hexadecimal FP number representation here for further
3443
     tests.  */
3444
 
3445
  END (nexttoward);
3446
}
3447
#endif
3448
 
3449
static void
3450
pow_test (void)
3451
{
3452
 
3453
  errno = 0;
3454
  FUNC(pow) (0, 0);
3455
  if (errno == ENOSYS)
3456
    /* Function not implemented.  */
3457
    return;
3458
 
3459
  START (pow);
3460
 
3461
  TEST_ff_f (pow, 0, 0, 1);
3462
  TEST_ff_f (pow, 0, minus_zero, 1);
3463
  TEST_ff_f (pow, minus_zero, 0, 1);
3464
  TEST_ff_f (pow, minus_zero, minus_zero, 1);
3465
 
3466
  TEST_ff_f (pow, 10, 0, 1);
3467
  TEST_ff_f (pow, 10, minus_zero, 1);
3468
  TEST_ff_f (pow, -10, 0, 1);
3469
  TEST_ff_f (pow, -10, minus_zero, 1);
3470
 
3471
  TEST_ff_f (pow, nan_value, 0, 1);
3472
  TEST_ff_f (pow, nan_value, minus_zero, 1);
3473
 
3474
 
3475
#ifndef TEST_INLINE
3476
  TEST_ff_f (pow, 1.1L, plus_infty, plus_infty);
3477
  TEST_ff_f (pow, plus_infty, plus_infty, plus_infty);
3478
  TEST_ff_f (pow, -1.1L, plus_infty, plus_infty);
3479
  TEST_ff_f (pow, minus_infty, plus_infty, plus_infty);
3480
 
3481
  TEST_ff_f (pow, 0.9L, plus_infty, 0);
3482
  TEST_ff_f (pow, 1e-7L, plus_infty, 0);
3483
  TEST_ff_f (pow, -0.9L, plus_infty, 0);
3484
  TEST_ff_f (pow, -1e-7L, plus_infty, 0);
3485
 
3486
  TEST_ff_f (pow, 1.1L, minus_infty, 0);
3487
  TEST_ff_f (pow, plus_infty, minus_infty, 0);
3488
  TEST_ff_f (pow, -1.1L, minus_infty, 0);
3489
  TEST_ff_f (pow, minus_infty, minus_infty, 0);
3490
 
3491
  TEST_ff_f (pow, 0.9L, minus_infty, plus_infty);
3492
  TEST_ff_f (pow, 1e-7L, minus_infty, plus_infty);
3493
  TEST_ff_f (pow, -0.9L, minus_infty, plus_infty);
3494
  TEST_ff_f (pow, -1e-7L, minus_infty, plus_infty);
3495
 
3496
  TEST_ff_f (pow, plus_infty, 1e-7L, plus_infty);
3497
  TEST_ff_f (pow, plus_infty, 1, plus_infty);
3498
  TEST_ff_f (pow, plus_infty, 1e7L, plus_infty);
3499
 
3500
  TEST_ff_f (pow, plus_infty, -1e-7L, 0);
3501
  TEST_ff_f (pow, plus_infty, -1, 0);
3502
  TEST_ff_f (pow, plus_infty, -1e7L, 0);
3503
 
3504
  TEST_ff_f (pow, minus_infty, 1, minus_infty);
3505
  TEST_ff_f (pow, minus_infty, 11, minus_infty);
3506
  TEST_ff_f (pow, minus_infty, 1001, minus_infty);
3507
 
3508
  TEST_ff_f (pow, minus_infty, 2, plus_infty);
3509
  TEST_ff_f (pow, minus_infty, 12, plus_infty);
3510
  TEST_ff_f (pow, minus_infty, 1002, plus_infty);
3511
  TEST_ff_f (pow, minus_infty, 0.1L, plus_infty);
3512
  TEST_ff_f (pow, minus_infty, 1.1L, plus_infty);
3513
  TEST_ff_f (pow, minus_infty, 11.1L, plus_infty);
3514
  TEST_ff_f (pow, minus_infty, 1001.1L, plus_infty);
3515
 
3516
  TEST_ff_f (pow, minus_infty, -1, minus_zero);
3517
  TEST_ff_f (pow, minus_infty, -11, minus_zero);
3518
  TEST_ff_f (pow, minus_infty, -1001, minus_zero);
3519
 
3520
  TEST_ff_f (pow, minus_infty, -2, 0);
3521
  TEST_ff_f (pow, minus_infty, -12, 0);
3522
  TEST_ff_f (pow, minus_infty, -1002, 0);
3523
  TEST_ff_f (pow, minus_infty, -0.1L, 0);
3524
  TEST_ff_f (pow, minus_infty, -1.1L, 0);
3525
  TEST_ff_f (pow, minus_infty, -11.1L, 0);
3526
  TEST_ff_f (pow, minus_infty, -1001.1L, 0);
3527
#endif
3528
 
3529
  TEST_ff_f (pow, nan_value, nan_value, nan_value);
3530
  TEST_ff_f (pow, 0, nan_value, nan_value);
3531
  TEST_ff_f (pow, 1, nan_value, 1);
3532
  TEST_ff_f (pow, -1, nan_value, nan_value);
3533
  TEST_ff_f (pow, nan_value, 1, nan_value);
3534
  TEST_ff_f (pow, nan_value, -1, nan_value);
3535
 
3536
  /* pow (x, NaN) == NaN.  */
3537
  TEST_ff_f (pow, 3.0, nan_value, nan_value);
3538
 
3539
  TEST_ff_f (pow, 1, plus_infty, 1);
3540
  TEST_ff_f (pow, -1, plus_infty, 1);
3541
  TEST_ff_f (pow, 1, minus_infty, 1);
3542
  TEST_ff_f (pow, -1, minus_infty, 1);
3543
 
3544
  TEST_ff_f (pow, -0.1L, 1.1L, nan_value, INVALID_EXCEPTION);
3545
  TEST_ff_f (pow, -0.1L, -1.1L, nan_value, INVALID_EXCEPTION);
3546
  TEST_ff_f (pow, -10.1L, 1.1L, nan_value, INVALID_EXCEPTION);
3547
  TEST_ff_f (pow, -10.1L, -1.1L, nan_value, INVALID_EXCEPTION);
3548
 
3549
  TEST_ff_f (pow, 0, -1, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
3550
  TEST_ff_f (pow, 0, -11, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
3551
  TEST_ff_f (pow, minus_zero, -1, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
3552
  TEST_ff_f (pow, minus_zero, -11, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
3553
 
3554
  TEST_ff_f (pow, 0, -2, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
3555
  TEST_ff_f (pow, 0, -11.1L, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
3556
  TEST_ff_f (pow, minus_zero, -2, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
3557
  TEST_ff_f (pow, minus_zero, -11.1L, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
3558
 
3559
 
3560
  TEST_ff_f (pow, 0, 1, 0);
3561
  TEST_ff_f (pow, 0, 11, 0);
3562
 
3563
  TEST_ff_f (pow, minus_zero, 1, minus_zero);
3564
  TEST_ff_f (pow, minus_zero, 11, minus_zero);
3565
 
3566
 
3567
  TEST_ff_f (pow, 0, 2, 0);
3568
  TEST_ff_f (pow, 0, 11.1L, 0);
3569
 
3570
 
3571
  TEST_ff_f (pow, minus_zero, 2, 0);
3572
  TEST_ff_f (pow, minus_zero, 11.1L, 0);
3573
 
3574
#ifndef TEST_INLINE
3575
  /* pow (x, +inf) == +inf for |x| > 1.  */
3576
  TEST_ff_f (pow, 1.5, plus_infty, plus_infty);
3577
 
3578
  /* pow (x, +inf) == +0 for |x| < 1.  */
3579
  TEST_ff_f (pow, 0.5, plus_infty, 0.0);
3580
 
3581
  /* pow (x, -inf) == +0 for |x| > 1.  */
3582
  TEST_ff_f (pow, 1.5, minus_infty, 0.0);
3583
 
3584
  /* pow (x, -inf) == +inf for |x| < 1.  */
3585
  TEST_ff_f (pow, 0.5, minus_infty, plus_infty);
3586
#endif
3587
 
3588
  /* pow (+inf, y) == +inf for y > 0.  */
3589
  TEST_ff_f (pow, plus_infty, 2, plus_infty);
3590
 
3591
  /* pow (+inf, y) == +0 for y < 0.  */
3592
  TEST_ff_f (pow, plus_infty, -1, 0.0);
3593
 
3594
  /* pow (-inf, y) == -inf for y an odd integer > 0.  */
3595
  TEST_ff_f (pow, minus_infty, 27, minus_infty);
3596
 
3597
  /* pow (-inf, y) == +inf for y > 0 and not an odd integer.  */
3598
  TEST_ff_f (pow, minus_infty, 28, plus_infty);
3599
 
3600
  /* pow (-inf, y) == -0 for y an odd integer < 0. */
3601
  TEST_ff_f (pow, minus_infty, -3, minus_zero);
3602
  /* pow (-inf, y) == +0 for y < 0 and not an odd integer.  */
3603
  TEST_ff_f (pow, minus_infty, -2.0, 0.0);
3604
 
3605
  /* pow (+0, y) == +0 for y an odd integer > 0.  */
3606
  TEST_ff_f (pow, 0.0, 27, 0.0);
3607
 
3608
  /* pow (-0, y) == -0 for y an odd integer > 0.  */
3609
  TEST_ff_f (pow, minus_zero, 27, minus_zero);
3610
 
3611
  /* pow (+0, y) == +0 for y > 0 and not an odd integer.  */
3612
  TEST_ff_f (pow, 0.0, 4, 0.0);
3613
 
3614
  /* pow (-0, y) == +0 for y > 0 and not an odd integer.  */
3615
  TEST_ff_f (pow, minus_zero, 4, 0.0);
3616
 
3617
  TEST_ff_f (pow, 0.7L, 1.2L, 0.65180494056638638188L);
3618
 
3619
#if defined TEST_DOUBLE || defined TEST_LDOUBLE
3620
  TEST_ff_f (pow, -7.49321e+133, -9.80818e+16, 0);
3621
#endif
3622
 
3623
  END (pow);
3624
}
3625
 
3626
static void
3627
remainder_test (void)
3628
{
3629
  errno = 0;
3630
  FUNC(remainder) (1.625, 1.0);
3631
  if (errno == ENOSYS)
3632
    /* Function not implemented.  */
3633
    return;
3634
 
3635
  START (remainder);
3636
 
3637
  TEST_ff_f (remainder, 1, 0, nan_value, INVALID_EXCEPTION);
3638
  TEST_ff_f (remainder, 1, minus_zero, nan_value, INVALID_EXCEPTION);
3639
  TEST_ff_f (remainder, plus_infty, 1, nan_value, INVALID_EXCEPTION);
3640
  TEST_ff_f (remainder, minus_infty, 1, nan_value, INVALID_EXCEPTION);
3641
  TEST_ff_f (remainder, nan_value, nan_value, nan_value);
3642
 
3643
  TEST_ff_f (remainder, 1.625, 1.0, -0.375);
3644
  TEST_ff_f (remainder, -1.625, 1.0, 0.375);
3645
  TEST_ff_f (remainder, 1.625, -1.0, -0.375);
3646
  TEST_ff_f (remainder, -1.625, -1.0, 0.375);
3647
  TEST_ff_f (remainder, 5.0, 2.0, 1.0);
3648
  TEST_ff_f (remainder, 3.0, 2.0, -1.0);
3649
 
3650
  END (remainder);
3651
}
3652
 
3653
#if 0
3654
static void
3655
remquo_test (void)
3656
{
3657
  /* x is needed.  */
3658
  int x;
3659
 
3660
  errno = 0;
3661
  FUNC(remquo) (1.625, 1.0, &x);
3662
  if (errno == ENOSYS)
3663
    /* Function not implemented.  */
3664
    return;
3665
 
3666
  START (remquo);
3667
 
3668
  TEST_ffI_f1 (remquo, 1, 0, nan_value, IGNORE, INVALID_EXCEPTION);
3669
  TEST_ffI_f1 (remquo, 1, minus_zero, nan_value, IGNORE, INVALID_EXCEPTION);
3670
  TEST_ffI_f1 (remquo, plus_infty, 1, nan_value, IGNORE, INVALID_EXCEPTION);
3671
  TEST_ffI_f1 (remquo, minus_infty, 1, nan_value, IGNORE, INVALID_EXCEPTION);
3672
  TEST_ffI_f1 (remquo, nan_value, nan_value, nan_value, IGNORE);
3673
 
3674
  TEST_ffI_f1 (remquo, 1.625, 1.0, -0.375, 2);
3675
  TEST_ffI_f1 (remquo, -1.625, 1.0, 0.375, -2);
3676
  TEST_ffI_f1 (remquo, 1.625, -1.0, -0.375, -2);
3677
  TEST_ffI_f1 (remquo, -1.625, -1.0, 0.375, 2);
3678
 
3679
  TEST_ffI_f1 (remquo, 5, 2, 1, 2);
3680
  TEST_ffI_f1 (remquo, 3, 2, -1, 2);
3681
 
3682
  END (remquo);
3683
}
3684
#endif
3685
 
3686
static void
3687
rint_test (void)
3688
{
3689
  START (rint);
3690
 
3691
  TEST_f_f (rint, 0.0, 0.0);
3692
  TEST_f_f (rint, minus_zero, minus_zero);
3693
  TEST_f_f (rint, plus_infty, plus_infty);
3694
  TEST_f_f (rint, minus_infty, minus_infty);
3695
 
3696
  /* Default rounding mode is round to even.  */
3697
  TEST_f_f (rint, 0.5, 0.0);
3698
  TEST_f_f (rint, 1.5, 2.0);
3699
  TEST_f_f (rint, 2.5, 2.0);
3700
  TEST_f_f (rint, 3.5, 4.0);
3701
  TEST_f_f (rint, 4.5, 4.0);
3702
  TEST_f_f (rint, -0.5, -0.0);
3703
  TEST_f_f (rint, -1.5, -2.0);
3704
  TEST_f_f (rint, -2.5, -2.0);
3705
  TEST_f_f (rint, -3.5, -4.0);
3706
  TEST_f_f (rint, -4.5, -4.0);
3707
 
3708
  END (rint);
3709
}
3710
 
3711
#if 0
3712
static void
3713
round_test (void)
3714
{
3715
  START (round);
3716
 
3717
  TEST_f_f (round, 0, 0);
3718
  TEST_f_f (round, minus_zero, minus_zero);
3719
  TEST_f_f (round, 0.2L, 0.0);
3720
  TEST_f_f (round, -0.2L, minus_zero);
3721
  TEST_f_f (round, 0.5, 1.0);
3722
  TEST_f_f (round, -0.5, -1.0);
3723
  TEST_f_f (round, 0.8L, 1.0);
3724
  TEST_f_f (round, -0.8L, -1.0);
3725
  TEST_f_f (round, 1.5, 2.0);
3726
  TEST_f_f (round, -1.5, -2.0);
3727
  TEST_f_f (round, 2097152.5, 2097153);
3728
  TEST_f_f (round, -2097152.5, -2097153);
3729
 
3730
  END (round);
3731
}
3732
#endif
3733
 
3734
 
3735
static void
3736
scalb_test (void)
3737
{
3738
 
3739
  START (scalb);
3740
 
3741
  TEST_ff_f (scalb, 2.0, 0.5, nan_value, INVALID_EXCEPTION);
3742
  TEST_ff_f (scalb, 3.0, -2.5, nan_value, INVALID_EXCEPTION);
3743
 
3744
  TEST_ff_f (scalb, 0, nan_value, nan_value);
3745
  TEST_ff_f (scalb, 1, nan_value, nan_value);
3746
 
3747
  TEST_ff_f (scalb, 1, 0, 1);
3748
  TEST_ff_f (scalb, -1, 0, -1);
3749
 
3750
  TEST_ff_f (scalb, 0, plus_infty, nan_value, INVALID_EXCEPTION);
3751
  TEST_ff_f (scalb, minus_zero, plus_infty, nan_value, INVALID_EXCEPTION);
3752
 
3753
  TEST_ff_f (scalb, 0, 2, 0);
3754
  TEST_ff_f (scalb, minus_zero, -4, minus_zero);
3755
  TEST_ff_f (scalb, 0, 0, 0);
3756
  TEST_ff_f (scalb, minus_zero, 0, minus_zero);
3757
  TEST_ff_f (scalb, 0, -1, 0);
3758
  TEST_ff_f (scalb, minus_zero, -10, minus_zero);
3759
  TEST_ff_f (scalb, 0, minus_infty, 0);
3760
  TEST_ff_f (scalb, minus_zero, minus_infty, minus_zero);
3761
 
3762
  TEST_ff_f (scalb, plus_infty, -1, plus_infty);
3763
  TEST_ff_f (scalb, minus_infty, -10, minus_infty);
3764
  TEST_ff_f (scalb, plus_infty, 0, plus_infty);
3765
  TEST_ff_f (scalb, minus_infty, 0, minus_infty);
3766
  TEST_ff_f (scalb, plus_infty, 2, plus_infty);
3767
  TEST_ff_f (scalb, minus_infty, 100, minus_infty);
3768
 
3769
  TEST_ff_f (scalb, 0.1L, minus_infty, 0.0);
3770
  TEST_ff_f (scalb, -0.1L, minus_infty, minus_zero);
3771
 
3772
  TEST_ff_f (scalb, 1, plus_infty, plus_infty);
3773
  TEST_ff_f (scalb, -1, plus_infty, minus_infty);
3774
  TEST_ff_f (scalb, plus_infty, plus_infty, plus_infty);
3775
  TEST_ff_f (scalb, minus_infty, plus_infty, minus_infty);
3776
 
3777
  TEST_ff_f (scalb, plus_infty, minus_infty, nan_value, INVALID_EXCEPTION);
3778
  TEST_ff_f (scalb, minus_infty, minus_infty, nan_value, INVALID_EXCEPTION);
3779
 
3780
  TEST_ff_f (scalb, nan_value, 1, nan_value);
3781
  TEST_ff_f (scalb, 1, nan_value, nan_value);
3782
  TEST_ff_f (scalb, nan_value, 0, nan_value);
3783
  TEST_ff_f (scalb, 0, nan_value, nan_value);
3784
  TEST_ff_f (scalb, nan_value, plus_infty, nan_value);
3785
  TEST_ff_f (scalb, plus_infty, nan_value, nan_value);
3786
  TEST_ff_f (scalb, nan_value, nan_value, nan_value);
3787
 
3788
  TEST_ff_f (scalb, 0.8L, 4, 12.8L);
3789
  TEST_ff_f (scalb, -0.854375L, 5, -27.34L);
3790
 
3791
  END (scalb);
3792
}
3793
 
3794
 
3795
static void
3796
scalbn_test (void)
3797
{
3798
 
3799
  START (scalbn);
3800
 
3801
  TEST_fi_f (scalbn, 0, 0, 0);
3802
  TEST_fi_f (scalbn, minus_zero, 0, minus_zero);
3803
 
3804
  TEST_fi_f (scalbn, plus_infty, 1, plus_infty);
3805
  TEST_fi_f (scalbn, minus_infty, 1, minus_infty);
3806
  TEST_fi_f (scalbn, nan_value, 1, nan_value);
3807
 
3808
  TEST_fi_f (scalbn, 0.8L, 4, 12.8L);
3809
  TEST_fi_f (scalbn, -0.854375L, 5, -27.34L);
3810
 
3811
  TEST_fi_f (scalbn, 1, 0L, 1);
3812
 
3813
  END (scalbn);
3814
}
3815
 
3816
#if 0
3817
static void
3818
scalbln_test (void)
3819
{
3820
 
3821
  START (scalbln);
3822
 
3823
  TEST_fl_f (scalbln, 0, 0, 0);
3824
  TEST_fl_f (scalbln, minus_zero, 0, minus_zero);
3825
 
3826
  TEST_fl_f (scalbln, plus_infty, 1, plus_infty);
3827
  TEST_fl_f (scalbln, minus_infty, 1, minus_infty);
3828
  TEST_fl_f (scalbln, nan_value, 1, nan_value);
3829
 
3830
  TEST_fl_f (scalbln, 0.8L, 4, 12.8L);
3831
  TEST_fl_f (scalbln, -0.854375L, 5, -27.34L);
3832
 
3833
  TEST_fl_f (scalbln, 1, 0L, 1);
3834
 
3835
  END (scalbn);
3836
}
3837
#endif
3838
 
3839
static void
3840
signbit_test (void)
3841
{
3842
 
3843
  START (signbit);
3844
 
3845
  TEST_f_b (signbit, 0, 0);
3846
  TEST_f_b (signbit, minus_zero, 1);
3847
  TEST_f_b (signbit, plus_infty, 0);
3848
  TEST_f_b (signbit, minus_infty, 1);
3849
 
3850
  /* signbit (x) != 0 for x < 0.  */
3851
  TEST_f_b (signbit, -1, 1);
3852
  /* signbit (x) == 0 for x >= 0.  */
3853
  TEST_f_b (signbit, 1, 0);
3854
 
3855
  END (signbit);
3856
}
3857
 
3858
static void
3859
sin_test (void)
3860
{
3861
  errno = 0;
3862
  FUNC(sin) (0);
3863
  if (errno == ENOSYS)
3864
    /* Function not implemented.  */
3865
    return;
3866
 
3867
  START (sin);
3868
 
3869
  TEST_f_f (sin, 0, 0);
3870
  TEST_f_f (sin, minus_zero, minus_zero);
3871
  TEST_f_f (sin, plus_infty, nan_value, INVALID_EXCEPTION);
3872
  TEST_f_f (sin, minus_infty, nan_value, INVALID_EXCEPTION);
3873
  TEST_f_f (sin, nan_value, nan_value);
3874
 
3875
  TEST_f_f (sin, M_PI_6l, 0.5);
3876
  TEST_f_f (sin, -M_PI_6l, -0.5);
3877
  TEST_f_f (sin, M_PI_2l, 1);
3878
  TEST_f_f (sin, -M_PI_2l, -1);
3879
  TEST_f_f (sin, 0.7L, 0.64421768723769105367261435139872014L);
3880
 
3881
  END (sin);
3882
 
3883
}
3884
 
3885
#if 0
3886
static void
3887
sincos_test (void)
3888
{
3889
  FLOAT sin_res, cos_res;
3890
 
3891
  errno = 0;
3892
  FUNC(sincos) (0, &sin_res, &cos_res);
3893
  if (errno == ENOSYS)
3894
    /* Function not implemented.  */
3895
    return;
3896
 
3897
  START (sincos);
3898
 
3899
  /* sincos is treated differently because it returns void.  */
3900
  TEST_extra (sincos, 0, 0, 1);
3901
 
3902
  TEST_extra (sincos, minus_zero, minus_zero, 1);
3903
  TEST_extra (sincos, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
3904
  TEST_extra (sincos, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
3905
  TEST_extra (sincos, nan_value, nan_value, nan_value);
3906
 
3907
  TEST_extra (sincos, M_PI_2l, 1, 0);
3908
  TEST_extra (sincos, M_PI_6l, 0.5, 0.86602540378443864676372317075293616L);
3909
  TEST_extra (sincos, M_PI_6l*2.0, 0.86602540378443864676372317075293616L, 0.5);
3910
  TEST_extra (sincos, 0.7L, 0.64421768723769105367261435139872014L, 0.76484218728448842625585999019186495L);
3911
 
3912
  END (sincos);
3913
}
3914
#endif
3915
 
3916
static void
3917
sinh_test (void)
3918
{
3919
  errno = 0;
3920
  FUNC(sinh) (0.7L);
3921
  if (errno == ENOSYS)
3922
    /* Function not implemented.  */
3923
    return;
3924
 
3925
  START (sinh);
3926
  TEST_f_f (sinh, 0, 0);
3927
  TEST_f_f (sinh, minus_zero, minus_zero);
3928
 
3929
#ifndef TEST_INLINE
3930
  TEST_f_f (sinh, plus_infty, plus_infty);
3931
  TEST_f_f (sinh, minus_infty, minus_infty);
3932
#endif
3933
  TEST_f_f (sinh, nan_value, nan_value);
3934
 
3935
  TEST_f_f (sinh, 0.7L, 0.75858370183953350346L);
3936
  TEST_f_f (sinh, 0x8p-32L, 1.86264514923095703232705808926175479e-9L);
3937
 
3938
  END (sinh);
3939
}
3940
 
3941
static void
3942
sqrt_test (void)
3943
{
3944
  errno = 0;
3945
  FUNC(sqrt) (1);
3946
  if (errno == ENOSYS)
3947
    /* Function not implemented.  */
3948
    return;
3949
 
3950
  START (sqrt);
3951
 
3952
  TEST_f_f (sqrt, 0, 0);
3953
  TEST_f_f (sqrt, nan_value, nan_value);
3954
  TEST_f_f (sqrt, plus_infty, plus_infty);
3955
 
3956
  TEST_f_f (sqrt, minus_zero, minus_zero);
3957
 
3958
  /* sqrt (x) == NaN plus invalid exception for x < 0.  */
3959
  TEST_f_f (sqrt, -1, nan_value, INVALID_EXCEPTION);
3960
  TEST_f_f (sqrt, minus_infty, nan_value, INVALID_EXCEPTION);
3961
  TEST_f_f (sqrt, nan_value, nan_value);
3962
 
3963
  TEST_f_f (sqrt, 2209, 47);
3964
  TEST_f_f (sqrt, 4, 2);
3965
  TEST_f_f (sqrt, 2, M_SQRT2l);
3966
  TEST_f_f (sqrt, 0.25, 0.5);
3967
  TEST_f_f (sqrt, 6642.25, 81.5);
3968
  TEST_f_f (sqrt, 15239.9025L, 123.45L);
3969
  TEST_f_f (sqrt, 0.7L, 0.83666002653407554797817202578518747L);
3970
 
3971
  END (sqrt);
3972
}
3973
 
3974
static void
3975
tan_test (void)
3976
{
3977
  errno = 0;
3978
  FUNC(tan) (0);
3979
  if (errno == ENOSYS)
3980
    /* Function not implemented.  */
3981
    return;
3982
 
3983
  START (tan);
3984
 
3985
  TEST_f_f (tan, 0, 0);
3986
  TEST_f_f (tan, minus_zero, minus_zero);
3987
  TEST_f_f (tan, plus_infty, nan_value, INVALID_EXCEPTION);
3988
  TEST_f_f (tan, minus_infty, nan_value, INVALID_EXCEPTION);
3989
  TEST_f_f (tan, nan_value, nan_value);
3990
 
3991
  TEST_f_f (tan, M_PI_4l, 1);
3992
  TEST_f_f (tan, 0.7L, 0.84228838046307944812813500221293775L);
3993
 
3994
  END (tan);
3995
}
3996
 
3997
static void
3998
tanh_test (void)
3999
{
4000
  errno = 0;
4001
  FUNC(tanh) (0.7L);
4002
  if (errno == ENOSYS)
4003
    /* Function not implemented.  */
4004
    return;
4005
 
4006
  START (tanh);
4007
 
4008
  TEST_f_f (tanh, 0, 0);
4009
  TEST_f_f (tanh, minus_zero, minus_zero);
4010
 
4011
#ifndef TEST_INLINE
4012
  TEST_f_f (tanh, plus_infty, 1);
4013
  TEST_f_f (tanh, minus_infty, -1);
4014
#endif
4015
  TEST_f_f (tanh, nan_value, nan_value);
4016
 
4017
  TEST_f_f (tanh, 0.7L, 0.60436777711716349631L);
4018
  TEST_f_f (tanh, -0.7L, -0.60436777711716349631L);
4019
 
4020
  TEST_f_f (tanh, 1.0L, 0.7615941559557648881194582826047935904L);
4021
  TEST_f_f (tanh, -1.0L, -0.7615941559557648881194582826047935904L);
4022
 
4023
  /* 2^-57  */
4024
  TEST_f_f (tanh, 6.938893903907228377647697925567626953125e-18L,6.938893903907228377647697925567626953125e-18L);
4025
 
4026
  END (tanh);
4027
}
4028
 
4029
#if 0
4030
static void
4031
tgamma_test (void)
4032
{
4033
  errno = 0;
4034
  FUNC(tgamma) (1);
4035
  if (errno == ENOSYS)
4036
    /* Function not implemented.  */
4037
    return;
4038
  feclearexcept (FE_ALL_EXCEPT);
4039
 
4040
  START (tgamma);
4041
 
4042
  TEST_f_f (tgamma, plus_infty, plus_infty);
4043
  TEST_f_f (tgamma, 0, nan_value, INVALID_EXCEPTION);
4044
  TEST_f_f (tgamma, minus_zero, nan_value, INVALID_EXCEPTION);
4045
  /* tgamma (x) == NaN plus invalid exception for integer x <= 0.  */
4046
  TEST_f_f (tgamma, -2, nan_value, INVALID_EXCEPTION);
4047
  TEST_f_f (tgamma, minus_infty, nan_value, INVALID_EXCEPTION);
4048
  TEST_f_f (tgamma, nan_value, nan_value);
4049
 
4050
  TEST_f_f (tgamma, 0.5, M_SQRT_PIl);
4051
  TEST_f_f (tgamma, -0.5, -M_2_SQRT_PIl);
4052
 
4053
  TEST_f_f (tgamma, 1, 1);
4054
  TEST_f_f (tgamma, 4, 6);
4055
 
4056
  TEST_f_f (tgamma, 0.7L, 1.29805533264755778568L);
4057
  TEST_f_f (tgamma, 1.2L, 0.91816874239976061064L);
4058
 
4059
  END (tgamma);
4060
}
4061
#endif
4062
 
4063
#if 0
4064
static void
4065
trunc_test (void)
4066
{
4067
  START (trunc);
4068
 
4069
  TEST_f_f (trunc, plus_infty, plus_infty);
4070
  TEST_f_f (trunc, minus_infty, minus_infty);
4071
  TEST_f_f (trunc, nan_value, nan_value);
4072
 
4073
  TEST_f_f (trunc, 0, 0);
4074
  TEST_f_f (trunc, minus_zero, minus_zero);
4075
  TEST_f_f (trunc, 0.625, 0);
4076
  TEST_f_f (trunc, -0.625, minus_zero);
4077
  TEST_f_f (trunc, 1, 1);
4078
  TEST_f_f (trunc, -1, -1);
4079
  TEST_f_f (trunc, 1.625, 1);
4080
  TEST_f_f (trunc, -1.625, -1);
4081
 
4082
  TEST_f_f (trunc, 1048580.625L, 1048580L);
4083
  TEST_f_f (trunc, -1048580.625L, -1048580L);
4084
 
4085
  TEST_f_f (trunc, 8388610.125L, 8388610.0L);
4086
  TEST_f_f (trunc, -8388610.125L, -8388610.0L);
4087
 
4088
  TEST_f_f (trunc, 4294967296.625L, 4294967296.0L);
4089
  TEST_f_f (trunc, -4294967296.625L, -4294967296.0L);
4090
 
4091
 
4092
  END (trunc);
4093
}
4094
#endif
4095
 
4096
static void
4097
y0_test (void)
4098
{
4099
  errno = 0;
4100
#if 0
4101
  FLOAT s, c;
4102
  FUNC (sincos) (0, &s, &c);
4103
  if (errno == ENOSYS)
4104
    /* Required function not implemented.  */
4105
    return;
4106
#endif
4107
  FUNC(y0) (1);
4108
  if (errno == ENOSYS)
4109
    /* Function not implemented.  */
4110
    return;
4111
 
4112
  /* y0 is the Bessel function of the second kind of order 0 */
4113
  START (y0);
4114
 
4115
  TEST_f_f (y0, -1.0, minus_infty);
4116
  TEST_f_f (y0, 0.0, minus_infty);
4117
  TEST_f_f (y0, nan_value, nan_value);
4118
  TEST_f_f (y0, plus_infty, 0);
4119
 
4120
  TEST_f_f (y0, 0.1L, -1.5342386513503668441L);
4121
  TEST_f_f (y0, 0.7L, -0.19066492933739506743L);
4122
  TEST_f_f (y0, 1.0, 0.088256964215676957983L);
4123
  TEST_f_f (y0, 1.5, 0.38244892379775884396L);
4124
  TEST_f_f (y0, 2.0, 0.51037567264974511960L);
4125
  TEST_f_f (y0, 8.0, 0.22352148938756622053L);
4126
  TEST_f_f (y0, 10.0, 0.055671167283599391424L);
4127
 
4128
  END (y0);
4129
}
4130
 
4131
 
4132
static void
4133
y1_test (void)
4134
{
4135
  errno = 0;
4136
#if 0
4137
  FLOAT s, c;
4138
  FUNC (sincos) (0, &s, &c);
4139
  if (errno == ENOSYS)
4140
    /* Required function not implemented.  */
4141
    return;
4142
#endif
4143
  FUNC(y1) (1);
4144
  if (errno == ENOSYS)
4145
    /* Function not implemented.  */
4146
    return;
4147
 
4148
  /* y1 is the Bessel function of the second kind of order 1 */
4149
  START (y1);
4150
 
4151
  TEST_f_f (y1, -1.0, minus_infty);
4152
  TEST_f_f (y1, 0.0, minus_infty);
4153
  TEST_f_f (y1, plus_infty, 0);
4154
  TEST_f_f (y1, nan_value, nan_value);
4155
 
4156
  TEST_f_f (y1, 0.1L, -6.4589510947020269877L);
4157
  TEST_f_f (y1, 0.7L, -1.1032498719076333697L);
4158
  TEST_f_f (y1, 1.0, -0.78121282130028871655L);
4159
  TEST_f_f (y1, 1.5, -0.41230862697391129595L);
4160
  TEST_f_f (y1, 2.0, -0.10703243154093754689L);
4161
  TEST_f_f (y1, 8.0, -0.15806046173124749426L);
4162
  TEST_f_f (y1, 10.0, 0.24901542420695388392L);
4163
 
4164
  END (y1);
4165
}
4166
 
4167
static void
4168
yn_test (void)
4169
{
4170
  errno = 0;
4171
#if 0
4172
  FLOAT s, c;
4173
  FUNC (sincos) (0, &s, &c);
4174
  if (errno == ENOSYS)
4175
    /* Required function not implemented.  */
4176
    return;
4177
#endif
4178
  FUNC(yn) (1, 1);
4179
  if (errno == ENOSYS)
4180
    /* Function not implemented.  */
4181
    return;
4182
 
4183
  /* yn is the Bessel function of the second kind of order n */
4184
  START (yn);
4185
 
4186
  /* yn (0, x) == y0 (x)  */
4187
  TEST_ff_f (yn, 0, -1.0, minus_infty);
4188
  TEST_ff_f (yn, 0, 0.0, minus_infty);
4189
  TEST_ff_f (yn, 0, nan_value, nan_value);
4190
  TEST_ff_f (yn, 0, plus_infty, 0);
4191
 
4192
  TEST_ff_f (yn, 0, 0.1L, -1.5342386513503668441L);
4193
  TEST_ff_f (yn, 0, 0.7L, -0.19066492933739506743L);
4194
  TEST_ff_f (yn, 0, 1.0, 0.088256964215676957983L);
4195
  TEST_ff_f (yn, 0, 1.5, 0.38244892379775884396L);
4196
  TEST_ff_f (yn, 0, 2.0, 0.51037567264974511960L);
4197
  TEST_ff_f (yn, 0, 8.0, 0.22352148938756622053L);
4198
  TEST_ff_f (yn, 0, 10.0, 0.055671167283599391424L);
4199
 
4200
  /* yn (1, x) == y1 (x)  */
4201
  TEST_ff_f (yn, 1, -1.0, minus_infty);
4202
  TEST_ff_f (yn, 1, 0.0, minus_infty);
4203
  TEST_ff_f (yn, 1, plus_infty, 0);
4204
  TEST_ff_f (yn, 1, nan_value, nan_value);
4205
 
4206
  TEST_ff_f (yn, 1, 0.1L, -6.4589510947020269877L);
4207
  TEST_ff_f (yn, 1, 0.7L, -1.1032498719076333697L);
4208
  TEST_ff_f (yn, 1, 1.0, -0.78121282130028871655L);
4209
  TEST_ff_f (yn, 1, 1.5, -0.41230862697391129595L);
4210
  TEST_ff_f (yn, 1, 2.0, -0.10703243154093754689L);
4211
  TEST_ff_f (yn, 1, 8.0, -0.15806046173124749426L);
4212
  TEST_ff_f (yn, 1, 10.0, 0.24901542420695388392L);
4213
 
4214
  /* yn (3, x)  */
4215
  TEST_ff_f (yn, 3, plus_infty, 0);
4216
  TEST_ff_f (yn, 3, nan_value, nan_value);
4217
 
4218
  TEST_ff_f (yn, 3, 0.1L, -5099.3323786129048894L);
4219
  TEST_ff_f (yn, 3, 0.7L, -15.819479052819633505L);
4220
  TEST_ff_f (yn, 3, 1.0, -5.8215176059647288478L);
4221
  TEST_ff_f (yn, 3, 2.0, -1.1277837768404277861L);
4222
  TEST_ff_f (yn, 3, 10.0, -0.25136265718383732978L);
4223
 
4224
  /* yn (10, x)  */
4225
  TEST_ff_f (yn, 10, plus_infty, 0);
4226
  TEST_ff_f (yn, 10, nan_value, nan_value);
4227
 
4228
  TEST_ff_f (yn, 10, 0.1L, -0.11831335132045197885e19L);
4229
  TEST_ff_f (yn, 10, 0.7L, -0.42447194260703866924e10L);
4230
  TEST_ff_f (yn, 10, 1.0, -0.12161801427868918929e9L);
4231
  TEST_ff_f (yn, 10, 2.0, -129184.54220803928264L);
4232
  TEST_ff_f (yn, 10, 10.0, -0.35981415218340272205L);
4233
 
4234
  END (yn);
4235
 
4236
}
4237
 
4238
 
4239
 
4240
static void
4241
initialize (void)
4242
{
4243
  fpstack_test ("start *init*");
4244
  plus_zero = 0.0;
4245
  nan_value = plus_zero / plus_zero;    /* Suppress GCC warning */
4246
 
4247
  minus_zero = FUNC(copysign) (0.0, -1.0);
4248
  plus_infty = CHOOSE (HUGE_VALL, HUGE_VAL, HUGE_VALF,
4249
                       HUGE_VALL, HUGE_VAL, HUGE_VALF);
4250
  minus_infty = CHOOSE (-HUGE_VALL, -HUGE_VAL, -HUGE_VALF,
4251
                        -HUGE_VALL, -HUGE_VAL, -HUGE_VALF);
4252
 
4253
  (void) &plus_zero;
4254
  (void) &nan_value;
4255
  (void) &minus_zero;
4256
  (void) &plus_infty;
4257
  (void) &minus_infty;
4258
 
4259
  /* Clear all exceptions.  From now on we must not get random exceptions.  */
4260
  feclearexcept (FE_ALL_EXCEPT);
4261
 
4262
  /* Test to make sure we start correctly.  */
4263
  fpstack_test ("end *init*");
4264
}
4265
 
4266
#if 0
4267
/* function to check our ulp calculation.  */
4268
void
4269
check_ulp (void)
4270
{
4271
  int i;
4272
 
4273
  FLOAT u, diff, ulp;
4274
  /* This gives one ulp.  */
4275
  u = FUNC(nextafter) (10, 20);
4276
  check_equal (10.0, u, 1, &diff, &ulp);
4277
  printf ("One ulp: % .4" PRINTF_NEXPR "\n", ulp);
4278
 
4279
  /* This gives one more ulp.  */
4280
  u = FUNC(nextafter) (u, 20);
4281
  check_equal (10.0, u, 2, &diff, &ulp);
4282
  printf ("two ulp: % .4" PRINTF_NEXPR "\n", ulp);
4283
 
4284
  /* And now calculate 100 ulp.  */
4285
  for (i = 2; i < 100; i++)
4286
    u = FUNC(nextafter) (u, 20);
4287
  check_equal (10.0, u, 100, &diff, &ulp);
4288
  printf ("100 ulp: % .4" PRINTF_NEXPR "\n", ulp);
4289
}
4290
#endif
4291
 
4292
int
4293
main (int argc, char **argv)
4294
{
4295
 
4296
  int key, remaining;
4297
 
4298
  verbose = 1;
4299
  output_ulps = 0;
4300
  output_max_error = 1;
4301
  output_points = 1;
4302
  /* XXX set to 0 for releases.  */
4303
  ignore_max_ulp = 0;
4304
 
4305
  /* Parse and process arguments.  */
4306
  while ((key = getopt(argc, argv, "fi:puv")) > 0) {
4307
      switch (key)
4308
      {
4309
          case 'f':
4310
              output_max_error = 0;
4311
              break;
4312
          case 'i':
4313
              if (strcmp (optarg, "yes") == 0)
4314
                  ignore_max_ulp = 1;
4315
              else if (strcmp (optarg, "no") == 0)
4316
                  ignore_max_ulp = 0;
4317
              break;
4318
          case 'p':
4319
              output_points = 0;
4320
              break;
4321
          case 'u':
4322
              output_ulps = 1;
4323
              break;
4324
          case 'v':
4325
              verbose = 3;
4326
              break;
4327
          default:
4328
              fprintf (stderr, "Unknown argument: %c", key);
4329
              exit (EXIT_FAILURE);
4330
      }
4331
  }
4332
 
4333
  if (optind != argc)
4334
    {
4335
      fprintf (stderr, "wrong number of arguments");
4336
      exit (EXIT_FAILURE);
4337
    }
4338
 
4339
  if (output_ulps)
4340
    {
4341
      ulps_file = fopen ("ULPs", "a");
4342
      if (ulps_file == NULL)
4343
        {
4344
          perror ("can't open file `ULPs' for writing: ");
4345
          exit (1);
4346
        }
4347
    }
4348
 
4349
 
4350
  initialize ();
4351
  printf (TEST_MSG);
4352
 
4353
#if 0
4354
  check_ulp ();
4355
#endif
4356
 
4357
  /* Keep the tests a wee bit ordered (according to ISO C99).  */
4358
  /* Classification macros:  */
4359
  fpclassify_test ();
4360
  isfinite_test ();
4361
  isnormal_test ();
4362
  signbit_test ();
4363
 
4364
  /* Trigonometric functions:  */
4365
  acos_test ();
4366
  asin_test ();
4367
  atan_test ();
4368
  atan2_test ();
4369
  cos_test ();
4370
  sin_test ();
4371
#if 0
4372
  sincos_test ();
4373
#endif
4374
  tan_test ();
4375
 
4376
  /* Hyperbolic functions:  */
4377
  acosh_test ();
4378
  asinh_test ();
4379
  atanh_test ();
4380
  cosh_test ();
4381
  sinh_test ();
4382
  tanh_test ();
4383
 
4384
  /* Exponential and logarithmic functions:  */
4385
  exp_test ();
4386
#if 0
4387
  exp10_test ();
4388
  exp2_test ();
4389
#endif
4390
  expm1_test ();
4391
  frexp_test ();
4392
  ldexp_test ();
4393
  log_test ();
4394
  log10_test ();
4395
  log1p_test ();
4396
#if 0
4397
  log2_test ();
4398
#endif
4399
  logb_test ();
4400
  modf_test ();
4401
  ilogb_test ();
4402
  scalb_test ();
4403
  scalbn_test ();
4404
#if 0
4405
  scalbln_test ();
4406
#endif
4407
 
4408
  /* Power and absolute value functions:  */
4409
  cbrt_test ();
4410
  fabs_test ();
4411
  hypot_test ();
4412
  pow_test ();
4413
  sqrt_test ();
4414
 
4415
  /* Error and gamma functions:  */
4416
  erf_test ();
4417
  erfc_test ();
4418
  gamma_test ();
4419
  lgamma_test ();
4420
#if 0
4421
  tgamma_test ();
4422
#endif
4423
 
4424
  /* Nearest integer functions:  */
4425
  ceil_test ();
4426
  floor_test ();
4427
#if 0
4428
  nearbyint_test ();
4429
#endif
4430
  rint_test ();
4431
#if 0
4432
  lrint_test ();
4433
  llrint_test ();
4434
  round_test ();
4435
  lround_test ();
4436
  llround_test ();
4437
  trunc_test ();
4438
#endif
4439
 
4440
  /* Remainder functions:  */
4441
  fmod_test ();
4442
  remainder_test ();
4443
#if 0
4444
  remquo_test ();
4445
#endif
4446
 
4447
  /* Manipulation functions:  */
4448
  copysign_test ();
4449
#if 0
4450
  nextafter_test ();
4451
  nexttoward_test ();
4452
 
4453
  /* maximum, minimum and positive difference functions */
4454
  fdim_test ();
4455
  fmax_test ();
4456
  fmin_test ();
4457
 
4458
  /* Multiply and add:  */
4459
  fma_test ();
4460
 
4461
  /* Complex functions:  */
4462
  cabs_test ();
4463
  cacos_test ();
4464
  cacosh_test ();
4465
  carg_test ();
4466
  casin_test ();
4467
  casinh_test ();
4468
  catan_test ();
4469
  catanh_test ();
4470
  ccos_test ();
4471
  ccosh_test ();
4472
  cexp_test ();
4473
  cimag_test ();
4474
  clog10_test ();
4475
  clog_test ();
4476
  conj_test ();
4477
  cpow_test ();
4478
  cproj_test ();
4479
  creal_test ();
4480
  csin_test ();
4481
  csinh_test ();
4482
  csqrt_test ();
4483
  ctan_test ();
4484
  ctanh_test ();
4485
#endif
4486
 
4487
  /* Bessel functions:  */
4488
#if 0
4489
  j0_test ();
4490
  j1_test ();
4491
  jn_test ();
4492
  y0_test ();
4493
  y1_test ();
4494
  yn_test ();
4495
#endif
4496
 
4497
  if (output_ulps)
4498
    fclose (ulps_file);
4499
 
4500
  printf ("\nTest suite completed:\n");
4501
  printf ("  %d test cases plus %d tests for exception flags executed.\n",
4502
          noTests, noExcTests);
4503
  if (noXFails)
4504
    printf ("  %d expected failures occurred.\n", noXFails);
4505
  if (noXPasses)
4506
    printf ("  %d unexpected passes occurred.\n", noXPasses);
4507
  if (noErrors)
4508
    {
4509
      printf ("  %d errors occurred.\n", noErrors);
4510
      return 1;
4511
    }
4512
  printf ("  All tests passed successfully.\n");
4513
 
4514
  return 0;
4515
}
4516
 
4517
/*
4518
 * Local Variables:
4519
 * mode:c
4520
 * End:
4521
 */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.