diff options
author | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2009-09-18 13:10:35 +0000 |
---|---|---|
committer | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2009-09-18 13:10:35 +0000 |
commit | 2dafe56e5c71211538eba3ab0dc58661ce09718c (patch) | |
tree | 690ec326b37f8b65e4f0938c5d4a3a1b41ba22e7 /sin.c | |
parent | a5765b637269cc7ab1c7225803e2de8cd2af6ca1 (diff) | |
download | mpfr-2dafe56e5c71211538eba3ab0dc58661ce09718c.tar.gz |
[sin.c,cos.c] use mpfr_sincos_fast when prec >= MPFR_SINCOS_THRESHOLD
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@6461 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'sin.c')
-rw-r--r-- | sin.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -23,6 +23,16 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., #define MPFR_NEED_LONGLONG_H #include "mpfr-impl.h" +static int +mpfr_sin_fast (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd_mode) +{ + int inex; + + inex = mpfr_sincos_fast (y, NULL, x, rnd_mode); + inex = inex & 3; /* 0: exact, 1: rounded up, 2: rounded down */ + return (inex == 2) ? -1 : inex; +} + int mpfr_sin (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd_mode) { @@ -62,6 +72,10 @@ mpfr_sin (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd_mode) /* Compute initial precision */ precy = MPFR_PREC (y); + + if (precy >= MPFR_SINCOS_THRESHOLD) + return mpfr_sin_fast (y, x, rnd_mode); + m = precy + MPFR_INT_CEIL_LOG2 (precy) + 13; expx = MPFR_GET_EXP (x); |