diff options
author | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2010-02-22 17:23:27 +0000 |
---|---|---|
committer | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2010-02-22 17:23:27 +0000 |
commit | 4fc10b29bcfd5b0ddd4aee1021235fb669ef302e (patch) | |
tree | e4fac1e8bc3208aa47b3c319fd06e94048b43a56 | |
parent | 5980e3509181df843fe8dcb30f46c9dfb51b0116 (diff) | |
download | mpfr-4fc10b29bcfd5b0ddd4aee1021235fb669ef302e.tar.gz |
changed mpfr_get_z_exp -> mpfr_get_z_2exp (old function)
mpfr_set_z_exp -> mpfr_set_z_2exp (new function)
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@6707 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | atan.c | 2 | ||||
-rw-r--r-- | cbrt.c | 2 | ||||
-rw-r--r-- | cos.c | 2 | ||||
-rw-r--r-- | eint.c | 2 | ||||
-rw-r--r-- | exp_2.c | 6 | ||||
-rw-r--r-- | get_z.c | 2 | ||||
-rw-r--r-- | get_z_exp.c | 6 | ||||
-rw-r--r-- | mpfr.h | 5 | ||||
-rw-r--r-- | mpfr.texi | 34 | ||||
-rw-r--r-- | pow.c | 4 | ||||
-rw-r--r-- | rem1.c | 4 | ||||
-rw-r--r-- | root.c | 2 | ||||
-rw-r--r-- | set_z.c | 2 | ||||
-rw-r--r-- | set_z_exp.c | 6 | ||||
-rw-r--r-- | sin_cos.c | 2 | ||||
-rw-r--r-- | tests/tset_z_exp.c | 10 |
17 files changed, 49 insertions, 46 deletions
@@ -21,6 +21,7 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., ############################################################################## Changes from versions 2.4.* to version 3.0: +- MPFR 3.0 is binary and API incompatible with previous versions. - MPFR is now distributed under the GNU Lesser General Public License version 3 or later (LGPL v3+). - Rounding modes GMP_RNDX are now MPFR_RNDX (GMP_RNDX kept for compatibility). @@ -35,7 +36,8 @@ _ The rounding mode type mp_rnd_t is now mpfr_rnd_t (mp_rnd_t kept for - New function mpfr_digamma. - New functions mpfr_set_flt and mpfr_get_flt to convert from/to the float type - New function mpfr_urandom. -- New function mpfr_set_z_exp (companion to mpfr_get_z_exp). +- New function mpfr_set_z_2exp (companion to mpfr_get_z_2exp, which was renamed + from mpfr_get_z_exp in previous versions). - Speed improvement for large operands in the trigonometric functions (mpfr_sin, mpfr_cos, mpfr_tan, mpfr_sin_cos): speedup of about 2.5 for 10^5 digits, of about 5 for 10^6 digits. @@ -377,7 +377,7 @@ mpfr_atan (mpfr_ptr atan, mpfr_srcptr x, mpfr_rnd_t rnd_mode) if (!MPFR_IS_ZERO (tmp)) { /* tmp = ukz*2^exptol */ - exptol = mpfr_get_z_exp (ukz, tmp); + exptol = mpfr_get_z_2exp (ukz, tmp); /* since the s_k are decreasing (see algorithms.tex), and s_0 = min(|x|, 1/|x|) < 1, we have sk < 1, thus exptol < 0 */ @@ -78,7 +78,7 @@ mpfr_cbrt (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd_mode) MPFR_SAVE_EXPO_MARK (expo); mpz_init (m); - e = mpfr_get_z_exp (m, x); /* x = m * 2^e */ + e = mpfr_get_z_2exp (m, x); /* x = m * 2^e */ if ((negative = MPFR_IS_NEG(x))) mpz_neg (m, m); r = e % 3; @@ -62,7 +62,7 @@ mpfr_cos2_aux (mpfr_ptr f, mpfr_srcptr r) mpz_init (x); mpz_init (s); mpz_init (t); - ex = mpfr_get_z_exp (x, r); /* r = x*2^ex */ + ex = mpfr_get_z_2exp (x, r); /* r = x*2^ex */ /* remove trailing zeroes */ l = mpz_scan1 (x, 0); @@ -59,7 +59,7 @@ mpfr_eint_aux (mpfr_t y, mpfr_srcptr x) mpz_init (u); mpz_init (m); MPFR_GROUP_INIT_3 (group, 31, eps, erru, errs); - e = mpfr_get_z_exp (m, x); /* x = m * 2^e */ + e = mpfr_get_z_2exp (m, x); /* x = m * 2^e */ MPFR_ASSERTD (mpz_sizeinbase (m, 2) == MPFR_PREC (x)); if (MPFR_PREC (x) > w) { @@ -189,7 +189,7 @@ mpfr_exp_2 (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd_mode) MPFR_TMP_MARK(marker); MY_INIT_MPZ(ss, 3 + 2*((q-1)/GMP_NUMB_BITS)); - exps = mpfr_get_z_exp (ss, s); + exps = mpfr_get_z_2exp (ss, s); /* s <- 1 + r/1! + r^2/2! + ... + r^l/l! */ MPFR_ASSERTD (MPFR_IS_PURE_FP (r) && MPFR_EXP (r) < 0); l = (precy < MPFR_EXP_2_THRESHOLD) @@ -268,7 +268,7 @@ mpfr_exp2_aux (mpz_t s, mpfr_srcptr r, mp_prec_t q, mp_exp_t *exps) mpz_set_ui(t, 1); mpz_set_ui(s, 1); mpz_mul_2exp(s, s, q-1); - expr = mpfr_get_z_exp(rr, r); /* no error here */ + expr = mpfr_get_z_2exp(rr, r); /* no error here */ l = 0; for (;;) { @@ -336,7 +336,7 @@ mpfr_exp2_aux2 (mpz_t s, mpfr_srcptr r, mp_prec_t q, mp_exp_t *exps) *exps = 1 - q; /* 1 ulp = 2^(1-q) */ for (i = 0 ; i <= m ; i++) MY_INIT_MPZ (R[i], sizer + 2); - expR[1] = mpfr_get_z_exp (R[1], r); /* exact operation: no error */ + expR[1] = mpfr_get_z_2exp (R[1], r); /* exact operation: no error */ expR[1] = mpz_normalize2 (R[1], R[1], expR[1], 1 - q); /* error <= 1 ulp */ mpz_mul (t, R[1], R[1]); /* err(t) <= 2 ulps */ mpz_fdiv_q_2exp (R[2], t, q - 1); /* err(R[2]) <= 3 ulps */ @@ -38,7 +38,7 @@ mpfr_get_z (mpz_ptr z, mpfr_srcptr f, mpfr_rnd_t rnd) MPFR_ASSERTN (inex != 1 && inex != -1); /* integral part of f is representable in r */ MPFR_ASSERTN (MPFR_IS_FP (r) ); - exp = mpfr_get_z_exp (z, r); + exp = mpfr_get_z_2exp (z, r); if (exp >= 0) mpz_mul_2exp (z, z, exp); else diff --git a/get_z_exp.c b/get_z_exp.c index 50fcecac2..8d4f31dd7 100644 --- a/get_z_exp.c +++ b/get_z_exp.c @@ -1,5 +1,5 @@ -/* mpfr_get_z_exp -- get a multiple-precision integer and an exponent - from a floating-point number +/* mpfr_get_z_2exp -- get a multiple-precision integer and an exponent + from a floating-point number Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. Contributed by the Arenaire and Cacao projects, INRIA. @@ -36,7 +36,7 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., */ mp_exp_t -mpfr_get_z_exp (mpz_ptr z, mpfr_srcptr f) +mpfr_get_z_2exp (mpz_ptr z, mpfr_srcptr f) { mp_size_t fn; int sh; @@ -296,7 +296,7 @@ __MPFR_DECLSPEC int __MPFR_DECLSPEC int mpfr_set_z _MPFR_PROTO ((mpfr_ptr, mpz_srcptr, mpfr_rnd_t)); __MPFR_DECLSPEC int - mpfr_set_z_exp _MPFR_PROTO ((mpfr_ptr, mpz_srcptr, mp_exp_t, mpfr_rnd_t)); + mpfr_set_z_2exp _MPFR_PROTO ((mpfr_ptr, mpz_srcptr, mp_exp_t, mpfr_rnd_t)); __MPFR_DECLSPEC void mpfr_set_nan _MPFR_PROTO ((mpfr_ptr)); __MPFR_DECLSPEC void mpfr_set_inf _MPFR_PROTO ((mpfr_ptr, int)); __MPFR_DECLSPEC void mpfr_set_zero _MPFR_PROTO ((mpfr_ptr, int)); @@ -348,7 +348,7 @@ __MPFR_DECLSPEC intmax_t mpfr_get_sj _MPFR_PROTO ((mpfr_srcptr, mpfr_rnd_t)); __MPFR_DECLSPEC uintmax_t mpfr_get_uj _MPFR_PROTO ((mpfr_srcptr, mpfr_rnd_t)); #endif -__MPFR_DECLSPEC mp_exp_t mpfr_get_z_exp _MPFR_PROTO ((mpz_ptr, mpfr_srcptr)); +__MPFR_DECLSPEC mp_exp_t mpfr_get_z_2exp _MPFR_PROTO ((mpz_ptr, mpfr_srcptr)); __MPFR_DECLSPEC float mpfr_get_flt _MPFR_PROTO ((mpfr_srcptr, mpfr_rnd_t)); __MPFR_DECLSPEC double mpfr_get_d _MPFR_PROTO ((mpfr_srcptr, mpfr_rnd_t)); #ifdef MPFR_WANT_DECIMAL_FLOATS @@ -642,6 +642,7 @@ __MPFR_DECLSPEC int mpfr_jn _MPFR_PROTO ((mpfr_ptr, long, mpfr_srcptr, mpfr_rnd_t)); __MPFR_DECLSPEC int mpfr_y0 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t)); __MPFR_DECLSPEC int mpfr_y1 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t)); +__MPFR_DECLSPEC int mpfr_Ai1 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t)); __MPFR_DECLSPEC int mpfr_yn _MPFR_PROTO ((mpfr_ptr, long, mpfr_srcptr, mpfr_rnd_t)); @@ -1104,7 +1104,7 @@ MPFR can work with it. @deftypefunx int mpfr_set_si_2exp (mpfr_t @var{rop}, long int @var{op}, mp_exp_t @var{e}, mpfr_rnd_t @var{rnd}) @deftypefunx int mpfr_set_uj_2exp (mpfr_t @var{rop}, uintmax_t @var{op}, intmax_t @var{e}, mpfr_rnd_t @var{rnd}) @deftypefunx int mpfr_set_sj_2exp (mpfr_t @var{rop}, intmax_t @var{op}, intmax_t @var{e}, mpfr_rnd_t @var{rnd}) -@deftypefunx int mpfr_set_z_exp (mpfr_t @var{rop}, mpz_t @var{op}, mp_exp_t @var{e}, mpfr_rnd_t @var{rnd}) +@deftypefunx int mpfr_set_z_2exp (mpfr_t @var{rop}, mpz_t @var{op}, mp_exp_t @var{e}, mpfr_rnd_t @var{rnd}) Set the value of @var{rop} from @m{@var{op} \times 2^e, @var{op} multiplied by two to the power @var{e}}, rounded toward the given direction @var{rnd}. Note that the input 0 is converted to +0. @@ -1252,21 +1252,6 @@ The @code{mpfr_get_decimal64} function is built only under some conditions: see the documentation of @code{mpfr_set_decimal64}. @end deftypefun -@deftypefun double mpfr_get_d_2exp (long *@var{exp}, mpfr_t @var{op}, mpfr_rnd_t @var{rnd}) -@deftypefunx {long double} mpfr_get_ld_2exp (long *@var{exp}, mpfr_t @var{op}, mpfr_rnd_t @var{rnd}) -Return @var{d} and set @var{exp} such that @math{0.5@le{}@GMPabs{@var{d}}<1} -and @m{@var{d}\times 2^{exp}, @var{d} times 2 raised to @var{exp}} equals -@var{op} rounded to double (resp.@: long double) -precision, using the given rounding mode. -@comment See ISO C standard, frexp function. -If @var{op} is zero, then a zero of the same sign (or an unsigned zero, -if the implementation does not have signed zeros) is returned, and -@var{exp} is set to 0. -If @var{op} is NaN or an infinity, then the corresponding double precision -(resp.@: long-double precision) -value is returned, and @var{exp} is undefined. -@end deftypefun - @deftypefun long mpfr_get_si (mpfr_t @var{op}, mpfr_rnd_t @var{rnd}) @deftypefunx {unsigned long} mpfr_get_ui (mpfr_t @var{op}, mpfr_rnd_t @var{rnd}) @deftypefunx intmax_t mpfr_get_sj (mpfr_t @var{op}, mpfr_rnd_t @var{rnd}) @@ -1282,7 +1267,22 @@ See also @code{mpfr_fits_slong_p}, @code{mpfr_fits_ulong_p}, @code{mpfr_fits_intmax_p} and @code{mpfr_fits_uintmax_p}. @end deftypefun -@deftypefun mp_exp_t mpfr_get_z_exp (mpz_t @var{rop}, mpfr_t @var{op}) +@deftypefun double mpfr_get_d_2exp (long *@var{exp}, mpfr_t @var{op}, mpfr_rnd_t @var{rnd}) +@deftypefunx {long double} mpfr_get_ld_2exp (long *@var{exp}, mpfr_t @var{op}, mpfr_rnd_t @var{rnd}) +Return @var{d} and set @var{exp} such that @math{0.5@le{}@GMPabs{@var{d}}<1} +and @m{@var{d}\times 2^{exp}, @var{d} times 2 raised to @var{exp}} equals +@var{op} rounded to double (resp.@: long double) +precision, using the given rounding mode. +@comment See ISO C standard, frexp function. +If @var{op} is zero, then a zero of the same sign (or an unsigned zero, +if the implementation does not have signed zeros) is returned, and +@var{exp} is set to 0. +If @var{op} is NaN or an infinity, then the corresponding double precision +(resp.@: long-double precision) +value is returned, and @var{exp} is undefined. +@end deftypefun + +@deftypefun mp_exp_t mpfr_get_z_2exp (mpz_t @var{rop}, mpfr_t @var{op}) Put the scaled significand of @var{op} (regarded as an integer, with the precision of @var{op}) into @var{rop}, and return the exponent @var{exp} (which may be outside the current exponent range) such that @var{op} @@ -50,7 +50,7 @@ mpfr_pow_is_exact (mpfr_ptr z, mpfr_srcptr x, mpfr_srcptr y, /* compute d such that y = c*2^d with c odd integer */ mpz_init (c); - d = mpfr_get_z_exp (c, y); + d = mpfr_get_z_2exp (c, y); i = mpz_scan1 (c, 0); mpz_fdiv_q_2exp (c, c, i); d += i; @@ -60,7 +60,7 @@ mpfr_pow_is_exact (mpfr_ptr z, mpfr_srcptr x, mpfr_srcptr y, /* Compute a,b such that x=a*2^b */ mpz_init (a); - b = mpfr_get_z_exp (a, x); + b = mpfr_get_z_2exp (a, x); i = mpz_scan1 (a, 0); mpz_fdiv_q_2exp (a, a, i); b += i; @@ -87,8 +87,8 @@ mpfr_rem1 (mpfr_ptr rem, long *quo, mpfr_rnd_t rnd_q, mpz_init (my); mpz_init (r); - ex = mpfr_get_z_exp (mx, x); /* x = mx*2^ex */ - ey = mpfr_get_z_exp (my, y); /* y = my*2^ey */ + ex = mpfr_get_z_2exp (mx, x); /* x = mx*2^ex */ + ey = mpfr_get_z_2exp (my, y); /* y = my*2^ey */ /* to get rid of sign problems, we compute it separately: quo(-x,-y) = quo(x,y), rem(-x,-y) = -rem(x,y) @@ -124,7 +124,7 @@ mpfr_root (mpfr_ptr y, mpfr_srcptr x, unsigned long k, mpfr_rnd_t rnd_mode) MPFR_SAVE_EXPO_MARK (expo); mpz_init (m); - e = mpfr_get_z_exp (m, x); /* x = m * 2^e */ + e = mpfr_get_z_2exp (m, x); /* x = m * 2^e */ if ((negative = MPFR_IS_NEG(x))) mpz_neg (m, m); r = e % (mp_exp_t) k; @@ -26,5 +26,5 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., int mpfr_set_z (mpfr_ptr f, mpz_srcptr z, mpfr_rnd_t rnd_mode) { - return mpfr_set_z_exp (f, z, 0, rnd_mode); + return mpfr_set_z_2exp (f, z, 0, rnd_mode); } diff --git a/set_z_exp.c b/set_z_exp.c index d22937174..ea238c629 100644 --- a/set_z_exp.c +++ b/set_z_exp.c @@ -1,5 +1,5 @@ -/* mpfr_set_z_exp -- set a floating-point number from a multiple-precision - integer and an exponent +/* mpfr_set_z_2exp -- set a floating-point number from a multiple-precision + integer and an exponent Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. Contributed by the Arenaire and Cacao projects, INRIA. @@ -26,7 +26,7 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., /* set f to the integer z multiplied by 2^e */ int -mpfr_set_z_exp (mpfr_ptr f, mpz_srcptr z, mp_exp_t e, mpfr_rnd_t rnd_mode) +mpfr_set_z_2exp (mpfr_ptr f, mpz_srcptr z, mp_exp_t e, mpfr_rnd_t rnd_mode) { mp_size_t fn, zn, dif, en; int k, sign_z, inex; @@ -485,7 +485,7 @@ sincos_aux (mpfr_t s, mpfr_t c, mpfr_srcptr x, mpfr_rnd_t rnd_mode) { if (sh > prec_s / 2) /* sin(x) = x + O(x^3), cos(x) = 1 + O(x^2) */ { - l2 = -mpfr_get_z_exp (S2, x2); /* S2/2^l2 = x2 */ + l2 = -mpfr_get_z_2exp (S2, x2); /* S2/2^l2 = x2 */ l2 += sh - 1; mpz_set_ui (Q2, 1); mpz_set_ui (C2, 1); diff --git a/tests/tset_z_exp.c b/tests/tset_z_exp.c index 7dcc0093d..d2526bb08 100644 --- a/tests/tset_z_exp.c +++ b/tests/tset_z_exp.c @@ -1,4 +1,4 @@ -/* Test file for mpfr_set_z_exp. +/* Test file for mpfr_set_z_2exp. Copyright 1999, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. Contributed by the Arenaire and Cacao projects, INRIA. @@ -48,10 +48,10 @@ check0 (void) for(r = 0; r < MPFR_RND_MAX; r++) { e = randexp (); - inexact = mpfr_set_z_exp (x, y, e, (mpfr_rnd_t) r); + inexact = mpfr_set_z_2exp (x, y, e, (mpfr_rnd_t) r); if (!MPFR_IS_ZERO(x) || !MPFR_IS_POS(x) || inexact) { - printf ("mpfr_set_z_exp(x,0,e) failed for e=%ld, rnd=%s\n", e, + printf ("mpfr_set_z_2exp(x,0,e) failed for e=%ld, rnd=%s\n", e, mpfr_print_rnd_mode ((mpfr_rnd_t) r)); exit (1); } @@ -75,11 +75,11 @@ check (long i, mpfr_rnd_t rnd) mpz_init (z); mpz_set_ui (z, i); e = randexp (); - mpfr_set_z_exp (f, z, e, rnd); + mpfr_set_z_2exp (f, z, e, rnd); mpfr_div_2si (f, f, e, rnd); if (mpfr_get_si (f, MPFR_RNDZ) != i) { - printf ("Error in mpfr_set_z_exp for i=%ld e=%ld rnd_mode=%d\n", + printf ("Error in mpfr_set_z_2exp for i=%ld e=%ld rnd_mode=%d\n", i, e, rnd); printf ("expected %ld\n", i); mpfr_printf ("got %Re\n", f); |