1 /* read_data,c -- Read data file and check function.
3 Copyright (C) 2008, 2009, 2010, 2011, 2012 INRIA
5 This file is part of GNU MPC.
7 GNU MPC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU Lesser General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
12 GNU MPC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
17 You should have received a copy of the GNU Lesser General Public License
18 along with this program. If not, see http://www.gnu.org/licenses/ .
23 #include "mpc-tests.h"
26 unsigned long line_number;
27 /* file name with complete path and currently read line;
28 kept globally to simplify parameter passing */
29 unsigned long test_line_number;
30 /* start line of data test (which may extend over several lines) */
32 /* character appearing next in the file, may be EOF */
34 #define MPC_INEX_CMP(r, i, c) \
35 (((r) == TERNARY_NOT_CHECKED || (r) == MPC_INEX_RE(c)) \
36 && ((i) == TERNARY_NOT_CHECKED || (i) == MPC_INEX_IM (c)))
38 #define MPFR_INEX_STR(inex) \
39 (inex) == TERNARY_NOT_CHECKED ? "?" \
40 : (inex) == +1 ? "+1" \
41 : (inex) == -1 ? "-1" : "0"
43 static const char *mpfr_rnd_mode [] =
44 { "GMP_RNDN", "GMP_RNDZ", "GMP_RNDU", "GMP_RNDD" };
46 const char *rnd_mode[] =
47 { "MPC_RNDNN", "MPC_RNDZN", "MPC_RNDUN", "MPC_RNDDN",
48 "undefined", "undefined", "undefined", "undefined", "undefined",
49 "undefined", "undefined", "undefined", "undefined", "undefined",
50 "undefined", "undefined",
51 "MPC_RNDNZ", "MPC_RNDZZ", "MPC_RNDUZ", "MPC_RNDDZ",
52 "undefined", "undefined", "undefined", "undefined", "undefined",
53 "undefined", "undefined", "undefined", "undefined", "undefined",
54 "undefined", "undefined",
55 "MPC_RNDNU", "MPC_RNDZU", "MPC_RNDUU", "MPC_RNDDU",
56 "undefined", "undefined", "undefined", "undefined", "undefined",
57 "undefined", "undefined", "undefined", "undefined", "undefined",
58 "undefined", "undefined",
59 "MPC_RNDND", "MPC_RNDZD", "MPC_RNDUD", "MPC_RNDDD",
60 "undefined", "undefined", "undefined", "undefined", "undefined",
61 "undefined", "undefined", "undefined", "undefined", "undefined",
62 "undefined", "undefined",
67 open_data_file (const char *file_name)
71 char default_srcdir[] = ".";
73 src_dir = getenv ("srcdir");
75 src_dir = default_srcdir;
77 pathname = (char *) malloc ((strlen (src_dir)) + strlen (file_name) + 2);
80 printf ("Cannot allocate memory\n");
83 sprintf (pathname, "%s/%s", src_dir, file_name);
84 fp = fopen (pathname, "r");
87 fprintf (stderr, "Unable to open %s\n", pathname);
95 close_data_file (FILE *fp)
101 /* read primitives */
104 /* skips characters until reaching '\n' or EOF; */
105 /* '\n' is skipped as well */
107 while (nextchar != EOF && nextchar != '\n')
108 nextchar = getc (fp);
112 nextchar = getc (fp);
117 skip_whitespace (FILE *fp)
118 /* skips over whitespace if any until reaching EOF */
119 /* or non-whitespace */
121 while (isspace (nextchar))
123 if (nextchar == '\n')
125 nextchar = getc (fp);
130 skip_whitespace_comments (FILE *fp)
131 /* skips over all whitespace and comments, if any */
133 skip_whitespace (fp);
134 while (nextchar == '#') {
137 skip_whitespace (fp);
143 read_string (FILE *fp, char **buffer_ptr, size_t buffer_length, const char *name)
149 buffer = *buffer_ptr;
152 nextchar = getc (fp);
156 while (nextchar != EOF && nextchar != '"')
158 if (nextchar == '\n')
160 if (pos + 1 > buffer_length)
162 buffer = (char *) realloc (buffer, 2 * buffer_length);
165 printf ("Cannot allocate memory\n");
170 buffer[pos++] = (char) nextchar;
171 nextchar = getc (fp);
177 if (pos + 1 > buffer_length)
179 buffer = (char *) realloc (buffer, buffer_length + 1);
182 printf ("Cannot allocate memory\n");
189 nextchar = getc (fp);
190 skip_whitespace_comments (fp);
192 *buffer_ptr = buffer;
194 return buffer_length;
197 printf ("Error: Unable to read %s in file '%s' line '%lu'\n",
198 name, pathname, line_number);
202 /* All following read routines skip over whitespace and comments; */
203 /* so after calling them, nextchar is either EOF or the beginning */
204 /* of a non-comment token. */
206 read_ternary (FILE *fp, int* ternary)
211 *ternary = TERNARY_ERROR;
214 *ternary = TERNARY_NOT_CHECKED;
226 printf ("Error: Unexpected ternary value '%c' in file '%s' line %lu\n",
227 nextchar, pathname, line_number);
231 nextchar = getc (fp);
232 skip_whitespace_comments (fp);
236 read_mpfr_rounding_mode (FILE *fp, mpfr_rnd_t* rnd)
253 printf ("Error: Unexpected rounding mode '%c' in file '%s' line %lu\n",
254 nextchar, pathname, line_number);
258 nextchar = getc (fp);
259 if (nextchar != EOF && !isspace (nextchar)) {
260 printf ("Error: Rounding mode not followed by white space in file "
262 pathname, line_number);
265 skip_whitespace_comments (fp);
269 read_mpc_rounding_mode (FILE *fp, mpc_rnd_t* rnd)
272 read_mpfr_rounding_mode (fp, &re);
273 read_mpfr_rounding_mode (fp, &im);
274 *rnd = MPC_RND (re, im);
278 read_int (FILE *fp, int *nread, const char *name)
284 printf ("Error: Unexpected EOF when reading int "
285 "in file '%s' line %lu\n",
286 pathname, line_number);
289 ungetc (nextchar, fp);
290 n = fscanf (fp, "%i", nread);
291 if (ferror (fp) || n == 0 || n == EOF)
293 printf ("Error: Cannot read %s in file '%s' line %lu\n",
294 name, pathname, line_number);
297 nextchar = getc (fp);
298 skip_whitespace_comments (fp);
302 read_uint (FILE *fp, unsigned long int *ui)
308 printf ("Error: Unexpected EOF when reading uint "
309 "in file '%s' line %lu\n",
310 pathname, line_number);
313 ungetc (nextchar, fp);
314 n = fscanf (fp, "%lu", ui);
315 if (ferror (fp) || n == 0 || n == EOF)
317 printf ("Error: Cannot read uint in file '%s' line %lu\n",
318 pathname, line_number);
321 nextchar = getc (fp);
322 skip_whitespace_comments (fp);
326 read_sint (FILE *fp, long int *si)
332 printf ("Error: Unexpected EOF when reading sint "
333 "in file '%s' line %lu\n",
334 pathname, line_number);
337 ungetc (nextchar, fp);
338 n = fscanf (fp, "%li", si);
339 if (ferror (fp) || n == 0 || n == EOF)
341 printf ("Error: Cannot read sint in file '%s' line %lu\n",
342 pathname, line_number);
345 nextchar = getc (fp);
346 skip_whitespace_comments (fp);
350 read_mpfr_prec (FILE *fp)
355 if (nextchar == EOF) {
356 printf ("Error: Unexpected EOF when reading mpfr precision "
357 "in file '%s' line %lu\n",
358 pathname, line_number);
361 ungetc (nextchar, fp);
362 n = fscanf (fp, "%lu", &prec);
363 if (ferror (fp)) /* then also n == EOF */
364 perror ("Error when reading mpfr precision");
365 if (n == 0 || n == EOF || prec < MPFR_PREC_MIN || prec > MPFR_PREC_MAX) {
366 printf ("Error: Impossible mpfr precision in file '%s' line %lu\n",
367 pathname, line_number);
370 nextchar = getc (fp);
371 skip_whitespace_comments (fp);
372 return (mpfr_prec_t) prec;
376 read_mpfr_mantissa (FILE *fp, mpfr_ptr x)
378 if (nextchar == EOF) {
379 printf ("Error: Unexpected EOF when reading mpfr mantissa "
380 "in file '%s' line %lu\n",
381 pathname, line_number);
384 ungetc (nextchar, fp);
385 if (mpfr_inp_str (x, fp, 0, GMP_RNDN) == 0) {
386 printf ("Error: Impossible to read mpfr mantissa "
387 "in file '%s' line %lu\n",
388 pathname, line_number);
391 nextchar = getc (fp);
392 skip_whitespace_comments (fp);
396 read_mpfr (FILE *fp, mpfr_ptr x, int *known_sign)
399 mpfr_set_prec (x, read_mpfr_prec (fp));
401 read_mpfr_mantissa (fp, x);
403 /* the sign always matters for regular values ('+' is implicit),
404 but when no sign appears before 0 or Inf in the data file, it means
405 that only absolute value must be checked. */
406 if (known_sign != NULL)
408 (!mpfr_zero_p (x) && !mpfr_inf_p (x))
409 || sign == '+' || sign == '-';
413 read_mpc (FILE *fp, mpc_ptr z, known_signs_t *ks)
415 read_mpfr (fp, mpc_realref (z), ks == NULL ? NULL : &ks->re);
416 read_mpfr (fp, mpc_imagref (z), ks == NULL ? NULL : &ks->im);
420 check_compatible (int inex, mpfr_t expected, mpfr_rnd_t rnd, const char *s)
422 if ((rnd == GMP_RNDU && inex == -1) ||
423 (rnd == GMP_RNDD && inex == +1) ||
424 (rnd == GMP_RNDZ && !mpfr_signbit (expected) && inex == +1) ||
425 (rnd == GMP_RNDZ && mpfr_signbit (expected) && inex == -1))
428 printf ("Incompatible ternary value '%c' (%s part) in file '%s' line %lu\n",
429 (inex == 1) ? '+' : '-', s, pathname, test_line_number);
431 printf ("Incompatible ternary value '%c' in file '%s' line %lu\n",
432 (inex == 1) ? '+' : '-', pathname, test_line_number);
436 /* read lines of data */
438 read_cc (FILE *fp, int *inex_re, int *inex_im, mpc_ptr expected,
439 known_signs_t *signs, mpc_ptr op, mpc_rnd_t *rnd)
441 test_line_number = line_number;
442 read_ternary (fp, inex_re);
443 read_ternary (fp, inex_im);
444 read_mpc (fp, expected, signs);
445 read_mpc (fp, op, NULL);
446 read_mpc_rounding_mode (fp, rnd);
447 check_compatible (*inex_re, mpc_realref(expected), MPC_RND_RE(*rnd), "real");
448 check_compatible (*inex_im, mpc_imagref(expected), MPC_RND_IM(*rnd), "imag");
452 read_fc (FILE *fp, int *inex, mpfr_ptr expected, int *sign, mpc_ptr op,
455 test_line_number = line_number;
456 read_ternary (fp, inex);
457 read_mpfr (fp, expected, sign);
458 read_mpc (fp, op, NULL);
459 read_mpfr_rounding_mode (fp, rnd);
460 check_compatible (*inex, expected, *rnd, NULL);
464 read_ccc (FILE *fp, int *inex_re, int *inex_im, mpc_ptr expected,
465 known_signs_t *signs, mpc_ptr op1, mpc_ptr op2, mpc_rnd_t *rnd)
467 test_line_number = line_number;
468 read_ternary (fp, inex_re);
469 read_ternary (fp, inex_im);
470 read_mpc (fp, expected, signs);
471 read_mpc (fp, op1, NULL);
472 read_mpc (fp, op2, NULL);
473 read_mpc_rounding_mode (fp, rnd);
474 check_compatible (*inex_re, mpc_realref(expected), MPC_RND_RE(*rnd), "real");
475 check_compatible (*inex_im, mpc_imagref(expected), MPC_RND_IM(*rnd), "imag");
478 /* read lines of data for function with three mpc_t inputs and one mpc_t
479 output like mpc_fma */
481 read_cccc (FILE *fp, int *inex_re, int *inex_im, mpc_ptr expected,
482 known_signs_t *signs, mpc_ptr op1, mpc_ptr op2, mpc_ptr op3,
485 test_line_number = line_number;
486 read_ternary (fp, inex_re);
487 read_ternary (fp, inex_im);
488 read_mpc (fp, expected, signs);
489 read_mpc (fp, op1, NULL);
490 read_mpc (fp, op2, NULL);
491 read_mpc (fp, op3, NULL);
492 read_mpc_rounding_mode (fp, rnd);
493 check_compatible (*inex_re, mpc_realref(expected), MPC_RND_RE(*rnd), "real");
494 check_compatible (*inex_im, mpc_imagref(expected), MPC_RND_IM(*rnd), "imag");
498 read_cfc (FILE *fp, int *inex_re, int *inex_im, mpc_ptr expected,
499 known_signs_t *signs, mpfr_ptr op1, mpc_ptr op2, mpc_rnd_t *rnd)
501 test_line_number = line_number;
502 read_ternary (fp, inex_re);
503 read_ternary (fp, inex_im);
504 read_mpc (fp, expected, signs);
505 read_mpfr (fp, op1, NULL);
506 read_mpc (fp, op2, NULL);
507 read_mpc_rounding_mode (fp, rnd);
508 check_compatible (*inex_re, mpc_realref(expected), MPC_RND_RE(*rnd), "real");
509 check_compatible (*inex_im, mpc_imagref(expected), MPC_RND_IM(*rnd), "imag");
513 read_ccf (FILE *fp, int *inex_re, int *inex_im, mpc_ptr expected,
514 known_signs_t *signs, mpc_ptr op1, mpfr_ptr op2, mpc_rnd_t *rnd)
516 test_line_number = line_number;
517 read_ternary (fp, inex_re);
518 read_ternary (fp, inex_im);
519 read_mpc (fp, expected, signs);
520 read_mpc (fp, op1, NULL);
521 read_mpfr (fp, op2, NULL);
522 read_mpc_rounding_mode (fp, rnd);
523 check_compatible (*inex_re, mpc_realref(expected), MPC_RND_RE(*rnd), "real");
524 check_compatible (*inex_im, mpc_imagref(expected), MPC_RND_IM(*rnd), "imag");
528 read_ccu (FILE *fp, int *inex_re, int *inex_im, mpc_ptr expected,
529 known_signs_t *signs, mpc_ptr op1, unsigned long int *op2, mpc_rnd_t *rnd)
531 test_line_number = line_number;
532 read_ternary (fp, inex_re);
533 read_ternary (fp, inex_im);
534 read_mpc (fp, expected, signs);
535 read_mpc (fp, op1, NULL);
537 read_mpc_rounding_mode (fp, rnd);
538 check_compatible (*inex_re, mpc_realref(expected), MPC_RND_RE(*rnd), "real");
539 check_compatible (*inex_im, mpc_imagref(expected), MPC_RND_IM(*rnd), "imag");
543 read_ccs (FILE *fp, int *inex_re, int *inex_im, mpc_ptr expected,
544 known_signs_t *signs, mpc_ptr op1, long int *op2, mpc_rnd_t *rnd)
546 test_line_number = line_number;
547 read_ternary (fp, inex_re);
548 read_ternary (fp, inex_im);
549 read_mpc (fp, expected, signs);
550 read_mpc (fp, op1, NULL);
552 read_mpc_rounding_mode (fp, rnd);
553 check_compatible (*inex_re, mpc_realref(expected), MPC_RND_RE(*rnd), "real");
554 check_compatible (*inex_im, mpc_imagref(expected), MPC_RND_IM(*rnd), "imag");
557 /* set MPFR flags to random values */
559 set_mpfr_flags (int counter)
562 mpfr_set_underflow ();
564 mpfr_clear_underflow ();
566 mpfr_set_overflow ();
568 mpfr_clear_overflow ();
569 /* the divide-by-0 flag was added in MPFR 3.1.0 */
570 #ifdef mpfr_set_divby0
574 mpfr_clear_divby0 ();
579 mpfr_clear_nanflag ();
581 mpfr_set_inexflag ();
583 mpfr_clear_inexflag ();
585 mpfr_set_erangeflag ();
587 mpfr_clear_erangeflag ();
590 /* Check MPFR flags: we allow that some flags are set internally by MPC,
591 for example if MPC does internal computations (using MPFR) which yield
592 an overflow, even if the final MPC result fits in the exponent range.
593 However we don't allow MPC to *clear* the MPFR flags */
595 check_mpfr_flags (int counter)
599 old = (counter & 1) != 0;
600 neu = mpfr_underflow_p () != 0;
601 if (old && (neu == 0))
603 printf ("Error, underflow flag has been modified from %d to %d\n",
607 old = (counter & 2) != 0;
608 neu = mpfr_overflow_p () != 0;
609 if (old && (neu == 0))
611 printf ("Error, overflow flag has been modified from %d to %d\n",
616 old = (counter & 4) != 0;
617 neu = mpfr_divby0_p () != 0;
618 if (old && (neu == 0))
620 printf ("Error, divby0 flag has been modified from %d to %d\n",
625 old = (counter & 8) != 0;
626 neu = mpfr_nanflag_p () != 0;
627 if (old && (neu == 0))
629 printf ("Error, nanflag flag has been modified from %d to %d\n",
633 old = (counter & 16) != 0;
634 neu = mpfr_inexflag_p () != 0;
635 if (old && (neu == 0))
637 printf ("Error, inexflag flag has been modified from %d to %d\n",
641 old = (counter & 32) != 0;
642 neu = mpfr_erangeflag_p () != 0;
643 if (old && (neu == 0))
645 printf ("Error, erangeflag flag has been modified from %d to %d\n",
651 /* data_check (function, data_file_name) checks function results against
652 precomputed data in a file.*/
654 data_check (mpc_function function, const char *file_name)
660 mpfr_rnd_t mpfr_rnd = GMP_RNDN;
664 mpc_t z1, z2, z3, z4, z5;
665 mpc_rnd_t rnd = MPC_RNDNN;
667 unsigned long int ui;
673 static int rand_counter = 0;
675 fp = open_data_file (file_name);
677 /* 1. init needed variables */
679 switch (function.type)
685 case CC: case CCU: case CCS:
709 /* 2. read data file */
711 nextchar = getc (fp);
712 skip_whitespace_comments (fp);
713 while (nextchar != EOF) {
714 set_mpfr_flags (rand_counter);
716 /* for each kind of function prototype: */
717 /* 3.1 read a line of data: expected result, parameters, rounding mode */
718 /* 3.2 compute function at the same precision as the expected result */
719 /* 3.3 compare this result with the expected one */
720 switch (function.type)
722 case FC: /* example mpc_norm */
723 read_fc (fp, &inex_re, x1, &sign_real, z1, &mpfr_rnd);
724 mpfr_set_prec (x2, mpfr_get_prec (x1));
725 inex = function.pointer.FC (x2, z1, mpfr_rnd);
726 if ((inex_re != TERNARY_NOT_CHECKED && inex_re != inex)
727 || !same_mpfr_value (x1, x2, sign_real))
729 mpfr_t got, expected;
734 printf ("%s(op) failed (%s:%lu)\nwith rounding mode %s\n",
735 function.name, file_name, test_line_number,
736 mpfr_rnd_mode[mpfr_rnd]);
737 if (inex_re != TERNARY_NOT_CHECKED && inex_re != inex)
738 printf("ternary value: got %s, expected %s\n",
739 MPFR_INEX_STR (inex), MPFR_INEX_STR (inex_re));
749 case CC: /* example mpc_log */
750 read_cc (fp, &inex_re, &inex_im, z1, &signs, z2, &rnd);
751 mpfr_set_prec (mpc_realref (z3), MPC_PREC_RE (z1));
752 mpfr_set_prec (mpc_imagref (z3), MPC_PREC_IM (z1));
753 inex = function.pointer.CC (z3, z2, rnd);
754 if (!MPC_INEX_CMP (inex_re, inex_im, inex)
755 || !same_mpc_value (z3, z1, signs))
757 mpc_t op, got, expected; /* display sensible variable names */
761 printf ("%s(op) failed (line %lu)\nwith rounding mode %s\n",
762 function.name, test_line_number, rnd_mode[rnd]);
763 if (!MPC_INEX_CMP (inex_re, inex_im, inex))
764 printf("ternary value: got %s, expected (%s, %s)\n",
766 MPFR_INEX_STR (inex_re), MPFR_INEX_STR (inex_im));
776 case C_CC: /* example mpc_mul */
777 read_ccc (fp, &inex_re, &inex_im, z1, &signs, z2, z3, &rnd);
778 mpfr_set_prec (mpc_realref(z4), MPC_PREC_RE (z1));
779 mpfr_set_prec (mpc_imagref(z4), MPC_PREC_IM (z1));
780 inex = function.pointer.C_CC (z4, z2, z3, rnd);
781 if (!MPC_INEX_CMP (inex_re, inex_im, inex)
782 || !same_mpc_value (z4, z1, signs))
784 /* display sensible variable names */
785 mpc_t op1, op2, got, expected;
790 printf ("%s(op) failed (line %lu)\nwith rounding mode %s\n",
791 function.name, test_line_number, rnd_mode[rnd]);
792 if (!MPC_INEX_CMP (inex_re, inex_im, inex))
793 printf("ternary value: got %s, expected (%s, %s)\n",
795 MPFR_INEX_STR (inex_re), MPFR_INEX_STR (inex_im));
804 if (function.properties & FUNC_PROP_SYMETRIC)
806 inex = function.pointer.C_CC (z4, z3, z2, rnd);
807 if (!MPC_INEX_CMP (inex_re, inex_im, inex)
808 || !same_mpc_value (z4, z1, signs))
810 /* display sensible variable names */
811 mpc_t op1, op2, got, expected;
816 printf ("%s(op) failed (line %lu/symetric test)\n"
817 "with rounding mode %s\n",
818 function.name, test_line_number, rnd_mode[rnd]);
819 if (!MPC_INEX_CMP (inex_re, inex_im, inex))
820 printf("ternary value: got %s, expected (%s, %s)\n",
822 MPFR_INEX_STR (inex_re), MPFR_INEX_STR (inex_im));
834 case CCCC: /* example mpc_fma */
835 read_cccc (fp, &inex_re, &inex_im, z1, &signs, z2, z3, z4, &rnd);
836 /* z1 is the expected value, z2, z3, z4 are the inputs, and z5 is
837 the computed value */
838 mpfr_set_prec (mpc_realref(z5), MPC_PREC_RE (z1));
839 mpfr_set_prec (mpc_imagref(z5), MPC_PREC_IM (z1));
840 inex = function.pointer.CCCC (z5, z2, z3, z4, rnd);
841 if (!MPC_INEX_CMP (inex_re, inex_im, inex)
842 || !same_mpc_value (z5, z1, signs))
844 /* display sensible variable names */
845 mpc_t op1, op2, op3, got, expected;
851 printf ("%s(op) failed (line %lu)\nwith rounding mode %s\n",
852 function.name, test_line_number, rnd_mode[rnd]);
853 if (!MPC_INEX_CMP (inex_re, inex_im, inex))
854 printf("ternary value: got %s, expected (%s, %s)\n",
856 MPFR_INEX_STR (inex_re), MPFR_INEX_STR (inex_im));
866 if (function.properties & FUNC_PROP_SYMETRIC)
868 inex = function.pointer.CCCC (z5, z3, z2, z4, rnd);
869 if (!MPC_INEX_CMP (inex_re, inex_im, inex)
870 || !same_mpc_value (z5, z1, signs))
872 /* display sensible variable names */
873 mpc_t op1, op2, op3, got, expected;
879 printf ("%s(op) failed (line %lu/symetric test)\n"
880 "with rounding mode %s\n",
881 function.name, test_line_number, rnd_mode[rnd]);
882 if (!MPC_INEX_CMP (inex_re, inex_im, inex))
883 printf("ternary value: got %s, expected (%s, %s)\n",
885 MPFR_INEX_STR (inex_re), MPFR_INEX_STR (inex_im));
898 case CFC: /* example mpc_fr_div */
899 read_cfc (fp, &inex_re, &inex_im, z1, &signs, x1, z2, &rnd);
900 mpfr_set_prec (mpc_realref(z3), MPC_PREC_RE (z1));
901 mpfr_set_prec (mpc_imagref(z3), MPC_PREC_IM (z1));
902 inex = function.pointer.CFC (z3, x1, z2, rnd);
903 if (!MPC_INEX_CMP (inex_re, inex_im, inex)
904 || !same_mpc_value (z3, z1, signs))
906 /* display sensible variable names */
907 mpc_t op2, got, expected;
913 printf ("%s(op) failed (line %lu)\nwith rounding mode %s\n",
914 function.name, test_line_number, rnd_mode[rnd]);
915 if (!MPC_INEX_CMP (inex_re, inex_im, inex))
916 printf("ternary value: got %s, expected (%s, %s)\n",
918 MPFR_INEX_STR (inex_re), MPFR_INEX_STR (inex_im));
929 case CCF: /* example mpc_mul_fr */
930 read_ccf (fp, &inex_re, &inex_im, z1, &signs, z2, x1, &rnd);
931 mpfr_set_prec (mpc_realref(z3), MPC_PREC_RE (z1));
932 mpfr_set_prec (mpc_imagref(z3), MPC_PREC_IM (z1));
933 inex = function.pointer.CCF (z3, z2, x1, rnd);
934 if (!MPC_INEX_CMP (inex_re, inex_im, inex)
935 || !same_mpc_value (z3, z1, signs))
937 /* display sensible variable names */
938 mpc_t op1, got, expected;
944 printf ("%s(op) failed (line %lu)\nwith rounding mode %s\n",
945 function.name, test_line_number, rnd_mode[rnd]);
946 if (!MPC_INEX_CMP (inex_re, inex_im, inex))
947 printf("ternary value: got %s, expected (%s, %s)\n",
949 MPFR_INEX_STR (inex_re), MPFR_INEX_STR (inex_im));
960 case CCU: /* example mpc_pow_ui */
961 read_ccu (fp, &inex_re, &inex_im, z1, &signs, z2, &ui, &rnd);
962 mpfr_set_prec (mpc_realref(z3), MPC_PREC_RE (z1));
963 mpfr_set_prec (mpc_imagref(z3), MPC_PREC_IM (z1));
964 inex = function.pointer.CCU (z3, z2, ui, rnd);
965 if (!MPC_INEX_CMP (inex_re, inex_im, inex)
966 || !same_mpc_value (z3, z1, signs))
968 /* display sensible variable names */
969 mpc_t op1, got, expected;
973 printf ("%s(op) failed (line %lu)\nwith rounding mode %s\n",
974 function.name, test_line_number, rnd_mode[rnd]);
975 if (!MPC_INEX_CMP (inex_re, inex_im, inex))
976 printf("ternary value: got %s, expected (%s, %s)\n",
978 MPFR_INEX_STR (inex_re), MPFR_INEX_STR (inex_im));
980 printf ("op2 %lu\n ", ui);
988 case CCS: /* example mpc_pow_si */
989 read_ccs (fp, &inex_re, &inex_im, z1, &signs, z2, &si, &rnd);
990 mpfr_set_prec (mpc_realref(z3), MPC_PREC_RE (z1));
991 mpfr_set_prec (mpc_imagref(z3), MPC_PREC_IM (z1));
992 inex = function.pointer.CCS (z3, z2, si, rnd);
993 if (!MPC_INEX_CMP (inex_re, inex_im, inex)
994 || !same_mpc_value (z3, z1, signs))
996 /* display sensible variable names */
997 mpc_t op1, got, expected;
1001 printf ("%s(op) failed (line %lu)\nwith rounding mode %s\n",
1002 function.name, test_line_number, rnd_mode[rnd]);
1003 if (!MPC_INEX_CMP (inex_re, inex_im, inex))
1004 printf("ternary value: got %s, expected (%s, %s)\n",
1005 MPC_INEX_STR (inex),
1006 MPFR_INEX_STR (inex_re), MPFR_INEX_STR (inex_im));
1008 printf ("op2 %li\n ", si);
1017 printf ("Unhandled function prototype %i in 'data_check'\n", function.type);
1021 /* check MPFR flags were not modified */
1022 check_mpfr_flags (rand_counter);
1026 /* 3. Clear used variables */
1028 switch (function.type)
1034 case CC: case CCU: case CCS:
1058 close_data_file (fp);