summaryrefslogtreecommitdiff
path: root/const_log2.c
diff options
context:
space:
mode:
authorpelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4>2004-04-21 12:36:30 +0000
committerpelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4>2004-04-21 12:36:30 +0000
commit208bfd1424477764d84b1a72d7c05489efae83a7 (patch)
tree458d0f78d626a9266f3c0de113557dc28bbf18e9 /const_log2.c
parent392bf02ed16af2d4838b79c397225aa1ff63efbe (diff)
downloadmpfr-208bfd1424477764d84b1a72d7c05489efae83a7.tar.gz
Add preliminary generic code to handle cached const.
Move const_pi, const_log2 to use this generic cache, which fix bugs of the previous implementation. const_euler is now cached too. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2876 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'const_log2.c')
-rw-r--r--const_log2.c28
1 files changed, 1 insertions, 27 deletions
diff --git a/const_log2.c b/const_log2.c
index 8cefe1ba8..e5e6c6137 100644
--- a/const_log2.c
+++ b/const_log2.c
@@ -23,10 +23,6 @@ MA 02111-1307, USA. */
#define MPFR_NEED_LONGLONG_H
#include "mpfr-impl.h"
-mpfr_t __mpfr_const_log2; /* stored value of log(2) */
-mp_prec_t __gmpfr_const_log2_prec = 0; /* precision of stored value */
-static mp_rnd_t __mpfr_const_log2_rnd; /* rounding mode of stored value */
-
static int mpfr_aux_log2 _MPFR_PROTO ((mpfr_ptr, mpz_srcptr, long, int));
static int mpfr_const_aux_log2 _MPFR_PROTO ((mpfr_ptr, mp_rnd_t));
@@ -128,25 +124,13 @@ mpfr_const_aux_log2 (mpfr_ptr mylog, mp_rnd_t rnd_mode)
Then 2^N*log(2)-S'(N) <= N-1+2/N <= N for N>=2.
*/
int
-mpfr_const_log2 (mpfr_ptr x, mp_rnd_t rnd_mode)
+(mpfr_const_log2) (mpfr_ptr x, mp_rnd_t rnd_mode)
{
mp_prec_t N, k, precx;
mpz_t s, t, u;
int inexact;
precx = MPFR_PREC(x);
- MPFR_CLEAR_FLAGS(x);
-
- /* has stored value enough precision ? */
- if (precx <= __gmpfr_const_log2_prec)
- {
- if ((rnd_mode == __mpfr_const_log2_rnd) ||
- mpfr_can_round (__mpfr_const_log2, __gmpfr_const_log2_prec - 1,
- __mpfr_const_log2_rnd, GMP_RNDZ, precx + (rnd_mode == GMP_RNDN)))
- {
- return mpfr_set (x, __mpfr_const_log2, rnd_mode);
- }
- }
/* need to recompute */
if (precx < LOG2_THRESHOLD) /* use nai"ve Taylor series evaluation */
@@ -178,15 +162,5 @@ mpfr_const_log2 (mpfr_ptr x, mp_rnd_t rnd_mode)
else /* use binary splitting method */
inexact = mpfr_const_aux_log2 (x, rnd_mode);
- /* store computed value */
- if (__gmpfr_const_log2_prec == 0)
- mpfr_init2 (__mpfr_const_log2, precx);
- else
- mpfr_set_prec (__mpfr_const_log2, precx);
-
- mpfr_set (__mpfr_const_log2, x, rnd_mode);
- __gmpfr_const_log2_prec = precx;
- __mpfr_const_log2_rnd = rnd_mode;
-
return inexact;
}