void check (mpfi_ptr i, mpfr_srcptr a, mpfr_srcptr b, mpfr_srcptr expected_left, mpfr_srcptr expected_right, int expected_inex) { int inex; inex = mpfi_interv_fr (i, a, b); if (inex != expected_inex) { printf ("Error: mpfi_interv_fr (i, a, b) returns %d instead of %d\n", inex, expected_inex); printf ("precision(i) = %lu\na =", mpfi_get_prec (i)); mpfr_out_str (stdout, 10, 0, a, MPFI_RNDD); printf ("\nb = "); mpfr_out_str (stdout, 10, 0, b, MPFI_RNDU); printf ("\n"); exit (1); } if (!same_mpfr_value (&(i->left), expected_left) || !same_mpfr_value (&(i->right), expected_right)) { printf ("Error: mpfi_interv_fr (i, a, b) failed.\n"); printf ("\na = "); mpfr_out_str (stdout, 10, 0, a, MPFI_RNDD); printf ("\nb = "); mpfr_out_str (stdout, 10, 0, b, MPFI_RNDU); printf ("\ngot i = "); mpfi_out_str (stdout, 10, 0, i); printf ("\nexpected = ["); mpfr_out_str (stdout, 10, 0, expected_left, MPFI_RNDD); printf (", "); mpfr_out_str (stdout, 10, 0, expected_right, MPFI_RNDU); printf ("]\n"); exit (1); } }
static void reuse_fc (mpc_function* function, mpc_ptr z, mpc_ptr x, mpfr_ptr expected) { mpc_set (x, z, MPC_RNDNN); /* exact */ function->pointer.FC (expected, z, MPFR_RNDN); function->pointer.FC (mpc_realref (x), x, MPFR_RNDN); if (!same_mpfr_value (mpc_realref (x), expected, 1)) { mpfr_t got; got[0] = mpc_realref(x)[0]; /* display sensible name */ printf ("Reuse error for %s(mpc_realref(z), z) for\n", function->name); MPC_OUT (z); MPFR_OUT (expected); MPFR_OUT (got); exit (1); } mpc_set (x, z, MPC_RNDNN); /* exact */ function->pointer.FC (mpc_imagref (x), x, MPFR_RNDN); if (!same_mpfr_value (mpc_imagref (x), expected, 1)) { mpfr_t got; got[0] = mpc_imagref(x)[0]; /* display sensible name */ printf ("Reuse error for %s(mpc_imagref(z), z) for \n", function->name); MPC_OUT (z); MPFR_OUT (expected); MPFR_OUT (got); exit (1); } }
static void tgeneric_fc (mpc_function *function, mpc_ptr op, mpfr_ptr rop, mpfr_ptr rop4, mpfr_ptr rop4rnd, mpfr_rnd_t rnd) { function->pointer.FC (rop4, op, rnd); function->pointer.FC (rop, op, rnd); if (MPFR_CAN_ROUND (rop4, 1, mpfr_get_prec (rop), rnd)) mpfr_set (rop4rnd, rop4, rnd); else return; if (same_mpfr_value (rop, rop4rnd, 1)) return; printf ("Rounding in %s might be incorrect for\n", function->name); MPC_OUT (op); printf ("with rounding mode %s", mpfr_print_rnd_mode (rnd)); printf ("\n%s gives ", function->name); MPFR_OUT (rop); printf ("%s quadruple precision gives ", function->name); MPFR_OUT (rop4); printf ("and is rounded to "); MPFR_OUT (rop4rnd); exit (1); }
int same_mpc_value (mpc_ptr got, mpc_ptr ref, known_signs_t known_signs) { return same_mpfr_value (MPC_RE (got), MPC_RE (ref), known_signs.re) && same_mpfr_value (MPC_IM (got), MPC_IM (ref), known_signs.im); }