diff options
author | pelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4> | 2004-12-09 10:13:55 +0000 |
---|---|---|
committer | pelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4> | 2004-12-09 10:13:55 +0000 |
commit | fded832d73678419307c2e87e68e8737276b65c4 (patch) | |
tree | b8574f828d53be452df2cce06c7219e001f39b48 /cache.c | |
parent | a824f7ad7bc1fe409778f39947af2914f36f0cb6 (diff) | |
download | mpfr-fded832d73678419307c2e87e68e8737276b65c4.tar.gz |
Optimize mpfr_set4.
Inline rounding in mpfr_set4 and mpfr_cache
mpfr_set4 dosn't return MPFR_EVEN_INEX (It was undocumented before).
Fix problems with tests (Avoid mixing MPFR_EVEN_INEX and 1).
Add MPFR_RNDRAW_EVEN for rounding with MPFR_EVEN_INEX inexact support
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@3121 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'cache.c')
-rw-r--r-- | cache.c | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -47,7 +47,7 @@ mpfr_cache (mpfr_ptr dest, mpfr_cache_t cache, mp_rnd_t rnd) { mp_prec_t prec = MPFR_PREC (dest); mp_prec_t pold = MPFR_PREC (cache->x); - int inexact; + int inexact, sign; /* Check if the cache has been already filled */ if (MPFR_UNLIKELY(pold == 0)) @@ -71,8 +71,16 @@ mpfr_cache (mpfr_ptr dest, mpfr_cache_t cache, mp_rnd_t rnd) and abs(x-exact) <= ulp(x)/2 */ MPFR_ASSERTD (MPFR_IS_POS(cache->x)); /* TODO...*/ /* We must use nextbelow instead of sub_one_ulp, since we know - that the exact value is < 1/2ulp(x) (We want sub_demi_ulp(x)). */ - inexact = mpfr_set (dest, cache->x, rnd); + that the exact value is < 1/2ulp(x) (We want sub_demi_ulp(x)). + Can't use mpfr_set since we need the even flag. */ + sign = MPFR_SIGN (cache->x); + MPFR_SET_EXP (dest, MPFR_GET_EXP (cache->x)); + MPFR_SET_SIGN (dest, sign); + MPFR_RNDRAW_EVEN (inexact, dest, + MPFR_MANT (cache->x), MPFR_PREC (cache->x), rnd, sign, + if (MPFR_UNLIKELY ( ++MPFR_EXP (dest) > __gmpfr_emax)) + mpfr_set_overflow (dest, rnd, sign) ); + /* inexact = mpfr_set (dest, cache->x, rnd); */ if (MPFR_LIKELY(cache->inexact != 0)) { switch (rnd) |