summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cbrt.c2
-rw-r--r--const_euler.c4
-rw-r--r--const_log2.c6
-rw-r--r--cos.c12
-rw-r--r--exp3.c4
-rw-r--r--exp_2.c12
-rw-r--r--get_z.c2
-rw-r--r--li2.c8
-rw-r--r--lngamma.c8
-rw-r--r--pow.c4
-rw-r--r--rem1.c8
-rw-r--r--root.c2
-rw-r--r--tests/mpf_compat.h2
-rw-r--r--urandomb.c2
-rw-r--r--zeta_ui.c6
15 files changed, 41 insertions, 41 deletions
diff --git a/cbrt.c b/cbrt.c
index 6402ef1a8..2d75610bc 100644
--- a/cbrt.c
+++ b/cbrt.c
@@ -115,7 +115,7 @@ mpfr_cbrt (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd_mode)
if (sh > 0) /* we have to flush to 0 the last sh bits from m */
{
inexact = inexact || ((mp_exp_t) mpz_scan1 (m, 0) < sh);
- mpz_div_2exp (m, m, sh);
+ mpz_fdiv_q_2exp (m, m, sh);
e += 3 * sh;
}
diff --git a/const_euler.c b/const_euler.c
index 58914cdb8..41b5fb7eb 100644
--- a/const_euler.c
+++ b/const_euler.c
@@ -190,7 +190,7 @@ mpfr_const_euler_R (mpfr_t x, unsigned long n)
for (k = 1; k <= n; k++)
{
mpz_mul_ui (a, a, k);
- mpz_div_ui (a, a, n);
+ mpz_fdiv_q_ui (a, a, n);
/* the error e(k) on a is e(k) <= 1 + k/n*e(k-1) with e(0)=0,
i.e. e(k) <= k */
if (k % 2)
@@ -199,7 +199,7 @@ mpfr_const_euler_R (mpfr_t x, unsigned long n)
mpz_add (s, s, a);
}
/* the error on s is at most 1+2+...+n = n*(n+1)/2 */
- mpz_div_ui (s, s, n); /* err <= 1 + (n+1)/2 */
+ mpz_fdiv_q_ui (s, s, n); /* err <= 1 + (n+1)/2 */
MPFR_ASSERTN (MPFR_PREC(x) >= mpz_sizeinbase(s, 2));
mpfr_set_z (x, s, MPFR_RNDD); /* exact */
mpfr_div_2ui (x, x, m, MPFR_RNDD);
diff --git a/const_log2.c b/const_log2.c
index 8a2763e94..c642867b5 100644
--- a/const_log2.c
+++ b/const_log2.c
@@ -92,10 +92,10 @@ S (mpz_t *T, mpz_t *P, mpz_t *Q, unsigned long n1, unsigned long n2, int need_P)
/* now v = min(val(T), val(Q), val(P)) */
if (v > 0)
{
- mpz_div_2exp (T[0], T[0], v);
- mpz_div_2exp (Q[0], Q[0], v);
+ mpz_fdiv_q_2exp (T[0], T[0], v);
+ mpz_fdiv_q_2exp (Q[0], Q[0], v);
if (need_P)
- mpz_div_2exp (P[0], P[0], v);
+ mpz_fdiv_q_2exp (P[0], P[0], v);
}
}
}
diff --git a/cos.c b/cos.c
index 43b06e54f..cd4d6acd1 100644
--- a/cos.c
+++ b/cos.c
@@ -57,7 +57,7 @@ mpfr_cos2_aux (mpfr_ptr f, mpfr_srcptr r)
/* remove trailing zeroes */
l = mpz_scan1 (x, 0);
ex += l;
- mpz_div_2exp (x, x, l);
+ mpz_fdiv_q_2exp (x, x, l);
/* since |r| < 1, r = x*2^ex, and x is an integer, necessarily ex < 0 */
@@ -77,19 +77,19 @@ mpfr_cos2_aux (mpfr_ptr f, mpfr_srcptr r)
if (l > m)
{
l -= m;
- mpz_div_2exp (x, x, l);
+ mpz_fdiv_q_2exp (x, x, l);
ex += l;
}
/* multiply t by r */
mpz_mul (t, t, x);
- mpz_div_2exp (t, t, -ex);
+ mpz_fdiv_q_2exp (t, t, -ex);
/* divide t by i*(i+1) */
if (i < maxi)
- mpz_div_ui (t, t, i * (i + 1));
+ mpz_fdiv_q_ui (t, t, i * (i + 1));
else
{
- mpz_div_ui (t, t, i);
- mpz_div_ui (t, t, i + 1);
+ mpz_fdiv_q_ui (t, t, i);
+ mpz_fdiv_q_ui (t, t, i + 1);
}
/* if m is the (current) number of bits of t, we can consider that
all operations on t so far had precision >= m, so we can prove
diff --git a/exp3.c b/exp3.c
index 4fa3ca598..51f1c8f2c 100644
--- a/exp3.c
+++ b/exp3.c
@@ -130,7 +130,7 @@ mpfr_exp_rational (mpfr_ptr y, mpz_ptr p, long r, int m,
diff = (mp_exp_t) prec_i_have - 2 * (mp_exp_t) precy;
expo = diff;
if (diff >= 0)
- mpz_div_2exp (S[0], S[0], diff);
+ mpz_fdiv_q_2exp (S[0], S[0], diff);
else
mpz_mul_2exp (S[0], S[0], -diff);
@@ -138,7 +138,7 @@ mpfr_exp_rational (mpfr_ptr y, mpz_ptr p, long r, int m,
diff = (mp_exp_t) prec_i_have - (mp_prec_t) precy;
expo -= diff;
if (diff > 0)
- mpz_div_2exp (Q[0], Q[0], diff);
+ mpz_fdiv_q_2exp (Q[0], Q[0], diff);
else
mpz_mul_2exp (Q[0], Q[0], -diff);
diff --git a/exp_2.c b/exp_2.c
index 1cb2b4409..a4960804d 100644
--- a/exp_2.c
+++ b/exp_2.c
@@ -51,7 +51,7 @@ mpz_normalize (mpz_t rop, mpz_t z, mp_exp_t q)
MPFR_ASSERTD (k == (mpfr_uexp_t) k);
if (q < 0 || (mpfr_uexp_t) k > (mpfr_uexp_t) q)
{
- mpz_div_2exp(rop, z, (unsigned long) ((mpfr_uexp_t) k - q));
+ mpz_fdiv_q_2exp (rop, z, (unsigned long) ((mpfr_uexp_t) k - q));
return (mp_exp_t) k - q;
}
if (MPFR_UNLIKELY(rop != z))
@@ -67,7 +67,7 @@ static mp_exp_t
mpz_normalize2 (mpz_t rop, mpz_t z, mp_exp_t expz, mp_exp_t target)
{
if (target > expz)
- mpz_div_2exp(rop, z, target-expz);
+ mpz_fdiv_q_2exp (rop, z, target-expz);
else
mpz_mul_2exp(rop, z, expz-target);
return target;
@@ -280,7 +280,7 @@ mpfr_exp2_aux (mpz_t s, mpfr_srcptr r, mp_prec_t q, mp_exp_t *exps)
dif = *exps + sbit - expt - tbit;
/* truncates the bits of t which are < ulp(s) = 2^(1-q) */
expt += mpz_normalize(t, t, (mp_exp_t) q-dif); /* error at most 2^(1-q) */
- mpz_div_ui(t, t, l); /* error at most 2^(1-q) */
+ mpz_fdiv_q_ui (t, t, l); /* error at most 2^(1-q) */
/* the error wrt t^l/l! is here at most 3*l*ulp(s) */
MPFR_ASSERTD (expt == *exps);
if (mpz_sgn (t) == 0)
@@ -338,12 +338,12 @@ mpfr_exp2_aux2 (mpz_t s, mpfr_srcptr r, mp_prec_t q, mp_exp_t *exps)
expR[1] = mpfr_get_z_exp(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_div_2exp(R[2], t, q-1); /* err(R[2]) <= 3 ulps */
+ mpz_fdiv_q_2exp (R[2], t, q-1); /* err(R[2]) <= 3 ulps */
expR[2] = 1-q;
for (i = 3 ; i <= m ; i++)
{
mpz_mul(t, R[i-1], R[1]); /* err(t) <= 2*i-2 */
- mpz_div_2exp(R[i], t, q-1); /* err(R[i]) <= 2*i-1 ulps */
+ mpz_fdiv_q_2exp (R[i], t, q-1); /* err(R[i]) <= 2*i-1 ulps */
expR[i] = 1-q;
}
mpz_set_ui (R[0], 1);
@@ -368,7 +368,7 @@ mpfr_exp2_aux2 (mpz_t s, mpfr_srcptr r, mp_prec_t q, mp_exp_t *exps)
using Horner's scheme */
for (i = m-1 ; i-- != 0 ; )
{
- mpz_div_ui (t, t, l+i+1); /* err(t) += 1 ulp */
+ mpz_fdiv_q_ui (t, t, l+i+1); /* err(t) += 1 ulp */
mpz_add (t, t, R[i]);
}
/* now err(t) <= (3m-2) ulps */
diff --git a/get_z.c b/get_z.c
index e7d5adb23..7f1ee7e6c 100644
--- a/get_z.c
+++ b/get_z.c
@@ -42,7 +42,7 @@ mpfr_get_z (mpz_ptr z, mpfr_srcptr f, mpfr_rnd_t rnd)
if (exp >= 0)
mpz_mul_2exp (z, z, exp);
else
- mpz_div_2exp (z, z, -exp);
+ mpz_fdiv_q_2exp (z, z, -exp);
mpfr_clear (r);
return inex;
diff --git a/li2.c b/li2.c
index b7984456d..ed3cd326d 100644
--- a/li2.c
+++ b/li2.c
@@ -57,7 +57,7 @@ bernoulli (mpz_t * b, unsigned long n)
mpz_mul_ui (t, t, 2 * n - 1);
mpz_mul_ui (t, t, 2 * n);
mpz_mul_ui (t, t, n);
- mpz_div_ui (t, t, 3); /* exact: t=binomial(2*n+1,2*k)*(2*n)!/(2*k+1)!
+ mpz_fdiv_q_ui (t, t, 3); /* exact: t=binomial(2*n+1,2*k)*(2*n)!/(2*k+1)!
for k=n-1 */
mpz_mul (b[n], t, b[n - 1]);
for (k = n - 1; k-- > 0;)
@@ -66,13 +66,13 @@ bernoulli (mpz_t * b, unsigned long n)
mpz_mul_ui (t, t, 2 * k + 2);
mpz_mul_ui (t, t, 2 * k + 2);
mpz_mul_ui (t, t, 2 * k + 3);
- mpz_div_ui (t, t, 2 * (n - k) + 1);
- mpz_div_ui (t, t, 2 * (n - k));
+ mpz_fdiv_q_ui (t, t, 2 * (n - k) + 1);
+ mpz_fdiv_q_ui (t, t, 2 * (n - k));
mpz_addmul (b[n], t, b[k]);
}
/* take into account C[1] */
mpz_mul_ui (t, t, 2 * n + 1);
- mpz_div_2exp (t, t, 1);
+ mpz_fdiv_q_2exp (t, t, 1);
mpz_sub (b[n], b[n], t);
mpz_neg (b[n], b[n]);
mpz_clear (t);
diff --git a/lngamma.c b/lngamma.c
index 527c8e18e..5361eb919 100644
--- a/lngamma.c
+++ b/lngamma.c
@@ -57,7 +57,7 @@ bernoulli (mpz_t *b, unsigned long n)
mpz_mul_ui (t, t, 2 * n - 1);
mpz_mul_ui (t, t, 2 * n);
mpz_mul_ui (t, t, n);
- mpz_div_ui (t, t, 3); /* exact: t=binomial(2*n+1,2*k)*(2*n)!/(2*k+1)!
+ mpz_fdiv_q_ui (t, t, 3); /* exact: t=binomial(2*n+1,2*k)*(2*n)!/(2*k+1)!
for k=n-1 */
mpz_mul (b[n], t, b[n-1]);
for (k = n - 1; k-- > 0;)
@@ -66,13 +66,13 @@ bernoulli (mpz_t *b, unsigned long n)
mpz_mul_ui (t, t, 2 * k + 2);
mpz_mul_ui (t, t, 2 * k + 2);
mpz_mul_ui (t, t, 2 * k + 3);
- mpz_div_ui (t, t, 2 * (n - k) + 1);
- mpz_div_ui (t, t, 2 * (n - k));
+ mpz_fdiv_q_ui (t, t, 2 * (n - k) + 1);
+ mpz_fdiv_q_ui (t, t, 2 * (n - k));
mpz_addmul (b[n], t, b[k]);
}
/* take into account C[1] */
mpz_mul_ui (t, t, 2 * n + 1);
- mpz_div_2exp (t, t, 1);
+ mpz_fdiv_q_2exp (t, t, 1);
mpz_sub (b[n], b[n], t);
mpz_neg (b[n], b[n]);
mpz_clear (t);
diff --git a/pow.c b/pow.c
index f72a17e0d..b4bb2c0c5 100644
--- a/pow.c
+++ b/pow.c
@@ -52,7 +52,7 @@ mpfr_pow_is_exact (mpfr_ptr z, mpfr_srcptr x, mpfr_srcptr y,
mpz_init (c);
d = mpfr_get_z_exp (c, y);
i = mpz_scan1 (c, 0);
- mpz_div_2exp (c, c, i);
+ mpz_fdiv_q_2exp (c, c, i);
d += i;
/* now y=c*2^d with c odd */
/* Since y is not an integer, d is necessarily < 0 */
@@ -62,7 +62,7 @@ mpfr_pow_is_exact (mpfr_ptr z, mpfr_srcptr x, mpfr_srcptr y,
mpz_init (a);
b = mpfr_get_z_exp (a, x);
i = mpz_scan1 (a, 0);
- mpz_div_2exp (a, a, i);
+ mpz_fdiv_q_2exp (a, a, i);
b += i;
/* now x=a*2^b with a is odd */
diff --git a/rem1.c b/rem1.c
index 92e56536f..d3c14ffb2 100644
--- a/rem1.c
+++ b/rem1.c
@@ -103,7 +103,7 @@ mpfr_rem1 (mpfr_ptr rem, long *quo, mpfr_rnd_t rnd_q,
{
unsigned long k = mpz_scan1 (my, 0);
ey += k;
- mpz_div_2exp (my, my, k);
+ mpz_fdiv_q_2exp (my, my, k);
}
if (ex <= ey)
@@ -149,7 +149,7 @@ mpfr_rem1 (mpfr_ptr rem, long *quo, mpfr_rnd_t rnd_q,
if (quo) /* now 0 <= r < 2^WANTED_BITS*Y */
{
- mpz_div_2exp (my, my, WANTED_BITS); /* back to Y */
+ mpz_fdiv_q_2exp (my, my, WANTED_BITS); /* back to Y */
mpz_tdiv_qr (mx, r, r, my);
/* oldr = mx*my + newr */
*quo = mpz_get_si (mx);
@@ -157,7 +157,7 @@ mpfr_rem1 (mpfr_ptr rem, long *quo, mpfr_rnd_t rnd_q,
}
else if (rnd_q == MPFR_RNDN) /* now 0 <= r < 2Y in the remainder case */
{
- mpz_div_2exp (my, my, 1); /* back to Y */
+ mpz_fdiv_q_2exp (my, my, 1); /* back to Y */
/* least significant bit of q */
q_is_odd = mpz_cmpabs (r, my) >= 0;
if (q_is_odd)
@@ -182,7 +182,7 @@ mpfr_rem1 (mpfr_ptr rem, long *quo, mpfr_rnd_t rnd_q,
at the mpn level */
mpz_mul_2exp (r, r, 1);
compare = mpz_cmpabs (r, my);
- mpz_div_2exp (r, r, 1);
+ mpz_fdiv_q_2exp (r, r, 1);
compare = ((compare > 0) ||
((rnd_q == MPFR_RNDN) && (compare == 0) && q_is_odd));
/* if compare != 0, we need to subtract my to r, and add 1 to quo */
diff --git a/root.c b/root.c
index e49bae002..975970a17 100644
--- a/root.c
+++ b/root.c
@@ -166,7 +166,7 @@ mpfr_root (mpfr_ptr y, mpfr_srcptr x, unsigned long k, mpfr_rnd_t rnd_mode)
if (sh > 0) /* we have to flush to 0 the last sh bits from m */
{
inexact = inexact || ((mp_exp_t) mpz_scan1 (m, 0) < sh);
- mpz_div_2exp (m, m, sh);
+ mpz_fdiv_q_2exp (m, m, sh);
e += k * sh;
}
diff --git a/tests/mpf_compat.h b/tests/mpf_compat.h
index 1564d0ee8..89c2d70a8 100644
--- a/tests/mpf_compat.h
+++ b/tests/mpf_compat.h
@@ -207,7 +207,7 @@ main ()
i = mpf_fits_ushort_p (x);
i = mpf_fits_sshort_p (x);
- gmp_randinit (state, GMP_RAND_ALG_LC, 128);
+ gmp_randinit_lc_2exp_size (state, 128);
mpf_urandomb (x, state, 10);
gmp_randclear (state);
diff --git a/urandomb.c b/urandomb.c
index 54b7c5efb..fe730087f 100644
--- a/urandomb.c
+++ b/urandomb.c
@@ -1,7 +1,7 @@
/* mpfr_urandomb (rop, state, nbits) -- Generate a uniform pseudorandom
real number between 0 (inclusive) and 1 (exclusive) of size NBITS,
using STATE as the random state previously initialized by a call to
- gmp_randinit().
+ gmp_randinit_lc_2exp_size().
Copyright 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
Contributed by the Arenaire and Cacao projects, INRIA.
diff --git a/zeta_ui.c b/zeta_ui.c
index 8c5a5fc28..3034807dc 100644
--- a/zeta_ui.c
+++ b/zeta_ui.c
@@ -179,7 +179,7 @@ mpfr_zeta_ui (mpfr_ptr z, unsigned long m, mpfr_rnd_t r)
mpz_mul_ui (t, t, k);
mpz_mul_ui (t, t, 2 * k - 1);
}
- mpz_div_2exp (t, t, 1);
+ mpz_fdiv_q_2exp (t, t, 1);
/* Warning: the test below assumes that an unsigned long
has no padding bits. */
if (n < 1UL << ((sizeof(unsigned long) * CHAR_BIT) / 2))
@@ -194,12 +194,12 @@ mpfr_zeta_ui (mpfr_ptr z, unsigned long m, mpfr_rnd_t r)
}
/* multiply by 1/(1-2^(1-m)) = 1 + 2^(1-m) + 2^(2-m) + ... */
- mpz_div_2exp (t, s, m - 1);
+ mpz_fdiv_q_2exp (t, s, m - 1);
do
{
err ++;
mpz_add (s, s, t);
- mpz_div_2exp (t, t, m - 1);
+ mpz_fdiv_q_2exp (t, t, m - 1);
}
while (mpz_cmp_ui (t, 0) > 0);