diff options
author | Andreas Enge <andreas.enge@inria.fr> | 2012-09-19 11:17:49 +0000 |
---|---|---|
committer | Andreas Enge <andreas.enge@inria.fr> | 2012-09-19 11:17:49 +0000 |
commit | 9d1fd17d4081b2a0ac2de5f1c86d1bc81427a5f9 (patch) | |
tree | 5d9efd557b23ca31a5921219c05f41b00f9c7932 /src/mpc-impl.h | |
parent | 75e6da9bb997ede499e9e282317f0c0b3fc92bbd (diff) | |
download | mpc-git-rootsunity.tar.gz |
merge trunk into branch rootsunityrootsunity
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/mpc/branches/rootsunity@1273 211d60ee-9f03-0410-a15a-8952a2c7a4e4
Diffstat (limited to 'src/mpc-impl.h')
-rw-r--r-- | src/mpc-impl.h | 57 |
1 files changed, 25 insertions, 32 deletions
diff --git a/src/mpc-impl.h b/src/mpc-impl.h index c3ca9af..5664955 100644 --- a/src/mpc-impl.h +++ b/src/mpc-impl.h @@ -55,46 +55,18 @@ 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) /* - * 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 GMP_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 */ @@ -103,7 +75,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 @@ -137,6 +109,27 @@ __MPC_DECLSPEC int mpfr_regular_p (mpfr_srcptr); } while (0) #endif + +/* + * Debug macros + */ + +#define MPC_OUT(x) \ +do { \ + printf (#x "[%lu,%lu]=", (unsigned long int) MPC_PREC_RE (x), \ + (unsigned long int) MPC_PREC_IM (x)); \ + mpc_out_str (stdout, 2, 0, x, MPC_RNDNN); \ + printf ("\n"); \ +} while (0) + +#define MPFR_OUT(x) \ +do { \ + printf (#x "[%lu]=", (unsigned long int) mpfr_get_prec (x)); \ + mpfr_out_str (stdout, 2, 0, x, MPFR_RNDN); \ + printf ("\n"); \ +} while (0) + + /* * Constants */ |