summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2017-02-27 12:07:15 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2017-02-27 12:07:15 +0000
commit0952ebb85ee4acb36a3c9f9b2ca6f4d9ccf1e09f (patch)
treecbfd5db4129da1b5d042293f1bde1fc7cf6e46d6 /src
parent84a0f98998e77137bd4dfa1209426d77b3aefb64 (diff)
downloadmpfr-0952ebb85ee4acb36a3c9f9b2ca6f4d9ccf1e09f.tar.gz
[src/Makefile.am] new file odd_p.c
[src/beta.c] fixed bug [src/mpfr-impl.h] renamed mpfr_is_odd into mpfr_odd_p [src/pow.c] moved mpfr_is_odd (renamed mpfr_odd_p) into separate file git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@11362 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/beta.c5
-rw-r--r--src/mpfr-impl.h2
-rw-r--r--src/pow.c61
4 files changed, 11 insertions, 59 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 87ec65187..c002950b6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -60,7 +60,7 @@ scale2.c set_z_exp.c ai.c gammaonethird.c ieee_floats.h \
grandom.c fpif.c set_float128.c get_float128.c rndna.c nrandom.c \
random_deviate.h random_deviate.c erandom.c mpfr-mini-gmp.c \
mpfr-mini-gmp.h fmma.c log_ui.c gamma_inc.c ubf.c invert_limb.h \
-invsqrt_limb.h beta.c
+invsqrt_limb.h beta.c odd_p.c
libmpfr_la_LIBADD = @LIBOBJS@
diff --git a/src/beta.c b/src/beta.c
index 87808af70..1471812cb 100644
--- a/src/beta.c
+++ b/src/beta.c
@@ -109,8 +109,7 @@ mpfr_beta (mpfr_ptr r, mpfr_srcptr z, mpfr_srcptr w, mpfr_rnd_t rnd_mode)
else
{
MPFR_SET_ZERO(r);
- /* FIXME: w is infinite. This does not make sense! */
- if (mpfr_is_odd (w))
+ if (mpfr_odd_p (z))
MPFR_SET_NEG(r);
else
MPFR_SET_POS(r);
@@ -160,7 +159,7 @@ mpfr_beta (mpfr_ptr r, mpfr_srcptr z, mpfr_srcptr w, mpfr_rnd_t rnd_mode)
MPFR_ASSERTN(inex == 0);
inex = mpfr_ui_sub (z_plus_w, 1, z_plus_w, MPFR_RNDN);
MPFR_ASSERTN(inex == 0);
- if (mpfr_is_odd (z))
+ if (mpfr_odd_p (z))
{
inex = -mpfr_beta (r, z, z_plus_w, MPFR_INVERT_RND (rnd_mode));
MPFR_CHANGE_SIGN(r);
diff --git a/src/mpfr-impl.h b/src/mpfr-impl.h
index 96aa639aa..61cb801ab 100644
--- a/src/mpfr-impl.h
+++ b/src/mpfr-impl.h
@@ -2210,7 +2210,7 @@ __MPFR_DECLSPEC void mpfr_mpz_init (mpz_ptr);
__MPFR_DECLSPEC void mpfr_mpz_init2 (mpz_t, mp_bitcnt_t);
__MPFR_DECLSPEC void mpfr_mpz_clear (mpz_ptr);
-__MPFR_DECLSPEC int mpfr_is_odd (mpfr_srcptr);
+__MPFR_DECLSPEC int mpfr_odd_p (mpfr_srcptr);
#ifdef _MPFR_H_HAVE_VA_LIST
/* Declared only if <stdarg.h> has been included. */
diff --git a/src/pow.c b/src/pow.c
index b3cbcd2c0..6d5c05f96 100644
--- a/src/pow.c
+++ b/src/pow.c
@@ -107,53 +107,6 @@ mpfr_pow_is_exact (mpfr_ptr z, mpfr_srcptr x, mpfr_srcptr y,
return res;
}
-/* Return 1 if y is an odd integer, 0 otherwise. */
-int
-mpfr_is_odd (mpfr_srcptr y)
-{
- mpfr_exp_t expo;
- mpfr_prec_t prec;
- mp_size_t yn;
- mp_limb_t *yp;
-
- /* NAN, INF or ZERO are not allowed */
- MPFR_ASSERTD (!MPFR_IS_SINGULAR (y));
-
- expo = MPFR_GET_EXP (y);
- if (expo <= 0)
- return 0; /* |y| < 1 and not 0 */
-
- prec = MPFR_PREC(y);
- if ((mpfr_prec_t) expo > prec)
- return 0; /* y is a multiple of 2^(expo-prec), thus not odd */
-
- /* 0 < expo <= prec:
- y = 1xxxxxxxxxt.zzzzzzzzzzzzzzzzzz[000]
- expo bits (prec-expo) bits
-
- We have to check that:
- (a) the bit 't' is set
- (b) all the 'z' bits are zero
- */
-
- prec = MPFR_PREC2LIMBS (prec) * GMP_NUMB_BITS - expo;
- /* number of z+0 bits */
-
- yn = prec / GMP_NUMB_BITS;
- MPFR_ASSERTN(yn >= 0);
- /* yn is the index of limb containing the 't' bit */
-
- yp = MPFR_MANT(y);
- /* if expo is a multiple of GMP_NUMB_BITS, t is bit 0 */
- if (expo % GMP_NUMB_BITS == 0 ? (yp[yn] & 1) == 0
- : yp[yn] << ((expo % GMP_NUMB_BITS) - 1) != MPFR_LIMB_HIGHBIT)
- return 0;
- while (--yn >= 0)
- if (yp[yn] != 0)
- return 0;
- return 1;
-}
-
/* Assumes that the exponent range has already been extended and if y is
an integer, then the result is not exact in unbounded exponent range.
If x < 0, assumes y is an integer.
@@ -191,7 +144,7 @@ mpfr_pow_general (mpfr_ptr z, mpfr_srcptr x, mpfr_srcptr y,
if (MPFR_IS_NEG (x))
{
MPFR_ASSERTD (y_is_integer);
- if (mpfr_is_odd (y))
+ if (mpfr_odd_p (y))
{
neg_result = 1;
rnd_mode = MPFR_INVERT_RND (rnd_mode);
@@ -505,7 +458,7 @@ mpfr_pow (mpfr_ptr z, mpfr_srcptr x, mpfr_srcptr y, mpfr_rnd_t rnd_mode)
{
int negative;
/* Determine the sign now, in case y and z are the same object */
- negative = MPFR_IS_NEG (x) && mpfr_is_odd (y);
+ negative = MPFR_IS_NEG (x) && mpfr_odd_p (y);
if (MPFR_IS_POS (y))
MPFR_SET_INF (z);
else
@@ -521,7 +474,7 @@ mpfr_pow (mpfr_ptr z, mpfr_srcptr x, mpfr_srcptr y, mpfr_rnd_t rnd_mode)
int negative;
MPFR_ASSERTD (MPFR_IS_ZERO (x));
/* Determine the sign now, in case y and z are the same object */
- negative = MPFR_IS_NEG(x) && mpfr_is_odd (y);
+ negative = MPFR_IS_NEG(x) && mpfr_odd_p (y);
if (MPFR_IS_NEG (y))
{
MPFR_ASSERTD (! MPFR_IS_INF (y));
@@ -552,7 +505,7 @@ mpfr_pow (mpfr_ptr z, mpfr_srcptr x, mpfr_srcptr y, mpfr_rnd_t rnd_mode)
cmp_x_1 = mpfr_cmpabs (x, __gmpfr_one);
if (cmp_x_1 == 0)
- return mpfr_set_si (z, MPFR_IS_NEG (x) && mpfr_is_odd (y) ? -1 : 1, rnd_mode);
+ return mpfr_set_si (z, MPFR_IS_NEG (x) && mpfr_odd_p (y) ? -1 : 1, rnd_mode);
/* now we have:
(1) either x > 0
@@ -608,7 +561,7 @@ mpfr_pow (mpfr_ptr z, mpfr_srcptr x, mpfr_srcptr y, mpfr_rnd_t rnd_mode)
if (overflow)
{
MPFR_LOG_MSG (("early overflow detection\n", 0));
- negative = MPFR_IS_NEG (x) && mpfr_is_odd (y);
+ negative = MPFR_IS_NEG (x) && mpfr_odd_p (y);
return mpfr_overflow (z, rnd_mode, negative ? -1 : 1);
}
}
@@ -651,7 +604,7 @@ mpfr_pow (mpfr_ptr z, mpfr_srcptr x, mpfr_srcptr y, mpfr_rnd_t rnd_mode)
MPFR_LOG_MSG (("early underflow detection\n", 0));
return mpfr_underflow (z,
rnd_mode == MPFR_RNDN ? MPFR_RNDZ : rnd_mode,
- MPFR_IS_NEG (x) && mpfr_is_odd (y) ? -1 : 1);
+ MPFR_IS_NEG (x) && mpfr_odd_p (y) ? -1 : 1);
}
}
@@ -701,7 +654,7 @@ mpfr_pow (mpfr_ptr z, mpfr_srcptr x, mpfr_srcptr y, mpfr_rnd_t rnd_mode)
MPFR_CLEAR_FLAGS ();
inexact = mpfr_exp2 (z, tmp, rnd_mode);
mpfr_clear (tmp);
- if (sgnx < 0 && mpfr_is_odd (y))
+ if (sgnx < 0 && mpfr_odd_p (y))
{
mpfr_neg (z, z, rnd_mode);
inexact = -inexact;