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