diff options
author | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2004-01-22 22:30:52 +0000 |
---|---|---|
committer | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2004-01-22 22:30:52 +0000 |
commit | 031deac645662aea8a72a5ed0c0bf148e609e681 (patch) | |
tree | 07c68b885a0c39a228ca4b0f7f901a9117f85a9f /erf.c | |
parent | 039c1c0135bac8353d17020543fe8b27f3b1937e (diff) | |
download | mpfr-031deac645662aea8a72a5ed0c0bf148e609e681.tar.gz |
added several hard-coded tests (and fixed bugs found)
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2644 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'erf.c')
-rw-r--r-- | erf.c | 29 |
1 files changed, 8 insertions, 21 deletions
@@ -1,6 +1,6 @@ /* mpfr_erf -- error function of a floating-point number -Copyright 2001, 2003 Free Software Foundation, Inc. +Copyright 2001, 2003, 2004 Free Software Foundation, Inc. Contributed by Ludovic Meunier and Paul Zimmermann. This file is part of the MPFR Library. @@ -65,17 +65,7 @@ mpfr_erf (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) xf = mpfr_get_d (x, GMP_RNDN); xf = xf * xf; /* xf ~ x^2 */ - if (MPFR_IS_POS_SIGN(sign_x)) - rnd2 = rnd_mode; - else - { - if (rnd_mode == GMP_RNDU) - rnd2 = GMP_RNDD; - else if (rnd_mode == GMP_RNDD) - rnd2 = GMP_RNDU; - else - rnd2 = rnd_mode; - } + rnd2 = MPFR_IS_POS_SIGN(sign_x) ? rnd_mode : MPFR_INVERT_RND(rnd_mode); /* use expansion at x=0 when e*x^2 <= n (target precision) otherwise use asymptotic expansion */ @@ -92,21 +82,18 @@ mpfr_erf (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) mpfr_setmax (y, 0); inex = -1; } + if (MPFR_IS_NEG_SIGN(sign_x)) + { + MPFR_CHANGE_SIGN (y); + inex = -inex; + } } else /* use Taylor */ { inex = mpfr_erf_0 (y, x, rnd2); } - if (MPFR_IS_NEG_SIGN(sign_x)) - { - MPFR_CHANGE_SIGN (y); - return - inex; - } - else - { - return inex; - } + return inex; } /* return x*2^e */ |