From 7a9011ba5b38de2496079f590362cd2a80c60da3 Mon Sep 17 00:00:00 2001 From: enge Date: Mon, 23 Jul 2012 12:24:50 +0000 Subject: changed GMP_RND? to MPFR_RND? git-svn-id: svn://scm.gforge.inria.fr/svn/mpc/trunk@1246 211d60ee-9f03-0410-a15a-8952a2c7a4e4 --- src/acos.c | 34 +++++++++---------- src/asin.c | 32 ++++++++--------- src/atan.c | 68 ++++++++++++++++++------------------- src/div.c | 82 ++++++++++++++++++++++---------------------- src/div_fr.c | 4 +-- src/exp.c | 30 ++++++++-------- src/fma.c | 28 +++++++-------- src/fr_div.c | 4 +-- src/get_version.c | 4 +-- src/log.c | 32 ++++++++--------- src/log10.c | 60 ++++++++++++++++---------------- src/mpc-impl.h | 12 +++---- src/mpc.h | 38 ++++++++++----------- src/mul.c | 50 +++++++++++++-------------- src/mul_fr.c | 4 +-- src/mul_i.c | 6 ++-- src/norm.c | 30 ++++++++-------- src/pow.c | 28 +++++++-------- src/pow_fr.c | 4 +-- src/pow_ui.c | 8 ++--- src/sin_cos.c | 42 +++++++++++------------ src/sqr.c | 26 +++++++------- src/sqrt.c | 80 +++++++++++++++++++++---------------------- src/strtoc.c | 4 +-- src/tan.c | 24 ++++++------- tests/mpc-tests.h | 2 +- tests/random.c | 10 +++--- tests/read_data.c | 22 ++++++------ tests/tadd_fr.c | 2 +- tests/tatan.c | 8 ++--- tests/tcos.c | 10 +++--- tests/tcosh.c | 10 +++--- tests/tgeneric.c | 100 +++++++++++++++++++++++++++--------------------------- tests/tmul.c | 16 ++++----- tests/tmul_i.c | 10 +++--- tests/tnorm.c | 18 +++++----- tests/tpow.c | 6 ++-- tests/tpow_fr.c | 4 +-- tests/tpow_ui.c | 8 ++--- tests/treimref.c | 10 +++--- tests/tset.c | 28 +++++++-------- tests/tsqr.c | 8 ++--- tests/ttan.c | 46 ++++++++++++------------- tests/tui_div.c | 6 ++-- 44 files changed, 529 insertions(+), 529 deletions(-) diff --git a/src/acos.c b/src/acos.c index e7a2691..6117786 100644 --- a/src/acos.c +++ b/src/acos.c @@ -67,7 +67,7 @@ mpc_acos (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) { inex_re = set_pi_over_2 (mpc_realref (rop), +1, MPC_RND_RE (rnd)); - mpfr_div_2ui (mpc_realref (rop), mpc_realref (rop), 1, GMP_RNDN); + mpfr_div_2ui (mpc_realref (rop), mpc_realref (rop), 1, MPFR_RNDN); } else { @@ -88,11 +88,11 @@ mpc_acos (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) { p += mpc_ceil_log2 (p); mpfr_set_prec (x, p); - mpfr_const_pi (x, GMP_RNDD); - mpfr_mul_ui (x, x, 3, GMP_RNDD); + mpfr_const_pi (x, MPFR_RNDD); + mpfr_mul_ui (x, x, 3, MPFR_RNDD); ok = - mpfr_can_round (x, p - 1, GMP_RNDD, MPC_RND_RE (rnd), - prec+(MPC_RND_RE (rnd) == GMP_RNDN)); + mpfr_can_round (x, p - 1, MPFR_RNDD, MPC_RND_RE (rnd), + prec+(MPC_RND_RE (rnd) == MPFR_RNDN)); } while (ok == 0); inex_re = @@ -103,7 +103,7 @@ mpc_acos (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) else { if (mpfr_sgn (mpc_realref (op)) > 0) - mpfr_set_ui (mpc_realref (rop), 0, GMP_RNDN); + mpfr_set_ui (mpc_realref (rop), 0, MPFR_RNDN); else inex_re = mpfr_const_pi (mpc_realref (rop), MPC_RND_RE (rnd)); } @@ -131,7 +131,7 @@ mpc_acos (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) inex_im = -mpfr_acosh (mpc_imagref (rop), mpc_realref (op), INV_RND (MPC_RND_IM (rnd))); - mpfr_set_ui (mpc_realref (rop), 0, GMP_RNDN); + mpfr_set_ui (mpc_realref (rop), 0, MPFR_RNDN); } else if (mpfr_cmp_si (mpc_realref (op), -1) < 0) { @@ -180,13 +180,13 @@ mpc_acos (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) /* the imaginary part of asin(z) has the same sign as Im(z), thus if Im(z) > 0 and rnd_im = RNDZ, we want to round the Im(asin(z)) to -Inf so that -Im(asin(z)) is rounded to zero */ - if (rnd_im == GMP_RNDZ) - rnd_im = mpfr_sgn (mpc_imagref(op)) > 0 ? GMP_RNDD : GMP_RNDU; + if (rnd_im == MPFR_RNDZ) + rnd_im = mpfr_sgn (mpc_imagref(op)) > 0 ? MPFR_RNDD : MPFR_RNDU; else - rnd_im = rnd_im == GMP_RNDU ? GMP_RNDD - : rnd_im == GMP_RNDD ? GMP_RNDU + rnd_im = rnd_im == MPFR_RNDU ? MPFR_RNDD + : rnd_im == MPFR_RNDD ? MPFR_RNDU : rnd_im; /* both RNDZ and RNDA map to themselves for -asin(z) */ - rnd1 = MPC_RND (GMP_RNDN, rnd_im); + rnd1 = MPC_RND (MPFR_RNDN, rnd_im); mpfr_init2 (pi_over_2, p); for (;;) { @@ -195,13 +195,13 @@ mpc_acos (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) mpfr_set_prec (mpc_realref(z1), p); mpfr_set_prec (pi_over_2, p); - set_pi_over_2 (pi_over_2, +1, GMP_RNDN); + set_pi_over_2 (pi_over_2, +1, MPFR_RNDN); e1 = 1; /* Exp(pi_over_2) */ inex = mpc_asin (z1, op, rnd1); /* asin(z) */ MPC_ASSERT (mpfr_sgn (mpc_imagref(z1)) * mpfr_sgn (mpc_imagref(op)) > 0); inex_im = MPC_INEX_IM(inex); /* inex_im is in {-1, 0, 1} */ e2 = mpfr_get_exp (mpc_realref(z1)); - mpfr_sub (mpc_realref(z1), pi_over_2, mpc_realref(z1), GMP_RNDN); + mpfr_sub (mpc_realref(z1), pi_over_2, mpc_realref(z1), MPFR_RNDN); if (!mpfr_zero_p (mpc_realref(z1))) { /* the error on x=Re(z1) is bounded by 1/2 ulp(x) + 2^(e1-p-1) + @@ -212,10 +212,10 @@ mpc_acos (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) /* the error on x is bounded by 1/2 ulp(x) [1 + 2^e1] */ e1 = e1 <= 0 ? 0 : e1; /* the error on x is bounded by 2^e1 * ulp(x) */ - mpfr_neg (mpc_imagref(z1), mpc_imagref(z1), GMP_RNDN); /* exact */ + mpfr_neg (mpc_imagref(z1), mpc_imagref(z1), MPFR_RNDN); /* exact */ inex_im = -inex_im; - if (mpfr_can_round (mpc_realref(z1), p - e1, GMP_RNDN, GMP_RNDZ, - p_re + (MPC_RND_RE(rnd) == GMP_RNDN))) + if (mpfr_can_round (mpc_realref(z1), p - e1, MPFR_RNDN, MPFR_RNDZ, + p_re + (MPC_RND_RE(rnd) == MPFR_RNDN))) break; } } diff --git a/src/asin.c b/src/asin.c index bd4e313..2d18489 100644 --- a/src/asin.c +++ b/src/asin.c @@ -1,6 +1,6 @@ /* mpc_asin -- arcsine of a complex number. -Copyright (C) 2009, 2010, 2011 INRIA +Copyright (C) 2009, 2010, 2011, 2012 INRIA This file is part of GNU MPC. @@ -38,7 +38,7 @@ mpc_asin (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) } else if (mpfr_zero_p (mpc_realref (op))) { - mpfr_set (mpc_realref (rop), mpc_realref (op), GMP_RNDN); + mpfr_set (mpc_realref (rop), mpc_realref (op), MPFR_RNDN); mpfr_set_nan (mpc_imagref (rop)); } else @@ -62,7 +62,7 @@ mpc_asin (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) mpfr_set_inf (mpc_imagref (rop), (mpfr_signbit (mpc_imagref (op)) ? -1 : 1)); if (inf_im) - mpfr_div_2ui (mpc_realref (rop), mpc_realref (rop), 1, GMP_RNDN); + mpfr_div_2ui (mpc_realref (rop), mpc_realref (rop), 1, MPFR_RNDN); } else { @@ -116,7 +116,7 @@ mpc_asin (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) { inex_im = mpfr_set_ui (mpc_imagref (rop), 0, MPC_RND_IM (rnd)); if (s_im) - mpfr_neg (mpc_imagref (rop), mpc_imagref (rop), GMP_RNDN); + mpfr_neg (mpc_imagref (rop), mpc_imagref (rop), MPFR_RNDN); inex_re = mpfr_asin (mpc_realref (rop), mpc_realref (op), MPC_RND_RE (rnd)); } @@ -129,9 +129,9 @@ mpc_asin (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) int inex_im; int s; s = mpfr_signbit (mpc_realref (op)); - mpfr_set_ui (mpc_realref (rop), 0, GMP_RNDN); + mpfr_set_ui (mpc_realref (rop), 0, MPFR_RNDN); if (s) - mpfr_neg (mpc_realref (rop), mpc_realref (rop), GMP_RNDN); + mpfr_neg (mpc_realref (rop), mpc_realref (rop), MPFR_RNDN); inex_im = mpfr_asinh (mpc_imagref (rop), mpc_imagref (op), MPC_RND_IM (rnd)); return MPC_INEX (0, inex_im); @@ -158,8 +158,8 @@ mpc_asin (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) /* err(x) <= 1/2 ulp(x), err(y) <= 1/2 ulp(y) */ /* z1 <- 1-z1 */ ex = mpfr_get_exp (mpc_realref(z1)); - mpfr_ui_sub (mpc_realref(z1), 1, mpc_realref(z1), GMP_RNDN); - mpfr_neg (mpc_imagref(z1), mpc_imagref(z1), GMP_RNDN); + mpfr_ui_sub (mpc_realref(z1), 1, mpc_realref(z1), MPFR_RNDN); + mpfr_neg (mpc_imagref(z1), mpc_imagref(z1), MPFR_RNDN); ex = ex - mpfr_get_exp (mpc_realref(z1)); ex = (ex <= 0) ? 0 : ex; /* err(x) <= 2^ex * ulp(x) */ @@ -186,8 +186,8 @@ mpc_asin (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) /* z1 <- i*z + z1 */ ex = mpfr_get_exp (mpc_realref(z1)); ey = mpfr_get_exp (mpc_imagref(z1)); - mpfr_sub (mpc_realref(z1), mpc_realref(z1), mpc_imagref(op), GMP_RNDN); - mpfr_add (mpc_imagref(z1), mpc_imagref(z1), mpc_realref(op), GMP_RNDN); + mpfr_sub (mpc_realref(z1), mpc_realref(z1), mpc_imagref(op), MPFR_RNDN); + mpfr_add (mpc_imagref(z1), mpc_imagref(z1), mpc_realref(op), MPFR_RNDN); if (mpfr_cmp_ui (mpc_realref(z1), 0) == 0 || mpfr_cmp_ui (mpc_imagref(z1), 0) == 0) continue; ex -= mpfr_get_exp (mpc_realref(z1)); /* cancellation in x */ @@ -201,7 +201,7 @@ mpc_asin (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) ey = mpfr_get_exp (mpc_imagref(z1)); ex = (ex >= ey) ? ex : ey; err += ex - p; /* revert to absolute error <= 2^err */ - mpc_log (z1, z1, GMP_RNDN); + mpc_log (z1, z1, MPFR_RNDN); err -= ex - 1; /* 1/|t| <= 1/|z| <= 2^(1-ex) */ /* express err in terms of ulp(z1) */ ey = mpfr_get_exp (mpc_realref(z1)) <= mpfr_get_exp (mpc_imagref(z1)) @@ -211,11 +211,11 @@ mpc_asin (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) err = (err <= 0) ? 1 : err + 1; /* z1 <- -i*z1 */ mpfr_swap (mpc_realref(z1), mpc_imagref(z1)); - mpfr_neg (mpc_imagref(z1), mpc_imagref(z1), GMP_RNDN); - if (mpfr_can_round (mpc_realref(z1), p - err, GMP_RNDN, GMP_RNDZ, - p_re + (rnd_re == GMP_RNDN)) && - mpfr_can_round (mpc_imagref(z1), p - err, GMP_RNDN, GMP_RNDZ, - p_im + (rnd_im == GMP_RNDN))) + mpfr_neg (mpc_imagref(z1), mpc_imagref(z1), MPFR_RNDN); + if (mpfr_can_round (mpc_realref(z1), p - err, MPFR_RNDN, MPFR_RNDZ, + p_re + (rnd_re == MPFR_RNDN)) && + mpfr_can_round (mpc_imagref(z1), p - err, MPFR_RNDN, MPFR_RNDZ, + p_im + (rnd_im == MPFR_RNDN))) break; } diff --git a/src/atan.c b/src/atan.c index c0b01a4..43c03eb 100644 --- a/src/atan.c +++ b/src/atan.c @@ -32,11 +32,11 @@ set_pi_over_2 (mpfr_ptr rop, int s, mpfr_rnd_t rnd) int inex; inex = mpfr_const_pi (rop, s < 0 ? INV_RND (rnd) : rnd); - mpfr_div_2ui (rop, rop, 1, GMP_RNDN); + mpfr_div_2ui (rop, rop, 1, MPFR_RNDN); if (s < 0) { inex = -inex; - mpfr_neg (rop, rop, GMP_RNDN); + mpfr_neg (rop, rop, MPFR_RNDN); } return inex; @@ -64,7 +64,7 @@ mpc_atan (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) mpfr_set_nan (mpc_realref (rop)); if (mpfr_zero_p (mpc_imagref (op)) || mpfr_inf_p (mpc_imagref (op))) { - mpfr_set_ui (mpc_imagref (rop), 0, GMP_RNDN); + mpfr_set_ui (mpc_imagref (rop), 0, MPFR_RNDN); if (s_im) mpc_conj (rop, rop, MPC_RNDNN); } @@ -76,7 +76,7 @@ mpc_atan (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) if (mpfr_inf_p (mpc_realref (op))) { inex_re = set_pi_over_2 (mpc_realref (rop), -s_re, MPC_RND_RE (rnd)); - mpfr_set_ui (mpc_imagref (rop), 0, GMP_RNDN); + mpfr_set_ui (mpc_imagref (rop), 0, MPFR_RNDN); } else { @@ -91,9 +91,9 @@ mpc_atan (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) { inex_re = set_pi_over_2 (mpc_realref (rop), -s_re, MPC_RND_RE (rnd)); - mpfr_set_ui (mpc_imagref (rop), 0, GMP_RNDN); + mpfr_set_ui (mpc_imagref (rop), 0, MPFR_RNDN); if (s_im) - mpc_conj (rop, rop, GMP_RNDN); + mpc_conj (rop, rop, MPFR_RNDN); return MPC_INEX (inex_re, 0); } @@ -103,9 +103,9 @@ mpc_atan (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) { inex_re = mpfr_atan (mpc_realref (rop), mpc_realref (op), MPC_RND_RE (rnd)); - mpfr_set_ui (mpc_imagref (rop), 0, GMP_RNDN); + mpfr_set_ui (mpc_imagref (rop), 0, MPFR_RNDN); if (s_im) - mpc_conj (rop, rop, GMP_RNDN); + mpc_conj (rop, rop, MPFR_RNDN); return MPC_INEX (inex_re, 0); } @@ -125,9 +125,9 @@ mpc_atan (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) /* atan(+0+iy) = +0 +i*atanh(y), if |y| < 1 atan(-0+iy) = -0 +i*atanh(y), if |y| < 1 */ - mpfr_set_ui (mpc_realref (rop), 0, GMP_RNDN); + mpfr_set_ui (mpc_realref (rop), 0, MPFR_RNDN); if (s_re) - mpfr_neg (mpc_realref (rop), mpc_realref (rop), GMP_RNDN); + mpfr_neg (mpc_realref (rop), mpc_realref (rop), MPFR_RNDN); inex_im = mpfr_atanh (mpc_imagref (rop), mpc_imagref (op), MPC_RND_IM (rnd)); } @@ -164,7 +164,7 @@ mpc_atan (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) { p += mpc_ceil_log2 (p) + 2; mpfr_set_prec (y, p); - rnd_away = s_im == 0 ? GMP_RNDU : GMP_RNDD; + rnd_away = s_im == 0 ? MPFR_RNDU : MPFR_RNDD; inex_im = mpfr_ui_div (y, 1, mpc_imagref (op), rnd_away); /* FIXME: should we consider the case with unreasonably huge precision prec(y)>3*exp_min, where atanh(1/Im(op)) could be @@ -176,8 +176,8 @@ mpc_atan (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) inex_im |= mpfr_atanh (y, y, rnd_away); ok = inex_im == 0 - || mpfr_can_round (y, p - 2, rnd_away, GMP_RNDZ, - p_im + (rnd_im == GMP_RNDN)); + || mpfr_can_round (y, p - 2, rnd_away, MPFR_RNDZ, + p_im + (rnd_im == MPFR_RNDN)); } while (ok == 0); inex_re = set_pi_over_2 (mpc_realref (rop), -s_re, MPC_RND_RE (rnd)); @@ -226,8 +226,8 @@ mpc_atan (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) /* p: working precision */ p = (op_im_exp > 0 || prec > SAFE_ABS (mpfr_prec_t, op_im_exp)) ? prec : (prec - op_im_exp); - rnd1 = mpfr_sgn (mpc_realref (op)) > 0 ? GMP_RNDD : GMP_RNDU; - rnd2 = mpfr_sgn (mpc_realref (op)) < 0 ? GMP_RNDU : GMP_RNDD; + rnd1 = mpfr_sgn (mpc_realref (op)) > 0 ? MPFR_RNDD : MPFR_RNDU; + rnd2 = mpfr_sgn (mpc_realref (op)) < 0 ? MPFR_RNDU : MPFR_RNDD; do { @@ -249,7 +249,7 @@ mpc_atan (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) } else err = mpfr_get_exp (a); /* err = Exp(a) with the notations above */ - mpfr_atan2 (x, mpc_realref (op), a, GMP_RNDU); + mpfr_atan2 (x, mpc_realref (op), a, MPFR_RNDU); /* b = lower bound for atan (-x/(1+y)): for x negative, we need a lower bound on -x/(1+y), i.e., an upper bound on 1+y */ @@ -264,21 +264,21 @@ mpc_atan (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) } else expo = mpfr_get_exp (a); /* expo = Exp(c) with the notations above */ - mpfr_atan2 (b, minus_op_re, a, GMP_RNDD); + mpfr_atan2 (b, minus_op_re, a, MPFR_RNDD); err = err < expo ? err : expo; /* err = min(Exp(a),Exp(c)) */ - mpfr_sub (x, x, b, GMP_RNDU); + mpfr_sub (x, x, b, MPFR_RNDU); err = 5 + op_re_exp - err - mpfr_get_exp (x); /* error is bounded by [1 + 2^err] ulp(e) */ err = err < 0 ? 1 : err + 1; - mpfr_div_2ui (x, x, 1, GMP_RNDU); + mpfr_div_2ui (x, x, 1, MPFR_RNDU); /* Note: using RND2=RNDD guarantees that if x is exactly representable on prec + ... bits, mpfr_can_round will return 0 */ - ok = mpfr_can_round (x, p - err, GMP_RNDU, GMP_RNDD, - prec + (MPC_RND_RE (rnd) == GMP_RNDN)); + ok = mpfr_can_round (x, p - err, MPFR_RNDU, MPFR_RNDD, + prec + (MPC_RND_RE (rnd) == MPFR_RNDN)); } while (ok == 0); /* Imaginary part @@ -314,22 +314,22 @@ mpc_atan (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) /* a = upper bound for log(x^2 + (1+y)^2) */ ROUND_AWAY (mpfr_add_ui (a, mpc_imagref (op), 1, MPFR_RNDA), a); - mpfr_sqr (a, a, GMP_RNDU); - mpfr_sqr (y, mpc_realref (op), GMP_RNDU); - mpfr_add (a, a, y, GMP_RNDU); - mpfr_log (a, a, GMP_RNDU); + mpfr_sqr (a, a, MPFR_RNDU); + mpfr_sqr (y, mpc_realref (op), MPFR_RNDU); + mpfr_add (a, a, y, MPFR_RNDU); + mpfr_log (a, a, MPFR_RNDU); /* b = lower bound for log(x^2 + (1-y)^2) */ - mpfr_ui_sub (b, 1, mpc_imagref (op), GMP_RNDZ); /* round to zero */ - mpfr_sqr (b, b, GMP_RNDZ); - /* we could write mpfr_sqr (y, mpc_realref (op), GMP_RNDZ) but it is + mpfr_ui_sub (b, 1, mpc_imagref (op), MPFR_RNDZ); /* round to zero */ + mpfr_sqr (b, b, MPFR_RNDZ); + /* we could write mpfr_sqr (y, mpc_realref (op), MPFR_RNDZ) but it is more efficient to reuse the value of y (x^2) above and subtract one ulp */ mpfr_nextbelow (y); - mpfr_add (b, b, y, GMP_RNDZ); - mpfr_log (b, b, GMP_RNDZ); + mpfr_add (b, b, y, MPFR_RNDZ); + mpfr_log (b, b, MPFR_RNDZ); - mpfr_sub (y, a, b, GMP_RNDU); + mpfr_sub (y, a, b, MPFR_RNDU); if (mpfr_zero_p (y)) /* FIXME: happens when x and y have very different magnitudes; @@ -346,7 +346,7 @@ mpc_atan (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) else err = (expo < 0) ? 1 : expo + 2; - mpfr_div_2ui (y, y, 2, GMP_RNDN); + mpfr_div_2ui (y, y, 2, MPFR_RNDN); MPC_ASSERT (!mpfr_zero_p (y)); /* FIXME: underflow. Since the main term of the Taylor series in y=0 is 1/(x^2+1) * y, this means that y is very small @@ -354,8 +354,8 @@ mpc_atan (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) should be true. This needs a proof, or better yet, special code. */ - ok = mpfr_can_round (y, p - err, GMP_RNDU, GMP_RNDD, - prec + (MPC_RND_IM (rnd) == GMP_RNDN)); + ok = mpfr_can_round (y, p - err, MPFR_RNDU, MPFR_RNDD, + prec + (MPC_RND_IM (rnd) == MPFR_RNDN)); } } while (ok == 0); diff --git a/src/div.c b/src/div.c index 83584b8..1dabebc 100644 --- a/src/div.c +++ b/src/div.c @@ -68,28 +68,28 @@ mpc_div_inf_fin (mpc_ptr rop, mpc_srcptr z, mpc_srcptr w) if (a == 1) if (b == 1) { - mpfr_add (sign, mpc_realref (w), mpc_imagref (w), GMP_RNDN); + mpfr_add (sign, mpc_realref (w), mpc_imagref (w), MPFR_RNDN); x = MPC_MPFR_SIGN (sign); - mpfr_sub (sign, mpc_realref (w), mpc_imagref (w), GMP_RNDN); + mpfr_sub (sign, mpc_realref (w), mpc_imagref (w), MPFR_RNDN); y = MPC_MPFR_SIGN (sign); } else { /* b == -1 */ - mpfr_sub (sign, mpc_realref (w), mpc_imagref (w), GMP_RNDN); + mpfr_sub (sign, mpc_realref (w), mpc_imagref (w), MPFR_RNDN); x = MPC_MPFR_SIGN (sign); - mpfr_add (sign, mpc_realref (w), mpc_imagref (w), GMP_RNDN); + mpfr_add (sign, mpc_realref (w), mpc_imagref (w), MPFR_RNDN); y = -MPC_MPFR_SIGN (sign); } else /* a == -1 */ if (b == 1) { - mpfr_sub (sign, mpc_imagref (w), mpc_realref (w), GMP_RNDN); + mpfr_sub (sign, mpc_imagref (w), mpc_realref (w), MPFR_RNDN); x = MPC_MPFR_SIGN (sign); - mpfr_add (sign, mpc_realref (w), mpc_imagref (w), GMP_RNDN); + mpfr_add (sign, mpc_realref (w), mpc_imagref (w), MPFR_RNDN); y = MPC_MPFR_SIGN (sign); } else { /* b == -1 */ - mpfr_add (sign, mpc_realref (w), mpc_imagref (w), GMP_RNDN); + mpfr_add (sign, mpc_realref (w), mpc_imagref (w), MPFR_RNDN); x = -MPC_MPFR_SIGN (sign); - mpfr_sub (sign, mpc_imagref (w), mpc_realref (w), GMP_RNDN); + mpfr_sub (sign, mpc_imagref (w), mpc_realref (w), MPFR_RNDN); y = MPC_MPFR_SIGN (sign); } mpfr_clear (sign); @@ -121,25 +121,25 @@ mpc_div_fin_inf (mpc_ptr rop, mpc_srcptr z, mpc_srcptr w) mpfr_init2 (x, 2); mpfr_init2 (y, 2); mpfr_init2 (zero, 2); - mpfr_set_ui (zero, 0ul, GMP_RNDN); + mpfr_set_ui (zero, 0ul, MPFR_RNDN); mpfr_init2 (a, mpfr_get_prec (mpc_realref (z))); mpfr_init2 (b, mpfr_get_prec (mpc_imagref (z))); - mpfr_set_ui (c, (mpfr_inf_p (mpc_realref (w)) ? 1 : 0), GMP_RNDN); - MPFR_COPYSIGN (c, c, mpc_realref (w), GMP_RNDN); - mpfr_set_ui (d, (mpfr_inf_p (mpc_imagref (w)) ? 1 : 0), GMP_RNDN); - MPFR_COPYSIGN (d, d, mpc_imagref (w), GMP_RNDN); + mpfr_set_ui (c, (mpfr_inf_p (mpc_realref (w)) ? 1 : 0), MPFR_RNDN); + MPFR_COPYSIGN (c, c, mpc_realref (w), MPFR_RNDN); + mpfr_set_ui (d, (mpfr_inf_p (mpc_imagref (w)) ? 1 : 0), MPFR_RNDN); + MPFR_COPYSIGN (d, d, mpc_imagref (w), MPFR_RNDN); - mpfr_mul (a, mpc_realref (z), c, GMP_RNDN); /* exact */ - mpfr_mul (b, mpc_imagref (z), d, GMP_RNDN); - mpfr_add (x, a, b, GMP_RNDN); + mpfr_mul (a, mpc_realref (z), c, MPFR_RNDN); /* exact */ + mpfr_mul (b, mpc_imagref (z), d, MPFR_RNDN); + mpfr_add (x, a, b, MPFR_RNDN); - mpfr_mul (b, mpc_imagref (z), c, GMP_RNDN); - mpfr_mul (a, mpc_realref (z), d, GMP_RNDN); - mpfr_sub (y, b, a, GMP_RNDN); + mpfr_mul (b, mpc_imagref (z), c, MPFR_RNDN); + mpfr_mul (a, mpc_realref (z), d, MPFR_RNDN); + mpfr_sub (y, b, a, MPFR_RNDN); - MPFR_COPYSIGN (mpc_realref (rop), zero, x, GMP_RNDN); - MPFR_COPYSIGN (mpc_imagref (rop), zero, y, GMP_RNDN); + MPFR_COPYSIGN (mpc_realref (rop), zero, x, MPFR_RNDN); + MPFR_COPYSIGN (mpc_imagref (rop), zero, y, MPFR_RNDN); mpfr_clear (c); mpfr_clear (d); @@ -173,10 +173,10 @@ mpc_div_real (mpc_ptr rop, mpc_srcptr z, mpc_srcptr w, mpc_rnd_t rnd) inexact flags */ if (mpfr_zero_p (mpc_realref (rop))) mpfr_setsign (mpc_realref (rop), mpc_realref (rop), (zrs != wrs && zis != wis), - GMP_RNDN); /* exact */ + MPFR_RNDN); /* exact */ if (mpfr_zero_p (mpc_imagref (rop))) mpfr_setsign (mpc_imagref (rop), mpc_imagref (rop), (zis != wrs && zrs == wis), - GMP_RNDN); + MPFR_RNDN); return MPC_INEX(inex_re, inex_im); } @@ -204,7 +204,7 @@ mpc_div_imag (mpc_ptr rop, mpc_srcptr z, mpc_srcptr w, mpc_rnd_t rnd) wloc[0] = mpc_imagref(w)[0]; /* copies mpfr struct IM(w) into wloc */ inex_re = mpfr_div (mpc_realref(dest), mpc_imagref(z), wloc, MPC_RND_RE(rnd)); - mpfr_neg (wloc, wloc, GMP_RNDN); + mpfr_neg (wloc, wloc, MPFR_RNDN); /* changes the sign only in wloc, not in w; no need to correct later */ inex_im = mpfr_div (mpc_imagref(dest), mpc_realref(z), wloc, MPC_RND_IM(rnd)); @@ -221,10 +221,10 @@ mpc_div_imag (mpc_ptr rop, mpc_srcptr z, mpc_srcptr w, mpc_rnd_t rnd) inexact flags */ if (mpfr_zero_p (mpc_realref (rop))) mpfr_setsign (mpc_realref (rop), mpc_realref (rop), (zrs != wrs && zis != wis), - GMP_RNDN); /* exact */ + MPFR_RNDN); /* exact */ if (imag_z) mpfr_setsign (mpc_imagref (rop), mpc_imagref (rop), (zis != wrs && zrs == wis), - GMP_RNDN); + MPFR_RNDN); return MPC_INEX(inex_re, inex_im); } @@ -292,11 +292,11 @@ mpc_div (mpc_ptr a, mpc_srcptr b, mpc_srcptr c, mpc_rnd_t rnd) /* first compute norm(c) */ mpfr_clear_underflow (); mpfr_clear_overflow (); - inexact_norm = mpc_norm (q, c, GMP_RNDU); + inexact_norm = mpc_norm (q, c, MPFR_RNDU); underflow_norm = mpfr_underflow_p (); overflow_norm = mpfr_overflow_p (); if (underflow_norm) - mpfr_set_ui (q, 0ul, GMP_RNDN); + mpfr_set_ui (q, 0ul, MPFR_RNDN); /* to obtain divisions by 0 later on */ /* now compute b*conjugate(c) */ @@ -361,28 +361,28 @@ mpc_div (mpc_ptr a, mpc_srcptr b, mpc_srcptr c, mpc_rnd_t rnd) /* we use the division code of mpfr, which handles the situation. */ mpfr_clear_underflow (); mpfr_clear_overflow (); - inexact_re |= mpfr_div (mpc_realref (res), mpc_realref (res), q, GMP_RNDZ); + inexact_re |= mpfr_div (mpc_realref (res), mpc_realref (res), q, MPFR_RNDZ); underflow_re = mpfr_underflow_p (); overflow_re = mpfr_overflow_p (); ok_re = !inexact_re || underflow_re || overflow_re - || mpfr_can_round (mpc_realref (res), prec - 4, GMP_RNDN, - GMP_RNDZ, MPC_PREC_RE(a) + (rnd_re == GMP_RNDN)); + || mpfr_can_round (mpc_realref (res), prec - 4, MPFR_RNDN, + MPFR_RNDZ, MPC_PREC_RE(a) + (rnd_re == MPFR_RNDN)); if (ok_re) /* compute imaginary part */ { mpfr_clear_underflow (); mpfr_clear_overflow (); - inexact_im |= mpfr_div (mpc_imagref (res), mpc_imagref (res), q, GMP_RNDZ); + inexact_im |= mpfr_div (mpc_imagref (res), mpc_imagref (res), q, MPFR_RNDZ); underflow_im = mpfr_underflow_p (); overflow_im = mpfr_overflow_p (); ok_im = !inexact_im || underflow_im || overflow_im - || mpfr_can_round (mpc_imagref (res), prec - 4, GMP_RNDN, - GMP_RNDZ, MPC_PREC_IM(a) + (rnd_im == GMP_RNDN)); + || mpfr_can_round (mpc_imagref (res), prec - 4, MPFR_RNDN, + MPFR_RNDZ, MPC_PREC_IM(a) + (rnd_im == MPFR_RNDN)); } } else { /* The division is inexact, so for efficiency reasons we invert q */ /* only once and multiply by the inverse. */ - if (mpfr_ui_div (q, 1ul, q, GMP_RNDZ) || inexact_norm) { + if (mpfr_ui_div (q, 1ul, q, MPFR_RNDZ) || inexact_norm) { /* if 1/q is inexact, the approximations of the real and imaginary part below will be inexact, unless RE(res) or IM(res) is zero */ @@ -391,22 +391,22 @@ mpc_div (mpc_ptr a, mpc_srcptr b, mpc_srcptr c, mpc_rnd_t rnd) } mpfr_clear_underflow (); mpfr_clear_overflow (); - inexact_re |= mpfr_mul (mpc_realref (res), mpc_realref (res), q, GMP_RNDZ); + inexact_re |= mpfr_mul (mpc_realref (res), mpc_realref (res), q, MPFR_RNDZ); underflow_re = mpfr_underflow_p (); overflow_re = mpfr_overflow_p (); ok_re = !inexact_re || underflow_re || overflow_re - || mpfr_can_round (mpc_realref (res), prec - 4, GMP_RNDN, - GMP_RNDZ, MPC_PREC_RE(a) + (rnd_re == GMP_RNDN)); + || mpfr_can_round (mpc_realref (res), prec - 4, MPFR_RNDN, + MPFR_RNDZ, MPC_PREC_RE(a) + (rnd_re == MPFR_RNDN)); if (ok_re) /* compute imaginary part */ { mpfr_clear_underflow (); mpfr_clear_overflow (); - inexact_im |= mpfr_mul (mpc_imagref (res), mpc_imagref (res), q, GMP_RNDZ); + inexact_im |= mpfr_mul (mpc_imagref (res), mpc_imagref (res), q, MPFR_RNDZ); underflow_im = mpfr_underflow_p (); overflow_im = mpfr_overflow_p (); ok_im = !inexact_im || underflow_im || overflow_im - || mpfr_can_round (mpc_imagref (res), prec - 4, GMP_RNDN, - GMP_RNDZ, MPC_PREC_IM(a) + (rnd_im == GMP_RNDN)); + || mpfr_can_round (mpc_imagref (res), prec - 4, MPFR_RNDN, + MPFR_RNDZ, MPC_PREC_IM(a) + (rnd_im == MPFR_RNDN)); } } } while ((!ok_re || !ok_im) && !underflow_norm && !overflow_norm diff --git a/src/div_fr.c b/src/div_fr.c index d5ea240..447c078 100644 --- a/src/div_fr.c +++ b/src/div_fr.c @@ -1,6 +1,6 @@ /* mpc_div_fr -- Divide a complex number by a floating-point number. -Copyright (C) 2002, 2008, 2009, 2010, 2011 INRIA +Copyright (C) 2002, 2008, 2009, 2010, 2011, 2012 INRIA This file is part of GNU MPC. @@ -31,7 +31,7 @@ mpc_div_fr (mpc_ptr a, mpc_srcptr b, mpfr_srcptr c, mpc_rnd_t rnd) inex_re = mpfr_div (real, mpc_realref(b), c, MPC_RND_RE(rnd)); inex_im = mpfr_div (mpc_imagref(a), mpc_imagref(b), c, MPC_RND_IM(rnd)); - mpfr_set (mpc_realref (a), real, GMP_RNDN); + mpfr_set (mpc_realref (a), real, MPFR_RNDN); mpfr_clear (real); diff --git a/src/exp.c b/src/exp.c index 3646225..06faff3 100644 --- a/src/exp.c +++ b/src/exp.c @@ -1,6 +1,6 @@ /* mpc_exp -- exponential of a complex number. -Copyright (C) 2002, 2009, 2010, 2011 INRIA +Copyright (C) 2002, 2009, 2010, 2011, 2012 INRIA This file is part of GNU MPC. @@ -88,15 +88,15 @@ mpc_exp (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) mpfr_init2 (n, 2); if (mpfr_signbit (mpc_realref (op))) - mpfr_set_ui (n, 0, GMP_RNDN); + mpfr_set_ui (n, 0, MPFR_RNDN); else mpfr_set_inf (n, +1); if (mpfr_inf_p (mpc_imagref (op))) { - inex_re = mpfr_set (mpc_realref (rop), n, GMP_RNDN); + inex_re = mpfr_set (mpc_realref (rop), n, MPFR_RNDN); if (mpfr_signbit (mpc_realref (op))) - inex_im = mpfr_set (mpc_imagref (rop), n, GMP_RNDN); + inex_im = mpfr_set (mpc_imagref (rop), n, MPFR_RNDN); else { mpfr_set_nan (mpc_imagref (rop)); @@ -109,9 +109,9 @@ mpc_exp (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) mpfr_init2 (c, 2); mpfr_init2 (s, 2); - mpfr_sin_cos (s, c, mpc_imagref (op), GMP_RNDN); - inex_re = mpfr_copysign (mpc_realref (rop), n, c, GMP_RNDN); - inex_im = mpfr_copysign (mpc_imagref (rop), n, s, GMP_RNDN); + mpfr_sin_cos (s, c, mpc_imagref (op), MPFR_RNDN); + inex_re = mpfr_copysign (mpc_realref (rop), n, c, MPFR_RNDN); + inex_im = mpfr_copysign (mpc_imagref (rop), n, s, MPFR_RNDN); mpfr_clear (s); mpfr_clear (c); @@ -159,18 +159,18 @@ mpc_exp (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) could be represented in the precision of rop. */ mpfr_clear_overflow (); mpfr_clear_underflow (); - mpfr_exp (x, mpc_realref(op), GMP_RNDN); /* error <= 0.5ulp */ - mpfr_sin_cos (z, y, mpc_imagref(op), GMP_RNDN); /* errors <= 0.5ulp */ - mpfr_mul (y, y, x, GMP_RNDN); /* error <= 2ulp */ + mpfr_exp (x, mpc_realref(op), MPFR_RNDN); /* error <= 0.5ulp */ + mpfr_sin_cos (z, y, mpc_imagref(op), MPFR_RNDN); /* errors <= 0.5ulp */ + mpfr_mul (y, y, x, MPFR_RNDN); /* error <= 2ulp */ ok = mpfr_overflow_p () || mpfr_zero_p (x) - || mpfr_can_round (y, prec - 2, GMP_RNDN, GMP_RNDZ, - MPC_PREC_RE(rop) + (MPC_RND_RE(rnd) == GMP_RNDN)); + || mpfr_can_round (y, prec - 2, MPFR_RNDN, MPFR_RNDZ, + MPC_PREC_RE(rop) + (MPC_RND_RE(rnd) == MPFR_RNDN)); if (ok) /* compute imaginary part */ { - mpfr_mul (z, z, x, GMP_RNDN); + mpfr_mul (z, z, x, MPFR_RNDN); ok = mpfr_overflow_p () || mpfr_zero_p (x) - || mpfr_can_round (z, prec - 2, GMP_RNDN, GMP_RNDZ, - MPC_PREC_IM(rop) + (MPC_RND_IM(rnd) == GMP_RNDN)); + || mpfr_can_round (z, prec - 2, MPFR_RNDN, MPFR_RNDZ, + MPC_PREC_IM(rop) + (MPC_RND_IM(rnd) == MPFR_RNDN)); } } while (ok == 0); diff --git a/src/fma.c b/src/fma.c index b0857f9..1da4297 100644 --- a/src/fma.c +++ b/src/fma.c @@ -51,10 +51,10 @@ mpc_fma_naive (mpc_ptr r, mpc_srcptr a, mpc_srcptr b, mpc_srcptr c, mpc_rnd_t rn mpfr_init2 (ima_reb, mpfr_get_prec (mpc_imagref(a)) + mpfr_get_prec (mpc_realref(b))); mpfr_init2 (ima_imb, mpfr_get_prec (mpc_imagref(a)) + mpfr_get_prec (mpc_imagref(b))); - mpfr_mul (rea_reb, mpc_realref(a), mpc_realref(b), GMP_RNDZ); /* exact */ - mpfr_mul (rea_imb, mpc_realref(a), mpc_imagref(b), GMP_RNDZ); /* exact */ - mpfr_mul (ima_reb, mpc_imagref(a), mpc_realref(b), GMP_RNDZ); /* exact */ - mpfr_mul (ima_imb, mpc_imagref(a), mpc_imagref(b), GMP_RNDZ); /* exact */ + mpfr_mul (rea_reb, mpc_realref(a), mpc_realref(b), MPFR_RNDZ); /* exact */ + mpfr_mul (rea_imb, mpc_realref(a), mpc_imagref(b), MPFR_RNDZ); /* exact */ + mpfr_mul (ima_reb, mpc_imagref(a), mpc_realref(b), MPFR_RNDZ); /* exact */ + mpfr_mul (ima_imb, mpc_imagref(a), mpc_imagref(b), MPFR_RNDZ); /* exact */ /* Re(r) <- rea_reb - ima_imb + Re(c) */ @@ -67,7 +67,7 @@ mpc_fma_naive (mpc_ptr r, mpc_srcptr a, mpc_srcptr b, mpc_srcptr c, mpc_rnd_t rn if (pre12 <= pre13 && pre12 <= pre23) /* (rea_reb - ima_imb) + Re(c) */ { mpfr_init2 (tmp, pre12); - mpfr_sub (tmp, rea_reb, ima_imb, GMP_RNDZ); /* exact */ + mpfr_sub (tmp, rea_reb, ima_imb, MPFR_RNDZ); /* exact */ inex_re = mpfr_add (mpc_realref(r), tmp, mpc_realref(c), MPC_RND_RE(rnd)); /* the only possible bad overlap is between r and c, but since we are only touching the real part of both, it is ok */ @@ -75,7 +75,7 @@ mpc_fma_naive (mpc_ptr r, mpc_srcptr a, mpc_srcptr b, mpc_srcptr c, mpc_rnd_t rn else if (pre13 <= pre23) /* (rea_reb + Re(c)) - ima_imb */ { mpfr_init2 (tmp, pre13); - mpfr_add (tmp, rea_reb, mpc_realref(c), GMP_RNDZ); /* exact */ + mpfr_add (tmp, rea_reb, mpc_realref(c), MPFR_RNDZ); /* exact */ inex_re = mpfr_sub (mpc_realref(r), tmp, ima_imb, MPC_RND_RE(rnd)); /* the only possible bad overlap is between r and c, but since we are only touching the real part of both, it is ok */ @@ -83,7 +83,7 @@ mpc_fma_naive (mpc_ptr r, mpc_srcptr a, mpc_srcptr b, mpc_srcptr c, mpc_rnd_t rn else /* rea_reb + (Re(c) - ima_imb) */ { mpfr_init2 (tmp, pre23); - mpfr_sub (tmp, mpc_realref(c), ima_imb, GMP_RNDZ); /* exact */ + mpfr_sub (tmp, mpc_realref(c), ima_imb, MPFR_RNDZ); /* exact */ inex_re = mpfr_add (mpc_realref(r), tmp, rea_reb, MPC_RND_RE(rnd)); /* the only possible bad overlap is between r and c, but since we are only touching the real part of both, it is ok */ @@ -99,7 +99,7 @@ mpc_fma_naive (mpc_ptr r, mpc_srcptr a, mpc_srcptr b, mpc_srcptr c, mpc_rnd_t rn if (pim12 <= pim13 && pim12 <= pim23) /* (rea_imb + ima_reb) + Im(c) */ { mpfr_set_prec (tmp, pim12); - mpfr_add (tmp, rea_imb, ima_reb, GMP_RNDZ); /* exact */ + mpfr_add (tmp, rea_imb, ima_reb, MPFR_RNDZ); /* exact */ inex_im = mpfr_add (mpc_imagref(r), tmp, mpc_imagref(c), MPC_RND_IM(rnd)); /* the only possible bad overlap is between r and c, but since we are only touching the imaginary part of both, it is ok */ @@ -107,7 +107,7 @@ mpc_fma_naive (mpc_ptr r, mpc_srcptr a, mpc_srcptr b, mpc_srcptr c, mpc_rnd_t rn else if (pim13 <= pim23) /* (rea_imb + Im(c)) + ima_reb */ { mpfr_set_prec (tmp, pim13); - mpfr_add (tmp, rea_imb, mpc_imagref(c), GMP_RNDZ); /* exact */ + mpfr_add (tmp, rea_imb, mpc_imagref(c), MPFR_RNDZ); /* exact */ inex_im = mpfr_add (mpc_imagref(r), tmp, ima_reb, MPC_RND_IM(rnd)); /* the only possible bad overlap is between r and c, but since we are only touching the imaginary part of both, it is ok */ @@ -115,7 +115,7 @@ mpc_fma_naive (mpc_ptr r, mpc_srcptr a, mpc_srcptr b, mpc_srcptr c, mpc_rnd_t rn else /* rea_imb + (Im(c) + ima_reb) */ { mpfr_set_prec (tmp, pre23); - mpfr_add (tmp, mpc_imagref(c), ima_reb, GMP_RNDZ); /* exact */ + mpfr_add (tmp, mpc_imagref(c), ima_reb, MPFR_RNDZ); /* exact */ inex_im = mpfr_add (mpc_imagref(r), tmp, rea_imb, MPC_RND_IM(rnd)); /* the only possible bad overlap is between r and c, but since we are only touching the imaginary part of both, it is ok */ @@ -167,11 +167,11 @@ mpc_fma (mpc_ptr r, mpc_srcptr a, mpc_srcptr b, mpc_srcptr c, mpc_rnd_t rnd) diffre = (diffre > 0 ? diffre + 1 : 1); diffim = (diffim > 0 ? diffim + 1 : 1); okre = diffre > (mpfr_exp_t) wpre ? 0 : mpfr_can_round (mpc_realref(ab), - wpre - diffre, GMP_RNDN, GMP_RNDZ, - pre + (MPC_RND_RE (rnd) == GMP_RNDN)); + wpre - diffre, MPFR_RNDN, MPFR_RNDZ, + pre + (MPC_RND_RE (rnd) == MPFR_RNDN)); okim = diffim > (mpfr_exp_t) wpim ? 0 : mpfr_can_round (mpc_imagref(ab), - wpim - diffim, GMP_RNDN, GMP_RNDZ, - pim + (MPC_RND_IM (rnd) == GMP_RNDN)); + wpim - diffim, MPFR_RNDN, MPFR_RNDZ, + pim + (MPC_RND_IM (rnd) == MPFR_RNDN)); if (okre && okim) { inex = mpc_set (r, ab, rnd); diff --git a/src/fr_div.c b/src/fr_div.c index e57eced..4c0536f 100644 --- a/src/fr_div.c +++ b/src/fr_div.c @@ -1,6 +1,6 @@ /* mpc_fr_div -- Divide a floating-point number by a complex number. -Copyright (C) 2008, 2009, 2011 INRIA +Copyright (C) 2008, 2009, 2011, 2012 INRIA This file is part of GNU MPC. @@ -29,7 +29,7 @@ mpc_fr_div (mpc_ptr a, mpfr_srcptr b, mpc_srcptr c, mpc_rnd_t rnd) mpc_realref (bc)[0] = b [0]; mpfr_init (mpc_imagref (bc)); /* we consider the operand b to have imaginary part +0 */ - mpfr_set_ui (mpc_imagref (bc), 0, GMP_RNDN); + mpfr_set_ui (mpc_imagref (bc), 0, MPFR_RNDN); inexact = mpc_div (a, bc, c, rnd); diff --git a/src/get_version.c b/src/get_version.c index a5c5bdb..f93e763 100644 --- a/src/get_version.c +++ b/src/get_version.c @@ -28,9 +28,9 @@ along with this program. If not, see http://www.gnu.org/licenses/ . void mpfr_set_zero (mpfr_ptr z, int s) { - mpfr_set_ui (z, 0ul, GMP_RNDN); + mpfr_set_ui (z, 0ul, MPFR_RNDN); if (s < 0) - mpfr_neg (z, z, GMP_RNDN); + mpfr_neg (z, z, MPFR_RNDN); } int diff --git a/src/log.c b/src/log.c index ad1d448..bfa83fa 100644 --- a/src/log.c +++ b/src/log.c @@ -100,7 +100,7 @@ mpc_log (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd){ inex_re = mpfr_log (mpc_realref (rop), mpc_imagref (op), MPC_RND_RE (rnd)); inex_im = mpfr_const_pi (mpc_imagref (rop), MPC_RND_IM (rnd)); /* division by 2 does not change the ternary flag */ - mpfr_div_2ui (mpc_imagref (rop), mpc_imagref (rop), 1, GMP_RNDN); + mpfr_div_2ui (mpc_imagref (rop), mpc_imagref (rop), 1, MPFR_RNDN); } else { w [0] = *mpc_imagref (op); @@ -108,8 +108,8 @@ mpc_log (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd){ inex_re = mpfr_log (mpc_realref (rop), w, MPC_RND_RE (rnd)); inex_im = mpfr_const_pi (mpc_imagref (rop), INV_RND (MPC_RND_IM (rnd))); /* division by 2 does not change the ternary flag */ - mpfr_div_2ui (mpc_imagref (rop), mpc_imagref (rop), 1, GMP_RNDN); - mpfr_neg (mpc_imagref (rop), mpc_imagref (rop), GMP_RNDN); + mpfr_div_2ui (mpc_imagref (rop), mpc_imagref (rop), 1, MPFR_RNDN); + mpfr_neg (mpc_imagref (rop), mpc_imagref (rop), MPFR_RNDN); inex_im = -inex_im; /* negate the ternary flag */ } return MPC_INEX(inex_re, inex_im); @@ -125,14 +125,14 @@ mpc_log (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd){ prec += mpc_ceil_log2 (prec) + 4; mpfr_set_prec (w, prec); - mpc_abs (w, op, GMP_RNDN); + mpc_abs (w, op, MPFR_RNDN); /* error 0.5 ulp */ if (mpfr_inf_p (w)) /* intermediate overflow; the logarithm may be representable. Intermediate underflow is impossible. */ break; - mpfr_log (w, w, GMP_RNDN); + mpfr_log (w, w, MPFR_RNDN); /* generic error of log: (2^(- exp(w)) + 0.5) ulp */ if (mpfr_zero_p (w)) @@ -141,8 +141,8 @@ mpc_log (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd){ err = MPC_MAX (-mpfr_get_exp (w), 0) + 1; /* number of lost digits */ - ok = mpfr_can_round (w, prec - err, GMP_RNDN, GMP_RNDZ, - mpfr_get_prec (mpc_realref (rop)) + (MPC_RND_RE (rnd) == GMP_RNDN)); + ok = mpfr_can_round (w, prec - err, MPFR_RNDN, MPFR_RNDZ, + mpfr_get_prec (mpc_realref (rop)) + (MPC_RND_RE (rnd) == MPFR_RNDN)); } if (!ok) { @@ -164,21 +164,21 @@ mpc_log (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd){ mpfr_set_prec (v, prec); mpfr_set_prec (w, prec); - mpfr_div (v, y, x, GMP_RNDD); /* error 1 ulp */ - mpfr_sqr (v, v, GMP_RNDD); + mpfr_div (v, y, x, MPFR_RNDD); /* error 1 ulp */ + mpfr_sqr (v, v, MPFR_RNDD); /* generic error of multiplication: 1 + 2*1*(2+1*2^(1-prec)) <= 5.0625 since prec >= 6 */ - mpfr_log1p (v, v, GMP_RNDD); + mpfr_log1p (v, v, MPFR_RNDD); /* error 1 + 4*5.0625 = 21.25 , see algorithms.tex */ - mpfr_div_2ui (v, v, 1, GMP_RNDD); + mpfr_div_2ui (v, v, 1, MPFR_RNDD); /* If the result is 0, then there has been an underflow somewhere. */ - mpfr_abs (w, x, GMP_RNDN); /* exact */ - mpfr_log (w, w, GMP_RNDN); /* error 0.5 ulp */ + mpfr_abs (w, x, MPFR_RNDN); /* exact */ + mpfr_log (w, w, MPFR_RNDN); /* error 0.5 ulp */ expw = mpfr_get_exp (w); sgnw = mpfr_signbit (w); - mpfr_add (w, w, v, GMP_RNDN); + mpfr_add (w, w, v, MPFR_RNDN); if (!sgnw) /* v is positive, so no cancellation; error 22.25 ulp; error counts lost bits */ err = 5; @@ -196,8 +196,8 @@ mpc_log (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd){ underflow = 1; } while (!underflow && - !mpfr_can_round (w, prec - err, GMP_RNDN, GMP_RNDZ, - mpfr_get_prec (mpc_realref (rop)) + (MPC_RND_RE (rnd) == GMP_RNDN))); + !mpfr_can_round (w, prec - err, MPFR_RNDN, MPFR_RNDZ, + mpfr_get_prec (mpc_realref (rop)) + (MPC_RND_RE (rnd) == MPFR_RNDN))); mpfr_clear (v); } diff --git a/src/log10.c b/src/log10.c index a6fc86c..6b7e687 100644 --- a/src/log10.c +++ b/src/log10.c @@ -39,8 +39,8 @@ mpc_log10_aux (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd, int flag, int nb) mpfr_init2 (log10, prec); while (ok == 0) { - mpfr_set_ui (log10, 10, GMP_RNDN); /* exact since prec >= 4 */ - mpfr_log (log10, log10, GMP_RNDN); + mpfr_set_ui (log10, 10, MPFR_RNDN); /* exact since prec >= 4 */ + mpfr_log (log10, log10, MPFR_RNDN); /* In each case we have two roundings, thus the final value is x * (1+u)^2 where x is the exact value, and |u| <= 2^(-prec-1). Thus the error is always less than 3 ulps. */ @@ -49,40 +49,40 @@ mpc_log10_aux (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd, int flag, int nb) case 0: /* imag <- atan2(y/x) */ mpfr_atan2 (mpc_imagref (tmp), mpc_imagref (op), mpc_realref (op), MPC_RND_IM (rnd)); - mpfr_div (mpc_imagref (tmp), mpc_imagref (tmp), log10, GMP_RNDN); - ok = mpfr_can_round (mpc_imagref (tmp), prec - 2, GMP_RNDN, - GMP_RNDZ, MPC_PREC_IM(rop) + - (MPC_RND_IM (rnd) == GMP_RNDN)); + mpfr_div (mpc_imagref (tmp), mpc_imagref (tmp), log10, MPFR_RNDN); + ok = mpfr_can_round (mpc_imagref (tmp), prec - 2, MPFR_RNDN, + MPFR_RNDZ, MPC_PREC_IM(rop) + + (MPC_RND_IM (rnd) == MPFR_RNDN)); if (ok) ret = mpfr_set (mpc_imagref (rop), mpc_imagref (tmp), MPC_RND_IM (rnd)); break; case 1: /* real <- log(x) */ mpfr_log (mpc_realref (tmp), mpc_realref (op), MPC_RND_RE (rnd)); - mpfr_div (mpc_realref (tmp), mpc_realref (tmp), log10, GMP_RNDN); - ok = mpfr_can_round (mpc_realref (tmp), prec - 2, GMP_RNDN, - GMP_RNDZ, MPC_PREC_RE(rop) + - (MPC_RND_RE (rnd) == GMP_RNDN)); + mpfr_div (mpc_realref (tmp), mpc_realref (tmp), log10, MPFR_RNDN); + ok = mpfr_can_round (mpc_realref (tmp), prec - 2, MPFR_RNDN, + MPFR_RNDZ, MPC_PREC_RE(rop) + + (MPC_RND_RE (rnd) == MPFR_RNDN)); if (ok) ret = mpfr_set (mpc_realref (rop), mpc_realref (tmp), MPC_RND_RE (rnd)); break; case 2: /* imag <- pi */ mpfr_const_pi (mpc_imagref (tmp), MPC_RND_IM (rnd)); - mpfr_div (mpc_imagref (tmp), mpc_imagref (tmp), log10, GMP_RNDN); - ok = mpfr_can_round (mpc_imagref (tmp), prec - 2, GMP_RNDN, - GMP_RNDZ, MPC_PREC_IM(rop) + - (MPC_RND_IM (rnd) == GMP_RNDN)); + mpfr_div (mpc_imagref (tmp), mpc_imagref (tmp), log10, MPFR_RNDN); + ok = mpfr_can_round (mpc_imagref (tmp), prec - 2, MPFR_RNDN, + MPFR_RNDZ, MPC_PREC_IM(rop) + + (MPC_RND_IM (rnd) == MPFR_RNDN)); if (ok) ret = mpfr_set (mpc_imagref (rop), mpc_imagref (tmp), MPC_RND_IM (rnd)); break; case 3: /* real <- log(y) */ mpfr_log (mpc_realref (tmp), mpc_imagref (op), MPC_RND_RE (rnd)); - mpfr_div (mpc_realref (tmp), mpc_realref (tmp), log10, GMP_RNDN); - ok = mpfr_can_round (mpc_realref (tmp), prec - 2, GMP_RNDN, - GMP_RNDZ, MPC_PREC_RE(rop) + - (MPC_RND_RE (rnd) == GMP_RNDN)); + mpfr_div (mpc_realref (tmp), mpc_realref (tmp), log10, MPFR_RNDN); + ok = mpfr_can_round (mpc_realref (tmp), prec - 2, MPFR_RNDN, + MPFR_RNDZ, MPC_PREC_RE(rop) + + (MPC_RND_RE (rnd) == MPFR_RNDN)); if (ok) ret = mpfr_set (mpc_realref (rop), mpc_realref (tmp), MPC_RND_RE (rnd)); @@ -200,7 +200,7 @@ mpc_log10 (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) inex_re = mpc_log10_aux (rop, op, rnd, 0, 3); inex_im = mpc_log10_aux (rop, op, rnd, 1, 2); /* division by 2 does not change the ternary flag */ - mpfr_div_2ui (mpc_imagref (rop), mpc_imagref (rop), 1, GMP_RNDN); + mpfr_div_2ui (mpc_imagref (rop), mpc_imagref (rop), 1, MPFR_RNDN); } else { @@ -211,8 +211,8 @@ mpc_log10 (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) invrnd = MPC_RND (0, INV_RND (MPC_RND_IM (rnd))); inex_im = mpc_log10_aux (rop, op, invrnd, 1, 2); /* division by 2 does not change the ternary flag */ - mpfr_div_2ui (mpc_imagref (rop), mpc_imagref (rop), 1, GMP_RNDN); - mpfr_neg (mpc_imagref (rop), mpc_imagref (rop), GMP_RNDN); + mpfr_div_2ui (mpc_imagref (rop), mpc_imagref (rop), 1, MPFR_RNDN); + mpfr_neg (mpc_imagref (rop), mpc_imagref (rop), MPFR_RNDN); inex_im = -inex_im; /* negate the ternary flag */ } return MPC_INEX(inex_re, inex_im); @@ -231,12 +231,12 @@ mpc_log10 (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) mpc_set_prec (ww, prec); mpc_log (ww, op, MPC_RNDNN); - mpfr_set_ui (w, 10, GMP_RNDN); /* exact since prec >= 4 */ - mpfr_log (w, w, GMP_RNDN); + mpfr_set_ui (w, 10, MPFR_RNDN); /* exact since prec >= 4 */ + mpfr_log (w, w, MPFR_RNDN); mpc_div_fr (ww, ww, w, MPC_RNDNN); - ok = mpfr_can_round (mpc_realref (ww), prec - 2, GMP_RNDN, GMP_RNDZ, - MPC_PREC_RE(rop) + (MPC_RND_RE (rnd) == GMP_RNDN)); + ok = mpfr_can_round (mpc_realref (ww), prec - 2, MPFR_RNDN, MPFR_RNDZ, + MPC_PREC_RE(rop) + (MPC_RND_RE (rnd) == MPFR_RNDN)); /* Special code to deal with cases where the real part of log10(x+i*y) is exact, like x=3 and y=1. Since Re(log10(x+i*y)) = log10(x^2+y^2)/2 @@ -258,8 +258,8 @@ mpc_log10 (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) mpz_init (x); mpz_init (y); - mpfr_get_z (x, mpc_realref (op), GMP_RNDN); /* exact */ - mpfr_get_z (y, mpc_imagref (op), GMP_RNDN); /* exact */ + mpfr_get_z (x, mpc_realref (op), MPFR_RNDN); /* exact */ + mpfr_get_z (y, mpc_imagref (op), MPFR_RNDN); /* exact */ mpz_mul (x, x, x); mpz_mul (y, y, y); mpz_add (x, x, y); /* x^2+y^2 */ @@ -277,7 +277,7 @@ mpc_log10 (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) /* we reset the precision of Re(ww) so that v can be represented exactly */ mpfr_set_prec (mpc_realref (ww), sizeof(unsigned long)*CHAR_BIT); - mpfr_set_ui_2exp (mpc_realref (ww), v, -1, GMP_RNDN); /* exact */ + mpfr_set_ui_2exp (mpc_realref (ww), v, -1, MPFR_RNDN); /* exact */ ok = 1; } } @@ -285,8 +285,8 @@ mpc_log10 (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) mpz_clear (y); } - ok = ok && mpfr_can_round (mpc_imagref (ww), prec-2, GMP_RNDN, GMP_RNDZ, - MPC_PREC_IM(rop) + (MPC_RND_IM (rnd) == GMP_RNDN)); + ok = ok && mpfr_can_round (mpc_imagref (ww), prec-2, MPFR_RNDN, MPFR_RNDZ, + MPC_PREC_IM(rop) + (MPC_RND_IM (rnd) == MPFR_RNDN)); } inex_re = mpfr_set (mpc_realref(rop), mpc_realref (ww), MPC_RND_RE (rnd)); diff --git a/src/mpc-impl.h b/src/mpc-impl.h index b2aaa90..628970d 100644 --- a/src/mpc-impl.h +++ b/src/mpc-impl.h @@ -55,13 +55,13 @@ along with this program. If not, see http://www.gnu.org/licenses/ . #define MPFR_SIGNBIT(x) (mpfr_signbit (x) ? -1 : 1) #define MPC_MPFR_SIGN(x) (mpfr_zero_p (x) ? 0 : MPFR_SIGNBIT (x)) /* should be called MPFR_SIGN, but this is taken in mpfr.h */ -#define MPFR_CHANGE_SIGN(x) mpfr_neg(x,x,GMP_RNDN) +#define MPFR_CHANGE_SIGN(x) mpfr_neg(x,x,MPFR_RNDN) #define MPFR_COPYSIGN(x,y,z,rnd) (mpfr_nan_p (z) ? \ mpfr_setsign (x, y, 0, rnd) : \ mpfr_copysign (x, y, z, rnd)) /* work around spurious signs in nan */ -#define MPFR_ADD_ONE_ULP(x) mpfr_add_one_ulp (x, GMP_RNDN) -#define MPFR_SUB_ONE_ULP(x) mpfr_sub_one_ulp (x, GMP_RNDN) +#define MPFR_ADD_ONE_ULP(x) mpfr_add_one_ulp (x, MPFR_RNDN) +#define MPFR_SUB_ONE_ULP(x) mpfr_sub_one_ulp (x, MPFR_RNDN) /* drop unused rounding mode from macroes */ #define MPFR_SWAP(a,b) do { mpfr_srcptr tmp; tmp = a; a = b; b = tmp; } while (0) @@ -79,7 +79,7 @@ along with this program. If not, see http://www.gnu.org/licenses/ . */ #if MPFR_VERSION_MAJOR < 3 /* round towards zero, add 1 ulp if not exact */ -#define MPFR_RNDA GMP_RNDZ +#define MPFR_RNDA MPFR_RNDZ #define ROUND_AWAY(f,rop) \ ((f) ? MPFR_ADD_ONE_ULP (rop), MPFR_SIGNBIT (rop) : 0) #else @@ -103,7 +103,7 @@ __MPC_DECLSPEC int mpfr_regular_p (mpfr_srcptr); #define MPC_MAX_PREC(x) MPC_MAX(MPC_PREC_RE(x), MPC_PREC_IM(x)) #define INV_RND(r) \ - (((r) == GMP_RNDU) ? GMP_RNDD : (((r) == GMP_RNDD) ? GMP_RNDU : (r))) + (((r) == MPFR_RNDU) ? MPFR_RNDD : (((r) == MPFR_RNDD) ? MPFR_RNDU : (r))) #define mpc_inf_p(z) (mpfr_inf_p(mpc_realref(z))||mpfr_inf_p(mpc_imagref(z))) /* Convention in C99 (G.3): z is regarded as an infinity if at least one of @@ -153,7 +153,7 @@ do { \ #define MPFR_OUT(x) \ do { \ printf (#x "[%lu]=", (unsigned long int) mpfr_get_prec (x)); \ - mpfr_out_str (stdout, 2, 0, x, GMP_RNDN); \ + mpfr_out_str (stdout, 2, 0, x, MPFR_RNDN); \ printf ("\n"); \ } while (0) diff --git a/src/mpc.h b/src/mpc.h index ca6c099..6f4adc7 100644 --- a/src/mpc.h +++ b/src/mpc.h @@ -78,25 +78,25 @@ typedef int mpc_rnd_t; #define MPC_RND_RE(x) ((mpfr_rnd_t)((x) & 0x0F)) #define MPC_RND_IM(x) ((mpfr_rnd_t)((x) >> 4)) -#define MPC_RNDNN MPC_RND (GMP_RNDN,GMP_RNDN) -#define MPC_RNDNZ MPC_RND (GMP_RNDN,GMP_RNDZ) -#define MPC_RNDNU MPC_RND (GMP_RNDN,GMP_RNDU) -#define MPC_RNDND MPC_RND (GMP_RNDN,GMP_RNDD) - -#define MPC_RNDZN MPC_RND (GMP_RNDZ,GMP_RNDN) -#define MPC_RNDZZ MPC_RND (GMP_RNDZ,GMP_RNDZ) -#define MPC_RNDZU MPC_RND (GMP_RNDZ,GMP_RNDU) -#define MPC_RNDZD MPC_RND (GMP_RNDZ,GMP_RNDD) - -#define MPC_RNDUN MPC_RND (GMP_RNDU,GMP_RNDN) -#define MPC_RNDUZ MPC_RND (GMP_RNDU,GMP_RNDZ) -#define MPC_RNDUU MPC_RND (GMP_RNDU,GMP_RNDU) -#define MPC_RNDUD MPC_RND (GMP_RNDU,GMP_RNDD) - -#define MPC_RNDDN MPC_RND (GMP_RNDD,GMP_RNDN) -#define MPC_RNDDZ MPC_RND (GMP_RNDD,GMP_RNDZ) -#define MPC_RNDDU MPC_RND (GMP_RNDD,GMP_RNDU) -#define MPC_RNDDD MPC_RND (GMP_RNDD,GMP_RNDD) +#define MPC_RNDNN MPC_RND (MPFR_RNDN,MPFR_RNDN) +#define MPC_RNDNZ MPC_RND (MPFR_RNDN,MPFR_RNDZ) +#define MPC_RNDNU MPC_RND (MPFR_RNDN,MPFR_RNDU) +#define MPC_RNDND MPC_RND (MPFR_RNDN,MPFR_RNDD) + +#define MPC_RNDZN MPC_RND (MPFR_RNDZ,MPFR_RNDN) +#define MPC_RNDZZ MPC_RND (MPFR_RNDZ,MPFR_RNDZ) +#define MPC_RNDZU MPC_RND (MPFR_RNDZ,MPFR_RNDU) +#define MPC_RNDZD MPC_RND (MPFR_RNDZ,MPFR_RNDD) + +#define MPC_RNDUN MPC_RND (MPFR_RNDU,MPFR_RNDN) +#define MPC_RNDUZ MPC_RND (MPFR_RNDU,MPFR_RNDZ) +#define MPC_RNDUU MPC_RND (MPFR_RNDU,MPFR_RNDU) +#define MPC_RNDUD MPC_RND (MPFR_RNDU,MPFR_RNDD) + +#define MPC_RNDDN MPC_RND (MPFR_RNDD,MPFR_RNDN) +#define MPC_RNDDZ MPC_RND (MPFR_RNDD,MPFR_RNDZ) +#define MPC_RNDDU MPC_RND (MPFR_RNDD,MPFR_RNDU) +#define MPC_RNDDD MPC_RND (MPFR_RNDD,MPFR_RNDD) /* Definitions of types and their semantics */ diff --git a/src/mul.c b/src/mul.c index 2be9b8d..78accce 100644 --- a/src/mul.c +++ b/src/mul.c @@ -125,11 +125,11 @@ mul_real (mpc_ptr z, mpc_srcptr x, mpc_srcptr y, mpc_rnd_t rnd) /* Signs of zeroes may be wrong. Their correction does not change the inexact flag. */ if (mpfr_zero_p (mpc_realref (z))) - mpfr_setsign (mpc_realref (z), mpc_realref (z), MPC_RND_RE(rnd) == GMP_RNDD - || (xrs != yrs && xis == yis), GMP_RNDN); + mpfr_setsign (mpc_realref (z), mpc_realref (z), MPC_RND_RE(rnd) == MPFR_RNDD + || (xrs != yrs && xis == yis), MPFR_RNDN); if (mpfr_zero_p (mpc_imagref (z))) - mpfr_setsign (mpc_imagref (z), mpc_imagref (z), MPC_RND_IM (rnd) == GMP_RNDD - || (xrs != yis && xis != yrs), GMP_RNDN); + mpfr_setsign (mpc_imagref (z), mpc_imagref (z), MPC_RND_IM (rnd) == MPFR_RNDD + || (xrs != yis && xis != yrs), MPFR_RNDN); return inex; } @@ -154,15 +154,15 @@ mul_imag (mpc_ptr z, mpc_srcptr x, mpc_srcptr y, mpc_rnd_t rnd) inex_re = -mpfr_mul (mpc_realref (rop), mpc_imagref (x), mpc_imagref (y), INV_RND (MPC_RND_RE (rnd))); - mpfr_neg (mpc_realref (rop), mpc_realref (rop), GMP_RNDN); /* exact */ + mpfr_neg (mpc_realref (rop), mpc_realref (rop), MPFR_RNDN); /* exact */ inex_im = mpfr_mul (mpc_imagref (rop), mpc_realref (x), mpc_imagref (y), MPC_RND_IM (rnd)); mpc_set (z, rop, MPC_RNDNN); /* Sign of zeroes may be wrong (note that Re(z) cannot be zero) */ if (mpfr_zero_p (mpc_imagref (z))) - mpfr_setsign (mpc_imagref (z), mpc_imagref (z), MPC_RND_IM (rnd) == GMP_RNDD - || sign, GMP_RNDN); + mpfr_setsign (mpc_imagref (z), mpc_imagref (z), MPC_RND_IM (rnd) == MPFR_RNDD + || sign, MPFR_RNDN); if (overlap) mpc_clear (rop); @@ -187,10 +187,10 @@ mpfr_fmma (mpfr_ptr z, mpfr_srcptr a, mpfr_srcptr b, mpfr_srcptr c, /* u=a*b, v=sign*c*d exactly */ mpfr_init2 (u, mpfr_get_prec (a) + mpfr_get_prec (b)); mpfr_init2 (v, mpfr_get_prec (c) + mpfr_get_prec (d)); - mpfr_mul (u, a, b, GMP_RNDN); - mpfr_mul (v, c, d, GMP_RNDN); + mpfr_mul (u, a, b, MPFR_RNDN); + mpfr_mul (v, c, d, MPFR_RNDN); if (sign < 0) - mpfr_neg (v, v, GMP_RNDN); + mpfr_neg (v, v, MPFR_RNDN); /* tentatively compute z as u+v; here we need z to be distinct from a, b, c, d to not lose the latter */ @@ -198,7 +198,7 @@ mpfr_fmma (mpfr_ptr z, mpfr_srcptr a, mpfr_srcptr b, mpfr_srcptr c, if (mpfr_inf_p (z)) { /* replace by "correctly rounded overflow" */ - mpfr_set_si (z, (mpfr_signbit (z) ? -1 : 1), GMP_RNDN); + mpfr_set_si (z, (mpfr_signbit (z) ? -1 : 1), MPFR_RNDN); inex = mpfr_mul_2ui (z, z, mpfr_get_emax (), rnd); } else if (mpfr_zero_p (u) && !mpfr_zero_p (v)) { @@ -238,13 +238,13 @@ mpfr_fmma (mpfr_ptr z, mpfr_srcptr a, mpfr_srcptr b, mpfr_srcptr c, mpz_add_si (ev, ev, (long int) ed); /* recompute u and v and move exponents to eu and ev */ - mpfr_mul (u, a, b, GMP_RNDN); + mpfr_mul (u, a, b, MPFR_RNDN); /* exponent of u is non-positive */ mpz_sub_ui (eu, eu, (unsigned long int) (-mpfr_get_exp (u))); mpfr_set_exp (u, (mpfr_prec_t) 0); - mpfr_mul (v, c, d, GMP_RNDN); + mpfr_mul (v, c, d, MPFR_RNDN); if (sign < 0) - mpfr_neg (v, v, GMP_RNDN); + mpfr_neg (v, v, MPFR_RNDN); mpz_sub_ui (ev, ev, (unsigned long int) (-mpfr_get_exp (v))); mpfr_set_exp (v, (mpfr_prec_t) 0); @@ -426,23 +426,23 @@ mpc_mul_karatsuba (mpc_ptr rop, mpc_srcptr op1, mpc_srcptr op2, mpc_rnd_t rnd) mpfr_init2 (u, 2); mpfr_init2 (x, 2); - inexact = mpfr_mul (v, a, d, GMP_RNDN); + inexact = mpfr_mul (v, a, d, MPFR_RNDN); if (inexact) { /* over- or underflow */ ok = 0; goto clear; } if (mul_a == -1) - mpfr_neg (v, v, GMP_RNDN); + mpfr_neg (v, v, MPFR_RNDN); - inexact = mpfr_mul (w, b, c, GMP_RNDN); + inexact = mpfr_mul (w, b, c, MPFR_RNDN); if (inexact) { /* over- or underflow */ ok = 0; goto clear; } if (mul_c == -1) - mpfr_neg (w, w, GMP_RNDN); + mpfr_neg (w, w, MPFR_RNDN); /* compute sign(v-w) */ sign_x = mpfr_cmp_abs (v, w); @@ -485,10 +485,10 @@ mpc_mul_karatsuba (mpc_ptr rop, mpc_srcptr op1, mpc_srcptr op2, mpc_rnd_t rnd) ROUND_AWAY (mpfr_add (x, c, d, MPFR_RNDA), x) : ROUND_AWAY (mpfr_sub (x, c, d, MPFR_RNDA), x)); if (mul_c == -1) - mpfr_neg (x, x, GMP_RNDN); + mpfr_neg (x, x, MPFR_RNDN); if (inexact == 0) - mpfr_prec_round (u, prec_u = 2 * prec, GMP_RNDN); + mpfr_prec_round (u, prec_u = 2 * prec, MPFR_RNDN); /* compute away(u*x) and store it in u */ inexact |= ROUND_AWAY (mpfr_mul (u, u, x, MPFR_RNDA), u); @@ -508,20 +508,20 @@ mpc_mul_karatsuba (mpc_ptr rop, mpc_srcptr op1, mpc_srcptr op2, mpc_rnd_t rnd) if (prec_x > prec_u) prec_x = prec_u; if (prec_x > prec) - mpfr_prec_round (x, prec_x, GMP_RNDN); + mpfr_prec_round (x, prec_x, MPFR_RNDN); } - rnd_u = (sign_u > 0) ? GMP_RNDU : GMP_RNDD; + rnd_u = (sign_u > 0) ? MPFR_RNDU : MPFR_RNDD; inexact |= mpfr_sub (x, v, w, rnd_u); /* ad - bc */ /* in case u=0, ensure that rnd_u rounds x away from zero */ if (mpfr_sgn (u) == 0) - rnd_u = (mpfr_sgn (x) > 0) ? GMP_RNDU : GMP_RNDD; + rnd_u = (mpfr_sgn (x) > 0) ? MPFR_RNDU : MPFR_RNDD; inexact |= mpfr_add (u, u, x, rnd_u); /* ac - bd */ ok = inexact == 0 || - mpfr_can_round (u, prec_u - 3, rnd_u, GMP_RNDZ, - prec_re + (rnd_re == GMP_RNDN)); + mpfr_can_round (u, prec_u - 3, rnd_u, MPFR_RNDZ, + prec_re + (rnd_re == MPFR_RNDN)); /* this ensures both we can round correctly and determine the correct inexact flag (for rounding to nearest) */ } diff --git a/src/mul_fr.c b/src/mul_fr.c index bd3574d..437b3ca 100644 --- a/src/mul_fr.c +++ b/src/mul_fr.c @@ -1,6 +1,6 @@ /* mpc_mul_fr -- Multiply a complex number by a floating-point number. -Copyright (C) 2002, 2008, 2009, 2010, 2011 INRIA +Copyright (C) 2002, 2008, 2009, 2010, 2011, 2012 INRIA This file is part of GNU MPC. @@ -34,7 +34,7 @@ mpc_mul_fr (mpc_ptr a, mpc_srcptr b, mpfr_srcptr c, mpc_rnd_t rnd) inex_re = mpfr_mul (real, mpc_realref(b), c, MPC_RND_RE(rnd)); inex_im = mpfr_mul (mpc_imagref(a), mpc_imagref(b), c, MPC_RND_IM(rnd)); - mpfr_set (mpc_realref (a), real, GMP_RNDN); /* exact */ + mpfr_set (mpc_realref (a), real, MPFR_RNDN); /* exact */ if (c == mpc_realref (a)) mpfr_clear (real); diff --git a/src/mul_i.c b/src/mul_i.c index 591b0c6..511b051 100644 --- a/src/mul_i.c +++ b/src/mul_i.c @@ -1,6 +1,6 @@ /* mpc_mul_i -- Multiply a complex number by plus or minus i. -Copyright (C) 2005, 2009, 2010, 2011 INRIA +Copyright (C) 2005, 2009, 2010, 2011, 2012 INRIA This file is part of GNU MPC. @@ -35,8 +35,8 @@ mpc_mul_i (mpc_ptr a, mpc_srcptr b, int sign, mpc_rnd_t rnd) mpfr_swap (mpc_realref (a), mpc_imagref (a)); else { - mpfr_set (mpc_realref (a), mpc_imagref (b), GMP_RNDN); - mpfr_set (mpc_imagref (a), mpc_realref (b), GMP_RNDN); + mpfr_set (mpc_realref (a), mpc_imagref (b), MPFR_RNDN); + mpfr_set (mpc_imagref (a), mpc_realref (b), MPFR_RNDN); } if (sign >= 0) MPFR_CHANGE_SIGN (mpc_realref (a)); diff --git a/src/norm.c b/src/norm.c index ab413b6..eca833f 100644 --- a/src/norm.c +++ b/src/norm.c @@ -1,6 +1,6 @@ /* mpc_norm -- Square of the norm of a complex number. -Copyright (C) 2002, 2005, 2008, 2009, 2010, 2011 INRIA +Copyright (C) 2002, 2005, 2008, 2009, 2010, 2011, 2012 INRIA This file is part of GNU MPC. @@ -77,8 +77,8 @@ mpc_norm (mpfr_ptr a, mpc_srcptr b, mpfr_rnd_t rnd) mpfr_set_prec (u, prec_u); mpfr_set_prec (v, prec_v); - inexact = mpfr_sqr (u, mpc_realref(b), GMP_RNDD); /* err <= 1 ulp in prec */ - inexact |= mpfr_sqr (v, mpc_imagref(b), GMP_RNDD); /* err <= 1 ulp in prec */ + inexact = mpfr_sqr (u, mpc_realref(b), MPFR_RNDD); /* err <= 1 ulp in prec */ + inexact |= mpfr_sqr (v, mpc_imagref(b), MPFR_RNDD); /* err <= 1 ulp in prec */ /* If loops = max_loops, inexact should be 0 here, except in case of underflow or overflow. @@ -86,12 +86,12 @@ mpc_norm (mpfr_ptr a, mpc_srcptr b, mpfr_rnd_t rnd) while-loop since it only remains to add u and v into a. */ if (inexact) { mpfr_set_prec (res, prec); - mpfr_add (res, u, v, GMP_RNDD); /* err <= 3 ulp in prec */ + mpfr_add (res, u, v, MPFR_RNDD); /* err <= 3 ulp in prec */ } } while (loops < max_loops && inexact != 0 - && !mpfr_can_round (res, prec - 2, GMP_RNDD, GMP_RNDU, - mpfr_get_prec (a) + (rnd == GMP_RNDN))); + && !mpfr_can_round (res, prec - 2, MPFR_RNDD, MPFR_RNDU, + mpfr_get_prec (a) + (rnd == MPFR_RNDN))); if (!inexact) /* squarings were exact, neither underflow nor overflow */ @@ -100,7 +100,7 @@ mpc_norm (mpfr_ptr a, mpc_srcptr b, mpfr_rnd_t rnd) since the norm is larger, there is an overflow for the norm */ else if (mpfr_overflow_p ()) { /* replace by "correctly rounded overflow" */ - mpfr_set_ui (a, 1ul, GMP_RNDN); + mpfr_set_ui (a, 1ul, MPFR_RNDN); inexact = mpfr_mul_2ui (a, a, mpfr_get_emax (), rnd); } else if (mpfr_underflow_p ()) { @@ -123,14 +123,14 @@ mpc_norm (mpfr_ptr a, mpc_srcptr b, mpfr_rnd_t rnd) && mpfr_get_exp (u) - 2 * (mpfr_exp_t) prec_u > emin && mpfr_get_exp (u) > -10) { mpfr_set_prec (v, MPFR_PREC_MIN); - mpfr_set_ui_2exp (v, 1, emin - 1, GMP_RNDZ); + mpfr_set_ui_2exp (v, 1, emin - 1, MPFR_RNDZ); inexact = mpfr_add (a, u, v, rnd); } else if (!mpfr_zero_p (v) && mpfr_get_exp (v) - 2 * (mpfr_exp_t) prec_v > emin && mpfr_get_exp (v) > -10) { mpfr_set_prec (u, MPFR_PREC_MIN); - mpfr_set_ui_2exp (u, 1, emin - 1, GMP_RNDZ); + mpfr_set_ui_2exp (u, 1, emin - 1, MPFR_RNDZ); inexact = mpfr_add (a, u, v, rnd); } else { @@ -145,17 +145,17 @@ mpc_norm (mpfr_ptr a, mpc_srcptr b, mpfr_rnd_t rnd) integer overflow */ if (mpfr_zero_p (u)) { /* recompute the scaled value exactly */ - mpfr_mul_2ui (u, mpc_realref (b), scale, GMP_RNDN); - mpfr_sqr (u, u, GMP_RNDN); + mpfr_mul_2ui (u, mpc_realref (b), scale, MPFR_RNDN); + mpfr_sqr (u, u, MPFR_RNDN); } else /* just scale */ - mpfr_mul_2ui (u, u, 2*scale, GMP_RNDN); + mpfr_mul_2ui (u, u, 2*scale, MPFR_RNDN); if (mpfr_zero_p (v)) { - mpfr_mul_2ui (v, mpc_imagref (b), scale, GMP_RNDN); - mpfr_sqr (v, v, GMP_RNDN); + mpfr_mul_2ui (v, mpc_imagref (b), scale, MPFR_RNDN); + mpfr_sqr (v, v, MPFR_RNDN); } else - mpfr_mul_2ui (v, v, 2*scale, GMP_RNDN); + mpfr_mul_2ui (v, v, 2*scale, MPFR_RNDN); inexact = mpfr_add (a, u, v, rnd); mpfr_clear_underflow (); diff --git a/src/pow.c b/src/pow.c index 892f467..4b394ea 100644 --- a/src/pow.c +++ b/src/pow.c @@ -137,7 +137,7 @@ fix_sign (mpc_ptr z, int sign_eps, int sign_a, mpfr_srcptr y) MPC_ASSERT (ymod4 == 1 || ymod4 == 3); if ((ymod4 == 3 && sign_eps == 0) || (ymod4 == 1 && sign_eps == 1)) - mpfr_neg (mpc_realref(z), mpc_realref(z), GMP_RNDZ); + mpfr_neg (mpc_realref(z), mpc_realref(z), MPFR_RNDZ); } else if (mpfr_zero_p (mpc_imagref(z))) { @@ -147,7 +147,7 @@ fix_sign (mpc_ptr z, int sign_eps, int sign_a, mpfr_srcptr y) MPC_ASSERT (ymod4 == 0 || ymod4 == 2); if ((ymod4 == 0 && sign_a == sign_eps) || (ymod4 == 2 && sign_a != sign_eps)) - mpfr_neg (mpc_imagref(z), mpc_imagref(z), GMP_RNDZ); + mpfr_neg (mpc_imagref(z), mpc_imagref(z), MPFR_RNDZ); } end: @@ -187,7 +187,7 @@ mpc_pow_exact (mpc_ptr z, mpc_srcptr x, mpfr_srcptr y, mpc_rnd_t rnd, { z_is_y = 1; mpfr_init2 (copy_of_y, mpfr_get_prec (y)); - mpfr_set (copy_of_y, y, GMP_RNDN); + mpfr_set (copy_of_y, y, MPFR_RNDN); } mpz_init (my); @@ -512,7 +512,7 @@ mpc_pow (mpc_ptr z, mpc_srcptr x, mpc_srcptr y, mpc_rnd_t rnd) cx1 > 0 if |x| > 1 */ mpfr_init (n); - inex = mpc_norm (n, x, GMP_RNDN); + inex = mpc_norm (n, x, MPFR_RNDN); cx1 = mpfr_cmp_ui (n, 1); if (cx1 == 0 && inex != 0) cx1 = -inex; @@ -525,7 +525,7 @@ mpc_pow (mpc_ptr z, mpc_srcptr x, mpc_srcptr y, mpc_rnd_t rnd) /* warning: mpc_set_ui_ui does not set Im(z) to -0 if Im(rnd)=RNDD */ ret = mpc_set_ui_ui (z, 1, 0, rnd); - if (MPC_RND_IM (rnd) == GMP_RNDD || sign_zi) + if (MPC_RND_IM (rnd) == MPFR_RNDD || sign_zi) mpc_conj (z, z, MPC_RNDNN); mpfr_clear (n); @@ -574,7 +574,7 @@ mpc_pow (mpc_ptr z, mpc_srcptr x, mpc_srcptr y, mpc_rnd_t rnd) Note that the sign must also be set explicitly when rnd=RNDD because mpfr_set_ui(z_i, 0, rnd) always sets z_i to +0. */ - if (MPC_RND_IM (rnd) == GMP_RNDD || s1 != s2) + if (MPC_RND_IM (rnd) == MPFR_RNDD || s1 != s2) mpc_conj (z, z, MPC_RNDNN); goto end; } @@ -600,7 +600,7 @@ mpc_pow (mpc_ptr z, mpc_srcptr x, mpc_srcptr y, mpc_rnd_t rnd) Note that the sign must also be set explicitly when rnd=RNDD because mpfr_set_ui(z_i, 0, rnd) always sets z_i to +0. */ - if (MPC_RND_IM(rnd) == GMP_RNDD || s1 != s2) + if (MPC_RND_IM(rnd) == MPFR_RNDD || s1 != s2) mpfr_neg (mpc_imagref(z), mpc_imagref(z), MPC_RND_IM(rnd)); goto end; } @@ -650,8 +650,8 @@ mpc_pow (mpc_ptr z, mpc_srcptr x, mpc_srcptr y, mpc_rnd_t rnd) p = 64; mpc_init2 (u, p); mpc_init2 (t, p); - pr += MPC_RND_RE(rnd) == GMP_RNDN; - pi += MPC_RND_IM(rnd) == GMP_RNDN; + pr += MPC_RND_RE(rnd) == MPFR_RNDN; + pi += MPC_RND_IM(rnd) == MPFR_RNDN; maxprec = MPC_MAX_PREC (z); x_imag = mpfr_zero_p (mpc_realref(x)); for (loop = 0;; loop++) @@ -702,8 +702,8 @@ mpc_pow (mpc_ptr z, mpc_srcptr x, mpc_srcptr y, mpc_rnd_t rnd) (see algorithms.tex) plus one due to the exponent difference: if z = a + I*b, where the relative error on z is at most 2^(-p), and EXP(a) = EXP(b) + k, the relative error on b is at most 2^(k-p) */ - if ((z_imag || (p > q + 3 + dr && mpfr_can_round (mpc_realref(u), p - q - 3 - dr, GMP_RNDN, GMP_RNDZ, pr))) && - (z_real || (p > q + 3 + di && mpfr_can_round (mpc_imagref(u), p - q - 3 - di, GMP_RNDN, GMP_RNDZ, pi)))) + if ((z_imag || (p > q + 3 + dr && mpfr_can_round (mpc_realref(u), p - q - 3 - dr, MPFR_RNDN, MPFR_RNDZ, pr))) && + (z_real || (p > q + 3 + di && mpfr_can_round (mpc_imagref(u), p - q - 3 - di, MPFR_RNDN, MPFR_RNDZ, pi)))) break; /* if Re(u) is not known to be zero, assume it is a normal number, i.e., @@ -750,7 +750,7 @@ mpc_pow (mpc_ptr z, mpc_srcptr x, mpc_srcptr y, mpc_rnd_t rnd) sign_rex = mpfr_signbit (mpc_realref (x)); sign_imx = mpfr_signbit (mpc_imagref (x)); mpfr_init (n); - inex = mpc_norm (n, x, GMP_RNDN); + inex = mpc_norm (n, x, MPFR_RNDN); cx1 = mpfr_cmp_ui (n, 1); if (cx1 == 0 && inex != 0) cx1 = -inex; @@ -761,7 +761,7 @@ mpc_pow (mpc_ptr z, mpc_srcptr x, mpc_srcptr y, mpc_rnd_t rnd) /* copy RE(y) to n since if z==y we will destroy Re(y) below */ mpfr_set_prec (n, mpfr_get_prec (mpc_realref (y))); - mpfr_set (n, mpc_realref (y), GMP_RNDN); + mpfr_set (n, mpc_realref (y), MPFR_RNDN); ret = mpfr_set (mpc_realref(z), mpc_realref(u), MPC_RND_RE(rnd)); if (y_real && (x_real || x_imag)) { @@ -776,7 +776,7 @@ mpc_pow (mpc_ptr z, mpc_srcptr x, mpc_srcptr y, mpc_rnd_t rnd) { ret = MPC_INEX (ret, mpfr_set_ui (mpc_imagref (z), 0, MPC_RND_IM (rnd))); /* warning: mpfr_set_ui does not set Im(z) to -0 if Im(rnd) = RNDD */ - if (MPC_RND_IM (rnd) == GMP_RNDD || sign_zi) + if (MPC_RND_IM (rnd) == MPFR_RNDD || sign_zi) mpc_conj (z, z, MPC_RNDNN); } diff --git a/src/pow_fr.c b/src/pow_fr.c index 8c5d930..87e255b 100644 --- a/src/pow_fr.c +++ b/src/pow_fr.c @@ -1,6 +1,6 @@ /* mpc_pow_fr -- Raise a complex number to a floating-point power. -Copyright (C) 2009, 2011 INRIA +Copyright (C) 2009, 2011, 2012 INRIA This file is part of GNU MPC. @@ -29,7 +29,7 @@ mpc_pow_fr (mpc_ptr z, mpc_srcptr x, mpfr_srcptr y, mpc_rnd_t rnd) /* avoid copying the significand of y by copying only the struct */ mpc_realref(yy)[0] = y[0]; mpfr_init2 (mpc_imagref(yy), MPFR_PREC_MIN); - mpfr_set_ui (mpc_imagref(yy), 0, GMP_RNDN); + mpfr_set_ui (mpc_imagref(yy), 0, MPFR_RNDN); inex = mpc_pow (z, x, yy, rnd); mpfr_clear (mpc_imagref(yy)); return inex; diff --git a/src/pow_ui.c b/src/pow_ui.c index da82a94..fb59310 100644 --- a/src/pow_ui.c +++ b/src/pow_ui.c @@ -131,10 +131,10 @@ mpc_pow_usi (mpc_ptr z, mpc_srcptr x, unsigned long y, int sign, /* the factor on the imaginary part is 2+2^(diff+2) <= 4 for diff <= -1 and < 2^(diff+3) for diff >= 0 */ ei = (diff <= -1) ? l0 + 3 : l0 + diff + 3; - if (mpfr_can_round (mpc_realref(t), p - er, GMP_RNDN, GMP_RNDZ, - MPC_PREC_RE(z) + (MPC_RND_RE(rnd) == GMP_RNDN)) - && mpfr_can_round (mpc_imagref(t), p - ei, GMP_RNDN, GMP_RNDZ, - MPC_PREC_IM(z) + (MPC_RND_IM(rnd) == GMP_RNDN))) { + if (mpfr_can_round (mpc_realref(t), p - er, MPFR_RNDN, MPFR_RNDZ, + MPC_PREC_RE(z) + (MPC_RND_RE(rnd) == MPFR_RNDN)) + && mpfr_can_round (mpc_imagref(t), p - ei, MPFR_RNDN, MPFR_RNDZ, + MPC_PREC_IM(z) + (MPC_RND_IM(rnd) == MPFR_RNDN))) { inex = mpc_set (z, t, rnd); done = 1; } diff --git a/src/sin_cos.c b/src/sin_cos.c index 0cff45a..0bb00cf 100644 --- a/src/sin_cos.c +++ b/src/sin_cos.c @@ -1,6 +1,6 @@ /* mpc_sin_cos -- combined sine and cosine of a complex number. -Copyright (C) 2010, 2011 INRIA +Copyright (C) 2010, 2011, 2012 INRIA This file is part of GNU MPC. @@ -81,7 +81,7 @@ mpc_sin_cos_nonfinite (mpc_ptr rop_sin, mpc_ptr rop_cos, mpc_srcptr op, mpfr_t s, c; mpfr_init2 (s, 2); mpfr_init2 (c, 2); - mpfr_sin_cos (s, c, mpc_realref (op_loc), GMP_RNDZ); + mpfr_sin_cos (s, c, mpc_realref (op_loc), MPFR_RNDZ); mpfr_set_inf (mpc_realref (rop_sin), MPFR_SIGN (s)); mpfr_set_inf (mpc_imagref (rop_sin), MPFR_SIGN (c)*MPFR_SIGN (mpc_imagref (op_loc))); mpfr_clear (s); @@ -157,7 +157,7 @@ mpc_sin_cos_nonfinite (mpc_ptr rop_sin, mpc_ptr rop_cos, mpc_srcptr op, mpfr_t s, c; mpfr_init2 (c, 2); mpfr_init2 (s, 2); - mpfr_sin_cos (s, c, mpc_realref (op_loc), GMP_RNDN); + mpfr_sin_cos (s, c, mpc_realref (op_loc), MPFR_RNDN); mpfr_set_inf (mpc_realref (rop_cos), mpfr_sgn (c)); mpfr_set_inf (mpc_imagref (rop_cos), (mpfr_sgn (mpc_imagref (op_loc)) == mpfr_sgn (s) ? -1 : +1)); @@ -203,7 +203,7 @@ mpc_sin_cos_real (mpc_ptr rop_sin, mpc_ptr rop_cos, mpc_srcptr op, arbitrary rounding mode will work. */ if (rop_sin != NULL) { - mpfr_set (mpc_realref (rop_sin), s, GMP_RNDN); /* exact */ + mpfr_set (mpc_realref (rop_sin), s, MPFR_RNDN); /* exact */ inex_sin_re = inex_s; mpfr_set_zero (mpc_imagref (rop_sin), ( ( sign_im && !mpfr_signbit(c)) @@ -211,7 +211,7 @@ mpc_sin_cos_real (mpc_ptr rop_sin, mpc_ptr rop_cos, mpc_srcptr op, } if (rop_cos != NULL) { - mpfr_set (mpc_realref (rop_cos), c, GMP_RNDN); /* exact */ + mpfr_set (mpc_realref (rop_cos), c, MPFR_RNDN); /* exact */ inex_cos_re = inex_c; mpfr_set_zero (mpc_imagref (rop_cos), ( ( sign_im && mpfr_signbit(s)) @@ -245,7 +245,7 @@ mpc_sin_cos_imag (mpc_ptr rop_sin, mpc_ptr rop_cos, mpc_srcptr op, if (rop_sin != NULL) { /* sin(+-O +i*y) = +-0 +i*sinh(y) */ - mpfr_set (mpc_realref(rop_sin), mpc_realref(op_loc), GMP_RNDN); + mpfr_set (mpc_realref(rop_sin), mpc_realref(op_loc), MPFR_RNDN); inex_sin_im = mpfr_sinh (mpc_imagref(rop_sin), mpc_imagref(op_loc), MPC_RND_IM(rnd_sin)); } @@ -325,43 +325,43 @@ mpc_sin_cos (mpc_ptr rop_sin, mpc_ptr rop_cos, mpc_srcptr op, mpfr_set_prec (sch, prec); mpfr_set_prec (csh, prec); - mpfr_sin_cos (s, c, mpc_realref(op), GMP_RNDN); - mpfr_sinh_cosh (sh, ch, mpc_imagref(op), GMP_RNDN); + mpfr_sin_cos (s, c, mpc_realref(op), MPFR_RNDN); + mpfr_sinh_cosh (sh, ch, mpc_imagref(op), MPFR_RNDN); if (rop_sin != NULL) { /* real part of sine */ - mpfr_mul (sch, s, ch, GMP_RNDN); + mpfr_mul (sch, s, ch, MPFR_RNDN); ok = (!mpfr_number_p (sch)) - || mpfr_can_round (sch, prec - 2, GMP_RNDN, GMP_RNDZ, + || mpfr_can_round (sch, prec - 2, MPFR_RNDN, MPFR_RNDZ, MPC_PREC_RE (rop_sin) - + (MPC_RND_RE (rnd_sin) == GMP_RNDN)); + + (MPC_RND_RE (rnd_sin) == MPFR_RNDN)); if (ok) { /* imaginary part of sine */ - mpfr_mul (csh, c, sh, GMP_RNDN); + mpfr_mul (csh, c, sh, MPFR_RNDN); ok = (!mpfr_number_p (csh)) - || mpfr_can_round (csh, prec - 2, GMP_RNDN, GMP_RNDZ, + || mpfr_can_round (csh, prec - 2, MPFR_RNDN, MPFR_RNDZ, MPC_PREC_IM (rop_sin) - + (MPC_RND_IM (rnd_sin) == GMP_RNDN)); + + (MPC_RND_IM (rnd_sin) == MPFR_RNDN)); } } if (rop_cos != NULL && ok) { /* real part of cosine */ - mpfr_mul (c, c, ch, GMP_RNDN); + mpfr_mul (c, c, ch, MPFR_RNDN); ok = (!mpfr_number_p (c)) - || mpfr_can_round (c, prec - 2, GMP_RNDN, GMP_RNDZ, + || mpfr_can_round (c, prec - 2, MPFR_RNDN, MPFR_RNDZ, MPC_PREC_RE (rop_cos) - + (MPC_RND_RE (rnd_cos) == GMP_RNDN)); + + (MPC_RND_RE (rnd_cos) == MPFR_RNDN)); if (ok) { /* imaginary part of cosine */ - mpfr_mul (s, s, sh, GMP_RNDN); - mpfr_neg (s, s, GMP_RNDN); + mpfr_mul (s, s, sh, MPFR_RNDN); + mpfr_neg (s, s, MPFR_RNDN); ok = (!mpfr_number_p (s)) - || mpfr_can_round (s, prec - 2, GMP_RNDN, GMP_RNDZ, + || mpfr_can_round (s, prec - 2, MPFR_RNDN, MPFR_RNDZ, MPC_PREC_IM (rop_cos) - + (MPC_RND_IM (rnd_cos) == GMP_RNDN)); + + (MPC_RND_IM (rnd_cos) == MPFR_RNDN)); } } } while (ok == 0); diff --git a/src/sqr.c b/src/sqr.c index f1ce1ba..fa7a259 100644 --- a/src/sqr.c +++ b/src/sqr.c @@ -36,8 +36,8 @@ mpfr_fsss (mpfr_ptr z, mpfr_srcptr a, mpfr_srcptr c, mpfr_rnd_t rnd) /* u=a^2, v=c^2 exactly */ mpfr_init2 (u, 2*mpfr_get_prec (a)); mpfr_init2 (v, 2*mpfr_get_prec (c)); - mpfr_sqr (u, a, GMP_RNDN); - mpfr_sqr (v, c, GMP_RNDN); + mpfr_sqr (u, a, MPFR_RNDN); + mpfr_sqr (v, c, MPFR_RNDN); /* tentatively compute z as u-v; here we need z to be distinct from a and c to not lose the latter */ @@ -45,7 +45,7 @@ mpfr_fsss (mpfr_ptr z, mpfr_srcptr a, mpfr_srcptr c, mpfr_rnd_t rnd) if (mpfr_inf_p (z)) { /* replace by "correctly rounded overflow" */ - mpfr_set_si (z, (mpfr_signbit (z) ? -1 : 1), GMP_RNDN); + mpfr_set_si (z, (mpfr_signbit (z) ? -1 : 1), MPFR_RNDN); inex = mpfr_mul_2ui (z, z, mpfr_get_emax (), rnd); } else if (mpfr_zero_p (u) && !mpfr_zero_p (v)) { @@ -81,11 +81,11 @@ mpfr_fsss (mpfr_ptr z, mpfr_srcptr a, mpfr_srcptr c, mpfr_rnd_t rnd) mpz_mul_2exp (ev, ev, 1); /* recompute u and v and move exponents to eu and ev */ - mpfr_sqr (u, a, GMP_RNDN); + mpfr_sqr (u, a, MPFR_RNDN); /* exponent of u is non-positive */ mpz_sub_ui (eu, eu, (unsigned long int) (-mpfr_get_exp (u))); mpfr_set_exp (u, (mpfr_prec_t) 0); - mpfr_sqr (v, c, GMP_RNDN); + mpfr_sqr (v, c, MPFR_RNDN); mpz_sub_ui (ev, ev, (unsigned long int) (-mpfr_get_exp (v))); mpfr_set_exp (v, (mpfr_prec_t) 0); if (mpfr_nan_p (z)) { @@ -210,7 +210,7 @@ mpc_sqr (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) if (mpfr_zero_p (mpc_imagref(op))) { int same_sign = mpfr_signbit (mpc_realref (op)) == mpfr_signbit (mpc_imagref (op)); inex_re = mpfr_sqr (mpc_realref(rop), mpc_realref(op), MPC_RND_RE(rnd)); - inex_im = mpfr_set_ui (mpc_imagref(rop), 0ul, GMP_RNDN); + inex_im = mpfr_set_ui (mpc_imagref(rop), 0ul, MPFR_RNDN); if (!same_sign) mpc_conj (rop, rop, MPC_RNDNN); return MPC_INEX(inex_re, inex_im); @@ -218,8 +218,8 @@ mpc_sqr (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) if (mpfr_zero_p (mpc_realref(op))) { int same_sign = mpfr_signbit (mpc_realref (op)) == mpfr_signbit (mpc_imagref (op)); inex_re = -mpfr_sqr (mpc_realref(rop), mpc_imagref(op), INV_RND (MPC_RND_RE(rnd))); - mpfr_neg (mpc_realref(rop), mpc_realref(rop), GMP_RNDN); - inex_im = mpfr_set_ui (mpc_imagref(rop), 0ul, GMP_RNDN); + mpfr_neg (mpc_realref(rop), mpc_realref(rop), MPFR_RNDN); + inex_im = mpfr_set_ui (mpc_imagref(rop), 0ul, MPFR_RNDN); if (!same_sign) mpc_conj (rop, rop, MPC_RNDNN); return MPC_INEX(inex_re, inex_im); @@ -228,7 +228,7 @@ mpc_sqr (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) if (rop == op) { mpfr_init2 (x, MPC_PREC_RE (op)); - mpfr_set (x, op->re, GMP_RNDN); + mpfr_set (x, op->re, MPFR_RNDN); } else x [0] = op->re [0]; @@ -274,14 +274,14 @@ mpc_sqr (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) if (mpfr_sgn (u) == 0 || mpfr_sgn (v) == 0) { /* as we have rounded away, the result is exact */ - mpfr_set_ui (mpc_realref (rop), 0, GMP_RNDN); + mpfr_set_ui (mpc_realref (rop), 0, MPFR_RNDN); inex_re = 0; ok = 1; } else { mpfr_rnd_t rnd_away; /* FIXME: can be replaced by MPFR_RNDA in mpfr >= 3 */ - rnd_away = (mpfr_sgn (u) * mpfr_sgn (v) > 0 ? GMP_RNDU : GMP_RNDD); + rnd_away = (mpfr_sgn (u) * mpfr_sgn (v) > 0 ? MPFR_RNDU : MPFR_RNDD); inexact |= ROUND_AWAY (mpfr_mul (u, u, v, MPFR_RNDA), u); /* error 5 */ if (mpfr_get_exp (u) == emin || mpfr_inf_p (u)) { /* under- or overflow */ @@ -290,8 +290,8 @@ mpc_sqr (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) } else { ok = (!inexact) | mpfr_can_round (u, prec - 3, - rnd_away, GMP_RNDZ, - MPC_PREC_RE (rop) + (MPC_RND_RE (rnd) == GMP_RNDN)); + rnd_away, MPFR_RNDZ, + MPC_PREC_RE (rop) + (MPC_RND_RE (rnd) == MPFR_RNDN)); if (ok) { inex_re = mpfr_set (mpc_realref (rop), u, MPC_RND_RE (rnd)); if (inex_re == 0) diff --git a/src/sqrt.c b/src/sqrt.c index dd2ff60..01753cc 100644 --- a/src/sqrt.c +++ b/src/sqrt.c @@ -46,7 +46,7 @@ mpc_sqrt (mpc_ptr a, mpc_srcptr b, mpc_rnd_t rnd) at the target precision */ const int im_sgn = mpfr_signbit (mpc_imagref (b)) == 0 ? 0 : -1; /* we need to know the sign of Im(b) when it is +/-0 */ - const mpfr_rnd_t r = im_sgn ? GMP_RNDD : GMP_RNDU; + const mpfr_rnd_t r = im_sgn ? MPFR_RNDD : MPFR_RNDU; /* rounding mode used when computing t */ /* special values */ @@ -68,7 +68,7 @@ mpc_sqrt (mpc_ptr a, mpc_srcptr b, mpc_rnd_t rnd) { /* sqrt(-Inf +i*y) = +0 +i*Inf, when y positive */ /* sqrt(-Inf +i*y) = +0 -i*Inf, when y positive */ - mpfr_set_ui (mpc_realref (a), 0, GMP_RNDN); + mpfr_set_ui (mpc_realref (a), 0, MPFR_RNDN); mpfr_set_inf (mpc_imagref (a), im_sgn); return MPC_INEX (0, 0); } @@ -87,7 +87,7 @@ mpc_sqrt (mpc_ptr a, mpc_srcptr b, mpc_rnd_t rnd) /* sqrt(+Inf +i*y) = +Inf +i*0, when y positive */ /* sqrt(+Inf +i*y) = +Inf -i*0, when y positive */ mpfr_set_inf (mpc_realref (a), +1); - mpfr_set_ui (mpc_imagref (a), 0, GMP_RNDN); + mpfr_set_ui (mpc_imagref (a), 0, MPFR_RNDN); if (im_sgn) mpc_conj (a, a, MPC_RNDNN); return MPC_INEX (0, 0); @@ -125,7 +125,7 @@ mpc_sqrt (mpc_ptr a, mpc_srcptr b, mpc_rnd_t rnd) else if (re_cmp > 0) { inex_w = mpfr_sqrt (mpc_realref (a), mpc_realref (b), MPC_RND_RE (rnd)); - mpfr_set_ui (mpc_imagref (a), 0, GMP_RNDN); + mpfr_set_ui (mpc_imagref (a), 0, MPFR_RNDN); if (im_sgn) mpc_conj (a, a, MPC_RNDNN); return MPC_INEX (inex_w, 0); @@ -133,16 +133,16 @@ mpc_sqrt (mpc_ptr a, mpc_srcptr b, mpc_rnd_t rnd) else { mpfr_init2 (w, MPC_PREC_RE (b)); - mpfr_neg (w, mpc_realref (b), GMP_RNDN); + mpfr_neg (w, mpc_realref (b), MPFR_RNDN); if (im_sgn) { inex_w = -mpfr_sqrt (mpc_imagref (a), w, INV_RND (MPC_RND_IM (rnd))); - mpfr_neg (mpc_imagref (a), mpc_imagref (a), GMP_RNDN); + mpfr_neg (mpc_imagref (a), mpc_imagref (a), MPFR_RNDN); } else inex_w = mpfr_sqrt (mpc_imagref (a), w, MPC_RND_IM (rnd)); - mpfr_set_ui (mpc_realref (a), 0, GMP_RNDN); + mpfr_set_ui (mpc_realref (a), 0, MPFR_RNDN); mpfr_clear (w); return MPC_INEX (0, inex_w); } @@ -155,7 +155,7 @@ mpc_sqrt (mpc_ptr a, mpc_srcptr b, mpc_rnd_t rnd) y[0] = mpc_imagref (b)[0]; /* If y/2 underflows, so does sqrt(y/2) */ - mpfr_div_2ui (y, y, 1, GMP_RNDN); + mpfr_div_2ui (y, y, 1, MPFR_RNDN); if (im_cmp > 0) { inex_w = mpfr_sqrt (mpc_realref (a), y, MPC_RND_RE (rnd)); @@ -163,10 +163,10 @@ mpc_sqrt (mpc_ptr a, mpc_srcptr b, mpc_rnd_t rnd) } else { - mpfr_neg (y, y, GMP_RNDN); + mpfr_neg (y, y, MPFR_RNDN); inex_w = mpfr_sqrt (mpc_realref (a), y, MPC_RND_RE (rnd)); inex_t = -mpfr_sqrt (mpc_imagref (a), y, INV_RND (MPC_RND_IM (rnd))); - mpfr_neg (mpc_imagref (a), mpc_imagref (a), GMP_RNDN); + mpfr_neg (mpc_imagref (a), mpc_imagref (a), MPFR_RNDN); } return MPC_INEX (inex_w, inex_t); } @@ -180,9 +180,9 @@ mpc_sqrt (mpc_ptr a, mpc_srcptr b, mpc_rnd_t rnd) rnd_w = MPC_RND_RE (rnd); prec_w = MPC_PREC_RE (a); rnd_t = MPC_RND_IM(rnd); - if (rnd_t == GMP_RNDZ) - /* force GMP_RNDD or GMP_RNDUP, using sign(t) = sign(y) */ - rnd_t = (im_cmp > 0 ? GMP_RNDD : GMP_RNDU); + if (rnd_t == MPFR_RNDZ) + /* force MPFR_RNDD or MPFR_RNDUP, using sign(t) = sign(y) */ + rnd_t = (im_cmp > 0 ? MPFR_RNDD : MPFR_RNDU); prec_t = MPC_PREC_IM (a); } else { @@ -191,14 +191,14 @@ mpc_sqrt (mpc_ptr a, mpc_srcptr b, mpc_rnd_t rnd) if (im_cmp > 0) { rnd_w = MPC_RND_IM(rnd); rnd_t = MPC_RND_RE(rnd); - if (rnd_t == GMP_RNDZ) - rnd_t = GMP_RNDD; + if (rnd_t == MPFR_RNDZ) + rnd_t = MPFR_RNDD; } else { rnd_w = INV_RND(MPC_RND_IM (rnd)); rnd_t = INV_RND(MPC_RND_RE (rnd)); - if (rnd_t == GMP_RNDZ) - rnd_t = GMP_RNDU; + if (rnd_t == MPFR_RNDZ) + rnd_t = MPFR_RNDU; } } @@ -211,30 +211,30 @@ mpc_sqrt (mpc_ptr a, mpc_srcptr b, mpc_rnd_t rnd) /* let b = x + iy */ /* w = sqrt ((|x| + sqrt (x^2 + y^2)) / 2), rounded down */ /* total error bounded by 3 ulps */ - inex_w = mpc_abs (w, b, GMP_RNDD); + inex_w = mpc_abs (w, b, MPFR_RNDD); if (re_cmp < 0) - inex_w |= mpfr_sub (w, w, mpc_realref (b), GMP_RNDD); + inex_w |= mpfr_sub (w, w, mpc_realref (b), MPFR_RNDD); else - inex_w |= mpfr_add (w, w, mpc_realref (b), GMP_RNDD); - inex_w |= mpfr_div_2ui (w, w, 1, GMP_RNDD); - inex_w |= mpfr_sqrt (w, w, GMP_RNDD); + inex_w |= mpfr_add (w, w, mpc_realref (b), MPFR_RNDD); + inex_w |= mpfr_div_2ui (w, w, 1, MPFR_RNDD); + inex_w |= mpfr_sqrt (w, w, MPFR_RNDD); repr_w = mpfr_min_prec (w) <= prec_w; if (!repr_w) /* use the usual trick for obtaining the ternary value */ - ok_w = mpfr_can_round (w, prec - 2, GMP_RNDD, GMP_RNDU, - prec_w + (rnd_w == GMP_RNDN)); + ok_w = mpfr_can_round (w, prec - 2, MPFR_RNDD, MPFR_RNDU, + prec_w + (rnd_w == MPFR_RNDN)); else { /* w is representable in the target precision and thus cannot be rounded up */ - if (rnd_w == GMP_RNDN) + if (rnd_w == MPFR_RNDN) /* If w can be rounded to nearest, then actually no rounding occurs, and the ternary value is known from inex_w. */ - ok_w = mpfr_can_round (w, prec - 2, GMP_RNDD, GMP_RNDN, prec_w); + ok_w = mpfr_can_round (w, prec - 2, MPFR_RNDD, MPFR_RNDN, prec_w); else /* If w can be rounded down, then any direct rounding and the ternary flag can be determined from inex_w. */ - ok_w = mpfr_can_round (w, prec - 2, GMP_RNDD, GMP_RNDD, prec_w); + ok_w = mpfr_can_round (w, prec - 2, MPFR_RNDD, MPFR_RNDD, prec_w); } if (!inex_w || ok_w) { @@ -249,11 +249,11 @@ mpc_sqrt (mpc_ptr a, mpc_srcptr b, mpc_rnd_t rnd) if (!repr_t) /* As for w; since t was rounded away, we check whether rounding to 0 is possible. */ - ok_t = mpfr_can_round (t, prec - 3, r, GMP_RNDZ, - prec_t + (rnd_t == GMP_RNDN)); + ok_t = mpfr_can_round (t, prec - 3, r, MPFR_RNDZ, + prec_t + (rnd_t == MPFR_RNDN)); else { - if (rnd_t == GMP_RNDN) - ok_t = mpfr_can_round (t, prec - 3, r, GMP_RNDN, prec_t); + if (rnd_t == MPFR_RNDN) + ok_t = mpfr_can_round (t, prec - 3, r, MPFR_RNDN, prec_t); else ok_t = mpfr_can_round (t, prec - 3, r, r, prec_t); } @@ -275,7 +275,7 @@ mpc_sqrt (mpc_ptr a, mpc_srcptr b, mpc_rnd_t rnd) } if (repr_w && inex_w) { - if (rnd_w == GMP_RNDN) { + if (rnd_w == MPFR_RNDN) { /* w has not been rounded with mpfr_set/mpfr_neg, determine ternary value from inex_w instead */ if (re_cmp > 0) @@ -289,7 +289,7 @@ mpc_sqrt (mpc_ptr a, mpc_srcptr b, mpc_rnd_t rnd) /* determine ternary value, but also potentially add 1 ulp; can only be done now when we are in the target precision */ if (re_cmp > 0) { - if (rnd_w == GMP_RNDU) { + if (rnd_w == MPFR_RNDU) { MPFR_ADD_ONE_ULP (mpc_realref (a)); inex_re = +1; } @@ -297,7 +297,7 @@ mpc_sqrt (mpc_ptr a, mpc_srcptr b, mpc_rnd_t rnd) inex_re = -1; } else if (im_cmp > 0) { - if (rnd_w == GMP_RNDU) { + if (rnd_w == MPFR_RNDU) { MPFR_ADD_ONE_ULP (mpc_imagref (a)); inex_im = +1; } @@ -305,7 +305,7 @@ mpc_sqrt (mpc_ptr a, mpc_srcptr b, mpc_rnd_t rnd) inex_im = -1; } else { - if (rnd_w == GMP_RNDU) { + if (rnd_w == MPFR_RNDU) { MPFR_ADD_ONE_ULP (mpc_imagref (a)); inex_im = -1; } @@ -315,7 +315,7 @@ mpc_sqrt (mpc_ptr a, mpc_srcptr b, mpc_rnd_t rnd) } } if (repr_t && inex_t) { - if (rnd_t == GMP_RNDN) { + if (rnd_t == MPFR_RNDN) { if (re_cmp > 0) inex_im = inex_t; else if (im_cmp > 0) @@ -330,9 +330,9 @@ mpc_sqrt (mpc_ptr a, mpc_srcptr b, mpc_rnd_t rnd) else { inex_im = -inex_t; /* im_cmp > 0 implies that Im(b) > 0, thus im_sgn = 0 - and r = GMP_RNDU. + and r = MPFR_RNDU. im_cmp < 0 implies that Im(b) < 0, thus im_sgn = -1 - and r = GMP_RNDD. */ + and r = MPFR_RNDD. */ MPFR_SUB_ONE_ULP (mpc_imagref (a)); } } @@ -341,7 +341,7 @@ mpc_sqrt (mpc_ptr a, mpc_srcptr b, mpc_rnd_t rnd) inex_re = inex_t; else { inex_re = -inex_t; - /* im_cmp > 0 implies r = GMP_RNDU (see above) */ + /* im_cmp > 0 implies r = MPFR_RNDU (see above) */ MPFR_SUB_ONE_ULP (mpc_realref (a)); } } @@ -350,7 +350,7 @@ mpc_sqrt (mpc_ptr a, mpc_srcptr b, mpc_rnd_t rnd) inex_re = -inex_t; else { inex_re = inex_t; - /* im_cmp < 0 implies r = GMP_RNDD (see above) */ + /* im_cmp < 0 implies r = MPFR_RNDD (see above) */ MPFR_SUB_ONE_ULP (mpc_realref (a)); } } diff --git a/src/strtoc.c b/src/strtoc.c index b96ccee..81702e2 100644 --- a/src/strtoc.c +++ b/src/strtoc.c @@ -1,6 +1,6 @@ /* mpc_strtoc -- Read a complex number from a string. -Copyright (C) 2009, 2010, 2011 INRIA +Copyright (C) 2009, 2010, 2011, 2012 INRIA This file is part of GNU MPC. @@ -57,7 +57,7 @@ mpc_strtoc (mpc_ptr rop, const char *nptr, char **endptr, int base, mpc_rnd_t rn p = end; if (!bracketed) - inex_im = mpfr_set_ui (mpc_imagref (rop), 0ul, GMP_RNDN); + inex_im = mpfr_set_ui (mpc_imagref (rop), 0ul, MPFR_RNDN); else { if (!isspace ((unsigned char)*p)) goto error; diff --git a/src/tan.c b/src/tan.c index 24cd92b..0764db8 100644 --- a/src/tan.c +++ b/src/tan.c @@ -1,6 +1,6 @@ /* mpc_tan -- tangent of a complex number. -Copyright (C) 2008, 2009, 2010, 2011 INRIA +Copyright (C) 2008, 2009, 2010, 2011, 2012 INRIA This file is part of GNU MPC. @@ -83,7 +83,7 @@ mpc_tan (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) int inex_im; mpfr_set_ui (mpc_realref (rop), 0, MPC_RND_RE (rnd)); - mpfr_setsign (mpc_realref (rop), mpc_realref (rop), sign_re, GMP_RNDN); + mpfr_setsign (mpc_realref (rop), mpc_realref (rop), sign_re, MPFR_RNDN); /* exact, unless 1 is not in exponent range */ inex_im = mpfr_set_si (mpc_imagref (rop), @@ -111,10 +111,10 @@ mpc_tan (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) mpfr_init (c); mpfr_init (s); - mpfr_sin_cos (s, c, mpc_realref (op), GMP_RNDN); + mpfr_sin_cos (s, c, mpc_realref (op), MPFR_RNDN); mpfr_set_ui (mpc_realref (rop), 0, MPC_RND_RE (rnd)); mpfr_setsign (mpc_realref (rop), mpc_realref (rop), - mpfr_signbit (c) != mpfr_signbit (s), GMP_RNDN); + mpfr_signbit (c) != mpfr_signbit (s), MPFR_RNDN); /* exact, unless 1 is not in exponent range */ inex_im = mpfr_set_si (mpc_imagref (rop), (mpfr_signbit (mpc_imagref (op)) ? -1 : +1), @@ -207,22 +207,22 @@ mpc_tan (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) sign(tan(Re(op)))*0 + sign(Im(op))*I, where sign(tan(Re(op))) = sign(Re(x))*sign(Re(y)). */ int inex_re, inex_im; - mpfr_set_ui (mpc_realref (rop), 0, GMP_RNDN); + mpfr_set_ui (mpc_realref (rop), 0, MPFR_RNDN); if (mpfr_sgn (mpc_realref (x)) * mpfr_sgn (mpc_realref (y)) < 0) { - mpfr_neg (mpc_realref (rop), mpc_realref (rop), GMP_RNDN); + mpfr_neg (mpc_realref (rop), mpc_realref (rop), MPFR_RNDN); inex_re = 1; } else inex_re = -1; /* +0 is rounded down */ if (mpfr_sgn (mpc_imagref (op)) > 0) { - mpfr_set_ui (mpc_imagref (rop), 1, GMP_RNDN); + mpfr_set_ui (mpc_imagref (rop), 1, MPFR_RNDN); inex_im = 1; } else { - mpfr_set_si (mpc_imagref (rop), -1, GMP_RNDN); + mpfr_set_si (mpc_imagref (rop), -1, MPFR_RNDN); inex_im = -1; } inex = MPC_INEX(inex_re, inex_im); @@ -261,15 +261,15 @@ mpc_tan (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) /* Can the real part be rounded? */ ok = (!mpfr_number_p (mpc_realref (x))) - || mpfr_can_round (mpc_realref(x), prec - err, GMP_RNDN, GMP_RNDZ, - MPC_PREC_RE(rop) + (MPC_RND_RE(rnd) == GMP_RNDN)); + || mpfr_can_round (mpc_realref(x), prec - err, MPFR_RNDN, MPFR_RNDZ, + MPC_PREC_RE(rop) + (MPC_RND_RE(rnd) == MPFR_RNDN)); if (ok) { /* Can the imaginary part be rounded? */ ok = (!mpfr_number_p (mpc_imagref (x))) - || mpfr_can_round (mpc_imagref(x), prec - 6, GMP_RNDN, GMP_RNDZ, - MPC_PREC_IM(rop) + (MPC_RND_IM(rnd) == GMP_RNDN)); + || mpfr_can_round (mpc_imagref(x), prec - 6, MPFR_RNDN, MPFR_RNDZ, + MPC_PREC_IM(rop) + (MPC_RND_IM(rnd) == MPFR_RNDN)); } } while (ok == 0); diff --git a/tests/mpc-tests.h b/tests/mpc-tests.h index d1ce586..fe3e452 100644 --- a/tests/mpc-tests.h +++ b/tests/mpc-tests.h @@ -65,7 +65,7 @@ do { \ #define MPFR_OUT(x) \ do { \ printf (#x "[%lu]=", (unsigned long int) mpfr_get_prec (x)); \ - mpfr_out_str (stdout, 2, 0, x, GMP_RNDN); \ + mpfr_out_str (stdout, 2, 0, x, MPFR_RNDN); \ printf ("\n"); \ } while (0) diff --git a/tests/random.c b/tests/random.c index aa06355..0730fee 100644 --- a/tests/random.c +++ b/tests/random.c @@ -1,6 +1,6 @@ /* random.c -- Handle seed for random numbers. -// Copyright (C) 2008, 2009, 2010, 2011 INRIA +// Copyright (C) 2008, 2009, 2010, 2011, 2012 INRIA This file is part of GNU MPC. @@ -140,9 +140,9 @@ test_default_random (mpc_ptr z, mpfr_exp_t emin, mpfr_exp_t emax, zero_im_p = !zero_re_p; } if (zero_re_p) - mpfr_set_ui (mpc_realref (z), 0, GMP_RNDN); + mpfr_set_ui (mpc_realref (z), 0, MPFR_RNDN); if (zero_im_p) - mpfr_set_ui (mpc_imagref (z), 0, GMP_RNDN); + mpfr_set_ui (mpc_imagref (z), 0, MPFR_RNDN); } if (!mpfr_zero_p (mpc_realref (z))) mpfr_set_exp (mpc_realref (z), (mpfr_exp_t) gmp_urandomm_ui (rands, range) + emin); @@ -154,7 +154,7 @@ test_default_random (mpc_ptr z, mpfr_exp_t emin, mpfr_exp_t emax, negative_probability = 256; r = gmp_urandomb_ui (rands, 16); if ((r & 0xFF) < negative_probability) - mpfr_neg (mpc_realref (z), mpc_realref (z), GMP_RNDN); + mpfr_neg (mpc_realref (z), mpc_realref (z), MPFR_RNDN); if (((r>>8) & 0xFF) < negative_probability) - mpfr_neg (mpc_imagref (z), mpc_imagref (z), GMP_RNDN); + mpfr_neg (mpc_imagref (z), mpc_imagref (z), MPFR_RNDN); } diff --git a/tests/read_data.c b/tests/read_data.c index 7f3d91f..c1cf677 100644 --- a/tests/read_data.c +++ b/tests/read_data.c @@ -41,7 +41,7 @@ int nextchar; : (inex) == -1 ? "-1" : "0" static const char *mpfr_rnd_mode [] = - { "GMP_RNDN", "GMP_RNDZ", "GMP_RNDU", "GMP_RNDD" }; + { "MPFR_RNDN", "MPFR_RNDZ", "MPFR_RNDU", "MPFR_RNDD" }; const char *rnd_mode[] = { "MPC_RNDNN", "MPC_RNDZN", "MPC_RNDUN", "MPC_RNDDN", @@ -238,16 +238,16 @@ read_mpfr_rounding_mode (FILE *fp, mpfr_rnd_t* rnd) switch (nextchar) { case 'n': case 'N': - *rnd = GMP_RNDN; + *rnd = MPFR_RNDN; break; case 'z': case 'Z': - *rnd = GMP_RNDZ; + *rnd = MPFR_RNDZ; break; case 'u': case 'U': - *rnd = GMP_RNDU; + *rnd = MPFR_RNDU; break; case 'd': case 'D': - *rnd = GMP_RNDD; + *rnd = MPFR_RNDD; break; default: printf ("Error: Unexpected rounding mode '%c' in file '%s' line %lu\n", @@ -382,7 +382,7 @@ read_mpfr_mantissa (FILE *fp, mpfr_ptr x) exit (1); } ungetc (nextchar, fp); - if (mpfr_inp_str (x, fp, 0, GMP_RNDN) == 0) { + if (mpfr_inp_str (x, fp, 0, MPFR_RNDN) == 0) { printf ("Error: Impossible to read mpfr mantissa " "in file '%s' line %lu\n", pathname, line_number); @@ -419,10 +419,10 @@ read_mpc (FILE *fp, mpc_ptr z, known_signs_t *ks) static void check_compatible (int inex, mpfr_t expected, mpfr_rnd_t rnd, const char *s) { - if ((rnd == GMP_RNDU && inex == -1) || - (rnd == GMP_RNDD && inex == +1) || - (rnd == GMP_RNDZ && !mpfr_signbit (expected) && inex == +1) || - (rnd == GMP_RNDZ && mpfr_signbit (expected) && inex == -1)) + if ((rnd == MPFR_RNDU && inex == -1) || + (rnd == MPFR_RNDD && inex == +1) || + (rnd == MPFR_RNDZ && !mpfr_signbit (expected) && inex == +1) || + (rnd == MPFR_RNDZ && mpfr_signbit (expected) && inex == -1)) { if (s != NULL) printf ("Incompatible ternary value '%c' (%s part) in file '%s' line %lu\n", @@ -657,7 +657,7 @@ data_check (mpc_function function, const char *file_name) int inex_re; mpfr_t x1, x2; - mpfr_rnd_t mpfr_rnd = GMP_RNDN; + mpfr_rnd_t mpfr_rnd = MPFR_RNDN; int sign_real; int inex_im; diff --git a/tests/tadd_fr.c b/tests/tadd_fr.c index 1f3b76a..0f1a5cf 100644 --- a/tests/tadd_fr.c +++ b/tests/tadd_fr.c @@ -37,7 +37,7 @@ check_ternary_value (mpfr_prec_t prec_max, mpfr_prec_t step) mpfr_set_prec (f, prec); mpc_set_ui (z, 1, MPC_RNDNN); - mpfr_set_ui (f, 1, GMP_RNDN); + mpfr_set_ui (f, 1, MPFR_RNDN); if (mpc_add_fr (z, z, f, MPC_RNDNZ)) { printf ("Error in mpc_add_fr: 1+1 should be exact\n"); diff --git a/tests/tatan.c b/tests/tatan.c index 8883588..ca93ec4 100644 --- a/tests/tatan.c +++ b/tests/tatan.c @@ -30,10 +30,10 @@ test_underflow (void) mpfr_set_emin (-10); mpc_init2 (z, 21); - mpfr_set_si (mpc_realref(z), -1, GMP_RNDZ); - mpfr_set_ui_2exp (mpc_imagref(z), 1, 20, GMP_RNDZ); - mpfr_add_ui (mpc_imagref(z), mpc_imagref(z), 1, GMP_RNDZ); - mpfr_div_2exp (mpc_imagref(z), mpc_imagref(z), 20, GMP_RNDZ); + mpfr_set_si (mpc_realref(z), -1, MPFR_RNDZ); + mpfr_set_ui_2exp (mpc_imagref(z), 1, 20, MPFR_RNDZ); + mpfr_add_ui (mpc_imagref(z), mpc_imagref(z), 1, MPFR_RNDZ); + mpfr_div_2exp (mpc_imagref(z), mpc_imagref(z), 20, MPFR_RNDZ); mpc_atan (z, z, MPC_RNDNN); if (mpfr_cmp_si_2exp (mpc_realref(z), -1066635, 20) != 0 || mpfr_cmp_si_2exp (mpc_imagref(z), 1687619, 22)) diff --git a/tests/tcos.c b/tests/tcos.c index 66a85ba..dafc01d 100644 --- a/tests/tcos.c +++ b/tests/tcos.c @@ -1,6 +1,6 @@ /* tcos -- test file for mpc_cos. -Copyright (C) 2008, 2009, 2011 INRIA +Copyright (C) 2008, 2009, 2011, 2012 INRIA This file is part of GNU MPC. @@ -30,13 +30,13 @@ bug20090105 (void) mpc_init2 (got, 324); mpfr_set_str (mpc_realref(op), "-3.f1813b1487372434fea4414a520f65a343a16d0ec1ffb" - "b2b880154db8d63377ce788fc4215c450300@1", 16, GMP_RNDN); + "b2b880154db8d63377ce788fc4215c450300@1", 16, MPFR_RNDN); mpfr_set_str (mpc_imagref(op), "-2.b7a0c80bcacf1ccbbac614bf53a58b672b1b503161bee" - "59a82e46a23570b652f7ba5f01ef766d1c50", 16,GMP_RNDN); + "59a82e46a23570b652f7ba5f01ef766d1c50", 16,MPFR_RNDN); mpfr_set_str (mpc_realref(expected), "7.57c5b08a2b11b660d906a354289b0724b9c4b237" - "95abe33424e8d9858e534bd5d776ddd18e34b0240", 16, GMP_RNDN); + "95abe33424e8d9858e534bd5d776ddd18e34b0240", 16, MPFR_RNDN); mpfr_set_str (mpc_imagref(expected), "-1.f41a389646d068e0263561cb3c5d1df763945ad" - "ed9339f2a98387a3c4f97dbfd8a08b7d0af2f11b46", 16,GMP_RNDN); + "ed9339f2a98387a3c4f97dbfd8a08b7d0af2f11b46", 16,MPFR_RNDN); mpc_cos (got, op, MPC_RNDNN); if (mpc_cmp (got, expected) != 0) diff --git a/tests/tcosh.c b/tests/tcosh.c index 57b5601..0d6a9da 100644 --- a/tests/tcosh.c +++ b/tests/tcosh.c @@ -1,6 +1,6 @@ /* test file for mpc_cosh. -Copyright (C) 2008, 2009, 2010, 2011 INRIA +Copyright (C) 2008, 2009, 2010, 2011, 2012 INRIA This file is part of GNU MPC. @@ -38,8 +38,8 @@ pure_real_argument (void) /* cosh(1 +i*0) = cosh(1) +i*0 */ mpc_set_ui_ui (z, 1, 0, MPC_RNDNN); - mpfr_cosh (mpc_realref (u), mpc_realref (z), GMP_RNDN); - mpfr_set_ui (mpc_imagref (u), 0, GMP_RNDN); + mpfr_cosh (mpc_realref (u), mpc_realref (z), MPFR_RNDN); + mpfr_set_ui (mpc_imagref (u), 0, MPFR_RNDN); mpc_cosh (cosh_z, z, MPC_RNDNN); if (mpc_cmp (cosh_z, u) != 0 || mpfr_signbit (mpc_imagref (cosh_z))) TEST_FAILED ("mpc_cosh", z, cosh_z, u, MPC_RNDNN); @@ -84,8 +84,8 @@ pure_imaginary_argument (void) /* cosh(+0 +i) = cos(1) + i*0 */ mpc_set_ui_ui (z, 0, 1, MPC_RNDNN); - mpfr_cos (mpc_realref (u), mpc_imagref (z), GMP_RNDN); - mpfr_set_ui (mpc_imagref (u), 0, GMP_RNDN); + mpfr_cos (mpc_realref (u), mpc_imagref (z), MPFR_RNDN); + mpfr_set_ui (mpc_imagref (u), 0, MPFR_RNDN); mpc_cosh (cosh_z, z, MPC_RNDNN); if (mpc_cmp (cosh_z, u) != 0 || mpfr_signbit (mpc_imagref (cosh_z))) TEST_FAILED ("mpc_cosh", z, cosh_z, u, MPC_RNDNN); diff --git a/tests/tgeneric.c b/tests/tgeneric.c index a2bb460..cf56997 100644 --- a/tests/tgeneric.c +++ b/tests/tgeneric.c @@ -25,7 +25,7 @@ along with this program. If not, see http://www.gnu.org/licenses/ . #define MPFR_CAN_ROUND(b,err,prec,rnd) \ (mpfr_zero_p (b) || mpfr_inf_p (b) \ || mpfr_can_round (b, (long)mpfr_get_prec (b) - (err), (rnd), \ - GMP_RNDZ, (prec) + ((rnd)==GMP_RNDN))) + MPFR_RNDZ, (prec) + ((rnd)==MPFR_RNDN))) /* functions with one input, one output */ static void @@ -563,8 +563,8 @@ 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, GMP_RNDN); - function->pointer.FC (mpc_realref (x), x, GMP_RNDN); + 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; @@ -577,7 +577,7 @@ reuse_fc (mpc_function* function, mpc_ptr z, mpc_ptr x, mpfr_ptr expected) exit (1); } mpc_set (x, z, MPC_RNDNN); /* exact */ - function->pointer.FC (mpc_imagref (x), x, GMP_RNDN); + function->pointer.FC (mpc_imagref (x), x, MPFR_RNDN); if (!same_mpfr_value (mpc_imagref (x), expected, 1)) { mpfr_t got; @@ -856,7 +856,7 @@ reuse_cuuc (mpc_function* function, unsigned long ul1, unsigned long ul2, static mpfr_rnd_t first_rnd_mode (void) { - return GMP_RNDN; + return MPFR_RNDN; } static mpfr_rnd_t @@ -865,16 +865,16 @@ next_rnd_mode (mpfr_rnd_t curr) when curr is the last rounding mode */ { switch (curr) { - case GMP_RNDN: - return GMP_RNDZ; - case GMP_RNDZ: - return GMP_RNDU; - case GMP_RNDU: - return GMP_RNDD; + case MPFR_RNDN: + return MPFR_RNDZ; + case MPFR_RNDZ: + return MPFR_RNDU; + case MPFR_RNDU: + return MPFR_RNDD; default: /* return invalid guard value in mpfr_rnd_t */ #if MPFR_VERSION_MAJOR < 3 - return GMP_RNDNA; + return MPFR_RNDNA; #else return MPFR_RNDA; /* valid rounding type, but not (yet) used in mpc */ #endif @@ -885,8 +885,8 @@ static int is_valid_rnd_mode (mpfr_rnd_t curr) /* returns 1 if curr is a valid rounding mode, and 0otherwise */ { - if ( curr == GMP_RNDN || curr == GMP_RNDZ - || curr == GMP_RNDU || curr == GMP_RNDD) + if ( curr == MPFR_RNDN || curr == MPFR_RNDZ + || curr == MPFR_RNDU || curr == MPFR_RNDD) return 1; else return 0; @@ -1010,25 +1010,25 @@ tgeneric (mpc_function function, mpfr_prec_t prec_min, switch (special) { case 1: - mpfr_set_ui (mpc_realref (z1), 0, GMP_RNDN); + mpfr_set_ui (mpc_realref (z1), 0, MPFR_RNDN); break; case 2: mpfr_set_inf (mpc_realref (z1), +1); break; case 3: - mpfr_set_ui (mpc_imagref (z1), 0, GMP_RNDN); + mpfr_set_ui (mpc_imagref (z1), 0, MPFR_RNDN); break; case 4: mpfr_set_inf (mpc_imagref (z1), -1); break; case 5: - mpfr_set_ui (mpc_realref (z2), 0, GMP_RNDN); + mpfr_set_ui (mpc_realref (z2), 0, MPFR_RNDN); break; case 6: mpfr_set_inf (mpc_realref (z2), -1); break; case 7: - mpfr_set_ui (mpc_imagref (z2), 0, GMP_RNDN); + mpfr_set_ui (mpc_imagref (z2), 0, MPFR_RNDN); break; case 8: mpfr_set_inf (mpc_imagref (z2), +1); @@ -1045,25 +1045,25 @@ tgeneric (mpc_function function, mpfr_prec_t prec_min, switch (special) { case 1: - mpfr_set_ui (mpc_realref (z1), 0, GMP_RNDN); + mpfr_set_ui (mpc_realref (z1), 0, MPFR_RNDN); break; case 2: mpfr_set_inf (mpc_realref (z1), +1); break; case 3: - mpfr_set_ui (mpc_imagref (z1), 0, GMP_RNDN); + mpfr_set_ui (mpc_imagref (z1), 0, MPFR_RNDN); break; case 4: mpfr_set_inf (mpc_imagref (z1), -1); break; case 5: - mpfr_set_ui (mpc_realref (z2), 0, GMP_RNDN); + mpfr_set_ui (mpc_realref (z2), 0, MPFR_RNDN); break; case 6: mpfr_set_inf (mpc_realref (z2), -1); break; case 7: - mpfr_set_ui (mpc_imagref (z2), 0, GMP_RNDN); + mpfr_set_ui (mpc_imagref (z2), 0, MPFR_RNDN); break; case 8: mpfr_set_inf (mpc_imagref (z2), +1); @@ -1078,13 +1078,13 @@ tgeneric (mpc_function function, mpfr_prec_t prec_min, switch (special) { case 1: - mpfr_set_ui (mpc_realref (z1), 0, GMP_RNDN); + mpfr_set_ui (mpc_realref (z1), 0, MPFR_RNDN); break; case 2: mpfr_set_inf (mpc_realref (z1), +1); break; case 3: - mpfr_set_ui (mpc_imagref (z1), 0, GMP_RNDN); + mpfr_set_ui (mpc_imagref (z1), 0, MPFR_RNDN); break; case 4: mpfr_set_inf (mpc_imagref (z1), -1); @@ -1095,21 +1095,21 @@ tgeneric (mpc_function function, mpfr_prec_t prec_min, mpc_set_prec (z2, 128); do { test_default_random (z2, 0, 64, 128, zero_probability); - } while (!mpfr_fits_ulong_p (mpc_realref (z2), GMP_RNDN)); - ul1 = mpfr_get_ui (mpc_realref(z2), GMP_RNDN); + } while (!mpfr_fits_ulong_p (mpc_realref (z2), MPFR_RNDN)); + ul1 = mpfr_get_ui (mpc_realref(z2), MPFR_RNDN); mpc_set_prec (z2, prec); mpc_set_prec (z3, prec); mpc_set_prec (zzzz, 4*prec); switch (special) { case 1: - mpfr_set_ui (mpc_realref (z1), 0, GMP_RNDN); + mpfr_set_ui (mpc_realref (z1), 0, MPFR_RNDN); break; case 2: mpfr_set_inf (mpc_realref (z1), +1); break; case 3: - mpfr_set_ui (mpc_imagref (z1), 0, GMP_RNDN); + mpfr_set_ui (mpc_imagref (z1), 0, MPFR_RNDN); break; case 4: mpfr_set_inf (mpc_imagref (z1), -1); @@ -1123,23 +1123,23 @@ tgeneric (mpc_function function, mpfr_prec_t prec_min, mpc_set_prec (z2, 128); do { test_default_random (z2, 0, 64, 128, zero_probability); - } while (!mpfr_fits_ulong_p (mpc_realref (z2), GMP_RNDN) - ||!mpfr_fits_ulong_p (mpc_imagref (z2), GMP_RNDN)); - ul1 = mpfr_get_ui (mpc_realref(z2), GMP_RNDN); - ul2 = mpfr_get_ui (mpc_imagref(z2), GMP_RNDN); + } while (!mpfr_fits_ulong_p (mpc_realref (z2), MPFR_RNDN) + ||!mpfr_fits_ulong_p (mpc_imagref (z2), MPFR_RNDN)); + ul1 = mpfr_get_ui (mpc_realref(z2), MPFR_RNDN); + ul2 = mpfr_get_ui (mpc_imagref(z2), MPFR_RNDN); mpc_set_prec (z2, prec); mpc_set_prec (z3, prec); mpc_set_prec (zzzz, 4*prec); switch (special) { case 1: - mpfr_set_ui (mpc_realref (z1), 0, GMP_RNDN); + mpfr_set_ui (mpc_realref (z1), 0, MPFR_RNDN); break; case 2: mpfr_set_inf (mpc_realref (z1), +1); break; case 3: - mpfr_set_ui (mpc_imagref (z1), 0, GMP_RNDN); + mpfr_set_ui (mpc_imagref (z1), 0, MPFR_RNDN); break; case 4: mpfr_set_inf (mpc_imagref (z1), -1); @@ -1156,21 +1156,21 @@ tgeneric (mpc_function function, mpfr_prec_t prec_min, mpc_set_prec (z2, 128); do { test_default_random (z2, 0, 64, 128, zero_probability); - } while (!mpfr_fits_slong_p (mpc_realref (z2), GMP_RNDN)); - lo = mpfr_get_si (mpc_realref(z2), GMP_RNDN); + } while (!mpfr_fits_slong_p (mpc_realref (z2), MPFR_RNDN)); + lo = mpfr_get_si (mpc_realref(z2), MPFR_RNDN); mpc_set_prec (z2, prec); mpc_set_prec (z3, prec); mpc_set_prec (zzzz, 4*prec); switch (special) { case 1: - mpfr_set_ui (mpc_realref (z1), 0, GMP_RNDN); + mpfr_set_ui (mpc_realref (z1), 0, MPFR_RNDN); break; case 2: mpfr_set_inf (mpc_realref (z1), +1); break; case 3: - mpfr_set_ui (mpc_imagref (z1), 0, GMP_RNDN); + mpfr_set_ui (mpc_imagref (z1), 0, MPFR_RNDN); break; case 4: mpfr_set_inf (mpc_imagref (z1), -1); @@ -1184,21 +1184,21 @@ tgeneric (mpc_function function, mpfr_prec_t prec_min, mpc_set_prec (z2, 128); do { test_default_random (z2, 0, 64, 128, zero_probability); - } while (!mpfr_fits_slong_p (mpc_realref (z2), GMP_RNDN)); - i = (int)mpfr_get_si (mpc_realref(z2), GMP_RNDN); + } while (!mpfr_fits_slong_p (mpc_realref (z2), MPFR_RNDN)); + i = (int)mpfr_get_si (mpc_realref(z2), MPFR_RNDN); mpc_set_prec (z2, prec); mpc_set_prec (z3, prec); mpc_set_prec (zzzz, 4*prec); switch (special) { case 1: - mpfr_set_ui (mpc_realref (z1), 0, GMP_RNDN); + mpfr_set_ui (mpc_realref (z1), 0, MPFR_RNDN); break; case 2: mpfr_set_inf (mpc_realref (z1), +1); break; case 3: - mpfr_set_ui (mpc_imagref (z1), 0, GMP_RNDN); + mpfr_set_ui (mpc_imagref (z1), 0, MPFR_RNDN); break; case 4: mpfr_set_inf (mpc_imagref (z1), -1); @@ -1210,7 +1210,7 @@ tgeneric (mpc_function function, mpfr_prec_t prec_min, break; case CCF: case CFC: mpfr_set_prec (x1, prec); - mpfr_set (x1, mpc_realref (z1), GMP_RNDN); + mpfr_set (x1, mpc_realref (z1), MPFR_RNDN); test_default_random (z1, exp_min, exp_max, 128, zero_probability); mpc_set_prec (z2, prec); mpc_set_prec (z3, prec); @@ -1218,19 +1218,19 @@ tgeneric (mpc_function function, mpfr_prec_t prec_min, switch (special) { case 1: - mpfr_set_ui (mpc_realref (z1), 0, GMP_RNDN); + mpfr_set_ui (mpc_realref (z1), 0, MPFR_RNDN); break; case 2: mpfr_set_inf (mpc_realref (z1), +1); break; case 3: - mpfr_set_ui (mpc_imagref (z1), 0, GMP_RNDN); + mpfr_set_ui (mpc_imagref (z1), 0, MPFR_RNDN); break; case 4: mpfr_set_inf (mpc_imagref (z1), -1); break; case 5: - mpfr_set_ui (x1, 0, GMP_RNDN); + mpfr_set_ui (x1, 0, MPFR_RNDN); break; case 6: mpfr_set_inf (x1, +1); @@ -1247,13 +1247,13 @@ tgeneric (mpc_function function, mpfr_prec_t prec_min, switch (special) { case 1: - mpfr_set_ui (mpc_realref (z1), 0, GMP_RNDN); + mpfr_set_ui (mpc_realref (z1), 0, MPFR_RNDN); break; case 2: mpfr_set_inf (mpc_realref (z1), +1); break; case 3: - mpfr_set_ui (mpc_imagref (z1), 0, GMP_RNDN); + mpfr_set_ui (mpc_imagref (z1), 0, MPFR_RNDN); break; case 4: mpfr_set_inf (mpc_imagref (z1), -1); @@ -1268,13 +1268,13 @@ tgeneric (mpc_function function, mpfr_prec_t prec_min, switch (special) { case 1: - mpfr_set_ui (mpc_realref (z1), 0, GMP_RNDN); + mpfr_set_ui (mpc_realref (z1), 0, MPFR_RNDN); break; case 2: mpfr_set_inf (mpc_realref (z1), +1); break; case 3: - mpfr_set_ui (mpc_imagref (z1), 0, GMP_RNDN); + mpfr_set_ui (mpc_imagref (z1), 0, MPFR_RNDN); break; case 4: mpfr_set_inf (mpc_imagref (z1), -1); diff --git a/tests/tmul.c b/tests/tmul.c index 46d3bb3..225cf0e 100644 --- a/tests/tmul.c +++ b/tests/tmul.c @@ -102,15 +102,15 @@ check_regular (void) imaginary part */ mpc_set_prec (x, 7); mpc_set_prec (y, 7); - mpfr_set_str (mpc_realref (x), "0xB4p+733", 16, GMP_RNDN); - mpfr_set_str (mpc_imagref (x), "0x90p+244", 16, GMP_RNDN); - mpfr_set_str (mpc_realref (y), "0xECp-146", 16, GMP_RNDN); - mpfr_set_str (mpc_imagref (y), "0xACp-471", 16, GMP_RNDN); + mpfr_set_str (mpc_realref (x), "0xB4p+733", 16, MPFR_RNDN); + mpfr_set_str (mpc_imagref (x), "0x90p+244", 16, MPFR_RNDN); + mpfr_set_str (mpc_realref (y), "0xECp-146", 16, MPFR_RNDN); + mpfr_set_str (mpc_imagref (y), "0xACp-471", 16, MPFR_RNDN); cmpmul (x, y, MPC_RNDNN); - mpfr_set_str (mpc_realref (x), "0xB4p+733", 16, GMP_RNDN); - mpfr_set_str (mpc_imagref (x), "0x90p+244", 16, GMP_RNDN); - mpfr_set_str (mpc_realref (y), "0xACp-471", 16, GMP_RNDN); - mpfr_set_str (mpc_imagref (y), "-0xECp-146", 16, GMP_RNDN); + mpfr_set_str (mpc_realref (x), "0xB4p+733", 16, MPFR_RNDN); + mpfr_set_str (mpc_imagref (x), "0x90p+244", 16, MPFR_RNDN); + mpfr_set_str (mpc_realref (y), "0xACp-471", 16, MPFR_RNDN); + mpfr_set_str (mpc_imagref (y), "-0xECp-146", 16, MPFR_RNDN); cmpmul (x, y, MPC_RNDNN); for (prec = 2; prec < 1000; prec = (mpfr_prec_t) (prec * 1.1 + 1)) diff --git a/tests/tmul_i.c b/tests/tmul_i.c index 3cde4ac..863ed5f 100644 --- a/tests/tmul_i.c +++ b/tests/tmul_i.c @@ -1,6 +1,6 @@ /* tmul_i -- test file for mpc_mul_i. -Copyright (C) 2008, 2009, 2010, 2011 INRIA +Copyright (C) 2008, 2009, 2010, 2011, 2012 INRIA This file is part of GNU MPC. @@ -36,10 +36,10 @@ check_different_precisions(void) mpfr_set_prec (mpc_imagref (expected), 32); mpfr_set_prec (mpc_imagref (got), 32); - mpfr_set_str (mpc_realref (z), "0x100000000fp-32", 16, GMP_RNDN); - mpfr_set_str (mpc_imagref (z), "-1", 2, GMP_RNDN); - mpfr_set_str (mpc_realref (expected), "+1", 2, GMP_RNDN); - mpfr_set_str (mpc_imagref (expected), "0x100000000fp-32", 16, GMP_RNDN); + mpfr_set_str (mpc_realref (z), "0x100000000fp-32", 16, MPFR_RNDN); + mpfr_set_str (mpc_imagref (z), "-1", 2, MPFR_RNDN); + mpfr_set_str (mpc_realref (expected), "+1", 2, MPFR_RNDN); + mpfr_set_str (mpc_imagref (expected), "0x100000000fp-32", 16, MPFR_RNDN); mpc_set (got, z, MPC_RNDNN); res = mpc_mul_i (got, got, +1, MPC_RNDNN); diff --git a/tests/tnorm.c b/tests/tnorm.c index 3f4dccd..1dba939 100644 --- a/tests/tnorm.c +++ b/tests/tnorm.c @@ -1,6 +1,6 @@ /* tnorm -- test file for mpc_norm. -Copyright (C) 2008, 2011 INRIA +Copyright (C) 2008, 2011, 2012 INRIA This file is part of GNU MPC. @@ -30,11 +30,11 @@ test_underflow (void) mpfr_set_emin (-1); /* smallest positive number is 0.5*2^emin = 0.25 */ mpc_init2 (z, 10); - mpfr_set_ui_2exp (mpc_realref (z), 1023, -11, GMP_RNDN); /* exact */ - mpfr_set_ui_2exp (mpc_imagref (z), 1023, -11, GMP_RNDN); /* exact */ + mpfr_set_ui_2exp (mpc_realref (z), 1023, -11, MPFR_RNDN); /* exact */ + mpfr_set_ui_2exp (mpc_imagref (z), 1023, -11, MPFR_RNDN); /* exact */ mpfr_init2 (f, 10); - inex = mpc_norm (f, z, GMP_RNDZ); /* should give 511/1024 */ + inex = mpc_norm (f, z, MPFR_RNDZ); /* should give 511/1024 */ if (inex >= 0) { printf ("Error in underflow case (1)\n"); @@ -47,12 +47,12 @@ test_underflow (void) printf ("got "); mpfr_dump (f); printf ("expected "); - mpfr_set_ui_2exp (f, 511, -10, GMP_RNDZ); + mpfr_set_ui_2exp (f, 511, -10, MPFR_RNDZ); mpfr_dump (f); exit (1); } - inex = mpc_norm (f, z, GMP_RNDN); /* should give 511/1024 */ + inex = mpc_norm (f, z, MPFR_RNDN); /* should give 511/1024 */ if (inex >= 0) { printf ("Error in underflow case (2)\n"); @@ -65,12 +65,12 @@ test_underflow (void) printf ("got "); mpfr_dump (f); printf ("expected "); - mpfr_set_ui_2exp (f, 511, -10, GMP_RNDZ); + mpfr_set_ui_2exp (f, 511, -10, MPFR_RNDZ); mpfr_dump (f); exit (1); } - inex = mpc_norm (f, z, GMP_RNDU); /* should give 1023/2048 */ + inex = mpc_norm (f, z, MPFR_RNDU); /* should give 1023/2048 */ if (inex <= 0) { printf ("Error in underflow case (3)\n"); @@ -83,7 +83,7 @@ test_underflow (void) printf ("got "); mpfr_dump (f); printf ("expected "); - mpfr_set_ui_2exp (f, 1023, -11, GMP_RNDZ); + mpfr_set_ui_2exp (f, 1023, -11, MPFR_RNDZ); mpfr_dump (f); exit (1); } diff --git a/tests/tpow.c b/tests/tpow.c index 3592209..31ac1ca 100644 --- a/tests/tpow.c +++ b/tests/tpow.c @@ -1,6 +1,6 @@ /* tpow -- test file for mpc_pow. -Copyright (C) 2009, 2011 INRIA +Copyright (C) 2009, 2011, 2012 INRIA This file is part of GNU MPC. @@ -34,8 +34,8 @@ reuse_bug (void) mpc_init2 (y, prec); mpc_init2 (z, prec); - mpfr_set_ui (mpc_realref (x), 0ul, GMP_RNDN); - mpfr_set_ui_2exp (mpc_imagref (x), 3ul, -2, GMP_RNDN); + mpfr_set_ui (mpc_realref (x), 0ul, MPFR_RNDN); + mpfr_set_ui_2exp (mpc_imagref (x), 3ul, -2, MPFR_RNDN); mpc_set_ui (y, 8ul, MPC_RNDNN); mpc_pow (z, x, y, MPC_RNDNN); diff --git a/tests/tpow_fr.c b/tests/tpow_fr.c index 47ef071..99274af 100644 --- a/tests/tpow_fr.c +++ b/tests/tpow_fr.c @@ -30,9 +30,9 @@ test_reuse (void) mpfr_init2 (y, 2); mpc_init2 (z, 2); mpc_set_si_si (z, 0, -1, MPC_RNDNN); - mpfr_neg (mpc_realref (z), mpc_realref (z), GMP_RNDN); + mpfr_neg (mpc_realref (z), mpc_realref (z), MPFR_RNDN); mpc_div_2ui (z, z, 4, MPC_RNDNN); - mpfr_set_ui (y, 512, GMP_RNDN); + mpfr_set_ui (y, 512, MPFR_RNDN); inex = mpc_pow_fr (z, z, y, MPC_RNDNN); if (MPC_INEX_RE(inex) != 0 || MPC_INEX_IM(inex) != 0 || mpfr_cmp_ui_2exp (mpc_realref(z), 1, -2048) != 0 || diff --git a/tests/tpow_ui.c b/tests/tpow_ui.c index 4e8cd31..1c7cc6b 100644 --- a/tests/tpow_ui.c +++ b/tests/tpow_ui.c @@ -1,6 +1,6 @@ /* tpow_ui -- test file for mpc_pow_ui. -Copyright (C) 2009, 2010 INRIA +Copyright (C) 2009, 2010, 2012 INRIA This file is part of GNU MPC. @@ -97,9 +97,9 @@ main (int argc, char *argv[]) MPC_ASSERT (k >= 0); mpc_init2 (z, p); mpc_init2 (res, p); - mpfr_const_pi (mpc_realref (z), GMP_RNDN); - mpfr_div_2exp (mpc_realref (z), mpc_realref (z), 2, GMP_RNDN); - mpfr_const_log2 (mpc_imagref (z), GMP_RNDN); + mpfr_const_pi (mpc_realref (z), MPFR_RNDN); + mpfr_div_2exp (mpc_realref (z), mpc_realref (z), 2, MPFR_RNDN); + mpfr_const_log2 (mpc_imagref (z), MPFR_RNDN); while (k--) mpc_pow_ui (res, z, (unsigned long int) n, MPC_RNDNN); mpc_clear (z); diff --git a/tests/treimref.c b/tests/treimref.c index 230d34c..9d3c75c 100644 --- a/tests/treimref.c +++ b/tests/treimref.c @@ -1,6 +1,6 @@ /* treimref -- test file for mpc_realref and mpc_imagref. -Copyright (C) 2009 INRIA +Copyright (C) 2009, 2012 INRIA This file is part of GNU MPC. @@ -30,14 +30,14 @@ main (void) mpc_init2 (z, 6); mpc_set_ui_ui (z, 17, 42, MPC_RNDNN); - mpfr_set_ui (mpc_realref (z), 18, GMP_RNDN); - if (mpfr_get_ui (mpc_realref (z), GMP_RNDN) != 18) + mpfr_set_ui (mpc_realref (z), 18, MPFR_RNDN); + if (mpfr_get_ui (mpc_realref (z), MPFR_RNDN) != 18) { fprintf (stderr, "Error in mpfr_set_ui/mpc_realref\n"); exit (1); } - mpfr_set_ui (mpc_imagref (z), 43, GMP_RNDN); - if (mpfr_get_ui (mpc_imagref (z), GMP_RNDN) != 43) + mpfr_set_ui (mpc_imagref (z), 43, MPFR_RNDN); + if (mpfr_get_ui (mpc_imagref (z), MPFR_RNDN) != 43) { fprintf (stderr, "Error in mpfr_set_ui/mpc_imagref\n"); exit (1); diff --git a/tests/tset.c b/tests/tset.c index 0049436..27ea0b3 100644 --- a/tests/tset.c +++ b/tests/tset.c @@ -1,6 +1,6 @@ /* tset -- Test file for mpc_set_x and mpc_set_x_x functions. -Copyright (C) 2009, 2010, 2011 INRIA +Copyright (C) 2009, 2010, 2011, 2012 INRIA This file is part of GNU MPC. @@ -92,7 +92,7 @@ check_set (void) lo = -prec; - mpfr_set_d (fr, 1.23456789, GMP_RNDN); + mpfr_set_d (fr, 1.23456789, MPFR_RNDN); mpc_set_d (z, 1.23456789, MPC_RNDNN); if (mpfr_cmp (mpc_realref(z), fr) != 0 || mpfr_cmp_si (mpc_imagref(z), 0) != 0) @@ -117,7 +117,7 @@ check_set (void) if (mpfr_cmp_si (mpc_realref(z), lo) != 0 || mpfr_cmp_ui (mpc_imagref(z), 0) != 0) PRINT_ERROR ("mpc_set_si", prec, z); - mpfr_set_ld (fr, 1.23456789L, GMP_RNDN); + mpfr_set_ld (fr, 1.23456789L, MPFR_RNDN); mpc_set_ld_ld (z, 1.23456789L, 1.23456789L, MPC_RNDNN); if (mpfr_cmp (mpc_realref(z), fr) != 0 || mpfr_cmp (mpc_imagref(z), fr) != 0) @@ -141,10 +141,10 @@ check_set (void) PRINT_ERROR ("mpc_set_ld", prec, z); mpc_set_prec (x, prec); - mpfr_set_ui(fr, 1, GMP_RNDN); - mpfr_div_ui(fr, fr, 3, GMP_RNDN); - mpfr_set(mpc_realref(x), fr, GMP_RNDN); - mpfr_set(mpc_imagref(x), fr, GMP_RNDN); + mpfr_set_ui(fr, 1, MPFR_RNDN); + mpfr_div_ui(fr, fr, 3, MPFR_RNDN); + mpfr_set(mpc_realref(x), fr, MPFR_RNDN); + mpfr_set(mpc_imagref(x), fr, MPFR_RNDN); mpc_set (z, x, MPC_RNDNN); mpfr_clear_flags (); /* mpc_cmp set erange flag when an operand is a @@ -170,7 +170,7 @@ check_set (void) || mpfr_erangeflag_p()) PRINT_ERROR ("mpc_set_fr", prec, z); - mpfr_set_z (fr, mpz, GMP_RNDN); + mpfr_set_z (fr, mpz, MPFR_RNDN); mpc_set_z_z (z, mpz, mpz, MPC_RNDNN); mpfr_clear_flags (); if (mpfr_cmp (mpc_realref(z), fr) != 0 @@ -192,7 +192,7 @@ check_set (void) || mpfr_erangeflag_p()) PRINT_ERROR ("mpc_set_z", prec, z); - mpfr_set_q (fr, mpq, GMP_RNDN); + mpfr_set_q (fr, mpq, MPFR_RNDN); mpc_set_q_q (z, mpq, mpq, MPC_RNDNN); mpfr_clear_flags (); if (mpfr_cmp (mpc_realref(z), fr) != 0 @@ -221,7 +221,7 @@ check_set (void) || mpfr_erangeflag_p()) PRINT_ERROR ("mpc_set_q", prec, z); - mpfr_set_f (fr, mpf, GMP_RNDN); + mpfr_set_f (fr, mpf, MPFR_RNDN); mpc_set_f_f (z, mpf, mpf, MPC_RNDNN); mpfr_clear_flags (); if (mpfr_cmp (mpc_realref(z), fr) != 0 @@ -277,13 +277,13 @@ check_set (void) im = 2 * im * im + 4 * im + 1; /* gives 2^(2n-1)-1 from 2^(n-1)-1 */ mpc_set_sj (z, im, MPC_RNDNN); - if (mpfr_get_sj (mpc_realref(z), GMP_RNDN) != im || + if (mpfr_get_sj (mpc_realref(z), MPFR_RNDN) != im || mpfr_cmp_ui (mpc_imagref(z), 0) != 0) PRINT_ERROR ("mpc_set_sj (2)", im, z); mpc_set_sj_sj (z, im, im, MPC_RNDNN); - if (mpfr_get_sj (mpc_realref(z), GMP_RNDN) != im || - mpfr_get_sj (mpc_imagref(z), GMP_RNDN) != im) + if (mpfr_get_sj (mpc_realref(z), MPFR_RNDN) != im || + mpfr_get_sj (mpc_imagref(z), MPFR_RNDN) != im) PRINT_ERROR ("mpc_set_sj_sj (2)", im, z); } #endif /* _MPC_H_HAVE_INTMAX_T */ @@ -408,7 +408,7 @@ check_set_str (mpfr_exp_t exp_max) /* the real part has a zero exponent in base ten (fixed in r439) */ mpc_set_prec (expected, 37); mpc_set_prec (got, 37); - mpc_set_str (expected, "921FC04EDp-35 ", 16, GMP_RNDN); + mpc_set_str (expected, "921FC04EDp-35 ", 16, MPFR_RNDN); str = mpc_get_str (10, 0, expected, MPC_RNDNN); if (mpc_set_str (got, str, 10, MPC_RNDNN) == -1 || mpc_cmp (got, expected) != 0) diff --git a/tests/tsqr.c b/tests/tsqr.c index 02fea7e..2ec2099 100644 --- a/tests/tsqr.c +++ b/tests/tsqr.c @@ -1,6 +1,6 @@ /* tsqr -- test file for mpc_sqr. -Copyright (C) 2002, 2005, 2008, 2010, 2011 INRIA +Copyright (C) 2002, 2005, 2008, 2010, 2011, 2012 INRIA This file is part of GNU MPC. @@ -148,9 +148,9 @@ reuse_bug (void) /* reuse bug found by Paul Zimmermann 20081021 */ mpc_init2 (z1, 2); /* RE (z1^2) overflows, IM(z^2) = -0 */ - mpfr_set_str (mpc_realref (z1), "0.11", 2, GMP_RNDN); - mpfr_mul_2si (mpc_realref (z1), mpc_realref (z1), mpfr_get_emax (), GMP_RNDN); - mpfr_set_ui (mpc_imagref (z1), 0, GMP_RNDN); + mpfr_set_str (mpc_realref (z1), "0.11", 2, MPFR_RNDN); + mpfr_mul_2si (mpc_realref (z1), mpc_realref (z1), mpfr_get_emax (), MPFR_RNDN); + mpfr_set_ui (mpc_imagref (z1), 0, MPFR_RNDN); mpc_conj (z1, z1, MPC_RNDNN); mpc_sqr (z1, z1, MPC_RNDNN); if (!mpfr_inf_p (mpc_realref (z1)) || mpfr_signbit (mpc_realref (z1)) diff --git a/tests/ttan.c b/tests/ttan.c index f1d826a..c7c672c 100644 --- a/tests/ttan.c +++ b/tests/ttan.c @@ -1,6 +1,6 @@ /* ttan -- test file for mpc_tan. -Copyright (C) 2008, 2011 INRIA +Copyright (C) 2008, 2011, 2012 INRIA This file is part of GNU MPC. @@ -38,8 +38,8 @@ pure_real_argument (void) /* tan(1 +i*0) = tan(1) +i*0 */ mpc_set_ui_ui (z, 1, 0, MPC_RNDNN); - mpfr_set_ui (x, 1, GMP_RNDN); - mpfr_tan (tan_x, x, GMP_RNDN); + mpfr_set_ui (x, 1, MPFR_RNDN); + mpfr_tan (tan_x, x, MPFR_RNDN); mpc_tan (tan_z, z, MPC_RNDNN); if (mpfr_cmp (mpc_realref (tan_z), tan_x) != 0 || !mpfr_zero_p (mpc_imagref (tan_z)) || mpfr_signbit (mpc_imagref (tan_z))) @@ -59,11 +59,11 @@ pure_real_argument (void) } /* tan(Pi/2 +i*0) = +Inf +i*0 */ - mpfr_const_pi (x, GMP_RNDN); - mpfr_div_2ui (x, x, 1, GMP_RNDN); - mpfr_set (mpc_realref (z), x, GMP_RNDN); - mpfr_set_ui (mpc_imagref (z), 0, GMP_RNDN); - mpfr_tan (tan_x, x, GMP_RNDN); + mpfr_const_pi (x, MPFR_RNDN); + mpfr_div_2ui (x, x, 1, MPFR_RNDN); + mpfr_set (mpc_realref (z), x, MPFR_RNDN); + mpfr_set_ui (mpc_imagref (z), 0, MPFR_RNDN); + mpfr_tan (tan_x, x, MPFR_RNDN); mpc_tan (tan_z, z, MPC_RNDNN); if (mpfr_cmp (mpc_realref (tan_z), tan_x) != 0 || !mpfr_zero_p (mpc_imagref (tan_z)) || mpfr_signbit (mpc_imagref (tan_z))) @@ -83,9 +83,9 @@ pure_real_argument (void) } /* tan(-Pi/2 +i*0) = -Inf +i*0 */ - mpfr_neg (x, x, GMP_RNDN); + mpfr_neg (x, x, MPFR_RNDN); mpc_neg (z, z, MPC_RNDNN); - mpfr_tan (tan_x, x, GMP_RNDN); + mpfr_tan (tan_x, x, MPFR_RNDN); mpc_tan (tan_z, z, MPC_RNDNN); if (mpfr_cmp (mpc_realref (tan_z), tan_x) != 0 || !mpfr_zero_p (mpc_imagref (tan_z)) || mpfr_signbit (mpc_imagref (tan_z))) @@ -128,8 +128,8 @@ pure_imaginary_argument (void) /* tan(0 +i) = +0 +i*tanh(1) */ mpc_set_ui_ui (z, 0, 1, MPC_RNDNN); - mpfr_set_ui (y, 1, GMP_RNDN); - mpfr_tanh (tanh_y, y, GMP_RNDN); + mpfr_set_ui (y, 1, MPFR_RNDN); + mpfr_tanh (tanh_y, y, MPFR_RNDN); mpc_tan (tan_z, z, MPC_RNDNN); if (mpfr_cmp (mpc_imagref (tan_z), tanh_y) != 0 || !mpfr_zero_p (mpc_realref (tan_z)) || mpfr_signbit (mpc_realref (tan_z))) @@ -137,15 +137,15 @@ pure_imaginary_argument (void) mpc_t c99; mpc_init2 (c99, prec); - mpfr_set_ui (mpc_realref (c99), 0, GMP_RNDN); - mpfr_set (mpc_imagref (c99), tanh_y, GMP_RNDN); + mpfr_set_ui (mpc_realref (c99), 0, MPFR_RNDN); + mpfr_set (mpc_imagref (c99), tanh_y, MPFR_RNDN); TEST_FAILED ("mpc_tan", z, tan_z, c99, MPC_RNDNN); } /* tan(0 -i) = +0 +i*tanh(-1) */ mpc_conj (z, z, MPC_RNDNN); - mpfr_neg (tanh_y, tanh_y, GMP_RNDN); + mpfr_neg (tanh_y, tanh_y, MPFR_RNDN); mpc_tan (tan_z, z, MPC_RNDNN); if (mpfr_cmp (mpc_imagref (tan_z), tanh_y) != 0 || !mpfr_zero_p (mpc_realref (tan_z)) || mpfr_signbit (mpc_realref (tan_z))) @@ -153,15 +153,15 @@ pure_imaginary_argument (void) mpc_t c99; mpc_init2 (c99, prec); - mpfr_set_ui (mpc_realref (c99), 0, GMP_RNDN); - mpfr_set (mpc_imagref (c99), tanh_y, GMP_RNDN); + mpfr_set_ui (mpc_realref (c99), 0, MPFR_RNDN); + mpfr_set (mpc_imagref (c99), tanh_y, MPFR_RNDN); TEST_FAILED ("mpc_tan", z, tan_z, c99, MPC_RNDNN); } /* tan(-0 +i) = -0 +i*tanh(1) */ mpc_neg (z, z, MPC_RNDNN); - mpfr_neg (tanh_y, tanh_y, GMP_RNDN); + mpfr_neg (tanh_y, tanh_y, MPFR_RNDN); mpc_tan (tan_z, z, MPC_RNDNN); if (mpfr_cmp (mpc_imagref (tan_z), tanh_y) != 0 || !mpfr_zero_p (mpc_realref (tan_z)) || !mpfr_signbit (mpc_realref (tan_z))) @@ -169,15 +169,15 @@ pure_imaginary_argument (void) mpc_t c99; mpc_init2 (c99, prec); - mpfr_set_ui (mpc_realref (c99), 0, GMP_RNDN); - mpfr_set (mpc_imagref (c99), tanh_y, GMP_RNDN); + mpfr_set_ui (mpc_realref (c99), 0, MPFR_RNDN); + mpfr_set (mpc_imagref (c99), tanh_y, MPFR_RNDN); TEST_FAILED ("mpc_tan", z, tan_z, c99, MPC_RNDNN); } /* tan(-0 -i) = -0 +i*tanh(-1) */ mpc_conj (z, z, MPC_RNDNN); - mpfr_neg (tanh_y, tanh_y, GMP_RNDN); + mpfr_neg (tanh_y, tanh_y, MPFR_RNDN); mpc_tan (tan_z, z, MPC_RNDNN); if (mpfr_cmp (mpc_imagref (tan_z), tanh_y) != 0 || !mpfr_zero_p (mpc_realref (tan_z)) || !mpfr_signbit (mpc_realref (tan_z))) @@ -185,8 +185,8 @@ pure_imaginary_argument (void) mpc_t c99; mpc_init2 (c99, prec); - mpfr_set_ui (mpc_realref (c99), 0, GMP_RNDN); - mpfr_set (mpc_imagref (c99), tanh_y, GMP_RNDN); + mpfr_set_ui (mpc_realref (c99), 0, MPFR_RNDN); + mpfr_set (mpc_imagref (c99), tanh_y, MPFR_RNDN); TEST_FAILED ("mpc_tan", z, tan_z, c99, MPC_RNDNN); } diff --git a/tests/tui_div.c b/tests/tui_div.c index c109189..40c740a 100644 --- a/tests/tui_div.c +++ b/tests/tui_div.c @@ -1,6 +1,6 @@ /* tui_div -- test file for mpc_ui_div. -Copyright (C) 2008, 2011 INRIA +Copyright (C) 2008, 2011, 2012 INRIA This file is part of GNU MPC. @@ -41,8 +41,8 @@ special (void) } /* 0/(-1-0*I) should give (-0, +0) */ - mpfr_set_str (mpc_realref(a), "-1", 10, GMP_RNDN); - mpfr_set_str (mpc_imagref(a), "-0", 10, GMP_RNDN); + mpfr_set_str (mpc_realref(a), "-1", 10, MPFR_RNDN); + mpfr_set_str (mpc_imagref(a), "-0", 10, MPFR_RNDN); mpc_ui_div (b, 0, a, MPC_RNDNN); if ((mpc_cmp_si_si (b, 0, 0) != 0) || (MPFR_SIGN (mpc_realref(b)) > 0) || (MPFR_SIGN (mpc_imagref(b)) < 0)) -- cgit v1.2.1