xref: /netbsd-src/external/lgpl3/mpfr/dist/tests/reuse.c (revision 1897181a7231d5fc7ab48994d1447fcbc4e13a49)
1 /* Test file for in-place operations.
2 
3 Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
4 Contributed by the Arenaire and Cacao projects, INRIA.
5 
6 This file is part of the GNU MPFR Library.
7 
8 The GNU MPFR Library is free software; you can redistribute it and/or modify
9 it under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or (at your
11 option) any later version.
12 
13 The GNU MPFR Library is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
16 License for more details.
17 
18 You should have received a copy of the GNU Lesser General Public License
19 along with the GNU MPFR Library; see the file COPYING.LESSER.  If not, see
20 http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
21 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */
22 
23 #include <stdio.h>
24 #include <stdlib.h>
25 
26 #include "mpfr-test.h"
27 
28 #define DISP(s, t) {printf(s); mpfr_out_str(stdout, 2, 0, t, MPFR_RNDN); }
29 #define DISP2(s,t) {DISP(s,t); putchar('\n');}
30 
31 #define SPECIAL_MAX 12
32 
33 static void
34 set_special (mpfr_ptr x, unsigned int select)
35 {
36   MPFR_ASSERTN (select < SPECIAL_MAX);
37   switch (select)
38     {
39     case 0:
40       MPFR_SET_NAN (x);
41       break;
42     case 1:
43       MPFR_SET_INF (x);
44       MPFR_SET_POS (x);
45       break;
46     case 2:
47       MPFR_SET_INF (x);
48       MPFR_SET_NEG (x);
49       break;
50     case 3:
51       MPFR_SET_ZERO (x);
52       MPFR_SET_POS  (x);
53       break;
54     case 4:
55       MPFR_SET_ZERO (x);
56       MPFR_SET_NEG  (x);
57       break;
58     case 5:
59       mpfr_set_str_binary (x, "1");
60       break;
61     case 6:
62       mpfr_set_str_binary (x, "-1");
63       break;
64     case 7:
65       mpfr_set_str_binary (x, "1e-1");
66       break;
67     case 8:
68       mpfr_set_str_binary (x, "1e+1");
69       break;
70     case 9:
71       mpfr_const_pi (x, MPFR_RNDN);
72       break;
73     case 10:
74       mpfr_const_pi (x, MPFR_RNDN);
75       MPFR_SET_EXP (x, MPFR_GET_EXP (x)-1);
76       break;
77     default:
78       mpfr_urandomb (x, RANDS);
79       break;
80     }
81 }
82 /* same than mpfr_cmp, but returns 0 for both NaN's */
83 static int
84 mpfr_compare (mpfr_srcptr a, mpfr_srcptr b)
85 {
86   return (MPFR_IS_NAN(a)) ? !MPFR_IS_NAN(b) :
87     (MPFR_IS_NAN(b) || mpfr_cmp(a, b));
88 }
89 
90 static void
91 test3 (int (*testfunc)(mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t),
92        char *foo, mpfr_prec_t prec, mpfr_rnd_t rnd)
93 {
94   mpfr_t ref1, ref2, ref3;
95   mpfr_t res1;
96   int i;
97 
98 #ifdef DEBUG
99   printf("checking %s\n", foo);
100 #endif
101   mpfr_init2 (ref1, prec);
102   mpfr_init2 (ref2, prec);
103   mpfr_init2 (ref3, prec);
104   mpfr_init2 (res1, prec);
105 
106   /* for each variable, consider each of the following 6 possibilities:
107      NaN, +Infinity, -Infinity, +0, -0 or a random number */
108   for (i=0; i < SPECIAL_MAX*SPECIAL_MAX ; i++) {
109     set_special (ref2, i%SPECIAL_MAX);
110     set_special (ref3, i/SPECIAL_MAX);
111 
112     /* reference call: foo(a, b, c) */
113     testfunc (ref1, ref2, ref3, rnd);
114 
115     /* foo(a, a, c) */
116     mpfr_set (res1, ref2, rnd); /* exact operation */
117     testfunc (res1, res1, ref3, rnd);
118 
119     if (mpfr_compare (res1, ref1))
120       {
121         printf ("Error for %s(a, a, c) for ", foo);
122         DISP("a=",ref2); DISP2(", c=",ref3);
123         printf ("expected "); mpfr_print_binary (ref1); puts ("");
124         printf ("got      "); mpfr_print_binary (res1); puts ("");
125         exit (1);
126       }
127 
128     /* foo(a, b, a) */
129     mpfr_set (res1, ref3, rnd);
130     testfunc (res1, ref2, res1, rnd);
131     if (mpfr_compare (res1, ref1))
132       {
133         printf ("Error for %s(a, b, a) for ", foo);
134         DISP("b=",ref2); DISP2(", a=", ref3);
135         DISP("expected ", ref1); DISP2(", got ",res1);
136         exit (1);
137       }
138 
139     /* foo(a, a, a) */
140     mpfr_set (ref3, ref2, rnd);
141     testfunc (ref1, ref2, ref3, rnd);
142     mpfr_set (res1, ref2, rnd);
143     testfunc (res1, res1, res1, rnd);
144 
145     if (mpfr_compare (res1, ref1))
146       {
147         printf ("Error for %s(a, a, a) for ", foo);
148         DISP2("a=",ref2);
149         DISP("expected ", ref1); DISP2(", got", res1);
150         exit (1);
151       }
152   }
153 
154   mpfr_clear (ref1);
155   mpfr_clear (ref2);
156   mpfr_clear (ref3);
157   mpfr_clear (res1);
158 }
159 
160 static void
161 test4 (int (*testfunc)(mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_srcptr,
162                        mpfr_rnd_t),
163        char *foo, mpfr_prec_t prec, mpfr_rnd_t rnd)
164 {
165   mpfr_t ref, op1, op2, op3;
166   mpfr_t res;
167   int i, j, k;
168 
169 #ifdef DEBUG
170   printf("checking %s\n", foo);
171 #endif
172   mpfr_init2 (ref, prec);
173   mpfr_init2 (op1, prec);
174   mpfr_init2 (op2, prec);
175   mpfr_init2 (op3, prec);
176   mpfr_init2 (res, prec);
177 
178   /* for each variable, consider each of the following 6 possibilities:
179      NaN, +Infinity, -Infinity, +0, -0 or a random number */
180 
181   for (i=0; i<SPECIAL_MAX; i++)
182     {
183       set_special (op1, i);
184       for (j=0; j<SPECIAL_MAX; j++)
185         {
186           set_special (op2, j);
187           for (k=0; k<SPECIAL_MAX; k++)
188             {
189               set_special (op3, k);
190 
191               /* reference call: foo(s, a, b, c) */
192               testfunc (ref, op1, op2, op3, rnd);
193 
194               /* foo(a, a, b, c) */
195               mpfr_set (res, op1, rnd); /* exact operation */
196               testfunc (res, res, op2, op3, rnd);
197 
198               if (mpfr_compare (res, ref))
199                 {
200                   printf ("Error for %s(a, a, b, c) for ", foo);
201                   DISP("a=", op1); DISP(", b=", op2); DISP2(", c=", op3);
202                   DISP("expected ", ref); DISP2(", got", res);
203                   exit (1);
204                 }
205 
206               /* foo(b, a, b, c) */
207               mpfr_set (res, op2, rnd);
208               testfunc (res, op1, res, op3, rnd);
209 
210               if (mpfr_compare (res, ref))
211                 {
212                   printf ("Error for %s(a, a, b, c) for ", foo);
213                   DISP("a=", op1); DISP(", b=", op2); DISP2(", c=", op3);
214                   DISP("expected ", ref); DISP2(", got", res);
215                   exit (1);
216                 }
217 
218               /* foo(c, a, b, c) */
219               mpfr_set (res, op3, rnd);
220               testfunc (res, op1, op2, res, rnd);
221 
222               if (mpfr_compare (res, ref))
223                 {
224                   printf ("Error for %s(a, a, b, c) for ", foo);
225                   DISP("a=", op1); DISP(", b=", op2); DISP2(", c=", op3);
226                   DISP("expected ", ref); DISP2(", got", res);
227                   exit (1);
228                 }
229 
230               /* foo(a, a, a,c) */
231               testfunc (ref, op1, op1, op3, rnd);
232               mpfr_set (res, op1, rnd);
233               testfunc (res, res, res, op3, rnd);
234               if (mpfr_compare (res, ref))
235                 {
236                   printf ("Error for %s(a, a, b, c) for ", foo);
237                   DISP("a=", op1); DISP(", a=", op2); DISP2(", c=", op3);
238                   DISP("expected ", ref); DISP2(", got", res);
239                   exit (1);
240                 }
241 
242               /* foo(a, a, b,a) */
243               testfunc (ref, op1, op2, op1, rnd);
244               mpfr_set (res, op1, rnd);
245               testfunc (res, res, op2, res, rnd);
246               if (mpfr_compare (res, ref))
247                 {
248                   printf ("Error for %s(a, a, b, c) for ", foo);
249                   DISP("a=", op1); DISP(", a=", op2); DISP2(", c=", op3);
250                   DISP("expected ", ref); DISP2(", got", res);
251                   exit (1);
252                 }
253 
254               /* foo(b, a, b, b) */
255               testfunc (ref, op1, op2, op2, rnd);
256               mpfr_set (res, op2, rnd);
257               testfunc (res, op1, res, res, rnd);
258               if (mpfr_compare (res, ref))
259                 {
260                   printf ("Error for %s(a, a, b, c) for ", foo);
261                   DISP("a=", op1); DISP(", a=", op2); DISP2(", c=", op3);
262                   DISP("expected ", ref); DISP2(", got", res);
263                   exit (1);
264                 }
265 
266               /* foo (a, a, a, a) */
267               testfunc (ref, op1, op1, op1 ,rnd);
268               mpfr_set (res, op1, rnd);
269               testfunc (res, res, res, res, rnd);
270               if (mpfr_compare (res, ref))
271                 {
272                   printf ("Error for %s(a, a, a, a) for ", foo);
273                   DISP2("a=", op1);
274                   DISP("expected ", ref); DISP2(", got", res);
275                   exit (1);
276                 }
277             }
278         }
279     }
280 
281   mpfr_clear (ref);
282   mpfr_clear (op1);
283   mpfr_clear (op2);
284   mpfr_clear (op3);
285   mpfr_clear (res);
286 
287 }
288 
289 static void
290 test2ui (int (*testfunc)(mpfr_ptr, mpfr_srcptr, unsigned long int, mpfr_rnd_t),
291          char *foo, mpfr_prec_t prec, mpfr_rnd_t rnd)
292 {
293   mpfr_t ref1, ref2;
294   unsigned int ref3;
295   mpfr_t res1;
296   int i;
297 
298 #ifdef DEBUG
299   printf("checking %s\n", foo);
300 #endif
301   mpfr_init2 (ref1, prec);
302   mpfr_init2 (ref2, prec);
303   mpfr_init2 (res1, prec);
304 
305   /* ref2 can be NaN, +Inf, -Inf, +0, -0 or any number
306      ref3 can be 0 or any number */
307   for (i=0; i<SPECIAL_MAX*2; i++)
308     {
309       set_special (ref2, i%SPECIAL_MAX);
310       ref3 = i/SPECIAL_MAX == 0 ? 0 : randlimb ();
311 
312       /* reference call: foo(a, b, c) */
313       testfunc (ref1, ref2, ref3, rnd);
314 
315       /* foo(a, a, c) */
316       mpfr_set (res1, ref2, rnd); /* exact operation */
317       testfunc (res1, res1, ref3, rnd);
318 
319       if (mpfr_compare (res1, ref1))
320         {
321           printf ("Error for %s(a, a, c) for c=%u\n", foo, ref3);
322           DISP2("a=",ref2);
323           printf ("expected "); mpfr_print_binary (ref1); puts ("");
324           printf ("got      "); mpfr_print_binary (res1); puts ("");
325           exit (1);
326         }
327     }
328 
329   mpfr_clear (ref1);
330   mpfr_clear (ref2);
331   mpfr_clear (res1);
332 }
333 
334 static void
335 testui2 (int (*testfunc)(mpfr_ptr, unsigned long int, mpfr_srcptr, mpfr_rnd_t),
336          char *foo, mpfr_prec_t prec, mpfr_rnd_t rnd)
337 {
338   mpfr_t ref1, ref3;
339   unsigned int ref2;
340   mpfr_t res1;
341   int i;
342 
343 #ifdef DEBUG
344   printf("checking %s\n", foo);
345 #endif
346   mpfr_init2 (ref1, prec);
347   mpfr_init2 (ref3, prec);
348   mpfr_init2 (res1, prec);
349 
350   for (i=0; i<SPECIAL_MAX*2; i++) {
351     set_special (ref3, i%SPECIAL_MAX);
352     ref2 = i/SPECIAL_MAX==0 ? 0 : randlimb ();
353 
354     /* reference call: foo(a, b, c) */
355     testfunc (ref1, ref2, ref3, rnd);
356 
357     /* foo(a, b, a) */
358     mpfr_set (res1, ref3, rnd); /* exact operation */
359     testfunc (res1, ref2, res1, rnd);
360     if (mpfr_compare (res1, ref1))
361       {
362         printf ("Error for %s(a, b, a) for b=%u \n", foo, ref2);
363         DISP2("a=", ref3);
364         DISP("expected", ref1); DISP2(", got ", res1);
365         exit (1);
366       }
367   }
368 
369   mpfr_clear (ref1);
370   mpfr_clear (ref3);
371   mpfr_clear (res1);
372 }
373 
374 /* foo(mpfr_ptr, mpfr_srcptr, mp_rndt) */
375 static void
376 test2 (int (*testfunc)(mpfr_ptr, mpfr_srcptr, mpfr_rnd_t),
377        char *foo, mpfr_prec_t prec, mpfr_rnd_t rnd)
378 {
379   mpfr_t ref1, ref2;
380   mpfr_t res1;
381   int i;
382 
383 #ifdef DEBUG
384   printf("checking %s\n", foo);
385 #endif
386   mpfr_init2 (ref1, prec);
387   mpfr_init2 (ref2, prec);
388   mpfr_init2 (res1, prec);
389 
390   for (i=0; i<SPECIAL_MAX; i++)
391     {
392       set_special (ref2, i);
393 
394       /* reference call: foo(a, b) */
395       testfunc (ref1, ref2, rnd);
396 
397       /* foo(a, a) */
398       mpfr_set (res1, ref2, rnd); /* exact operation */
399       testfunc (res1, res1, rnd);
400       if (mpfr_compare (res1, ref1))
401         {
402           printf ("Error for %s(a, a) for ", foo);
403           DISP2("a=", ref2);
404           DISP("expected", ref1); DISP2(", got ", res1);
405           exit (1);
406         }
407     }
408 
409   mpfr_clear (ref1);
410   mpfr_clear (ref2);
411   mpfr_clear (res1);
412 }
413 
414 /* foo(mpfr_ptr, mpfr_srcptr) */
415 static void
416 test2a (int (*testfunc)(mpfr_ptr, mpfr_srcptr),
417         char *foo, mpfr_prec_t prec)
418 {
419   mpfr_t ref1, ref2;
420   mpfr_t res1;
421   int i;
422 
423 #ifdef DEBUG
424   printf ("checking %s\n", foo);
425 #endif
426   mpfr_init2 (ref1, prec);
427   mpfr_init2 (ref2, prec);
428   mpfr_init2 (res1, prec);
429 
430   for (i=0; i<SPECIAL_MAX; i++)
431     {
432       set_special (ref2, i);
433 
434       /* reference call: foo(a, b) */
435       testfunc (ref1, ref2);
436 
437       /* foo(a, a) */
438       mpfr_set (res1, ref2, MPFR_RNDN); /* exact operation */
439       testfunc (res1, res1);
440       if (mpfr_compare (res1, ref1))
441         {
442           printf ("Error for %s(a, a) for ", foo);
443           DISP2("a=",ref2);
444           DISP("expected", ref1); DISP2(", got ", res1);
445           exit (1);
446         }
447     }
448 
449   mpfr_clear (ref1);
450   mpfr_clear (ref2);
451   mpfr_clear (res1);
452 }
453 
454 /* one operand, two results */
455 static void
456 test3a (int (*testfunc)(mpfr_ptr, mpfr_ptr, mpfr_srcptr, mpfr_rnd_t),
457         char *foo, mpfr_prec_t prec, mpfr_rnd_t rnd)
458 {
459   mpfr_t ref1, ref2, ref3;
460   mpfr_t res1, res2;
461   int i;
462 
463 #ifdef DEBUG
464   printf ("checking %s\n", foo);
465 #endif
466   mpfr_init2 (ref1, prec);
467   mpfr_init2 (ref2, prec);
468   mpfr_init2 (ref3, prec);
469   mpfr_init2 (res1, prec);
470   mpfr_init2 (res2, prec);
471 
472   for (i=0; i<SPECIAL_MAX; i++)
473     {
474       set_special (ref3, i);
475 
476       /* reference call: foo(a, b, c) */
477       testfunc (ref1, ref2, ref3, rnd);
478 
479       /* foo(a, b, a) */
480       mpfr_set (res1, ref3, rnd); /* exact operation */
481       testfunc (res1, res2, res1, rnd);
482       if (mpfr_compare (res1, ref1) || mpfr_compare (res2, ref2))
483         {
484           printf ("Error for %s(a, b, a) for rnd=%s, ", foo,
485                   mpfr_print_rnd_mode (rnd));
486           DISP2("a=",ref3);
487           DISP("expected (", ref1); DISP(",",ref2);
488           DISP("), got (", res1); DISP(",", res2); printf(")\n");
489           exit (1);
490         }
491 
492       /* foo(a, b, b) */
493       mpfr_set (res2, ref3, rnd); /* exact operation */
494       testfunc (res1, res2, res2, rnd);
495       if (mpfr_compare (res1, ref1) || mpfr_compare (res2, ref2))
496         {
497           printf ("Error for %s(a, b, b) for ", foo);
498           DISP2("b=",ref3);
499           DISP("expected (", ref1); DISP(",",ref2);
500           DISP("), got (", res1); DISP(",", res2); printf(")\n");
501           exit (1);
502         }
503     }
504 
505   mpfr_clear (ref1);
506   mpfr_clear (ref2);
507   mpfr_clear (ref3);
508   mpfr_clear (res1);
509   mpfr_clear (res2);
510 }
511 
512 static int
513 reldiff_wrapper (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mpfr_rnd_t rnd_mode)
514 {
515   mpfr_reldiff (a, b, c, rnd_mode);
516   return 0;
517 }
518 
519 static void
520 pow_int (mpfr_rnd_t rnd)
521 {
522   mpfr_t ref1, ref2, ref3;
523   mpfr_t res1;
524   int i;
525 
526 #ifdef DEBUG
527   printf("pow_int\n");
528 #endif
529   mpfr_inits2 ((randlimb () % 200) + MPFR_PREC_MIN,
530                ref1, ref2, res1, (mpfr_ptr) 0);
531   mpfr_init2 (ref3, 1005);
532 
533   for (i = 0; i <= 15; i++)
534     {
535       mpfr_urandomb (ref2, RANDS);
536       if (i & 1)
537         mpfr_neg (ref2, ref2, MPFR_RNDN);
538       mpfr_set_ui (ref3, 20, MPFR_RNDN);
539       /* We need to test huge integers because different algorithms/codes
540          are used for not-too-large integers (mpfr_pow_z) and for general
541          cases, in particular huge integers (mpfr_pow_general). [r7606] */
542       if (i & 2)
543         mpfr_mul_2ui (ref3, ref3, 1000, MPFR_RNDN);
544       if (i & 4)
545         mpfr_add_ui (ref3, ref3, 1, MPFR_RNDN);  /* odd integer */
546 
547       /* reference call: pow(a, b, c) */
548       mpfr_pow (ref1, ref2, ref3, rnd);
549 
550       /* pow(a, a, c) */
551       mpfr_set (res1, ref2, rnd); /* exact operation */
552       mpfr_pow (res1, res1, ref3, rnd);
553 
554       if (mpfr_compare (res1, ref1))
555         {
556           printf ("Error for pow_int(a, a, c) for ");
557           DISP("a=",ref2); DISP2(", c=",ref3);
558           printf ("expected "); mpfr_print_binary (ref1); puts ("");
559           printf ("got      "); mpfr_print_binary (res1); puts ("");
560           exit (1);
561         }
562     }
563 
564   mpfr_clears (ref1, ref2, ref3, res1, (mpfr_ptr) 0);
565 }
566 
567 int
568 main (void)
569 {
570   int rnd;
571   mpfr_prec_t p;
572   tests_start_mpfr ();
573 
574   p = (randlimb () % 200)+ MPFR_PREC_MIN;
575   RND_LOOP (rnd)
576   {
577     test2a (mpfr_round, "mpfr_round", p);
578     test2a (mpfr_ceil, "mpfr_ceil", p);
579     test2a (mpfr_floor, "mpfr_floor", p);
580     test2a (mpfr_trunc, "mpfr_trunc", p);
581 
582     test2ui (mpfr_add_ui, "mpfr_add_ui", p, (mpfr_rnd_t) rnd);
583     test2ui (mpfr_div_2exp, "mpfr_div_2exp", p, (mpfr_rnd_t) rnd);
584     test2ui (mpfr_div_ui, "mpfr_div_ui", p, (mpfr_rnd_t) rnd);
585     test2ui (mpfr_mul_2exp, "mpfr_mul_2exp", p, (mpfr_rnd_t) rnd);
586     test2ui (mpfr_mul_ui, "mpfr_mul_ui", p, (mpfr_rnd_t) rnd);
587     test2ui (mpfr_pow_ui, "mpfr_pow_ui", p, (mpfr_rnd_t) rnd);
588     test2ui (mpfr_sub_ui, "mpfr_sub_ui", p, (mpfr_rnd_t) rnd);
589 
590     testui2 (mpfr_ui_div, "mpfr_ui_div", p, (mpfr_rnd_t) rnd);
591     testui2 (mpfr_ui_sub, "mpfr_ui_sub", p, (mpfr_rnd_t) rnd);
592     testui2 (mpfr_ui_pow, "mpfr_ui_pow", p, (mpfr_rnd_t) rnd);
593 
594     test2 (mpfr_sqr, "mpfr_sqr", p, (mpfr_rnd_t) rnd);
595     test2 (mpfr_sqrt, "mpfr_sqrt", p, (mpfr_rnd_t) rnd);
596     test2 (mpfr_abs, "mpfr_abs", p, (mpfr_rnd_t) rnd);
597     test2 (mpfr_neg, "mpfr_neg", p, (mpfr_rnd_t) rnd);
598 
599     test2 (mpfr_log, "mpfr_log", p, (mpfr_rnd_t) rnd);
600     test2 (mpfr_log2, "mpfr_log2", p, (mpfr_rnd_t) rnd);
601     test2 (mpfr_log10, "mpfr_log10", p, (mpfr_rnd_t) rnd);
602     test2 (mpfr_log1p, "mpfr_log1p", p, (mpfr_rnd_t) rnd);
603 
604     test2 (mpfr_exp, "mpfr_exp", p, (mpfr_rnd_t) rnd);
605     test2 (mpfr_exp2, "mpfr_exp2", p, (mpfr_rnd_t) rnd);
606     test2 (mpfr_exp10, "mpfr_exp10", p, (mpfr_rnd_t) rnd);
607     test2 (mpfr_expm1, "mpfr_expm1", p, (mpfr_rnd_t) rnd);
608     test2 (mpfr_eint, "mpfr_eint", p, (mpfr_rnd_t) rnd);
609 
610     test2 (mpfr_sinh, "mpfr_sinh", p, (mpfr_rnd_t) rnd);
611     test2 (mpfr_cosh, "mpfr_cosh", p, (mpfr_rnd_t) rnd);
612     test2 (mpfr_tanh, "mpfr_tanh", p, (mpfr_rnd_t) rnd);
613     test2 (mpfr_asinh, "mpfr_asinh", p, (mpfr_rnd_t) rnd);
614     test2 (mpfr_acosh, "mpfr_acosh", p, (mpfr_rnd_t) rnd);
615     test2 (mpfr_atanh, "mpfr_atanh", p, (mpfr_rnd_t) rnd);
616     test2 (mpfr_sech, "mpfr_sech", p, (mpfr_rnd_t) rnd);
617     test2 (mpfr_csch, "mpfr_csch", p, (mpfr_rnd_t) rnd);
618     test2 (mpfr_coth, "mpfr_coth", p, (mpfr_rnd_t) rnd);
619 
620     test2 (mpfr_asin, "mpfr_asin", p, (mpfr_rnd_t) rnd);
621     test2 (mpfr_acos, "mpfr_acos", p, (mpfr_rnd_t) rnd);
622     test2 (mpfr_atan, "mpfr_atan", p, (mpfr_rnd_t) rnd);
623     test2 (mpfr_cos, "mpfr_cos", p, (mpfr_rnd_t) rnd);
624     test2 (mpfr_sin, "mpfr_sin", p, (mpfr_rnd_t) rnd);
625     test2 (mpfr_tan, "mpfr_tan", p, (mpfr_rnd_t) rnd);
626     test2 (mpfr_sec, "mpfr_sec", p, (mpfr_rnd_t) rnd);
627     test2 (mpfr_csc, "mpfr_csc", p, (mpfr_rnd_t) rnd);
628     test2 (mpfr_cot, "mpfr_cot", p, (mpfr_rnd_t) rnd);
629 
630     test2 (mpfr_erf,  "mpfr_erf",  p, (mpfr_rnd_t) rnd);
631     test2 (mpfr_erfc, "mpfr_erfc", p, (mpfr_rnd_t) rnd);
632     test2 (mpfr_j0,   "mpfr_j0",   p, (mpfr_rnd_t) rnd);
633     test2 (mpfr_j1,   "mpfr_j1",   p, (mpfr_rnd_t) rnd);
634     test2 (mpfr_y0,   "mpfr_y0",   p, (mpfr_rnd_t) rnd);
635     test2 (mpfr_y1,   "mpfr_y1",   p, (mpfr_rnd_t) rnd);
636     test2 (mpfr_zeta, "mpfr_zeta", p, (mpfr_rnd_t) rnd);
637     test2 (mpfr_gamma, "mpfr_gamma", p, (mpfr_rnd_t) rnd);
638     test2 (mpfr_lngamma, "mpfr_lngamma", p, (mpfr_rnd_t) rnd);
639 
640     test2 (mpfr_rint, "mpfr_rint", p, (mpfr_rnd_t) rnd);
641     test2 (mpfr_rint_ceil, "mpfr_rint_ceil", p, (mpfr_rnd_t) rnd);
642     test2 (mpfr_rint_floor, "mpfr_rint_floor", p, (mpfr_rnd_t) rnd);
643     test2 (mpfr_rint_round, "mpfr_rint_round", p, (mpfr_rnd_t) rnd);
644     test2 (mpfr_rint_trunc, "mpfr_rint_trunc", p, (mpfr_rnd_t) rnd);
645     test2 (mpfr_frac, "mpfr_frac", p, (mpfr_rnd_t) rnd);
646 
647     test3 (mpfr_add, "mpfr_add", p, (mpfr_rnd_t) rnd);
648     test3 (mpfr_sub, "mpfr_sub", p, (mpfr_rnd_t) rnd);
649     test3 (mpfr_mul, "mpfr_mul", p, (mpfr_rnd_t) rnd);
650     test3 (mpfr_div, "mpfr_div", p, (mpfr_rnd_t) rnd);
651 
652     test3 (mpfr_agm, "mpfr_agm", p, (mpfr_rnd_t) rnd);
653     test3 (mpfr_min, "mpfr_min", p, (mpfr_rnd_t) rnd);
654     test3 (mpfr_max, "mpfr_max", p, (mpfr_rnd_t) rnd);
655 
656     test3 (reldiff_wrapper, "mpfr_reldiff", p, (mpfr_rnd_t) rnd);
657     test3 (mpfr_dim, "mpfr_dim", p, (mpfr_rnd_t) rnd);
658 
659     test3 (mpfr_remainder, "mpfr_remainder", p, (mpfr_rnd_t) rnd);
660     test3 (mpfr_pow, "mpfr_pow", p, (mpfr_rnd_t) rnd);
661     pow_int ((mpfr_rnd_t) rnd);
662     test3 (mpfr_atan2, "mpfr_atan2", p, (mpfr_rnd_t) rnd);
663     test3 (mpfr_hypot, "mpfr_hypot", p, (mpfr_rnd_t) rnd);
664 
665     test3a (mpfr_sin_cos, "mpfr_sin_cos", p, (mpfr_rnd_t) rnd);
666 
667     test4 (mpfr_fma, "mpfr_fma", p, (mpfr_rnd_t) rnd);
668     test4 (mpfr_fms, "mpfr_fms", p, (mpfr_rnd_t) rnd);
669 
670 #if MPFR_VERSION >= MPFR_VERSION_NUM(2,4,0)
671     test2 (mpfr_li2, "mpfr_li2",  p, (mpfr_rnd_t) rnd);
672     test2 (mpfr_rec_sqrt, "mpfr_rec_sqrt",  p, (mpfr_rnd_t) rnd);
673     test3 (mpfr_fmod, "mpfr_fmod", p, (mpfr_rnd_t) rnd);
674     test3a (mpfr_modf, "mpfr_modf", p, (mpfr_rnd_t) rnd);
675     test3a (mpfr_sinh_cosh, "mpfr_sinh_cosh", p, (mpfr_rnd_t) rnd);
676 #endif
677   }
678 
679   tests_end_mpfr ();
680   return 0;
681 }
682