From 89090be0373878ed70288733b455d481cc9674bd Mon Sep 17 00:00:00 2001 From: enge Date: Mon, 23 Jul 2012 13:17:47 +0000 Subject: remove compatibility function ROUND_AWAY git-svn-id: svn://scm.gforge.inria.fr/svn/mpc/trunk@1247 211d60ee-9f03-0410-a15a-8952a2c7a4e4 --- src/atan.c | 2 +- src/get_version.c | 21 --------------------- src/mpc-impl.h | 28 ---------------------------- src/mul.c | 10 +++++----- src/sqr.c | 11 ++++------- 5 files changed, 10 insertions(+), 62 deletions(-) (limited to 'src') diff --git a/src/atan.c b/src/atan.c index 43c03eb..70e1726 100644 --- a/src/atan.c +++ b/src/atan.c @@ -313,7 +313,7 @@ mpc_atan (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) mpfr_set_prec (y, p); /* a = upper bound for log(x^2 + (1+y)^2) */ - ROUND_AWAY (mpfr_add_ui (a, mpc_imagref (op), 1, MPFR_RNDA), a); + mpfr_add_ui (a, mpc_imagref (op), 1, MPFR_RNDA); mpfr_sqr (a, a, MPFR_RNDU); mpfr_sqr (y, mpc_realref (op), MPFR_RNDU); mpfr_add (a, a, y, MPFR_RNDU); diff --git a/src/get_version.c b/src/get_version.c index f93e763..e3b95a1 100644 --- a/src/get_version.c +++ b/src/get_version.c @@ -20,27 +20,6 @@ along with this program. If not, see http://www.gnu.org/licenses/ . #include "mpc-impl.h" -#if MPFR_VERSION_MAJOR < 3 -/* The following are functions defined for compatibility with mpfr < 3; - logically, they should be defined in a separate file, but then gcc - complains about an empty translation unit with mpfr >= 3. */ - -void -mpfr_set_zero (mpfr_ptr z, int s) -{ - mpfr_set_ui (z, 0ul, MPFR_RNDN); - if (s < 0) - mpfr_neg (z, z, MPFR_RNDN); -} - -int -mpfr_regular_p (mpfr_srcptr z) -{ - return (mpfr_number_p (z) && !mpfr_zero_p (z)); -} -#endif /* mpfr < 3 */ - - const char * mpc_get_version (void) { diff --git a/src/mpc-impl.h b/src/mpc-impl.h index 628970d..5664955 100644 --- a/src/mpc-impl.h +++ b/src/mpc-impl.h @@ -66,34 +66,6 @@ along with this program. If not, see http://www.gnu.org/licenses/ . #define MPFR_SWAP(a,b) do { mpfr_srcptr tmp; tmp = a; a = b; b = tmp; } while (0) -/* - * Macro implementing rounding away from zero, to ease compatibility with - * mpfr < 3. f is the complete function call with a rounding mode of - * MPFR_RNDA, rop the name of the variable containing the result; it is - * already contained in f, but needs to be repeated so that the macro can - * modify the variable. - * Usage: replace each call to a function such as - * mpfr_add (rop, a, b, MPFR_RNDA) - * by - * ROUND_AWAY (mpfr_add (rop, a, b, MPFR_RNDA), rop) -*/ -#if MPFR_VERSION_MAJOR < 3 - /* round towards zero, add 1 ulp if not exact */ -#define MPFR_RNDA MPFR_RNDZ -#define ROUND_AWAY(f,rop) \ - ((f) ? MPFR_ADD_ONE_ULP (rop), MPFR_SIGNBIT (rop) : 0) -#else -#define ROUND_AWAY(f,rop) \ - (f) -#endif /* mpfr < 3 */ - -#if MPFR_VERSION_MAJOR < 3 -/* declare missing functions, defined in get_version.c */ -__MPC_DECLSPEC void mpfr_set_zero (mpfr_ptr, int); -__MPC_DECLSPEC int mpfr_regular_p (mpfr_srcptr); -#endif /* mpfr < 3 */ - - /* * MPC macros */ diff --git a/src/mul.c b/src/mul.c index 78accce..3927888 100644 --- a/src/mul.c +++ b/src/mul.c @@ -477,13 +477,13 @@ mpc_mul_karatsuba (mpc_ptr rop, mpc_srcptr op1, mpc_srcptr op2, mpc_rnd_t rnd) /* first compute away(b +/- a) and store it in u */ inexact = (mul_a == -1 ? - ROUND_AWAY (mpfr_sub (u, b, a, MPFR_RNDA), u) : - ROUND_AWAY (mpfr_add (u, b, a, MPFR_RNDA), u)); + mpfr_sub (u, b, a, MPFR_RNDA) : + mpfr_add (u, b, a, MPFR_RNDA)); /* then compute away(+/-c - d) and store it in x */ inexact |= (mul_c == -1 ? - ROUND_AWAY (mpfr_add (x, c, d, MPFR_RNDA), x) : - ROUND_AWAY (mpfr_sub (x, c, d, MPFR_RNDA), x)); + mpfr_add (x, c, d, MPFR_RNDA) : + mpfr_sub (x, c, d, MPFR_RNDA)); if (mul_c == -1) mpfr_neg (x, x, MPFR_RNDN); @@ -491,7 +491,7 @@ mpc_mul_karatsuba (mpc_ptr rop, mpc_srcptr op1, mpc_srcptr op2, mpc_rnd_t rnd) 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); + inexact |= mpfr_mul (u, u, x, MPFR_RNDA); /* (a+b)*(c-d) */ /* if all computations are exact up to here, it may be that diff --git a/src/sqr.c b/src/sqr.c index fa7a259..f7d35fd 100644 --- a/src/sqr.c +++ b/src/sqr.c @@ -266,8 +266,8 @@ mpc_sqr (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) /* The error is bounded above by 1 ulp. */ /* We first let inexact be 1 if the real part is not computed */ /* exactly and determine the sign later. */ - inexact = ROUND_AWAY (mpfr_add (u, x, mpc_imagref (op), MPFR_RNDA), u) - | ROUND_AWAY (mpfr_sub (v, x, mpc_imagref (op), MPFR_RNDA), v); + inexact = mpfr_add (u, x, mpc_imagref (op), MPFR_RNDA) + | mpfr_sub (v, x, mpc_imagref (op), MPFR_RNDA); /* compute the real part as u*v, rounded away */ /* determine also the sign of inex_re */ @@ -279,10 +279,7 @@ mpc_sqr (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) 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 ? MPFR_RNDU : MPFR_RNDD); - inexact |= ROUND_AWAY (mpfr_mul (u, u, v, MPFR_RNDA), u); /* error 5 */ + inexact |= mpfr_mul (u, u, v, MPFR_RNDA); /* error 5 */ if (mpfr_get_exp (u) == emin || mpfr_inf_p (u)) { /* under- or overflow */ inex_re = mpfr_fsss (rop->re, x, op->im, MPC_RND_RE (rnd)); @@ -290,7 +287,7 @@ mpc_sqr (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) } else { ok = (!inexact) | mpfr_can_round (u, prec - 3, - rnd_away, MPFR_RNDZ, + MPFR_RNDA, 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)); -- cgit v1.2.1