diff options
72 files changed, 1428 insertions, 624 deletions
diff --git a/Makefile.in b/Makefile.in index b3a335505..3e77b5960 100644 --- a/Makefile.in +++ b/Makefile.in @@ -157,6 +157,7 @@ MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ MAKEINFO = @MAKEINFO@ MPFR_CFLAGS = @MPFR_CFLAGS@ +MPFR_LIBM = @MPFR_LIBM@ MPFR_LIBS = @MPFR_LIBS@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ diff --git a/cxx/Makefile.in b/cxx/Makefile.in index d4feedfe1..49fac5da7 100644 --- a/cxx/Makefile.in +++ b/cxx/Makefile.in @@ -127,6 +127,7 @@ MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ MAKEINFO = @MAKEINFO@ MPFR_CFLAGS = @MPFR_CFLAGS@ +MPFR_LIBM = @MPFR_LIBM@ MPFR_LIBS = @MPFR_LIBS@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ diff --git a/demos/Makefile.in b/demos/Makefile.in index 8b49e0a5b..6a73656a3 100644 --- a/demos/Makefile.in +++ b/demos/Makefile.in @@ -127,6 +127,7 @@ MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ MAKEINFO = @MAKEINFO@ MPFR_CFLAGS = @MPFR_CFLAGS@ +MPFR_LIBM = @MPFR_LIBM@ MPFR_LIBS = @MPFR_LIBS@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ diff --git a/demos/calc/Makefile.in b/demos/calc/Makefile.in index 2079e2207..086c87cad 100644 --- a/demos/calc/Makefile.in +++ b/demos/calc/Makefile.in @@ -127,6 +127,7 @@ MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ MAKEINFO = @MAKEINFO@ MPFR_CFLAGS = @MPFR_CFLAGS@ +MPFR_LIBM = @MPFR_LIBM@ MPFR_LIBS = @MPFR_LIBS@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ diff --git a/demos/expr/Makefile.in b/demos/expr/Makefile.in index ce4b5a712..52ae278d7 100644 --- a/demos/expr/Makefile.in +++ b/demos/expr/Makefile.in @@ -127,6 +127,7 @@ MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ MAKEINFO = @MAKEINFO@ MPFR_CFLAGS = @MPFR_CFLAGS@ +MPFR_LIBM = @MPFR_LIBM@ MPFR_LIBS = @MPFR_LIBS@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ diff --git a/mpbsd/Makefile.in b/mpbsd/Makefile.in index 4ebfff936..137dc6da2 100644 --- a/mpbsd/Makefile.in +++ b/mpbsd/Makefile.in @@ -127,6 +127,7 @@ MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ MAKEINFO = @MAKEINFO@ MPFR_CFLAGS = @MPFR_CFLAGS@ +MPFR_LIBM = @MPFR_LIBM@ MPFR_LIBS = @MPFR_LIBS@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ diff --git a/mpf/Makefile.in b/mpf/Makefile.in index 4c73d3fbe..ed0316c1c 100644 --- a/mpf/Makefile.in +++ b/mpf/Makefile.in @@ -128,6 +128,7 @@ MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ MAKEINFO = @MAKEINFO@ MPFR_CFLAGS = @MPFR_CFLAGS@ +MPFR_LIBM = @MPFR_LIBM@ MPFR_LIBS = @MPFR_LIBS@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ @@ -1,3 +1,25 @@ +Copyright 1999, 2001, 2002, 2003 Free Software Foundation. +Contributed by the Spaces project, INRIA Lorraine. + +This file is part of the MPFR Library. + +The MPFR Library is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at your +option) any later version. + +The MPFR Library is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with the MPFR Library; see the file COPYING.LIB. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +MA 02111-1307, USA. + +############################################################################## + Probably many bugs. Known bugs: diff --git a/mpfr/ChangeLog b/mpfr/ChangeLog index ed0be65d5..a4086901c 100644 --- a/mpfr/ChangeLog +++ b/mpfr/ChangeLog @@ -1,8 +1,3 @@ -2003-01-17 Torbjorn Granlund <tege@swox.com> - - * tests/tadd.c: Patch from Paul. - * tests/tests.c: Patch from Paul. - 2002-12-13 Vincent Lefevre <Vincent.Lefevre@loria.fr> * mpfr.texi: IEEE 754 / IEEE P754 -> IEEE 754-1985. diff --git a/mpfr/Makefile.in b/mpfr/Makefile.in index cb74e1e9c..3500fe00d 100644 --- a/mpfr/Makefile.in +++ b/mpfr/Makefile.in @@ -132,6 +132,7 @@ MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ MAKEINFO = @MAKEINFO@ MPFR_CFLAGS = @MPFR_CFLAGS@ +MPFR_LIBM = @MPFR_LIBM@ MPFR_LIBS = @MPFR_LIBS@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ @@ -1,3 +1,25 @@ +Copyright 2000, 2001, 2002, 2003 Free Software Foundation. +Contributed by the Spaces project, INRIA Lorraine. + +This file is part of the MPFR Library. + +The MPFR Library is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at your +option) any later version. + +The MPFR Library is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with the MPFR Library; see the file COPYING.LIB. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +MA 02111-1307, USA. + +############################################################################## + Changes from version 2001 to version 2.0.1: - new mathematical functions: acos, acosh, asin, asinh, atan, atanh, cosh, base-2 exponential and logarithm, base-10 logarithm, expm1, factorial, diff --git a/mpfr/README b/mpfr/README index 1325a2950..2180ce51a 100644 --- a/mpfr/README +++ b/mpfr/README @@ -1,3 +1,6 @@ +Copyright 2000, 2001, 2002, 2003 Free Software Foundation. +Contributed by the Spaces project, INRIA Lorraine. + This file is part of the MPFR Library. The MPFR Library is free software; you can redistribute it and/or modify it @@ -16,6 +19,7 @@ along with the MPFR Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +############################################################################## The MPFR distribution contains the following files: (This does not apply to code retrieved by CVS.) @@ -1,3 +1,26 @@ +Copyright 1999, 2000, 2001, 2002, 2003 Free Software Foundation. +Contributed by the Spaces project, INRIA Lorraine. + +This file is part of the MPFR Library. + +The MPFR Library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License (either version 2.1 +of the License, or, at your option, any later version) and the GNU General +Public License as published by the Free Software Foundation (most of MPFR is +under the former, some under the latter). + +The MPFR Library is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with the MPFR Library; see the file COPYING.LIB. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. + +############################################################################## + Documentation: - add a description of the algorithms used + proof of correctness @@ -60,8 +83,6 @@ Changes in existing functions: and @NaN@ instead of the possibly ambiguous Inf and NaN in bases > 10. Modify the other functions to make them consistent with this choice. Possibly accept other strings, like those accepted by strtod. -- implement ternary flag for mpfr_agm: result is exact when u=v, or u=0, - or v=0. New functions to implement: @@ -122,10 +143,7 @@ Miscellaneous: - problem when reading a float followed by a character, for example 1.5*x [from Fabrice.Rouillier@loria.fr, Mon, 04 Dec 2000] -- rewrite mpfr_set_str to use mpn_set_str. - (Torbjorn Granlund <tege@swox.com>, 30 Jan 2002) - -- mpfr_pow isn't completely specified (concerning signed zeros). +- use AC_CHECK_FUNCS for __setfpucw rather than grepping a header file. - rename (and rewrite) mpfr_isinteger to mpfr_integer_p. (Kevin Ryde, 05 Mar 2002) diff --git a/mpfr/acinclude.m4 b/mpfr/acinclude.m4 index 8e152dad1..5caa4e869 100644 --- a/mpfr/acinclude.m4 +++ b/mpfr/acinclude.m4 @@ -1,3 +1,31 @@ +dnl MPFR specific autoconf macros + +dnl Copyright 2000, 2002, 2003 Free Software Foundation. +dnl Contributed by the Spaces project, INRIA Lorraine. +dnl +dnl This file is part of the MPFR Library. +dnl +dnl The MPFR Library is free software; you can redistribute it and/or modify +dnl it under the terms of the GNU Lesser General Public License as published +dnl by the Free Software Foundation; either version 2.1 of the License, or (at +dnl your option) any later version. +dnl +dnl The MPFR Library is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +dnl License for more details. +dnl +dnl You should have received a copy of the GNU Lesser General Public License +dnl along with the MPFR Library; see the file COPYING.LIB. If not, write to +dnl the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +dnl MA 02111-1307, USA. + +dnl autoconf 2.50 is necessary because of the use of AH_VERBATIM, +dnl but it would be better to make the config file compatible with +dnl both autoconf 2.13 and autoconf 2.50. +dnl The following line allows the autoconf wrapper (when installed) +dnl to work as expected. +AC_PREREQ(2.50) AC_DEFUN(AC_MY_LIBS, [ @@ -47,11 +75,8 @@ dnl ------------------------------------------------------------ AC_DEFUN(MPFR_CONFIGS, [ -case $host in - *-*-solaris*) - LM9X="-lm9x" - ;; -esac +AC_REQUIRE([AC_OBJEXT]) +AC_REQUIRE([MPFR_CHECK_LIBM]) # CPU-dependent objects for the test programs case $host in @@ -94,25 +119,15 @@ AC_CHECK_HEADERS(sys/fpu.h) dnl Check for fesetround AC_CACHE_CHECK([for fesetround], mpfr_cv_have_fesetround, [ saved_LIBS="$LIBS" -LIBS="$LIBS $LM9X" +LIBS="$LIBS $MPFR_LIBM" AC_TRY_LINK([#include <fenv.h>], [fesetround(FE_TONEAREST);], mpfr_cv_have_fesetround=yes, mpfr_cv_have_fesetround=no) LIBS="$saved_LIBS" ]) if test "$mpfr_cv_have_fesetround" = "yes"; then - LIBS="$LIBS $LM9X" AC_DEFINE(MPFR_HAVE_FESETROUND,1,[Define if you have the `fesetround' function via the <fenv.h> header file.]) fi -dnl Check for isnan -AC_CACHE_CHECK([for isnan], mpfr_cv_have_isnan, [ -AC_TRY_LINK([#include <math.h>], [isnan(0.0);], - mpfr_cv_have_isnan=yes, mpfr_cv_have_isnan=no) -]) -if test "$mpfr_cv_have_isnan" = "yes"; then - AC_DEFINE(MPFR_HAVE_ISNAN,1,[Define if you have the `isnan' function via the <math.h> header file.]) -fi - dnl Check random functions AC_CHECK_FUNCS(lrand48) @@ -139,6 +154,8 @@ dnl the double-rounding problem (x86 processors still have to be set to the dnl IEEE-754 compatible rounding mode). if test -n "$GCC"; then AC_CACHE_CHECK([for gcc float-conversion bug], mpfr_cv_gcc_floatconv_bug, [ + saved_LIBS="$LIBS" + LIBS="$LIBS $MPFR_LIBM" AC_TRY_RUN([ #include <float.h> #ifdef MPFR_HAVE_FESETROUND @@ -165,6 +182,7 @@ int main() ], [mpfr_cv_gcc_floatconv_bug="no"], [mpfr_cv_gcc_floatconv_bug="yes, use -ffloat-store"], [mpfr_cv_gcc_floatconv_bug="cannot test, use -ffloat-store"]) + LIBS="$saved_LIBS" ]) if test "$mpfr_cv_gcc_floatconv_bug" != "no"; then CFLAGS="$CFLAGS -ffloat-store" @@ -233,7 +251,8 @@ dnl use DOUBLE macros when sizeof(double)==sizeof(long double). AC_DEFUN(MPFR_C_LONG_DOUBLE_FORMAT, [AC_REQUIRE([AC_PROG_CC]) AC_REQUIRE([AC_PROG_AWK]) -AC_CACHE_CHECK([format of `long double' floating point], +AC_REQUIRE([AC_OBJEXT]) +AC_CACHE_CHECK([format of \`long double' floating point], mpfr_cv_c_long_double_format, [mpfr_cv_c_long_double_format=unknown cat >conftest.c <<\EOF @@ -406,3 +425,37 @@ case $mpfr_cv_c_long_double_format in ;; esac ]) + + +dnl MPFR_CHECK_LIBM +dnl --------------- +dnl Determine a math library -lm to use. + +AC_DEFUN(MPFR_CHECK_LIBM, +[AC_REQUIRE([AC_CANONICAL_HOST]) +AC_SUBST(MPFR_LIBM,'') +case $host in + *-*-beos* | *-*-cygwin* | *-*-pw32*) + # According to libtool AC_CHECK_LIBM, these systems don't have libm + ;; + *-*-hpux*) + # -lM means something subtly different to -lm, SVID style error handling + # or something. FIXME: Why exactly do we want this? + AC_CHECK_LIB(M, main, MPFR_LIBM="-lM") + ;; + *-*-solaris*) + # On Solaris the math functions new in C99 are in -lm9x. + # FIXME: Do we need -lm9x as well as -lm, or just instead of? + AC_CHECK_LIB(m9x, main, MPFR_LIBM="-lm9x") + AC_CHECK_LIB(m, main, MPFR_LIBM="$MPFR_LIBM -lm") + ;; + *-ncr-sysv4.3*) + # FIXME: What does -lmw mean? Libtool AC_CHECK_LIBM does it this way. + AC_CHECK_LIB(mw, _mwvalidcheckl, MPFR_LIBM="-lmw") + AC_CHECK_LIB(m, main, MPFR_LIBM="$MPFR_LIBM -lm") + ;; + *) + AC_CHECK_LIB(m, main, MPFR_LIBM="-lm") + ;; +esac +]) diff --git a/mpfr/gamma.c b/mpfr/gamma.c index c92bf496a..9a4e456dd 100644 --- a/mpfr/gamma.c +++ b/mpfr/gamma.c @@ -1,6 +1,6 @@ /* mpfr_gamma -- gamma function -Copyright 2001, 2002 Free Software Foundation. +Copyright 2001, 2002, 2003 Free Software Foundation. This file is part of the MPFR Library, and was contributed by Mathieu Dutour. @@ -19,16 +19,16 @@ along with the MPFR Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#ifdef DEBUG #include <stdio.h> #include <stdlib.h> -#include <math.h> +#endif + #include "gmp.h" #include "gmp-impl.h" #include "mpfr.h" #include "mpfr-impl.h" -int mpfr_gamma _PROTO ((mpfr_ptr, mpfr_srcptr, mp_rnd_t)); - /* We use the reflection formula Gamma(1+t) Gamma(1-t) = - Pi t / sin(Pi (1 + t)) in order to treat the case x <= 1, @@ -48,13 +48,13 @@ mpfr_gamma (mpfr_ptr gamma, mpfr_srcptr x, mp_rnd_t rnd_mode) mpfr_t GammaTrial; mpfr_t tmp, tmp2; - int Prec; - int prec_gamma; - int prec_nec; + mp_prec_t Prec; + mp_prec_t prec_gamma; + mp_prec_t prec_nec; int good = 0; double C; - long A, N, estimated_cancel; - int realprec; + mp_prec_t A, N, estimated_cancel; + mp_prec_t realprec; int compared; int k; int sign; @@ -63,155 +63,158 @@ mpfr_gamma (mpfr_ptr gamma, mpfr_srcptr x, mp_rnd_t rnd_mode) if (MPFR_IS_NAN(x)) { MPFR_SET_NAN(gamma); - return 1; + MPFR_RET_NAN; } - if (!MPFR_NOTZERO(x)) + if (MPFR_IS_INF(x)) { - MPFR_SET_INF(gamma); - return 1; + if (MPFR_SIGN(x) < 0) + { + MPFR_SET_NAN(gamma); + MPFR_RET_NAN; + } + else + { + MPFR_CLEAR_NAN(gamma); + MPFR_SET_INF(gamma); + MPFR_SET_POS(gamma); + return 0; /* exact */ + } } - if (MPFR_IS_INF(x)) + if (MPFR_IS_ZERO(x)) { + MPFR_CLEAR_NAN(gamma); MPFR_SET_INF(gamma); - return 1; + MPFR_SET_SAME_SIGN(gamma, x); + return 0; /* exact */ } /* Set x_p=x if x> 1 else set x_p=2-x */ prec_gamma = MPFR_PREC (gamma); compared = mpfr_cmp_ui (x, 1); if (compared == 0) - { - mpfr_set_ui (gamma, 1, rnd_mode); - return 1; - } + return mpfr_set_ui (gamma, 1, rnd_mode); + realprec = prec_gamma + 10; mpfr_init2 (xp, 2); while (!good) { - /* Precision stuff */ - if (compared < 0) - { - prec_nec = 2+realprec; /* We will use the reflexion formula! */ - } - else - { - prec_nec = realprec; - } - C = (double)(((double) prec_nec)*CST-0.5); - A = (int)C; - N = A-1; + /* Precision stuff */ + prec_nec = compared < 0 ? + 2 + realprec /* We will use the reflexion formula! */ + : realprec; + C = (double)(((double) prec_nec)*CST-0.5); + A = (mp_prec_t) C; + N = A - 1; #ifdef DEBUG - printf("C=%u", (int)C); - printf(" A=%u", (int)A); - printf(" N=%u", (int)N); - printf("\n"); + printf("C=%u", (int)C); + printf(" A=%u", (int)A); + printf(" N=%u", (int)N); + printf("\n"); #endif - /* estimated_cancel is the amount of bit that will be flushed */ - estimated_cancel= (long) ceil(ecCST*A); - Prec = prec_nec + estimated_cancel+20; - - - mpfr_set_prec (xp, Prec); - if (compared < 0) - { - mpfr_ui_sub (xp, 1, x, GMP_RNDN); - } - else - { - mpfr_sub_ui (xp, x, 1, GMP_RNDN); - } - - /* Initialisation */ - mpfr_init2(tmp, Prec); - mpfr_init2(tmp2, Prec); - mpfr_init2(the_pi, Prec); - mpfr_init2(product, Prec); - mpfr_init2(GammaTrial, Prec); - - - mpfr_set_ui(GammaTrial, 0, GMP_RNDN); - sign=1; - for (k = 1; k<=N; k++) - { - mpfr_set_ui(tmp, A-k, GMP_RNDN); - mpfr_exp(product, tmp, GMP_RNDN); - mpfr_ui_pow_ui(tmp, A-k, k-1, GMP_RNDN); - mpfr_mul(product, product, tmp, GMP_RNDN); - mpfr_sqrt_ui(tmp, A-k, GMP_RNDN); - mpfr_mul(product, product, tmp, GMP_RNDN); - mpfr_fac_ui(tmp, k-1, GMP_RNDN); - mpfr_div(product, product, tmp, GMP_RNDN); - mpfr_add_ui(tmp, xp, k, GMP_RNDN); - mpfr_div(product, product, tmp, GMP_RNDN); - sign=-sign; - if (sign == 1) - { - mpfr_neg(product, product, GMP_RNDN); + /* estimated_cancel is the amount of bit that will be flushed */ + estimated_cancel= (mp_prec_t) (ecCST * (double) A + 1.0); + Prec = prec_nec + estimated_cancel + 20; + + mpfr_set_prec (xp, Prec); + if (compared < 0) + { + mpfr_ui_sub (xp, 1, x, GMP_RNDN); + } + else + { + mpfr_sub_ui (xp, x, 1, GMP_RNDN); + } + + /* Initialisation */ + mpfr_init2(tmp, Prec); + mpfr_init2(tmp2, Prec); + mpfr_init2(the_pi, Prec); + mpfr_init2(product, Prec); + mpfr_init2(GammaTrial, Prec); + + mpfr_set_ui(GammaTrial, 0, GMP_RNDN); + sign = 1; + for (k = 1; k <= N; k++) + { + mpfr_set_ui(tmp, A-k, GMP_RNDN); + mpfr_exp(product, tmp, GMP_RNDN); + mpfr_ui_pow_ui(tmp, A-k, k-1, GMP_RNDN); + mpfr_mul(product, product, tmp, GMP_RNDN); + mpfr_sqrt_ui(tmp, A-k, GMP_RNDN); + mpfr_mul(product, product, tmp, GMP_RNDN); + mpfr_fac_ui(tmp, k-1, GMP_RNDN); + mpfr_div(product, product, tmp, GMP_RNDN); + mpfr_add_ui(tmp, xp, k, GMP_RNDN); + mpfr_div(product, product, tmp, GMP_RNDN); + sign = -sign; + if (sign == 1) + { + mpfr_neg(product, product, GMP_RNDN); #ifdef DEBUG - /* printf(" k=%u", k); - printf("\n");*/ + /* printf(" k=%u", k); + printf("\n");*/ #endif - } - mpfr_add(GammaTrial, GammaTrial, product, GMP_RNDN); - } + } + mpfr_add(GammaTrial, GammaTrial, product, GMP_RNDN); + } #ifdef DEBUG - printf("GammaTrial ="); - mpfr_out_str (stdout, 10, 0, GammaTrial, GMP_RNDD); - printf ("\n"); + printf("GammaTrial ="); + mpfr_out_str (stdout, 10, 0, GammaTrial, GMP_RNDD); + printf ("\n"); #endif - mpfr_const_pi(the_pi, GMP_RNDN); - mpfr_const_pi(tmp, GMP_RNDN); - mpfr_mul_2ui(tmp, tmp, 1, GMP_RNDN); - mpfr_sqrt(tmp, tmp, GMP_RNDN); - mpfr_add(GammaTrial, GammaTrial, tmp, GMP_RNDN); - mpfr_add_ui(tmp2, xp, A, GMP_RNDN); - mpfr_set_ui(tmp, 1, GMP_RNDN); - mpfr_div_2ui(tmp, tmp, 1, GMP_RNDN); - mpfr_add(tmp, tmp, xp, GMP_RNDN); - mpfr_pow(tmp, tmp2, tmp, GMP_RNDN); - mpfr_mul(GammaTrial, GammaTrial, tmp, GMP_RNDN); - mpfr_neg(tmp, tmp2, GMP_RNDN); - mpfr_exp(tmp, tmp, GMP_RNDN); - mpfr_mul(GammaTrial, GammaTrial, tmp, GMP_RNDN); - if (compared < 0) - { - mpfr_sub_ui (tmp, x, 1, GMP_RNDN); - mpfr_mul (tmp, the_pi, tmp, GMP_RNDN); - mpfr_div (GammaTrial, tmp, GammaTrial, GMP_RNDN); - mpfr_sin (tmp, tmp, GMP_RNDN); - mpfr_div (GammaTrial, GammaTrial, tmp, GMP_RNDN); - } + mpfr_const_pi(the_pi, GMP_RNDN); + mpfr_const_pi(tmp, GMP_RNDN); + mpfr_mul_2ui(tmp, tmp, 1, GMP_RNDN); + mpfr_sqrt(tmp, tmp, GMP_RNDN); + mpfr_add(GammaTrial, GammaTrial, tmp, GMP_RNDN); + mpfr_add_ui(tmp2, xp, A, GMP_RNDN); + mpfr_set_ui(tmp, 1, GMP_RNDN); + mpfr_div_2ui(tmp, tmp, 1, GMP_RNDN); + mpfr_add(tmp, tmp, xp, GMP_RNDN); + mpfr_pow(tmp, tmp2, tmp, GMP_RNDN); + mpfr_mul(GammaTrial, GammaTrial, tmp, GMP_RNDN); + mpfr_neg(tmp, tmp2, GMP_RNDN); + mpfr_exp(tmp, tmp, GMP_RNDN); + mpfr_mul(GammaTrial, GammaTrial, tmp, GMP_RNDN); + if (compared < 0) + { + mpfr_sub_ui (tmp, x, 1, GMP_RNDN); + mpfr_mul (tmp, the_pi, tmp, GMP_RNDN); + mpfr_div (GammaTrial, tmp, GammaTrial, GMP_RNDN); + mpfr_sin (tmp, tmp, GMP_RNDN); + mpfr_div (GammaTrial, GammaTrial, tmp, GMP_RNDN); + } #ifdef DEBUG - printf("GammaTrial ="); - mpfr_out_str (stdout, 10, 0, GammaTrial, GMP_RNDD); - printf ("\n"); + printf("GammaTrial ="); + mpfr_out_str (stdout, 10, 0, GammaTrial, GMP_RNDD); + printf ("\n"); #endif - if (mpfr_can_round (GammaTrial, realprec, GMP_RNDD, rnd_mode, MPFR_PREC(gamma))) - { - mpfr_set (gamma, GammaTrial, rnd_mode); - good = 1; - } - else - { - realprec += __gmpfr_ceil_log2 ((double) realprec); + if (mpfr_can_round (GammaTrial, realprec, GMP_RNDD, rnd_mode, + MPFR_PREC(gamma))) + { + mpfr_set (gamma, GammaTrial, rnd_mode); + good = 1; + } + else + { + realprec += __gmpfr_ceil_log2 ((double) realprec); #ifdef DEBUG - printf("RETRY\n"); + printf("RETRY\n"); #endif - } - mpfr_clear(tmp); - mpfr_clear(tmp2); - mpfr_clear(the_pi); - mpfr_clear(product); - mpfr_clear(GammaTrial); - } + } + mpfr_clear(tmp); + mpfr_clear(tmp2); + mpfr_clear(the_pi); + mpfr_clear(product); + mpfr_clear(GammaTrial); + } mpfr_clear (xp); return 1; /* inexact result */ } - diff --git a/mpfr/get_str.c b/mpfr/get_str.c index d215eca32..b1c6aa92d 100644 --- a/mpfr/get_str.c +++ b/mpfr/get_str.c @@ -31,7 +31,6 @@ MA 02111-1307, USA. */ #include "mpfr-impl.h" static double _mpfr_ceil _PROTO ((double)); -static long mpn_exp _PROTO ((mp_limb_t *, mp_exp_t *, int, mp_exp_t, size_t)); static int mpfr_get_str_aux _PROTO ((char *, mp_exp_t *, mp_limb_t *, mp_size_t, mp_exp_t, long, int, size_t, mp_rnd_t)); static mp_exp_t mpfr_get_str_compute_g _PROTO ((int, mp_exp_t)); @@ -191,7 +190,7 @@ _mpfr_ceil (double x) a*2^exp_r <= b^e <= 2^exp_r (a + 2^f), where a represents {a, n}, i.e. the integer a[0] + a[1]*B + ... + a[n-1]*B^(n-1) where B=2^BITS_PER_MP_LIMB */ -static long +long mpn_exp (mp_limb_t *a, mp_exp_t *exp_r, int b, mp_exp_t e, size_t n) { mp_limb_t *c, B; diff --git a/mpfr/log_b2.h b/mpfr/log_b2.h new file mode 100644 index 000000000..f2f2d7e42 --- /dev/null +++ b/mpfr/log_b2.h @@ -0,0 +1,127 @@ +/* used by mpfr_get_str and mpfr_set_str */ + +/* for 2 <= b <= 36, log_b2[b-2] + log_b2_low[b-2] is a 76-bit upper + approximation of log(2)/log(b), with log_b2[b-2] having 23 significative + bits only. These approximations were computed with the following program. + +#include <stdio.h> +#include "gmp.h" +#include "mpfr.h" + +double log_b2[35], log_b2_low[35]; + +main() +{ + int beta; + mpfr_t l, l0; + + for (beta=2;beta<=36;beta++) + { + mpfr_init2 (l, 77); + mpfr_set_ui (l, beta, GMP_RNDD); + mpfr_log2 (l, l, GMP_RNDD); + mpfr_ui_div (l, 1, l, GMP_RNDU); + mpfr_init2 (l0, 23); + mpfr_set (l0, l, GMP_RNDD); + mpfr_sub (l, l, l0, GMP_RNDU); + mpfr_round_prec (l, GMP_RNDU, 53); + log_b2[beta-2] = mpfr_get_d (l0, GMP_RNDU); + log_b2_low[beta-2] = mpfr_get_d (l, GMP_RNDU); + mpfr_clear (l0); + mpfr_clear (l); + } + + printf ("static const double log_b2[35] = {"); + for (beta=2;beta<=36;beta++) + { + printf ("\n%1.20e", log_b2[beta-2]); + if (beta < 36) printf (","); + } + printf ("\n};\n"); + + printf ("static const double log_b2_low[35] = {"); + for (beta=2;beta<=36;beta++) + { + printf ("\n%1.20e", log_b2_low[beta-2]); + if (beta < 36) printf (","); + } + printf ("\n};\n"); +} +*/ + +static const double log_b2_low[35] = { + 0.00000000000000000000e+00, + 4.50906224761620348192e-08, + 0.00000000000000000000e+00, + 3.82026349940294905572e-08, + 6.38844173335462308442e-09, + 5.47685446374516835508e-08, + 1.98682149251302105391e-08, + 2.25453112380810174096e-08, + 1.54813334901356166450e-08, + 1.73674161903183898500e-09, + 3.03180611272229558617e-09, + 5.29449283838722401896e-08, + 5.85090258233695360801e-08, + 4.12271221790330610183e-09, + 0.00000000000000000000e+00, + 2.91844949512882013763e-08, + 3.04617404727474892263e-09, + 1.11983643106657188415e-08, + 1.54897762641074502508e-08, + 2.61761247509117662805e-08, + 4.50398291018069050027e-09, + 1.28799738389232369510e-08, + 1.89047057535652783545e-08, + 1.91013174970147452786e-08, + 2.94215882512624420131e-08, + 2.49643149546191168760e-08, + 2.00493274507626165734e-08, + 1.61590886321114899524e-08, + 1.47626363632181082532e-09, + 1.34104842501325808254e-08, + 1.19209289550781256617e-08, + 2.51706771840338761560e-10, + 2.74945871340834855649e-08, + 7.23962676182708790191e-09, + 3.19422086667731154221e-09 +}; + +static const double log_b2[35] = { + 1.00000000000000000000e+00, + 6.30929708480834960938e-01, + 5.00000000000000000000e-01, + 4.30676519870758056641e-01, + 3.86852800846099853516e-01, + 3.56207132339477539062e-01, + 3.33333313465118408203e-01, + 3.15464854240417480469e-01, + 3.01029980182647705078e-01, + 2.89064824581146240234e-01, + 2.78942942619323730469e-01, + 2.70238101482391357422e-01, + 2.62649476528167724609e-01, + 2.55958020687103271484e-01, + 2.50000000000000000000e-01, + 2.44650512933731079102e-01, + 2.39812463521957397461e-01, + 2.35408902168273925781e-01, + 2.31378197669982910156e-01, + 2.27670222520828247070e-01, + 2.24243819713592529297e-01, + 2.21064716577529907227e-01, + 2.18104273080825805664e-01, + 2.15338259935379028320e-01, + 2.12746024131774902344e-01, + 2.10309892892837524414e-01, + 2.08014577627182006836e-01, + 2.05846816301345825195e-01, + 2.03795045614242553711e-01, + 2.01849073171615600586e-01, + 1.99999988079071044922e-01, + 1.98239862918853759766e-01, + 1.96561604738235473633e-01, + 1.94959014654159545898e-01, + 1.93426400423049926758e-01 +}; + diff --git a/mpfr/mpfr-impl.h b/mpfr/mpfr-impl.h index 689ae4f85..df4d7b30a 100644 --- a/mpfr/mpfr-impl.h +++ b/mpfr/mpfr-impl.h @@ -94,6 +94,7 @@ typedef unsigned long int mp_size_unsigned_t; typedef union ieee_double_extract Ieee_double_extract; +/* for x of type ieee_double_extract */ #define DOUBLE_ISNANorINF(x) (((Ieee_double_extract *)&(x))->s.exp == 0x7ff) #define DOUBLE_ISINF(x) (DOUBLE_ISNANorINF(x) && \ (((Ieee_double_extract *)&(x))->s.manl == 0) && \ @@ -102,8 +103,6 @@ typedef union ieee_double_extract Ieee_double_extract; ((((Ieee_double_extract *)&(x))->s.manl != 0) || \ (((Ieee_double_extract *)&(x))->s.manh != 0))) -#define LONGDOUBLE_ISNAN(x) ((x) != (x)) - #define DBL_POS_INF (1.0/0.0) #define DBL_NEG_INF (-1.0/0.0) #define DBL_NAN (0.0/0.0) @@ -145,7 +144,7 @@ typedef union ieee_double_extract Ieee_double_extract; #define MPFR_SET_ZERO(x) \ (MPFR_MANT(x)[(MPFR_PREC(x)-1)/BITS_PER_MP_LIMB] = (mp_limb_t) 0) #define MPFR_ESIZE(x) \ - ((MPFR_PREC((x)) - 1) / BITS_PER_MP_LIMB + 1); + ((MPFR_PREC((x)) - 1) / BITS_PER_MP_LIMB + 1) #define MPFR_EVEN_INEX 2 /* When returning the ternary inexact value, ALWAYS use one of the @@ -218,6 +217,7 @@ int mpfr_exp3 _PROTO ((mpfr_ptr, mpfr_srcptr, mp_rnd_t)); int mpfr_powerof2_raw _PROTO ((mpfr_srcptr)); void mpfr_setmax _PROTO ((mpfr_ptr, mp_exp_t)); void mpfr_setmin _PROTO ((mpfr_ptr, mp_exp_t)); +long mpn_exp _PROTO ((mp_limb_t *, mp_exp_t *, int, mp_exp_t, size_t)); #define mpfr_round_raw(yp, xp, xprec, neg, yprec, r, inexp) \ mpfr_round_raw_generic((yp), (xp), (xprec), (neg), (yprec), (r), (inexp), 0) diff --git a/mpfr/mpfr-test.h b/mpfr/mpfr-test.h index 27e081392..9ba7bf921 100644 --- a/mpfr/mpfr-test.h +++ b/mpfr/mpfr-test.h @@ -83,7 +83,5 @@ int ulp _PROTO ((double, double)); double dbl _PROTO ((double, int)); double Ulp _PROTO ((double)); -#if !defined(HAVE_ISNAN) && !defined(isnan) int Isnan _PROTO ((double)); -#define isnan(d) Isnan(d) -#endif +#define LONGDOUBLE_ISNAN(x) ((x) != (x)) diff --git a/mpfr/set_ld.c b/mpfr/set_ld.c index d6c391810..2f83124ed 100644 --- a/mpfr/set_ld.c +++ b/mpfr/set_ld.c @@ -36,6 +36,8 @@ MA 02111-1307, USA. */ #define CHAR_BIT 8 #endif +#define LONGDOUBLE_ISNAN(x) ((x) != (x)) + /* Various i386 systems have been seen with float.h LDBL constants equal to the DBL ones, whereas they ought to be bigger, reflecting the 10-byte diff --git a/mpfr/set_str.c b/mpfr/set_str.c index 6ff0e26f9..12b739ea8 100644 --- a/mpfr/set_str.c +++ b/mpfr/set_str.c @@ -19,18 +19,26 @@ along with the MPFR Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include <ctype.h> #include <stdio.h> #include <stdlib.h> -#include <limits.h> #include <string.h> -#include <errno.h> - +#include <ctype.h> #include "gmp.h" #include "gmp-impl.h" #include "longlong.h" #include "mpfr.h" #include "mpfr-impl.h" +#include "log_b2.h" + +static double __gmpfr_ceil _PROTO((double)); +static int digit_value_in_base _PROTO ((int, int)); + +static double +__gmpfr_ceil (double x) +{ + double y = (double) (long int) x; + return ((y < x) ? y + 1.0 : y); +} /* Compatible with any locale, but one still assumes that 'a', 'b', 'c', ..., 'z', and 'A', 'B', 'C', ..., 'Z' are consecutive values (like @@ -54,17 +62,35 @@ digit_value_in_base (int c, int base) return -1; } +/* Set x to the value of str, in base base, rounded in direction rnd. + return value is: 0 if the entire string up to the final required '\0' + is a valid number, otherwise -1 (compatibility with + mpf_set_str) + */ int -mpfr_set_str (mpfr_ptr x, __gmp_const char *str, int base, mp_rnd_t rnd_mode) +mpfr_set_str (mpfr_t x, const char *str, int base, mp_rnd_t rnd) { - mpz_t mantissa; - int negative, inex, value; - long k = 0; - unsigned char c; - long e; - mp_prec_t q; - mpfr_t y, z; - const char *str0 = str; + mp_limb_t *y; /* current value of x */ + mp_exp_t exp_y; /* such as x = y*base^exp_y */ + mp_limb_t *z, *result; /* temporary variables */ + mp_exp_t exp_z; /* exponent of z */ + size_t n; /* working precision in limbs */ + size_t prec_s; /* precision of str */ + mp_exp_t pr; /* needed precision requise for str */ + mp_exp_t exp_s = 0; /* exponent in base 'base', normalized for a + mantissa 0.xxx...xxx */ + mp_exp_t prec_x; /* working precision for x */ + char *str1; /* copy of str, should not be modified */ + size_t size_str1; /* number of characters in str1 */ + char *mant_s; /* pointer in str1 */ + int negative = 0; /* 1 if str<=0, 0 otherwise */ + size_t i, j; + long err = 0; + int exact; /* is the computation exact */ + int point = 0; /* position in str */ + int cboucle = 1; + int c, res = 0; + TMP_DECL(marker); if (base < 2 || base > 36) return -1; @@ -77,150 +103,264 @@ mpfr_set_str (mpfr_ptr x, __gmp_const char *str, int base, mp_rnd_t rnd_mode) MPFR_SET_NAN(x); /* MPFR_RET_NAN not used as the return value isn't a ternary value */ __gmpfr_flags |= MPFR_FLAGS_NAN; - return 3; + return 0; } - negative = *str == '-'; - if (negative || *str == '+') - str++; + /* deals with the sign */ + negative = (str[0] == '-'); + if ((str[0] == '-') || (str[0] == '+')) + str ++; /* be careful that 'inf' is a valid number in base >= 24, since i=18, n=23, f=15 */ if (((base < 24) ? strncasecmp (str, "Inf", 3) : strncmp (str, "Inf", 3)) == 0) { - MPFR_CLEAR_NAN(x); - MPFR_SET_INF(x); - if (negative) - MPFR_SET_NEG(x); - else - MPFR_SET_POS(x); - return 3 + (str - str0); + MPFR_CLEAR_NAN (x); + MPFR_SET_INF (x); + (negative) ? MPFR_SET_NEG (x) : MPFR_SET_POS (x); + return 0; } - mpz_init (mantissa); - mpz_set_ui (mantissa, 0); - - while (*str == '0') - str++; /* skip initial zeros */ + /* allocate str1 to store value of characters in str. + FIXME: we could use str directly here if mpn_set_str would deal + with real characters. */ + size_str1 = strlen (str); + str1 = (*__gmp_allocate_func) (size_str1 * sizeof (char)); + /* the str1 pointer should not be modified */ - /* allowed characters are '0' to '0'+base-1 if base <= 10, - and '0' to '9' plus 'a' to 'a'+base-11 if 10 < base <= 36 */ - while (c = *str, - (value = digit_value_in_base (c, base)) >= 0) + /* checks if the input string is valid, and converts characters into + their value */ + for (mant_s = str1; *str != 0; str++) { - str++; - mpz_mul_ui (mantissa, mantissa, base); - mpz_add_ui (mantissa, mantissa, value); - } - - /* k is the number of non-zero digits before the decimal point */ - - if (*str == '.') - { - str++; - while (c = *str, - (value = digit_value_in_base (c, base)) >= 0) - { - if (k == LONG_MAX) + if (((base < 10) && (*str == 'e')) || (*str == 'E') || + (*str == '@')) + { + char *endptr[1]; + /* the exponent digits are kept in ASCII */ + exp_s += (mp_exp_t) strtol (str + 1, endptr, 10); + if (**endptr != '\0') { - mpz_clear (mantissa); - return -1; + res = -1; /* invalid input: garbage after exponent */ + goto end; } - k++; - str++; - mpz_mul_ui (mantissa, mantissa, base); - mpz_add_ui (mantissa, mantissa, value); - } + break; + } + else if (*str == '.') + { + point = 1; + continue; /* go to next character */ + } + else if ((c = digit_value_in_base (*str, base)) != -1) + *mant_s = c; /* valid character */ + else + { + res = -1; /* invalid input */ + goto end; + } + if (!point) + exp_s ++; + mant_s ++; } + prec_s = mant_s - str1; /* number of characters in the mantissa */ - if ((base <= 10 && (*str == 'e' || *str == 'E')) || *str == '@') - { - char *endptr; - - if (*++str == '\0') /* exponent character but no exponent */ - { - mpz_clear (mantissa); - return -1; - } - - errno = 0; - e = strtol (str, &endptr, 10); /* signed exponent after 'e', 'E' or '@' */ -#ifdef REQUIRE_END_OF_STRING - if (*endptr != '\0') - { - mpz_clear (mantissa); - return -1; - } -#endif - str = endptr; - if (errno) - { - mpz_clear(mantissa); - return -1; - } - - if (e < 0 && (unsigned long) e - k < (unsigned long) LONG_MIN) - { - mpz_clear(mantissa); - return -1; - } - e -= k; - } - else /* no exponent */ + mant_s = str1; + /* remove 0's at the beginning and end of mant_s[0..prec_s-1] */ + for (; (prec_s > 0) && (*mant_s == 0); mant_s++, prec_s--, exp_s--); + for (; (prec_s > 0) && (mant_s[prec_s - 1] == 0); prec_s--); + + /* test if x = 0 */ + if (prec_s == 0) { -#ifdef REQUIRE_END_OF_STRING - if (*str != '\0') - { - mpz_clear (mantissa); - return -1; - } -#endif - e = -k; + MPFR_SET_ZERO (x); + res = 0; + goto end; } - /* the number is mantissa*base^expn */ + /* now we have str = 0.mant_s[0]...mant_s[prec_s-1]*base^exp_s */ - q = MPFR_PREC(x) & ~(mp_prec_t) (BITS_PER_MP_LIMB - 1); - mpfr_init (y); - mpfr_init (z); + /* determine the minimal precision for the computation */ + prec_x = MPFR_PREC(x) + (mp_exp_t) __gmpfr_ceil_log2 ((double) MPFR_PREC(x)); - do + /* compute y as long as rounding is not possible */ + for (;;cboucle ++) { - q += BITS_PER_MP_LIMB; - mpfr_set_prec (y, q); - mpfr_set_z (y, mantissa, GMP_RNDN); /* error <= 1/2*ulp(y) */ - - mpfr_set_prec (z, q); - if (e > 0) - { - inex = mpfr_ui_pow_ui (z, base, e, GMP_RNDN); - mpfr_mul (y, y, z, GMP_RNDN); - } - else if (e < 0) - { - inex = mpfr_ui_pow_ui (z, base, -e, GMP_RNDN); - mpfr_div (y, y, z, GMP_RNDN); - } + TMP_MARK(marker); + + /* number of limbs needed to compute x */ + n = (prec_x - 1) / BITS_PER_MP_LIMB + 1; + + /* initialize y to the value of 0.mant_s[0]...mant_s[pr-1] */ + y = TMP_ALLOC ((2 * n + 1) * sizeof (mp_limb_t)); + y += n; + /* remember that y - n is allocated for n limbs */ + + /* required precision for str */ + pr = (mp_exp_t) __gmpfr_ceil + (((double) (n * BITS_PER_MP_LIMB) - 1.0) * log_b2[base-2]) + 1; + + /* check is there are enough digits in str */ + if (pr >= prec_s) + pr = prec_s; + + /* convert str into binary */ + i = mpn_set_str (y, mant_s, pr, base); + + /* normalize y */ + count_leading_zeros (j, *(y + i - 1)); + if ((exact = (i <= n))) /* shift y to the left + in that case y shoud be exact */ + { + /* shift {y, i} for j bits to the left */ + if (j != 0) + mpn_lshift (y, y, i, j); + /* shift {y, i} for (n-i) limbs to the left */ + if (i != n) + { + MPN_COPY_DECR (y + n - i, y, i); + MPN_ZERO (y, n - i); + } + /* for each bit shift decrease exponent of y */ + exp_y = - ((n - i) * BITS_PER_MP_LIMB + j); + } + else /* shift y for the right */ + { + /* shift {y, i} for (BITS_PER_MP_LIMB - j) bits to the right */ + mpn_rshift (y, y, i, BITS_PER_MP_LIMB - j); + /* for each bit shift increase exponent of y */ + exp_y = BITS_PER_MP_LIMB - j; + } + + /* compute base^(exp_s-pr) on n limbs */ + + if (IS_POW2 (base)) + { + int pow2; + + count_leading_zeros (pow2, (mp_limb_t) base); + pow2 = BITS_PER_MP_LIMB - pow2 - 1; /* base = 2^pow2 */ + + exp_y = exp_y + pow2 * (exp_s - (mp_exp_t) pr); + + result = y - n; + } + /* case exp_s > pr */ + else if (exp_s > (mp_exp_t) pr) + { + result = TMP_ALLOC ((2 * n + 1) * sizeof (mp_limb_t)); + + /* (z, exp_z) = base^(exp_s-pr), then result = y*z */ + /* z is allocated at y - n */ + z = y - n; + err = mpn_exp (z, &exp_z, base, exp_s - (mp_exp_t) pr, n); + exact = (exact && (err == -1)); + + /* multiply (y = 0.mant_s[0]...mant_s[pr-1])_base by base^(exp_s-g) */ + mpn_mul_n (result, y, z, n); + + /* compute the error on the product */ + if (err == -1) + err = 0; + err ++; + + /* compute the exponent of y */ + exp_y += exp_z + n * BITS_PER_MP_LIMB; + + /* normalize result */ + if ((result[2 * n - 1] & MPFR_LIMB_HIGHBIT) == 0) + { + mpn_lshift (result + n - 1, result + n - 1, n + 1, 1); + exp_y --; + } + + exact = (exact && (mpn_scan1 (result, 0) >= n * BITS_PER_MP_LIMB)); + } + + /* cass exp_s < pr */ + else if (exp_s < (mp_exp_t) pr) + { + result = TMP_ALLOC ((2 * n + 1) * sizeof (mp_limb_t)); + + /* set y to y * K^n */ + y = y - n; /* we have allocated n limbs at y - n */ + MPN_ZERO (y, n); + + /* (z, exp_z) = base^(exp_s-pr) */ + z = TMP_ALLOC (n * sizeof (mp_limb_t)); + err = mpn_exp (z, &exp_z, base, pr - exp_s, n); + exact = (exact && (err == -1)); + + if (err == -1) + err = 0; + + /* compute y / z */ + /* result will be put into result + n, and remainder into result */ + mpn_tdiv_qr (result + n, result, (mp_size_t) 0, y, 2*n, z, n); + + exp_y = exp_y - exp_z - n * BITS_PER_MP_LIMB; + + err += 2; + + exact = (exact && (mpn_popcount (result, n) == 0)); + + /* normalize result */ + if (result[2 * n] == 1) + { + exact = (exact && ((result[n] & 1) == 0)); + mpn_rshift (result + n, result + n, n + 1, 1); + exp_y ++; + } + } + else + { + /* cass exp_s = pr : base^(exp_s-pr) = 1 + nothing to compute, but we must put y into result and free it */ + result = y - n; + } + + /* test if rounding is possible, and if so exit the loop */ + if (exact || mpfr_can_round_raw (result + n, n, (negative) ? -1 : 1, + n * BITS_PER_MP_LIMB - err - 1, GMP_RNDN, rnd, MPFR_PREC(x))) + break; + + /* update for next loop */ + if (cboucle == 2) + prec_x = (mp_exp_t) + __gmpfr_ceil ((double) prec_s / log_b2[base - 2]) + 3; else - inex = 1; - if (negative) - mpfr_neg (y, y, GMP_RNDN); + { + mp_exp_t ajout = __gmpfr_ceil_log2 ((double) prec_x); + prec_x += (ajout < BITS_PER_MP_LIMB) ? BITS_PER_MP_LIMB : ajout; + } + + TMP_FREE(marker); } - while (mpfr_can_round (y, q-inex, GMP_RNDN, rnd_mode, MPFR_PREC(x)) == 0 - && q <= 2*MPFR_PREC(x)); - mpfr_set (x, y, rnd_mode); + /* round y */ - mpz_clear (mantissa); - mpfr_clear (y); - mpfr_clear (z); - return str - str0; -} + if (mpfr_round_raw_generic (MPFR_MANT(x), result + n, n * BITS_PER_MP_LIMB, + negative, MPFR_PREC(x), rnd, NULL, (int) 0)) + { + /* overflaw when rounding y */ + MPFR_MANT(x)[MPFR_ESIZE(x) - 1] + = MPFR_LIMB_HIGHBIT; + exp_y ++; + } -int -mpfr_init_set_str (mpfr_ptr x, char *str, int base, mp_rnd_t rnd_mode) -{ - mpfr_init (x); - return mpfr_set_str (x, str, base, rnd_mode); + TMP_FREE(marker); + + MPFR_CLEAR_FLAGS(x); + if (negative) + MPFR_SET_NEG(x); + else + MPFR_SET_POS(x); + MPFR_EXP(x) = exp_y + n * BITS_PER_MP_LIMB; + + end: + (*__gmp_free_func) (str1, size_str1 * sizeof (char)); + + return res; } + + + diff --git a/mpfr/tests/Makefile.am b/mpfr/tests/Makefile.am index d1d0f44c8..4cab5454c 100644 --- a/mpfr/tests/Makefile.am +++ b/mpfr/tests/Makefile.am @@ -24,7 +24,7 @@ INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/mpfr CFLAGS = @MPFR_CFLAGS@ LIBS = @MPFR_LIBS@ -LDADD = libfrtests.a ../libmpfr.a $(top_builddir)/libgmp.la +LDADD = libfrtests.a $(MPFR_LIBM) ../libmpfr.a $(top_builddir)/libgmp.la libfrtests_a_SOURCES = memory.c rnd_mode.c tests.c EXTRA_libfrtests_a_SOURCES = x86.asm @@ -32,7 +32,7 @@ libfrtests_a_DEPENDENCIES = $(TESTS_ASM_OBJECTS) libfrtests_a_LIBADD = $(libfrtests_a_DEPENDENCIES) if WANT_MPFR -check_PROGRAMS = reuse tabs tadd tagm tcan_round tcmp tcmp2 tcmp_ui tdiv tdiv_ui tdump teq texp tfrac tget_str tlog tconst_log2 tmul tmul_2exp tmul_ui tout_str tconst_pi tpow trandom tround_prec tset_d tset_f tset_q tset_si tset_str tset_z tsqrt tsqrt_ui tui_div tui_sub tswap ttrunc trint tisnan tget_d tatan tcosh tsinh ttanh tacosh tasinh tatanh thyperbolic texp2 tfactorial tsub tasin tconst_euler tcos tsin ttan tsub_ui tset tlog1p texpm1 tlog2 tlog10 tui_pow tpow3 tadd_ui texceptions tfma thypot tacos tgamma tset_ld tcbrt +check_PROGRAMS = reuse tabs tadd tagm tcan_round tcmp tcmp2 tcmp_ui tdiv tdiv_ui tdump teq texp tfrac tget_str tlog tconst_log2 tmul tmul_2exp tmul_ui tout_str tconst_pi tpow trandom tround_prec tset_d tset_f tset_q tset_si tset_str tset_z tsqrt tsqrt_ui tui_div tui_sub tswap ttrunc trint tisnan tget_d tatan tcosh tsinh ttanh tacosh tasinh tatanh thyperbolic texp2 tfactorial tsub tasin tconst_euler tcos tsin ttan tsub_ui tset tlog1p texpm1 tlog2 tlog10 tui_pow tpow3 tadd_ui texceptions tfma thypot tacos tgamma tset_ld tcbrt tsin_cos check_LIBRARIES = libfrtests.a TESTS = $(check_PROGRAMS) endif diff --git a/mpfr/tests/Makefile.in b/mpfr/tests/Makefile.in index 1d9321967..ca6751d84 100644 --- a/mpfr/tests/Makefile.in +++ b/mpfr/tests/Makefile.in @@ -127,6 +127,7 @@ MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ MAKEINFO = @MAKEINFO@ MPFR_CFLAGS = @MPFR_CFLAGS@ +MPFR_LIBM = @MPFR_LIBM@ MPFR_LIBS = @MPFR_LIBS@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ @@ -205,7 +206,7 @@ EXTRA_libfrtests_a_SOURCES = x86.asm libfrtests_a_DEPENDENCIES = $(TESTS_ASM_OBJECTS) libfrtests_a_LIBADD = $(libfrtests_a_DEPENDENCIES) -@WANT_MPFR_TRUE@check_PROGRAMS = reuse tabs tadd tagm tcan_round tcmp tcmp2 tcmp_ui tdiv tdiv_ui tdump teq texp tfrac tget_str tlog tconst_log2 tmul tmul_2exp tmul_ui tout_str tconst_pi tpow trandom tround_prec tset_d tset_f tset_q tset_si tset_str tset_z tsqrt tsqrt_ui tui_div tui_sub tswap ttrunc trint tisnan tget_d tatan tcosh tsinh ttanh tacosh tasinh tatanh thyperbolic texp2 tfactorial tsub tasin tconst_euler tcos tsin ttan tsub_ui tset tlog1p texpm1 tlog2 tlog10 tui_pow tpow3 tadd_ui texceptions tfma thypot tacos tgamma tset_ld tcbrt +@WANT_MPFR_TRUE@check_PROGRAMS = reuse tabs tadd tagm tcan_round tcmp tcmp2 tcmp_ui tdiv tdiv_ui tdump teq texp tfrac tget_str tlog tconst_log2 tmul tmul_2exp tmul_ui tout_str tconst_pi tpow trandom tround_prec tset_d tset_f tset_q tset_si tset_str tset_z tsqrt tsqrt_ui tui_div tui_sub tswap ttrunc trint tisnan tget_d tatan tcosh tsinh ttanh tacosh tasinh tatanh thyperbolic texp2 tfactorial tsub tasin tconst_euler tcos tsin ttan tsub_ui tset tlog1p texpm1 tlog2 tlog10 tui_pow tpow3 tadd_ui texceptions tfma thypot tacos tgamma tset_ld tcbrt tsin_cos @WANT_MPFR_TRUE@check_LIBRARIES = libfrtests.a @WANT_MPFR_TRUE@TESTS = $(check_PROGRAMS) EXTRA_DIST = tgeneric.c @@ -249,7 +250,8 @@ libfrtests_a_OBJECTS = $(am_libfrtests_a_OBJECTS) @WANT_MPFR_TRUE@ tpow3$(EXEEXT) tadd_ui$(EXEEXT) \ @WANT_MPFR_TRUE@ texceptions$(EXEEXT) tfma$(EXEEXT) \ @WANT_MPFR_TRUE@ thypot$(EXEEXT) tacos$(EXEEXT) tgamma$(EXEEXT) \ -@WANT_MPFR_TRUE@ tset_ld$(EXEEXT) tcbrt$(EXEEXT) +@WANT_MPFR_TRUE@ tset_ld$(EXEEXT) tcbrt$(EXEEXT) \ +@WANT_MPFR_TRUE@ tsin_cos$(EXEEXT) @WANT_MPFR_FALSE@check_PROGRAMS = reuse_SOURCES = reuse.c reuse_OBJECTS = reuse$U.$(OBJEXT) @@ -584,6 +586,12 @@ tsin_OBJECTS = tsin$U.$(OBJEXT) tsin_LDADD = $(LDADD) tsin_DEPENDENCIES = libfrtests.a ../libmpfr.a $(top_builddir)/libgmp.la tsin_LDFLAGS = +tsin_cos_SOURCES = tsin_cos.c +tsin_cos_OBJECTS = tsin_cos$U.$(OBJEXT) +tsin_cos_LDADD = $(LDADD) +tsin_cos_DEPENDENCIES = libfrtests.a ../libmpfr.a \ + $(top_builddir)/libgmp.la +tsin_cos_LDFLAGS = tsinh_SOURCES = tsinh.c tsinh_OBJECTS = tsinh$U.$(OBJEXT) tsinh_LDADD = $(LDADD) @@ -671,10 +679,10 @@ DIST_SOURCES = $(libfrtests_a_SOURCES) $(EXTRA_libfrtests_a_SOURCES) \ tlog1p.c tlog2.c tmul.c tmul_2exp.c tmul_ui.c tout_str.c tpow.c \ tpow3.c trandom.c trint.c tround_prec.c tset.c tset_d.c \ tset_f.c tset_ld.c tset_q.c tset_si.c tset_str.c tset_z.c \ - tsin.c tsinh.c tsqrt.c tsqrt_ui.c tsub.c tsub_ui.c tswap.c \ - ttan.c ttanh.c ttrunc.c tui_div.c tui_pow.c tui_sub.c + tsin.c tsin_cos.c tsinh.c tsqrt.c tsqrt_ui.c tsub.c tsub_ui.c \ + tswap.c ttan.c ttanh.c ttrunc.c tui_div.c tui_pow.c tui_sub.c DIST_COMMON = Makefile.am Makefile.in -SOURCES = $(libfrtests_a_SOURCES) $(EXTRA_libfrtests_a_SOURCES) reuse.c tabs.c tacos.c tacosh.c tadd.c tadd_ui.c tagm.c tasin.c tasinh.c tatan.c tatanh.c tcan_round.c tcbrt.c tcmp.c tcmp2.c tcmp_ui.c tconst_euler.c tconst_log2.c tconst_pi.c tcos.c tcosh.c tdiv.c tdiv_ui.c tdump.c teq.c texceptions.c texp.c texp2.c texpm1.c tfactorial.c tfma.c tfrac.c tgamma.c tget_d.c tget_str.c thyperbolic.c thypot.c tisnan.c tlog.c tlog10.c tlog1p.c tlog2.c tmul.c tmul_2exp.c tmul_ui.c tout_str.c tpow.c tpow3.c trandom.c trint.c tround_prec.c tset.c tset_d.c tset_f.c tset_ld.c tset_q.c tset_si.c tset_str.c tset_z.c tsin.c tsinh.c tsqrt.c tsqrt_ui.c tsub.c tsub_ui.c tswap.c ttan.c ttanh.c ttrunc.c tui_div.c tui_pow.c tui_sub.c +SOURCES = $(libfrtests_a_SOURCES) $(EXTRA_libfrtests_a_SOURCES) reuse.c tabs.c tacos.c tacosh.c tadd.c tadd_ui.c tagm.c tasin.c tasinh.c tatan.c tatanh.c tcan_round.c tcbrt.c tcmp.c tcmp2.c tcmp_ui.c tconst_euler.c tconst_log2.c tconst_pi.c tcos.c tcosh.c tdiv.c tdiv_ui.c tdump.c teq.c texceptions.c texp.c texp2.c texpm1.c tfactorial.c tfma.c tfrac.c tgamma.c tget_d.c tget_str.c thyperbolic.c thypot.c tisnan.c tlog.c tlog10.c tlog1p.c tlog2.c tmul.c tmul_2exp.c tmul_ui.c tout_str.c tpow.c tpow3.c trandom.c trint.c tround_prec.c tset.c tset_d.c tset_f.c tset_ld.c tset_q.c tset_si.c tset_str.c tset_z.c tsin.c tsin_cos.c tsinh.c tsqrt.c tsqrt_ui.c tsub.c tsub_ui.c tswap.c ttan.c ttanh.c ttrunc.c tui_div.c tui_pow.c tui_sub.c all: all-am @@ -879,6 +887,9 @@ tset_z$(EXEEXT): $(tset_z_OBJECTS) $(tset_z_DEPENDENCIES) tsin$(EXEEXT): $(tsin_OBJECTS) $(tsin_DEPENDENCIES) @rm -f tsin$(EXEEXT) $(LINK) $(tsin_LDFLAGS) $(tsin_OBJECTS) $(tsin_LDADD) $(LIBS) +tsin_cos$(EXEEXT): $(tsin_cos_OBJECTS) $(tsin_cos_DEPENDENCIES) + @rm -f tsin_cos$(EXEEXT) + $(LINK) $(tsin_cos_LDFLAGS) $(tsin_cos_OBJECTS) $(tsin_cos_LDADD) $(LIBS) tsinh$(EXEEXT): $(tsinh_OBJECTS) $(tsinh_DEPENDENCIES) @rm -f tsinh$(EXEEXT) $(LINK) $(tsinh_LDFLAGS) $(tsinh_OBJECTS) $(tsinh_LDADD) $(LIBS) @@ -1063,6 +1074,8 @@ tset_z_.c: tset_z.c $(ANSI2KNR) $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/tset_z.c; then echo $(srcdir)/tset_z.c; else echo tset_z.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ tsin_.c: tsin.c $(ANSI2KNR) $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/tsin.c; then echo $(srcdir)/tsin.c; else echo tsin.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ +tsin_cos_.c: tsin_cos.c $(ANSI2KNR) + $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/tsin_cos.c; then echo $(srcdir)/tsin_cos.c; else echo tsin_cos.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ tsinh_.c: tsinh.c $(ANSI2KNR) $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/tsinh.c; then echo $(srcdir)/tsinh.c; else echo tsinh.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@ tsqrt_.c: tsqrt.c $(ANSI2KNR) @@ -1116,8 +1129,9 @@ tround_prec_.lo tset_.$(OBJEXT) tset_.lo tset_d_.$(OBJEXT) tset_d_.lo \ tset_f_.$(OBJEXT) tset_f_.lo tset_ld_.$(OBJEXT) tset_ld_.lo \ tset_q_.$(OBJEXT) tset_q_.lo tset_si_.$(OBJEXT) tset_si_.lo \ tset_str_.$(OBJEXT) tset_str_.lo tset_z_.$(OBJEXT) tset_z_.lo \ -tsin_.$(OBJEXT) tsin_.lo tsinh_.$(OBJEXT) tsinh_.lo tsqrt_.$(OBJEXT) \ -tsqrt_.lo tsqrt_ui_.$(OBJEXT) tsqrt_ui_.lo tsub_.$(OBJEXT) tsub_.lo \ +tsin_.$(OBJEXT) tsin_.lo tsin_cos_.$(OBJEXT) tsin_cos_.lo \ +tsinh_.$(OBJEXT) tsinh_.lo tsqrt_.$(OBJEXT) tsqrt_.lo \ +tsqrt_ui_.$(OBJEXT) tsqrt_ui_.lo tsub_.$(OBJEXT) tsub_.lo \ tsub_ui_.$(OBJEXT) tsub_ui_.lo tswap_.$(OBJEXT) tswap_.lo \ ttan_.$(OBJEXT) ttan_.lo ttanh_.$(OBJEXT) ttanh_.lo ttrunc_.$(OBJEXT) \ ttrunc_.lo tui_div_.$(OBJEXT) tui_div_.lo tui_pow_.$(OBJEXT) \ diff --git a/mpfr/tests/memory.c b/mpfr/tests/memory.c index b8ed29867..8284e3d13 100644 --- a/mpfr/tests/memory.c +++ b/mpfr/tests/memory.c @@ -1,6 +1,6 @@ /* Memory allocation used during tests. -Copyright 2001, 2002 Free Software Foundation, Inc. +Copyright 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of the GNU MP Library. diff --git a/mpfr/tests/tabs.c b/mpfr/tests/tabs.c index a767cda1f..7ec390f9e 100644 --- a/mpfr/tests/tabs.c +++ b/mpfr/tests/tabs.c @@ -1,6 +1,6 @@ /* Test file for mpfr_abs. -Copyright 2000, 2001, 2002 Free Software Foundation, Inc. +Copyright 2000, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -24,7 +24,6 @@ MA 02111-1307, USA. */ #include <float.h> #include "gmp.h" #include "mpfr.h" -#include "mpfr-impl.h" #include "mpfr-test.h" void check_inexact _PROTO((void)); @@ -139,7 +138,7 @@ main (int argc, char *argv[]) mpfr_set_d (x, d, 0); mpfr_abs (x, x, rnd); dd = mpfr_get_d1 (x); - if (!isnan(d) && (dd != absd)) + if (!Isnan(d) && (dd != absd)) { fprintf(stderr, "Mismatch on d = %.20e\n", d); diff --git a/mpfr/tests/tadd.c b/mpfr/tests/tadd.c index 3ab549639..26436f8e8 100644 --- a/mpfr/tests/tadd.c +++ b/mpfr/tests/tadd.c @@ -1,6 +1,6 @@ /* Test file for mpfr_add and mpfr_sub. -Copyright 1999, 2000, 2001, 2002 Free Software Foundation. +Copyright 1999, 2000, 2001, 2002, 2003 Free Software Foundation. This file is part of the MPFR Library. @@ -71,32 +71,46 @@ _check (double x, double y, double z1, mp_rnd_t rnd_mode, unsigned int px, cert = 1; z2 = mpfr_get_d1 (zz); mpfr_set_d (yy, z2, GMP_RNDN); - if (!mpfr_cmp (zz, yy) && cert && z1!=z2 && !(isnan(z1) && isnan(z2))) { - printf("expected sum is %1.20e, got %1.20e\n",z1,z2); - printf("mpfr_add failed for x=%1.20e y=%1.20e with rnd_mode=%s\n", - x, y, mpfr_print_rnd_mode(rnd_mode)); - exit(1); - } - mpfr_clear(xx); mpfr_clear(yy); mpfr_clear(zz); + if (!mpfr_cmp (zz, yy) && cert && z1!=z2 && !(Isnan(z1) && Isnan(z2))) + { + printf ("expected sum is %1.20e, got %1.20e\n", z1, z2); + printf ("mpfr_add failed for x=%1.20e y=%1.20e with rnd_mode=%s\n", + x, y, mpfr_print_rnd_mode (rnd_mode)); + exit (1); + } + mpfr_clear (xx); + mpfr_clear (yy); + mpfr_clear (zz); } void checknan (double x, double y, mp_rnd_t rnd_mode, unsigned int px, unsigned int py, unsigned int pz) { - double z2; mpfr_t xx, yy, zz; + double z2; + mpfr_t xx, yy, zz; - mpfr_init2(xx, px); - mpfr_init2(yy, py); - mpfr_init2(zz, pz); - mpfr_set_d(xx, x, rnd_mode); - mpfr_set_d(yy, y, rnd_mode); - mpfr_add(zz, xx, yy, rnd_mode); - if (MPFR_IS_NAN(zz) == 0) { printf("Error, not an MPFR_NAN for xx = %1.20e, y = %1.20e\n", x, y); exit(1); } + mpfr_init2 (xx, px); + mpfr_init2 (yy, py); + mpfr_init2 (zz, pz); + mpfr_set_d (xx, x, rnd_mode); + mpfr_set_d (yy, y, rnd_mode); + mpfr_add (zz, xx, yy, rnd_mode); + if (MPFR_IS_NAN(zz) == 0) + { + printf ("Error, not an MPFR_NAN for xx = %1.20e, y = %1.20e\n", x, y); + exit (1); + } z2 = mpfr_get_d1 (zz); - if (!isnan(z2)) { printf("Error, not a NaN after conversion, xx = %1.20e yy = %1.20e, got %1.20e\n", x, y, z2); exit(1); } + if (!Isnan(z2)) + { + printf ("Error, not a NaN after conversion, xx = %1.20e yy = %1.20e, got %1.20e\n", x, y, z2); + exit (1); + } - mpfr_clear(xx); mpfr_clear(yy); mpfr_clear(zz); + mpfr_clear (xx); + mpfr_clear (yy); + mpfr_clear (zz); } void @@ -705,10 +719,12 @@ main (int argc, char *argv[]) check53(5.76707395945001907217e-58, 4.74752971449827687074e-51, GMP_RNDD, 4.747530291205672325e-51); check53(277363943109.0, 11.0, GMP_RNDN, 277363943120.0); +#ifdef HAVE_DENORMS /* test denormalized numbers too */ x = 70360154255223.0; for (i=0; i<1073; i++) x = x / 2.0; check53(8.06294740693074521573e-310, x, GMP_RNDU, - 1.5015454417650041761e-309); + 1.5015454417650041761e-309); +#endif #ifdef HAVE_INFS /* the following check double overflow */ check53(6.27557402141211962228e+307, 1.32141396570101687757e+308, diff --git a/mpfr/tests/tadd_ui.c b/mpfr/tests/tadd_ui.c index f6563839d..2110ed291 100644 --- a/mpfr/tests/tadd_ui.c +++ b/mpfr/tests/tadd_ui.c @@ -1,6 +1,6 @@ /* Test file for mpfr_add_ui -Copyright 2000, 2001, 2002 Free Software Foundation. +Copyright 2000, 2001, 2002, 2003 Free Software Foundation. This file is part of the MPFR Library. @@ -19,10 +19,6 @@ along with the MPFR Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* #define DEBUG */ -/* #define VERBOSE */ - -#include <math.h> #include <stdio.h> #include <stdlib.h> #include <float.h> @@ -42,20 +38,23 @@ void special _PROTO((void)); void check3 (double x, unsigned long y, unsigned int rnd_mode, double z1) { - double z2; mpfr_t xx,zz; + double z2; + mpfr_t xx, zz; - mpfr_init2(xx, 53); - mpfr_init2(zz, 53); - mpfr_set_d(xx, x, rnd_mode); - mpfr_add_ui(zz, xx, y, rnd_mode); + mpfr_init2 (xx, 53); + mpfr_init2 (zz, 53); + mpfr_set_d (xx, x, rnd_mode); + mpfr_add_ui (zz, xx, y, rnd_mode); z2 = mpfr_get_d1 (zz); - if (z1!=z2 && !(isnan(z1) && isnan(z2))) { - printf("expected sum is %1.20e, got %1.20e\n",z1,z2); - printf("mpfr_add_ui failed for x=%1.20e y=%lu with rnd_mode=%s\n", - x, y, mpfr_print_rnd_mode(rnd_mode)); - exit(1); + if (z1 != z2 && !(Isnan(z1) && Isnan(z2))) + { + printf ("expected sum is %1.20e, got %1.20e\n",z1,z2); + printf ("mpfr_add_ui failed for x=%1.20e y=%lu with rnd_mode=%s\n", + x, y, mpfr_print_rnd_mode(rnd_mode)); + exit (1); } - mpfr_clear(xx); mpfr_clear(zz); + mpfr_clear (xx); + mpfr_clear (zz); } void diff --git a/mpfr/tests/tagm.c b/mpfr/tests/tagm.c index 7b4a3bd69..514eb730e 100644 --- a/mpfr/tests/tagm.c +++ b/mpfr/tests/tagm.c @@ -1,6 +1,6 @@ /* Test file for mpfr_agm. -Copyright 1999, 2001, 2002 Free Software Foundation, Inc. +Copyright 1999, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -19,16 +19,15 @@ along with the MPFR Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include <math.h> #include <stdio.h> #include <stdlib.h> #include <time.h> #include "gmp.h" #include "mpfr.h" +#include "mpfr-impl.h" #include "mpfr-test.h" double drand_agm _PROTO((void)); -double dagm _PROTO((double, double)); void check4 _PROTO((double, double, mp_rnd_t, double)); void check_large _PROTO((void)); void slave _PROTO((int, int)); @@ -48,30 +47,6 @@ drand_agm (void) return d; } -double -dagm (double a, double b) -{ - double u, v, tmpu, tmpv; - - if ((isnan(a))||(isnan(b))) - return a+b; - - tmpv=MAX(a,b); - tmpu=MIN(a,b); - - do - { - u=tmpu; - v=tmpv; - tmpu=sqrt(u*v); - tmpv=(u+v)/2.0; - } - while (!(((tmpu==u)&&(tmpv==v))||(ulp(u,v)==0))); - - /* printf("difference : %i ulp\n",ulp(u,v)); */ - return u; -} - #define check(a,b,r) check4(a,b,r,0.0) void @@ -91,7 +66,7 @@ check4 (double a, double b, mp_rnd_t rnd_mode, double res1) res2 = mpfr_get_d1 (tres); - if (res1!=res2 && (!isnan(res1) || !isnan(res2))) + if (res1!=res2 && !(Isnan(res1) && Isnan(res2))) { printf ("mpfr_agm failed for a=%1.20e, b=%1.20e, rnd_mode=%d\n",a,b,rnd_mode); printf ("expected result is %1.20e, got %1.20e (%d ulp)\n",res1,res2, @@ -150,39 +125,50 @@ main (int argc, char* argv[]) tests_start_mpfr (); - if (argc==3) { /* tagm N p : N calculus with precision p*/ - printf("Doing %d random tests in %d precision\n",atoi(argv[1]),atoi(argv[2])); - slave(atoi(argv[1]),atoi(argv[2])); + if (argc == 3) /* tagm N p : N calculus with precision p*/ + { + printf ("Doing %d random tests in %d precision\n", atoi (argv[1]), + atoi (argv[2])); + slave (atoi (argv[1]), atoi (argv[2])); return 0; - } - - if (argc==2) { /* tagm N: N tests with random double's */ - int i; - double a,b; - - N = atoi(argv[1]); - for (i=0;i<N;i++) { - a = drand(); - b = drand(); - check(a, b, LONG_RAND() % 4); - } - return 0; - } - else { - check_large(); - check4(2.0, 1.0, GMP_RNDN, 1.45679103104690677029); - check4(6.0, 4.0, GMP_RNDN, 4.94936087247260925182); - check4(62.0, 61.0, GMP_RNDN, 6.14989837188450749750e+01); - check4(0.5, 1.0, GMP_RNDN, 7.28395515523453385143e-01); - check4(1.0, 2.0, GMP_RNDN, 1.45679103104690677029); - check4(234375765.0, 234375000.0, GMP_RNDN, 2.3437538249984395504e8); - check4(8.0, 1.0, GMP_RNDU, 3.615756177597362786); - check4(1.0, 44.0, GMP_RNDU, 1.33658354512981247808e1); - check4(1.0, 3.7252902984619140625e-9, GMP_RNDU, 7.55393356971199025907e-02); - } - - /* TODO : tests des infinis dans tagm.c */ + } + + if (argc == 2) /* tagm N: N tests with random double's */ + { + int i; + double a, b; + + N = atoi (argv[1]); + for (i = 0; i < N; i++) + { + a = drand(); + b = drand(); + check(a, b, LONG_RAND() % 4); + } + return 0; + } + else + { + check_large (); + check4 (2.0, 1.0, GMP_RNDN, 1.45679103104690677029); + check4 (6.0, 4.0, GMP_RNDN, 4.94936087247260925182); + check4 (62.0, 61.0, GMP_RNDN, 6.14989837188450749750e+01); + check4 (0.5, 1.0, GMP_RNDN, 7.28395515523453385143e-01); + check4 (1.0, 2.0, GMP_RNDN, 1.45679103104690677029); + check4 (234375765.0, 234375000.0, GMP_RNDN, 2.3437538249984395504e8); + check4 (8.0, 1.0, GMP_RNDU, 3.615756177597362786); + check4 (1.0, 44.0, GMP_RNDU, 1.33658354512981247808e1); + check4 (1.0, 3.7252902984619140625e-9, GMP_RNDU, 7.55393356971199025907e-02); + } + +#ifdef HAVE_INFS + check4 (1.0, DBL_NAN, GMP_RNDN, DBL_NAN); + check4 (1.0, DBL_POS_INF, GMP_RNDN, DBL_POS_INF); + check4 (DBL_POS_INF, DBL_POS_INF, GMP_RNDN, DBL_POS_INF); + check4 (DBL_NEG_INF, DBL_POS_INF, GMP_RNDN, DBL_NAN); +#endif tests_end_mpfr (); + return 0; } diff --git a/mpfr/tests/tcmp.c b/mpfr/tests/tcmp.c index e60fe18ad..a1bf851be 100644 --- a/mpfr/tests/tcmp.c +++ b/mpfr/tests/tcmp.c @@ -1,6 +1,6 @@ /* Test file for mpfr_cmp. -Copyright 1999, 2001, 2002 Free Software Foundation, Inc. +Copyright 1999, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -21,7 +21,6 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include <math.h> #include "gmp.h" #include "mpfr.h" #include "mpfr-impl.h" @@ -161,20 +160,27 @@ main (void) exit (1); } - for (i=0;i<1000000;) { x=drand(); y=drand(); - if (!isnan(x) && !isnan(y)) { - i++; - mpfr_set_d(xx, x, 0); - mpfr_set_d(yy, y, 0); - c = mpfr_cmp(xx,yy); - if ((c>0 && x<=y) || (c==0 && x!=y) || (c<0 && x>=y)) { - printf("Error in mpfr_cmp with x=%1.20e, y=%1.20e mpfr_cmp(x,y)=%d\n", - x,y,c); exit(1); - } + for (i=0; i<1000000; ) + { + x = drand(); + y = drand(); + if (!Isnan(x) && !Isnan(y)) + { + i++; + mpfr_set_d (xx, x, 0); + mpfr_set_d (yy, y, 0); + c = mpfr_cmp (xx,yy); + if ((c>0 && x<=y) || (c==0 && x!=y) || (c<0 && x>=y)) + { + printf ("Error in mpfr_cmp with x=%1.20e, y=%1.20e mpfr_cmp(x,y)=%d\n", + x, y, c); + exit (1); + } + } } - } - mpfr_clear(xx); mpfr_clear(yy); + mpfr_clear (xx); + mpfr_clear (yy); tests_end_mpfr (); return 0; diff --git a/mpfr/tests/tcmp2.c b/mpfr/tests/tcmp2.c index d36350ef1..b290c9b92 100644 --- a/mpfr/tests/tcmp2.c +++ b/mpfr/tests/tcmp2.c @@ -1,6 +1,6 @@ /* Test file for mpfr_cmp2. -Copyright 1999, 2000, 2001, 2002 Free Software Foundation. +Copyright 1999, 2000, 2001, 2002, 2003 Free Software Foundation. This file is part of the MPFR Library. @@ -21,7 +21,6 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include <math.h> #include "gmp.h" #include "mpfr.h" #include "mpfr-impl.h" @@ -153,9 +152,12 @@ tcmp2 (double x, double y, int i) mpfr_t xx, yy; mp_prec_t j; - if (i==-1) { - if (x==y) i=53; - else i = (int) floor(log(x)/log(2.0)) - (int) floor(log(x-y)/log(2.0)); + if (i == -1) + { + if (x == y) + i = 53; + else + i = (int) (__gmpfr_floor_log2 (x) - __gmpfr_floor_log2 (x - y)); } mpfr_init2(xx, 53); mpfr_init2(yy, 53); mpfr_set_d (xx, x, GMP_RNDN); @@ -279,31 +281,42 @@ special (void) int main (void) { - int i,j; double x=1.0, y, z; + int i, j; + double x = 1.0, y, z; tests_start_mpfr (); mpfr_test_init (); worst_cases (); special (); - tcmp2(5.43885304644369510000e+185, -1.87427265794105340000e-57, 1); - tcmp2(1.06022698059744327881e+71, 1.05824655795525779205e+71, -1); - tcmp2(1.0, 1.0, 53); - for (i=0;i<54;i++) { - tcmp2 (1.0, 1.0-x, i); - x /= 2.0; - } - for (x=0.5, i=1; i<100; i++) { - tcmp2 (1.0, x, 1); - x /= 2.0; - } - for (j=0; j<100000; j++) { - x = DBL_RAND (); - y = DBL_RAND (); - if (x<y) { z=x; x=y; y=z; } - if (y != 0.0 && y != -0.0) tcmp2(x, y, -1); + tcmp2 (5.43885304644369510000e+185, -1.87427265794105340000e-57, 1); + tcmp2 (1.06022698059744327881e+71, 1.05824655795525779205e+71, -1); + tcmp2 (1.0, 1.0, 53); + for (i = 0; i < 54; i++) + { + tcmp2 (1.0, 1.0-x, i); + x /= 2.0; + } + for (x = 0.5, i = 1; i < 100; i++) + { + tcmp2 (1.0, x, 1); + x /= 2.0; + } + for (j = 0; j < 100000; j++) + { + x = DBL_RAND (); + y = DBL_RAND (); + if (x < y) + { + z = x; + x = y; + y = z; + } + if (y != 0.0 && y != -0.0) + tcmp2 (x, y, -1); } tests_end_mpfr (); + return 0; } diff --git a/mpfr/tests/tcmp_ui.c b/mpfr/tests/tcmp_ui.c index 5b6b35a2c..3beb7b85e 100644 --- a/mpfr/tests/tcmp_ui.c +++ b/mpfr/tests/tcmp_ui.c @@ -1,6 +1,6 @@ /* Test file for mpfr_cmp_ui. -Copyright 1999, 2001, 2002 Free Software Foundation, Inc. +Copyright 1999, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -21,7 +21,6 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include <math.h> #include "gmp.h" #include "mpfr.h" #include "mpfr-test.h" diff --git a/mpfr/tests/tcos.c b/mpfr/tests/tcos.c index aacfa0142..65c5c2100 100644 --- a/mpfr/tests/tcos.c +++ b/mpfr/tests/tcos.c @@ -1,6 +1,6 @@ /* Test file for mpfr_cos. -Copyright 2001, 2002 Free Software Foundation, Inc. +Copyright 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -21,7 +21,6 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include <math.h> #include "gmp.h" #include "mpfr.h" #include "mpfr-impl.h" @@ -38,7 +37,7 @@ check53 (double x, double cos_x, mp_rnd_t rnd_mode) mpfr_init2 (c, 53); mpfr_set_d (xx, x, rnd_mode); /* should be exact */ mpfr_cos (c, xx, rnd_mode); - if (mpfr_get_d1 (c) != cos_x && (!isnan(cos_x) || !mpfr_nan_p(c))) + if (mpfr_get_d1 (c) != cos_x && !(Isnan(cos_x) && mpfr_nan_p(c))) { fprintf (stderr, "mpfr_cos failed for x=%1.20e, rnd=%s\n", x, mpfr_print_rnd_mode (rnd_mode)); diff --git a/mpfr/tests/tdiv.c b/mpfr/tests/tdiv.c index d0588dc6e..029cedb12 100644 --- a/mpfr/tests/tdiv.c +++ b/mpfr/tests/tdiv.c @@ -1,6 +1,6 @@ /* Test file for mpfr_div. -Copyright 1999, 2001, 2002 Free Software Foundation, Inc. +Copyright 1999, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -52,10 +52,10 @@ check4 (double N, double D, mp_rnd_t rnd_mode, int p, double Q) mpfr_set_d(d, D, rnd_mode); mpfr_div(q, n, d, rnd_mode); Q2 = mpfr_get_d1 (q); - if (p == 53 && Q != Q2 && (!isnan(Q) || !isnan(Q2))) + if (p == 53 && Q != Q2 && !(Isnan(Q) && Isnan(Q2))) { printf ("mpfr_div failed for n=%1.20e, d=%1.20e, rnd_mode=%s\n", - N, D, mpfr_print_rnd_mode(rnd_mode)); + N, D, mpfr_print_rnd_mode (rnd_mode)); printf ("correct quotient is %1.20e, mpfr_div gives %1.20e (%d ulp)\n", Q, Q2, ulp (Q2, Q)); exit (1); diff --git a/mpfr/tests/tdiv_ui.c b/mpfr/tests/tdiv_ui.c index 85d08e03f..2feecaf07 100644 --- a/mpfr/tests/tdiv_ui.c +++ b/mpfr/tests/tdiv_ui.c @@ -1,6 +1,6 @@ /* Test file for mpfr_div_ui. -Copyright 1999, 2000, 2001, 2002 Free Software Foundation. +Copyright 1999, 2000, 2001, 2002, 2003 Free Software Foundation. This file is part of the MPFR Library. @@ -37,17 +37,21 @@ check (double d, unsigned long u, mp_rnd_t rnd, double e) mpfr_t x, y; double f; - mpfr_init2(x, 53); mpfr_init2(y, 53); - mpfr_set_d(x, d, rnd); - mpfr_div_ui(y, x, u, rnd); + mpfr_init2 (x, 53); + mpfr_init2 (y, 53); + mpfr_set_d (x, d, rnd); + mpfr_div_ui (y, x, u, rnd); f = mpfr_get_d1 (y); - if (f != e && (!isnan(f) || !isnan(e))) { - printf("mpfr_div_ui failed for x=%1.20e, u=%lu, rnd=%s\n", d, u, - mpfr_print_rnd_mode(rnd)); - printf("expected result is %1.20e, got %1.20e, dif=%d ulp\n",e,f,ulp(e,f)); - exit(1); + if (f != e && !(Isnan(f) && Isnan(e))) + { + printf ("mpfr_div_ui failed for x=%1.20e, u=%lu, rnd=%s\n", d, u, + mpfr_print_rnd_mode (rnd)); + printf ("expected result is %1.20e, got %1.20e, dif=%d ulp\n", + e, f, ulp (e,f)); + exit (1); } - mpfr_clear(x); mpfr_clear(y); + mpfr_clear (x); + mpfr_clear (y); } void diff --git a/mpfr/tests/teq.c b/mpfr/tests/teq.c index fa2c2857e..79933dd9b 100644 --- a/mpfr/tests/teq.c +++ b/mpfr/tests/teq.c @@ -1,6 +1,6 @@ /* Test file for mpfr_eq. -Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc. +Copyright 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -21,7 +21,6 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include <math.h> #include "gmp.h" #include "mpfr.h" #include "mpfr-impl.h" diff --git a/mpfr/tests/tests.c b/mpfr/tests/tests.c index 31c202c4b..ef374c607 100644 --- a/mpfr/tests/tests.c +++ b/mpfr/tests/tests.c @@ -87,8 +87,8 @@ mpfr_test_init () tests_machine_prec_double (); - /* generate DBL_EPSILON with a loop to avoid that the preprocessor - optimizes the code below in non-IEEE 754 mode, deciding that + /* generate DBL_EPSILON with a loop to avoid that the compiler + optimizes the code below in non-IEEE 754 mode, deciding that c = d is always false. */ for (eps = 1.0; eps != DBL_EPSILON; eps /= 2.0); c = 1.0 + eps; @@ -100,6 +100,7 @@ mpfr_test_init () fprintf (stderr, " (maybe extended precision not disabled)\n"); fprintf (stderr, " Some tests may fail\n"); } + } @@ -145,7 +146,7 @@ drand (void) i[1] = LONG_RAND(); while (i[expo] >= 2146435072) i[expo] = LONG_RAND(); /* avoids NaNs */ - if ((LONG_RAND() % 2) && !isnan (d)) + if ((LONG_RAND() % 2) && !Isnan(d)) d = -d; /* generates negative numbers */ return d; } @@ -200,10 +201,8 @@ dbl (double m, int e) return m; } -#ifndef HAVE_ISNAN int Isnan (double d) { return (d) != (d); } -#endif diff --git a/mpfr/tests/texp.c b/mpfr/tests/texp.c index 4bad0bac0..c5af39d69 100644 --- a/mpfr/tests/texp.c +++ b/mpfr/tests/texp.c @@ -1,6 +1,6 @@ /* Test file for mpfr_exp. -Copyright 1999, 2001, 2002 Free Software Foundation, Inc. +Copyright 1999, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -19,7 +19,6 @@ along with the MPFR Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include <math.h> #include <stdio.h> #include <stdlib.h> #include <time.h> @@ -43,26 +42,35 @@ int maxu=0; int check3 (double d, mp_rnd_t rnd, double e) { - mpfr_t x, y; double f; int u=0; + mpfr_t x, y; + double f; + int u = 0; - mpfr_init2(x, 53); mpfr_init2(y, 53); - mpfr_set_d(x, d, rnd); - mpfr_exp(y, x, rnd); + mpfr_init2 (x, 53); + mpfr_init2 (y, 53); + mpfr_set_d (x, d, rnd); + mpfr_exp (y, x, rnd); f = mpfr_get_d1 (y); - if (f != e && (!isnan(f) || !isnan(e))) { - u = ulp(e, f); - if (u<0) { - if (u == (mp_limb_t) 1 << (mp_bits_per_limb-1)) u += 1; - u=-u; - } - if (u!=0) { - printf ("mpfr_exp failed for x=%1.20e, rnd=%s\n", d, - mpfr_print_rnd_mode(rnd)); - printf ("expected result is %1.20e, got %1.20e, dif=%d ulp\n",e,f,u); - exit (1); + if (f != e && !(Isnan(f) && Isnan(e))) + { + u = ulp (e, f); + if (u < 0) + { + if (u == (mp_limb_t) 1 << (mp_bits_per_limb-1)) + u += 1; + u = -u; + } + if (u != 0) + { + printf ("mpfr_exp failed for x=%1.20e, rnd=%s\n", d, + mpfr_print_rnd_mode (rnd)); + printf ("expected result is %1.20e, got %1.20e, dif=%d ulp\n", + e, f, u); + exit (1); + } } - } - mpfr_clear(x); mpfr_clear(y); + mpfr_clear (x); + mpfr_clear (y); return u; } diff --git a/mpfr/tests/tget_str.c b/mpfr/tests/tget_str.c index 5a4353b14..a15a141f1 100644 --- a/mpfr/tests/tget_str.c +++ b/mpfr/tests/tget_str.c @@ -1,6 +1,6 @@ /* Test file for mpfr_get_str. -Copyright 1999, 2001, 2002 Free Software Foundation, Inc. +Copyright 1999, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -19,7 +19,6 @@ along with the MPFR Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> diff --git a/mpfr/tests/tlog.c b/mpfr/tests/tlog.c index 168d6d802..df5d26c62 100644 --- a/mpfr/tests/tlog.c +++ b/mpfr/tests/tlog.c @@ -1,6 +1,6 @@ /* Test file for mpfr_log. -Copyright 1999, 2001, 2002 Free Software Foundation, Inc. +Copyright 1999, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -21,7 +21,6 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include <math.h> #include <time.h> #include "gmp.h" #include "mpfr.h" @@ -64,24 +63,27 @@ check1 (double a, mp_rnd_t rnd_mode, double res1, int ck, int max_ulp) { mpfr_t ta, tres; double res2; - int diff=0; + int diff = 0; /* ck=1 iff res1 is certified correct */ - mpfr_init2(ta, 53); - mpfr_init2(tres, 53); - mpfr_set_d(ta, a, GMP_RNDN); - mpfr_log(tres, ta, rnd_mode); - res2=mpfr_get_d1 (tres); - mpfr_clear(ta); mpfr_clear(tres); - - if (res1!=res2 && (!isnan(res1) || !isnan(res2))) { - diff = ulp(res1,res2); - printf("mpfr_log failed for a=%1.20e, rnd_mode=%s\n", a, - mpfr_print_rnd_mode(rnd_mode)); - printf("correct result is %1.20e\n mpfr_log gives %1.20e (%d ulp)\n",res1,res2,ulp(res1,res2)); - exit(1); - } - if (!isnan(res1) || !isnan(res2)) + mpfr_init2 (ta, 53); + mpfr_init2 (tres, 53); + mpfr_set_d (ta, a, GMP_RNDN); + mpfr_log (tres, ta, rnd_mode); + res2 = mpfr_get_d1 (tres); + mpfr_clear (ta); + mpfr_clear (tres); + + if (res1 != res2 && !(Isnan(res1) && Isnan(res2))) + { + diff = ulp (res1,res2); + printf ("mpfr_log failed for a=%1.20e, rnd_mode=%s\n", a, + mpfr_print_rnd_mode (rnd_mode)); + printf ("correct result is %1.20e\n mpfr_log gives %1.20e (%d ulp)\n", + res1, res2, ulp (res1,res2)); + exit (1); + } + if (!Isnan(res1) || !Isnan(res2)) return diff; else return 0; diff --git a/mpfr/tests/tmul.c b/mpfr/tests/tmul.c index c2d348747..9394594ee 100644 --- a/mpfr/tests/tmul.c +++ b/mpfr/tests/tmul.c @@ -1,6 +1,6 @@ /* Test file for mpfr_mul. -Copyright 1999, 2001, 2002 Free Software Foundation, Inc. +Copyright 1999, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -68,7 +68,8 @@ _check (double x, double y, double res, mp_rnd_t rnd_mode, unsigned int px, void check53 (double x, double y, mp_rnd_t rnd_mode, double z1) { - double z2; mpfr_t xx, yy, zz; + double z2; + mpfr_t xx, yy, zz; mpfr_init2 (xx, 53); mpfr_init2 (yy, 53); @@ -77,13 +78,16 @@ check53 (double x, double y, mp_rnd_t rnd_mode, double z1) mpfr_set_d (yy, y, rnd_mode); mpfr_mul (zz, xx, yy, rnd_mode); z2 = mpfr_get_d1 (zz); - if (z1!=z2 && (!isnan(z1) || !isnan(z2))) { - printf("mpfr_mul failed for x=%1.20e y=%1.20e with rnd_mode=%s\n", - x, y, mpfr_print_rnd_mode(rnd_mode)); - printf("correct result is %1.20e, mpfr_mul gives %1.20e\n", z1, z2); - exit(1); - } - mpfr_clear(xx); mpfr_clear(yy); mpfr_clear(zz); + if (z1 != z2 && !(Isnan(z1) && Isnan(z2))) + { + printf ("mpfr_mul failed for x=%1.20e y=%1.20e with rnd_mode=%s\n", + x, y, mpfr_print_rnd_mode(rnd_mode)); + printf ("correct result is %1.20e, mpfr_mul gives %1.20e\n", z1, z2); + exit (1); + } + mpfr_clear (xx); + mpfr_clear (yy); + mpfr_clear (zz); } /* checks that x*y gives the same results in double diff --git a/mpfr/tests/tmul_ui.c b/mpfr/tests/tmul_ui.c index 54533d179..ee4bf9f3d 100644 --- a/mpfr/tests/tmul_ui.c +++ b/mpfr/tests/tmul_ui.c @@ -1,6 +1,6 @@ /* Test file for mpfr_mul_ui. -Copyright 1999, 2000, 2001, 2002 Free Software Foundation. +Copyright 1999, 2000, 2001, 2002, 2003 Free Software Foundation. This file is part of the MPFR Library. @@ -21,7 +21,6 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include <math.h> #include "gmp.h" #include "gmp-impl.h" #include "mpfr.h" diff --git a/mpfr/tests/tout_str.c b/mpfr/tests/tout_str.c index 0f1a4cfe6..af4d4c23a 100644 --- a/mpfr/tests/tout_str.c +++ b/mpfr/tests/tout_str.c @@ -1,6 +1,6 @@ /* Test file for mpfr_out_str. -Copyright 1999, 2001, 2002 Free Software Foundation, Inc. +Copyright 1999, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -19,7 +19,6 @@ along with the MPFR Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include <math.h> #include <float.h> #include <stdio.h> #include <stdlib.h> diff --git a/mpfr/tests/trandom.c b/mpfr/tests/trandom.c index 0637eb0ab..a1c5663d2 100644 --- a/mpfr/tests/trandom.c +++ b/mpfr/tests/trandom.c @@ -21,7 +21,6 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include <math.h> #include <time.h> #include "gmp.h" #include "mpfr.h" diff --git a/mpfr/tests/tset.c b/mpfr/tests/tset.c index 910185050..e103ac796 100644 --- a/mpfr/tests/tset.c +++ b/mpfr/tests/tset.c @@ -1,6 +1,6 @@ /* Test file for mpfr_set. -Copyright 2001, 2002 Free Software Foundation. +Copyright 2001, 2002, 2003 Free Software Foundation. This file is part of the MPFR Library. @@ -19,7 +19,6 @@ along with the MPFR Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include <math.h> #include <stdio.h> #include <stdlib.h> #include "gmp.h" diff --git a/mpfr/tests/tset_d.c b/mpfr/tests/tset_d.c index 5fab50807..2b3c4578b 100644 --- a/mpfr/tests/tset_d.c +++ b/mpfr/tests/tset_d.c @@ -1,6 +1,6 @@ /* Test file for mpfr_set_d and mpfr_get_d. -Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc. +Copyright 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -118,16 +118,19 @@ main (int argc, char *argv[]) #endif mpfr_set_d (x, d, 0); dd = mpfr_get_d1 (x); - if (d != dd && (!isnan(d) || !isnan(dd))) + if (d != dd && !(Isnan(d) && Isnan(dd))) { - fprintf(stderr, - "Mismatch on : %1.18g != %1.18g\n", d, mpfr_get_d1 (x)); - mpfr_print_binary(x); putchar('\n'); - exit(1); + fprintf (stderr, + "Mismatch on : %1.18g != %1.18g\n", d, mpfr_get_d1 (x)); + mpfr_print_binary (x); + putchar ('\n'); + exit (1); } } - mpfr_clear(x); mpfr_clear(y); mpfr_clear(z); + mpfr_clear (x); + mpfr_clear (y); + mpfr_clear (z); tests_end_mpfr (); return 0; diff --git a/mpfr/tests/tset_ld.c b/mpfr/tests/tset_ld.c index 2ec220936..c1b974c0f 100644 --- a/mpfr/tests/tset_ld.c +++ b/mpfr/tests/tset_ld.c @@ -47,7 +47,7 @@ check_set_get (long double d, mpfr_t x) exit (1); } e = mpfr_get_ld (x, r); - if (e != d && !(isnan(e) && isnan(d))) + if (e != d && !(LONGDOUBLE_ISNAN(e) && LONGDOUBLE_ISNAN(d))) { fprintf (stderr, "Error: mpfr_get_ld o mpfr_set_ld <> Id\n"); fprintf (stderr, "d=%1.30Le get_ld(set_ld(d))=%1.30Le\n", d, e); diff --git a/mpfr/tests/tset_str.c b/mpfr/tests/tset_str.c index acdf24cf9..431441fbb 100644 --- a/mpfr/tests/tset_str.c +++ b/mpfr/tests/tset_str.c @@ -1,6 +1,6 @@ /* Test file for mpfr_set_str. -Copyright 1999, 2001, 2002 Free Software Foundation, Inc. +Copyright 1999, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -51,6 +51,8 @@ main (int argc, char *argv[]) return 0; } + mpfr_init2 (x, 2); + SEED_RAND (time(NULL)); nc = (argc > 1) ? atoi(argv[1]) : 53; @@ -62,6 +64,7 @@ main (int argc, char *argv[]) str2 = str = (*__gmp_allocate_func) (nc * sizeof(char)); if (bd) + { for(k = 1; k <= bd; k++) *(str2++) = (LONG_RAND() & 1) + '0'; @@ -77,7 +80,7 @@ main (int argc, char *argv[]) *(str2++) = 'e'; sprintf (str2, "%d", (int) LONG_RAND() - (1 << 30)); - mpfr_init2 (x, nc + 10); + mpfr_set_prec (x, nc + 10); mpfr_set_str_raw (x, str); mpfr_set_prec (x, 54); @@ -86,14 +89,14 @@ main (int argc, char *argv[]) mpfr_set_str (y, "4.936a52bc17254@-133", 16, GMP_RNDN); if (mpfr_cmp (x, y)) { - fprintf (stderr, "Error in mpfr_set_str\n"); - mpfr_print_binary(x); - putchar('\n'); - mpfr_print_binary(y); - putchar('\n'); - mpfr_clear(x); - mpfr_clear(y); - exit(1); + fprintf (stderr, "Error in mpfr_set_str (1):\n"); + mpfr_print_binary (x); + putchar ('\n'); + mpfr_print_binary (y); + putchar ('\n'); + mpfr_clear (x); + mpfr_clear (y); + exit (1); } (*__gmp_free_func) (str, nc * sizeof(char)); @@ -166,27 +169,27 @@ main (int argc, char *argv[]) (*__gmp_free_func) (str, strlen (str) + 1); } - if (mpfr_set_str (x, "NaNgarbage", 10, GMP_RNDN) != 3 || !mpfr_nan_p(x)) + if (mpfr_set_str (x, "NaNgarbage", 10, GMP_RNDN) != 0 || !mpfr_nan_p(x)) { fprintf (stderr, "mpfr_set_str failed on NaN\n"); exit (1); } - if (mpfr_set_str (x, "Infgarbage", 10, GMP_RNDN) != 3 || !mpfr_inf_p(x) || + if (mpfr_set_str (x, "Infgarbage", 10, GMP_RNDN) != 0 || !mpfr_inf_p(x) || MPFR_SIGN(x) < 0) { fprintf (stderr, "mpfr_set_str failed on Inf\n"); exit (1); } - if (mpfr_set_str (x, "-Infgarbage", 10, GMP_RNDN) != 4 || !mpfr_inf_p(x) || + if (mpfr_set_str (x, "-Infgarbage", 10, GMP_RNDN) != 0 || !mpfr_inf_p(x) || MPFR_SIGN(x) > 0) { fprintf (stderr, "mpfr_set_str failed on -Inf\n"); exit (1); } - if (mpfr_set_str (x, "+Infgarbage", 10, GMP_RNDN) != 4 || !mpfr_inf_p(x) || + if (mpfr_set_str (x, "+Infgarbage", 10, GMP_RNDN) != 0 || !mpfr_inf_p(x) || MPFR_SIGN(x) < 0) { fprintf (stderr, "mpfr_set_str failed on +Inf\n"); @@ -202,6 +205,187 @@ main (int argc, char *argv[]) exit (1); } + /* start of tests added by Alain Delplanque */ + + /* in this example an overflow can occur */ + mpfr_set_prec (x, 64); + mpfr_set_prec (y, 64); + mpfr_set_str_raw (x, "1.0E-532"); + mpfr_set_str (y, "0.71128279983522479470@-160", 10, GMP_RNDU); + if (mpfr_cmp (x, y)) + { + fprintf (stderr, "Error in mpfr_set_str (2):\n"); + mpfr_print_binary (x); + putchar ('\n'); + mpfr_print_binary (y); + putchar ('\n'); + mpfr_clear (x); + mpfr_clear (y); + exit (1); + } + + /* in this example, I think there was a pb in the old function : + result of mpfr_set_str_old for the same number , but with more + precision is: 1.111111111110000000000000000111111111111111111111111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100111000100001100000010101100111010e184 + this result is the same as mpfr_set_str */ + mpfr_set_prec (x, 64); + mpfr_set_prec (y, 64); + mpfr_set_str_raw (x, "1.111111111110000000000000000111111111111111111111111110000000001E184"); + mpfr_set_str (y, "0.jo08hg31hc5mmpj5mjjmgn55p2h35g@39", 27, GMP_RNDU); + /* y = 49027884868983130654865109690613178467841148597221480052 */ + if (mpfr_cmp (x, y)) + { + fprintf (stderr, "Error in mpfr_set_str (3):\n"); + mpfr_print_binary (x); + putchar ('\n'); + mpfr_print_binary (y); + putchar ('\n'); + mpfr_clear (x); + mpfr_clear (y); + exit (1); + } + + /* not exact rounding in mpfr_set_str + same number with more precision is : 1.111111111111111111111111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011011111101000001101110110010101101000010100110011101110010001110e195 + this result is the same as mpfr_set_str */ + /* problem was : can_round was call with GMP_RNDN round mode, + so can_round use an error : 1/2 * 2^err * ulp(y) + instead of 2^err * ulp(y) + I have increase err by 1 */ + mpfr_set_prec (x, 64); /* it was round down instead of up */ + mpfr_set_prec (y, 64); + mpfr_set_str_raw (x, "1.111111111111111111111111111000000000000000000000000000000000001e195"); + mpfr_set_str (y, "0.6e23ekb6acgh96abk10b6c9f2ka16i@45", 21, GMP_RNDU); + /* y = 100433627392042473064661483711179345482301462325708736552078 */ + if (mpfr_cmp (x, y)) + { + fprintf (stderr, "Error in mpfr_set_str (4):\n"); + mpfr_print_binary (x); + putchar ('\n'); + mpfr_print_binary (y); + putchar ('\n'); + mpfr_clear (x); + mpfr_clear (y); + exit (1); + } + + /* may be an error in mpfr_set_str_old + with more precision : 1.111111100000001111110000000000011111011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110111101010001110111011000010111001011100110110e180 */ + mpfr_set_prec (x, 64); /* it was round down instead of up */ + mpfr_set_prec (y, 64); + mpfr_set_str_raw (x, "1.111111100000001111110000000000011111011111111111111111111111111e180"); + mpfr_set_str (y, "0.10j8j2k82ehahha56390df0a1de030@41", 23, GMP_RNDZ); + /* y = 3053110535624388280648330929253842828159081875986159414 */ + if (mpfr_cmp (x, y)) + { + fprintf (stderr, "Error in mpfr_set_str (5):\n"); + mpfr_print_binary (x); + putchar ('\n'); + mpfr_print_binary (y); + putchar ('\n'); + mpfr_clear (x); + mpfr_clear (y); + exit (1); + } + + mpfr_set_prec (x, 64); + mpfr_set_prec (y, 64); + mpfr_set_str (y, "0.jrchfhpp9en7hidqm9bmcofid9q3jg@39", 28, GMP_RNDU); + /* y = 196159429139499688661464718784226062699788036696626429952 */ + mpfr_set_str_raw (x, "0.1111111111111111111111111111111000000000000011100000001111100001E187"); + if (mpfr_cmp (x, y)) + { + fprintf (stderr, "Error in mpfr_set_str (6):\n"); + mpfr_print_binary (x); + putchar ('\n'); + mpfr_print_binary (y); + putchar ('\n'); + mpfr_clear (x); + mpfr_clear (y); + exit (1); + } + + mpfr_set_prec (x, 64); + mpfr_set_prec (y, 64); + mpfr_set_str (y, "0.h148m5ld5cf8gk1kd70b6ege92g6ba@47", 24, GMP_RNDZ); + /* y = 52652933527468502324759448399183654588831274530295083078827114496 */ + mpfr_set_str_raw (x, "0.1111111111111100000000001000000000000000000011111111111111101111E215"); + if (mpfr_cmp (x, y)) + { + fprintf (stderr, "Error in mpfr_set_str (7):\n"); + mpfr_print_binary (x); + putchar ('\n'); + mpfr_print_binary (y); + putchar ('\n'); + mpfr_clear (x); + mpfr_clear (y); + exit (1); + } + + /* to check this problem : I convert limb (10--0 or 101--1) into base b + with more than mp_bits_per_limb digits, + so when convert into base 2 I should have + the limb that I have choose */ + /* this use mpfr_get_str */ + { + size_t nb_digit = mp_bits_per_limb; + mp_limb_t check_limb[2] = {MPFR_LIMB_HIGHBIT, ~(MPFR_LIMB_HIGHBIT >> 1)}; + int base[3] = {10, 16, 19}; + mp_rnd_t rnd[3] = {GMP_RNDU, GMP_RNDN, GMP_RNDD}; + int cbase, climb, crnd; + char *str; + + mpfr_set_prec (x, mp_bits_per_limb); /* x and y have only one limb */ + mpfr_set_prec (y, mp_bits_per_limb); + + str = (*__gmp_allocate_func) (100000 + 20); + + mpfr_set_ui (x, 1, GMP_RNDN); /* ensures that x is not NaN or Inf */ + for (; nb_digit < 100000; nb_digit *= 10) + for (cbase = 0; cbase < 3; cbase++) + for (climb = 0; climb < 2; climb++) + for (crnd = 0; crnd < 3; crnd++) + { + char *str1; + mp_exp_t exp; + + *(MPFR_MANT(x)) = check_limb[climb]; + MPFR_EXP(x) = 0; + + mpfr_get_str (str + 2, &exp, base[cbase], + nb_digit, x, rnd[crnd]); + if (str[2] == '-') + { + str[0] = '-'; str[1] = '0'; str[2] = '.'; + } + else + { + str[0] = '0'; str[1] = '.'; + } + for (str1 = str; *str1 != 0; str1++); + sprintf (str1, "@%i", (int) exp); + + mpfr_set_str (y, str, base[cbase], rnd[2 - crnd]); + + if (mpfr_cmp (x, y) != 0) + { + fprintf (stderr, "Error in mpfr_set_str for nb_digit=%u, base=%u, rnd=%s:\n", nb_digit, base[cbase], mpfr_print_rnd_mode (rnd[crnd])); + fprintf (stderr, "instead of: "); + mpfr_print_binary (x); + putchar ('\n'); + fprintf (stderr, "return : "); + mpfr_print_binary (y); + putchar ('\n'); + } + + } + + (*__gmp_free_func) (str, 100000 + 20); + + } + + /* end of tests added by Alain Delplanque */ + mpfr_clear (x); mpfr_clear (y); diff --git a/mpfr/tests/tsin.c b/mpfr/tests/tsin.c index 5e04aee8a..85795bef8 100644 --- a/mpfr/tests/tsin.c +++ b/mpfr/tests/tsin.c @@ -1,6 +1,6 @@ /* Test file for mpfr_sin. -Copyright 2001, 2002 Free Software Foundation, Inc. +Copyright 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -21,7 +21,6 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include <math.h> #include "gmp.h" #include "mpfr.h" #include "mpfr-impl.h" @@ -36,7 +35,7 @@ check53 (double x, double sin_x, mp_rnd_t rnd_mode) mpfr_init2 (s, 53); mpfr_set_d (xx, x, rnd_mode); /* should be exact */ mpfr_sin (s, xx, rnd_mode); - if (mpfr_get_d1 (s) != sin_x && (!isnan(sin_x) || !mpfr_nan_p(s))) + if (mpfr_get_d1 (s) != sin_x && !(Isnan(sin_x) && mpfr_nan_p(s))) { fprintf (stderr, "mpfr_sin failed for x=%1.20e, rnd=%s\n", x, mpfr_print_rnd_mode (rnd_mode)); diff --git a/mpfr/tests/tsin_cos.c b/mpfr/tests/tsin_cos.c new file mode 100644 index 000000000..582f37aa9 --- /dev/null +++ b/mpfr/tests/tsin_cos.c @@ -0,0 +1,162 @@ +/* Test file for mpfr_sin_cos. + +Copyright 2000, 2001, 2002, 2003 Free Software Foundation, Inc. + +This file is part of the MPFR Library. + +The MPFR Library is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at your +option) any later version. + +The MPFR Library is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with the MPFR Library; see the file COPYING.LIB. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +MA 02111-1307, USA. */ + +#include <stdio.h> +#include <stdlib.h> +#include "gmp.h" +#include "mpfr.h" +#include "mpfr-impl.h" +#include "mpfr-test.h" + +void large_test _PROTO ((int, int)); +void check53 _PROTO ((double, double, double, mp_rnd_t)); +void check53sin _PROTO ((double, double, mp_rnd_t)); +void check53cos _PROTO ((double, double, mp_rnd_t)); + +void large_test (int prec, int N) +{ + int i; + mpfr_t x, s, c; + + mpfr_init2 (x, prec); + mpfr_init2 (s, prec); + mpfr_init2 (c, prec); + mpfr_set_d (x, 3.0, GMP_RNDN); + mpfr_sqrt (x, x, GMP_RNDN); + for (i=0; i<N; i++) mpfr_sin_cos (s, c, x, GMP_RNDN); + mpfr_out_str (stdout, 10, 0, s, GMP_RNDN); putchar('\n'); + mpfr_clear (x); + mpfr_clear (s); + mpfr_clear (c); +} + +void check53 (double x, double sin_x, double cos_x, mp_rnd_t rnd_mode) +{ + mpfr_t xx, s, c; + + mpfr_init2 (xx, 53); + mpfr_init2 (s, 53); + mpfr_init2 (c, 53); + mpfr_set_d (xx, x, rnd_mode); /* should be exact */ + mpfr_sin_cos (s, c, xx, rnd_mode); + if (mpfr_get_d1 (s) != sin_x && !(Isnan(sin_x) && mpfr_nan_p(s))) + { + fprintf (stderr, "mpfr_sin_cos failed for x=%1.20e, rnd=%s\n", x, + mpfr_print_rnd_mode (rnd_mode)); + fprintf (stderr, "mpfr_sin_cos gives sin(x)=%1.20e, expected %1.20e\n", + mpfr_get_d1 (s), sin_x); + exit (1); + } + if (mpfr_get_d1 (c) != cos_x && !(Isnan(cos_x) && mpfr_nan_p(c))) + { + fprintf (stderr, "mpfr_sin_cos failed for x=%1.20e, rnd=%s\n", x, + mpfr_print_rnd_mode (rnd_mode)); + fprintf (stderr, "mpfr_sin_cos gives cos(x)=%1.20e, expected %1.20e\n", + mpfr_get_d1 (c), cos_x); + exit (1); + } + mpfr_clear (xx); + mpfr_clear (s); + mpfr_clear (c); +} + +void check53sin (double x, double sin_x, mp_rnd_t rnd_mode) +{ + mpfr_t xx, s, c; + + mpfr_init2 (xx, 53); + mpfr_init2 (s, 53); + mpfr_init2 (c, 53); + mpfr_set_d (xx, x, rnd_mode); /* should be exact */ + mpfr_sin_cos (s, c, xx, rnd_mode); + if (mpfr_get_d1 (s) != sin_x && !(Isnan(sin_x) && mpfr_nan_p(s))) + { + fprintf (stderr, "mpfr_sin_cos failed for x=%1.20e, rnd=%s\n", x, + mpfr_print_rnd_mode (rnd_mode)); + fprintf (stderr, "mpfr_sin_cos gives sin(x)=%1.20e, expected %1.20e\n", + mpfr_get_d1 (s), sin_x); + exit (1); + } + mpfr_clear (xx); + mpfr_clear (s); + mpfr_clear (c); +} + +void check53cos (double x, double cos_x, mp_rnd_t rnd_mode) +{ + mpfr_t xx, c, s; + + mpfr_init2 (xx, 53); + mpfr_init2 (c, 53); + mpfr_init2 (s, 53); + mpfr_set_d (xx, x, rnd_mode); /* should be exact */ + mpfr_sin_cos (s, c, xx, rnd_mode); + if (mpfr_get_d1 (c) != cos_x && !(Isnan(cos_x) && mpfr_nan_p(c))) + { + fprintf (stderr, "mpfr_sin_cos failed for x=%1.20e, rnd=%s\n", x, + mpfr_print_rnd_mode (rnd_mode)); + fprintf (stderr, "mpfr_sin_cos gives cos(x)=%1.20e, expected %1.20e\n", + mpfr_get_d1 (c), cos_x); + exit (1); + } + mpfr_clear (xx); + mpfr_clear (c); + mpfr_clear (s); +} + +/* tsin_cos prec [N] performs N tests with prec bits */ +int +main(int argc, char *argv[]) +{ + if (argc > 1) + { + large_test (atoi (argv[1]), (argc > 2) ? atoi (argv[2]) : 1); + } + +#ifdef HAVE_INFS + check53 (DBL_NAN, DBL_NAN, DBL_NAN, GMP_RNDN); + check53 (DBL_POS_INF, DBL_NAN, DBL_NAN, GMP_RNDN); + check53 (DBL_NEG_INF, DBL_NAN, DBL_NAN, GMP_RNDN); +#endif + /* worst case from PhD thesis of Vincent Lefe`vre: x=8980155785351021/2^54 */ + check53 (4.984987858808754279e-1, 4.781075595393330379e-1, + 8.783012931285841817e-1, GMP_RNDN); + check53 (4.984987858808754279e-1, 4.781075595393329824e-1, + 8.783012931285840707e-1, GMP_RNDD); + check53 (4.984987858808754279e-1, 4.781075595393329824e-1, + 8.783012931285840707e-1, GMP_RNDZ); + check53 (4.984987858808754279e-1, 4.781075595393330379e-1, + 8.783012931285841817e-1, GMP_RNDU); + check53 (1.00031274099908640274, 8.416399183372403892e-1, + 0.540039116973283217504, GMP_RNDN); + check53 (1.00229256850978698523, 8.427074524447979442e-1, + 0.538371757797526551137, GMP_RNDZ); + check53 (1.00288304857059840103, 8.430252033025980029e-1, + 0.537874062022526966409, GMP_RNDZ); + check53 (1.00591265847407274059, 8.446508805292128885e-1, + 0.53531755997839769456, GMP_RNDN); + + /* check one argument only */ + check53sin (1.00591265847407274059, 8.446508805292128885e-1, GMP_RNDN); + check53cos (1.00591265847407274059, 0.53531755997839769456, GMP_RNDN); + + return 0; +} diff --git a/mpfr/tests/tsqrt.c b/mpfr/tests/tsqrt.c index ada9f2b33..dc97700b2 100644 --- a/mpfr/tests/tsqrt.c +++ b/mpfr/tests/tsqrt.c @@ -1,6 +1,6 @@ /* Test file for mpfr_sqrt. -Copyright 1999, 2001, 2002 Free Software Foundation, Inc. +Copyright 1999, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -19,7 +19,6 @@ along with the MPFR Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include <math.h> #include <stdio.h> #include <stdlib.h> #include <time.h> @@ -44,21 +43,24 @@ void check_nan _PROTO((void)); void check3 (double a, mp_rnd_t rnd_mode, double Q) { - mpfr_t q; double Q2; int u; + mpfr_t q; + double Q2; + int u; - mpfr_init2(q, 53); - mpfr_set_d(q, a, rnd_mode); - mpfr_sqrt(q, q, rnd_mode); + mpfr_init2 (q, 53); + mpfr_set_d (q, a, rnd_mode); + mpfr_sqrt (q, q, rnd_mode); Q2 = mpfr_get_d1 (q); - if (Q!=Q2 && (!isnan(Q) || !isnan(Q2))) { - u = ulp(Q2,Q); - printf("mpfr_sqrt failed for a=%1.20e, rnd_mode=%s\n", - a, mpfr_print_rnd_mode(rnd_mode)); - printf("expected sqrt is %1.20e, got %1.20e (%d ulp)\n",Q,Q2,u); - mpfr_clear(q); - exit(1); - } - mpfr_clear(q); + if (Q!=Q2 && !(Isnan(Q) && Isnan(Q2))) + { + u = ulp (Q2,Q); + printf ("mpfr_sqrt failed for a=%1.20e, rnd_mode=%s\n", + a, mpfr_print_rnd_mode (rnd_mode)); + printf ("expected sqrt is %1.20e, got %1.20e (%d ulp)\n",Q,Q2,u); + mpfr_clear (q); + exit (1); + } + mpfr_clear (q); } void diff --git a/mpfr/tests/tsqrt_ui.c b/mpfr/tests/tsqrt_ui.c index 64f2239c9..558515507 100644 --- a/mpfr/tests/tsqrt_ui.c +++ b/mpfr/tests/tsqrt_ui.c @@ -1,6 +1,6 @@ /* Test file for mpfr_sqrt_ui. -Copyright 2000, 2001, 2002 Free Software Foundation, Inc. +Copyright 2000, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -19,7 +19,6 @@ along with the MPFR Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include <math.h> #include <stdio.h> #include <stdlib.h> #include <time.h> @@ -34,19 +33,23 @@ int maxulp=0; void check (unsigned long a, mp_rnd_t rnd_mode, double Q) { - mpfr_t q; double Q2; int u; + mpfr_t q; + double Q2; + int u; - mpfr_init2(q, 53); - mpfr_sqrt_ui(q, a, rnd_mode); + mpfr_init2 (q, 53); + mpfr_sqrt_ui (q, a, rnd_mode); Q2 = mpfr_get_d1 (q); - if (Q!=Q2 && (!isnan(Q) || !isnan(Q2))) { - u = ulp(Q2,Q); - printf("mpfr_sqrt_ui failed for a=%lu, rnd_mode=%s\n", - a, mpfr_print_rnd_mode(rnd_mode)); - printf("sqrt gives %1.20e, mpfr_sqrt_ui gives %1.20e (%d ulp)\n",Q,Q2,u); - exit(1); - } - mpfr_clear(q); + if (Q != Q2 && !(Isnan(Q) && Isnan(Q2))) + { + u = ulp (Q2,Q); + printf ("mpfr_sqrt_ui failed for a=%lu, rnd_mode=%s\n", + a, mpfr_print_rnd_mode (rnd_mode)); + printf ("sqrt gives %1.20e, mpfr_sqrt_ui gives %1.20e (%d ulp)\n", + Q, Q2, u); + exit (1); + } + mpfr_clear (q); } double five = 5.0; diff --git a/mpfr/tests/tsub.c b/mpfr/tests/tsub.c index 5a7123ed7..8ecf858ea 100644 --- a/mpfr/tests/tsub.c +++ b/mpfr/tests/tsub.c @@ -1,6 +1,6 @@ /* Test file for mpfr_sub. -Copyright 2001, 2002 Free Software Foundation. +Copyright 2001, 2002, 2003 Free Software Foundation. This file is part of the MPFR Library. @@ -19,7 +19,6 @@ along with the MPFR Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include <math.h> #include <stdio.h> #include <stdlib.h> #include "gmp.h" diff --git a/mpfr/tests/tsub_ui.c b/mpfr/tests/tsub_ui.c index 5dd992d80..354a22539 100644 --- a/mpfr/tests/tsub_ui.c +++ b/mpfr/tests/tsub_ui.c @@ -1,6 +1,6 @@ /* Test file for mpfr_sub_ui -Copyright 2000, 2001, 2002 Free Software Foundation. +Copyright 2000, 2001, 2002, 2003 Free Software Foundation. This file is part of the MPFR Library. @@ -19,7 +19,6 @@ along with the MPFR Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include <math.h> #include <stdio.h> #include <stdlib.h> #include <float.h> @@ -42,21 +41,22 @@ check3 (double x, unsigned long y, mp_rnd_t rnd_mode, double z1) double z2; mpfr_t xx,zz; - mpfr_init(xx); - mpfr_init(zz); - mpfr_set_prec(xx, 53); - mpfr_set_prec(zz, 53); - mpfr_set_d(xx, x, rnd_mode); - mpfr_sub_ui(zz, xx, y, rnd_mode); + mpfr_init (xx); + mpfr_init (zz); + mpfr_set_prec (xx, 53); + mpfr_set_prec (zz, 53); + mpfr_set_d (xx, x, rnd_mode); + mpfr_sub_ui (zz, xx, y, rnd_mode); z2 = mpfr_get_d1 (zz); - if (z1!=z2 && !(isnan(z1) && isnan(z2))) { - printf("expected sum is %1.20e, got %1.20e\n",z1,z2); - printf("mpfr_sub_ui failed for x=%1.20e y=%lu with rnd_mode=%s\n", - x, y, mpfr_print_rnd_mode(rnd_mode)); - exit(1); + if (z1!=z2 && !(Isnan(z1) && Isnan(z2))) + { + printf ("expected sum is %1.20e, got %1.20e\n",z1,z2); + printf ("mpfr_sub_ui failed for x=%1.20e y=%lu with rnd_mode=%s\n", + x, y, mpfr_print_rnd_mode (rnd_mode)); + exit (1); } - mpfr_clear(xx); - mpfr_clear(zz); + mpfr_clear (xx); + mpfr_clear (zz); } /* FastTwoSum: if EXP(x) >= EXP(y), u = o(x+y), v = o(u-x), w = o(y-v), diff --git a/mpfr/tests/ttan.c b/mpfr/tests/ttan.c index f0efd5eb9..953e8f561 100644 --- a/mpfr/tests/ttan.c +++ b/mpfr/tests/ttan.c @@ -1,6 +1,6 @@ /* Test file for mpfr_tan. -Copyright 2001, 2002 Free Software Foundation, Inc. +Copyright 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -21,7 +21,6 @@ MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> -#include <math.h> #include "gmp.h" #include "mpfr.h" #include "mpfr-impl.h" @@ -38,13 +37,14 @@ check53 (double x, double tan_x, mp_rnd_t rnd_mode) mpfr_init2 (s, 53); mpfr_set_d (xx, x, rnd_mode); /* should be exact */ mpfr_tan (s, xx, rnd_mode); - if (mpfr_get_d1 (s) != tan_x && (!isnan(tan_x) || !mpfr_nan_p(s))) { - fprintf (stderr, "mpfr_tan failed for x=%1.20e, rnd=%s\n", x, - mpfr_print_rnd_mode (rnd_mode)); - fprintf (stderr, "mpfr_tan gives tan(x)=%1.20e, expected %1.20e\n", - mpfr_get_d1 (s), tan_x); - exit(1); - } + if (mpfr_get_d1 (s) != tan_x && !(Isnan(tan_x) && mpfr_nan_p(s))) + { + fprintf (stderr, "mpfr_tan failed for x=%1.20e, rnd=%s\n", x, + mpfr_print_rnd_mode (rnd_mode)); + fprintf (stderr, "mpfr_tan gives tan(x)=%1.20e, expected %1.20e\n", + mpfr_get_d1 (s), tan_x); + exit (1); + } mpfr_clear (xx); mpfr_clear (s); } diff --git a/mpfr/tests/tui_div.c b/mpfr/tests/tui_div.c index 9c7fd6c51..e210d9f0f 100644 --- a/mpfr/tests/tui_div.c +++ b/mpfr/tests/tui_div.c @@ -1,6 +1,6 @@ /* Test file for mpfr_ui_div. -Copyright 2000, 2001, 2002 Free Software Foundation, Inc. +Copyright 2000, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -19,7 +19,6 @@ along with the MPFR Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include <math.h> #include <stdio.h> #include <stdlib.h> #include <time.h> @@ -38,21 +37,23 @@ void check_nan _PROTO((void)); void check (unsigned long y, double x, mp_rnd_t rnd_mode, double z1) { - double z2; mpfr_t xx, zz; + double z2; + mpfr_t xx, zz; - mpfr_init2(xx, 53); - mpfr_init2(zz, 53); - mpfr_set_d(xx, x, rnd_mode); - mpfr_ui_div(zz, y, xx, rnd_mode); + mpfr_init2 (xx, 53); + mpfr_init2 (zz, 53); + mpfr_set_d (xx, x, rnd_mode); + mpfr_ui_div (zz, y, xx, rnd_mode); z2 = mpfr_get_d1 (zz); - if (z1!=z2 && !(isnan(z1) && isnan(z2))) { - printf("expected quotient is %1.20e, got %1.20e\n",z1,z2); - printf("mpfr_ui_div failed for y=%lu x=%1.20e with rnd_mode=%s\n", - y, x, mpfr_print_rnd_mode(rnd_mode)); - exit(1); + if (z1 != z2 && !(Isnan(z1) && Isnan(z2))) + { + printf ("expected quotient is %1.20e, got %1.20e\n", z1, z2); + printf ("mpfr_ui_div failed for y=%lu x=%1.20e with rnd_mode=%s\n", + y, x, mpfr_print_rnd_mode (rnd_mode)); + exit (1); } - mpfr_clear(xx); - mpfr_clear(zz); + mpfr_clear (xx); + mpfr_clear (zz); } void diff --git a/mpfr/tests/tui_sub.c b/mpfr/tests/tui_sub.c index 1a2c67421..0bbe45c76 100644 --- a/mpfr/tests/tui_sub.c +++ b/mpfr/tests/tui_sub.c @@ -1,6 +1,6 @@ /* Test file for mpfr_ui_sub. -Copyright 2000, 2001, 2002 Free Software Foundation. +Copyright 2000, 2001, 2002, 2003 Free Software Foundation. This file is part of the MPFR Library. @@ -19,7 +19,6 @@ along with the MPFR Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include <math.h> #include <stdio.h> #include <stdlib.h> #include <float.h> @@ -135,20 +134,23 @@ special (void) void check (unsigned long y, double x, mp_rnd_t rnd_mode, double z1) { - double z2; mpfr_t xx, zz; + double z2; + mpfr_t xx, zz; - mpfr_init2(xx, 53); - mpfr_init2(zz, 53); - mpfr_set_d(xx, x, rnd_mode); - mpfr_ui_sub(zz, y, xx, rnd_mode); + mpfr_init2 (xx, 53); + mpfr_init2 (zz, 53); + mpfr_set_d (xx, x, rnd_mode); + mpfr_ui_sub (zz, y, xx, rnd_mode); z2 = mpfr_get_d1 (zz); - if (z1!=z2 && !(isnan(z1) && isnan(z2))) { - printf("expected difference is %1.20e, got %1.20e\n",z1,z2); - printf("mpfr_ui_sub failed for y=%lu x=%1.20e with rnd_mode=%s\n", - y, x, mpfr_print_rnd_mode(rnd_mode)); - exit(1); - } - mpfr_clear(xx); mpfr_clear(zz); + if (z1 != z2 && !(Isnan(z1) && Isnan(z2))) + { + printf ("expected difference is %1.20e, got %1.20e\n",z1,z2); + printf ("mpfr_ui_sub failed for y=%lu x=%1.20e with rnd_mode=%s\n", + y, x, mpfr_print_rnd_mode (rnd_mode)); + exit (1); + } + mpfr_clear (xx); + mpfr_clear (zz); } /* if u = o(x-y), v = o(u-x), w = o(v+y), then x-y = u-w */ diff --git a/mpn/Makefile.in b/mpn/Makefile.in index 166d896ca..8c7e62964 100644 --- a/mpn/Makefile.in +++ b/mpn/Makefile.in @@ -148,6 +148,7 @@ MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ MAKEINFO = @MAKEINFO@ MPFR_CFLAGS = @MPFR_CFLAGS@ +MPFR_LIBM = @MPFR_LIBM@ MPFR_LIBS = @MPFR_LIBS@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ diff --git a/mpq/Makefile.in b/mpq/Makefile.in index f19c6b478..f274d0409 100644 --- a/mpq/Makefile.in +++ b/mpq/Makefile.in @@ -127,6 +127,7 @@ MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ MAKEINFO = @MAKEINFO@ MPFR_CFLAGS = @MPFR_CFLAGS@ +MPFR_LIBM = @MPFR_LIBM@ MPFR_LIBS = @MPFR_LIBS@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ diff --git a/mpz/Makefile.in b/mpz/Makefile.in index 7e1e368e7..5fc282f58 100644 --- a/mpz/Makefile.in +++ b/mpz/Makefile.in @@ -128,6 +128,7 @@ MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ MAKEINFO = @MAKEINFO@ MPFR_CFLAGS = @MPFR_CFLAGS@ +MPFR_LIBM = @MPFR_LIBM@ MPFR_LIBS = @MPFR_LIBS@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ diff --git a/printf/Makefile.in b/printf/Makefile.in index 60da21b3a..570e993d0 100644 --- a/printf/Makefile.in +++ b/printf/Makefile.in @@ -127,6 +127,7 @@ MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ MAKEINFO = @MAKEINFO@ MPFR_CFLAGS = @MPFR_CFLAGS@ +MPFR_LIBM = @MPFR_LIBM@ MPFR_LIBS = @MPFR_LIBS@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ diff --git a/scanf/Makefile.in b/scanf/Makefile.in index 956bb1a19..776c83b0a 100644 --- a/scanf/Makefile.in +++ b/scanf/Makefile.in @@ -127,6 +127,7 @@ MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ MAKEINFO = @MAKEINFO@ MPFR_CFLAGS = @MPFR_CFLAGS@ +MPFR_LIBM = @MPFR_LIBM@ MPFR_LIBS = @MPFR_LIBS@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ diff --git a/tests/Makefile.in b/tests/Makefile.in index 51b9f5207..c4b9f6894 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -147,6 +147,7 @@ MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ MAKEINFO = @MAKEINFO@ MPFR_CFLAGS = @MPFR_CFLAGS@ +MPFR_LIBM = @MPFR_LIBM@ MPFR_LIBS = @MPFR_LIBS@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ diff --git a/tests/cxx/Makefile.in b/tests/cxx/Makefile.in index b8e51fef1..58b8b8006 100644 --- a/tests/cxx/Makefile.in +++ b/tests/cxx/Makefile.in @@ -127,6 +127,7 @@ MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ MAKEINFO = @MAKEINFO@ MPFR_CFLAGS = @MPFR_CFLAGS@ +MPFR_LIBM = @MPFR_LIBM@ MPFR_LIBS = @MPFR_LIBS@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ diff --git a/tests/devel/Makefile.in b/tests/devel/Makefile.in index fbe3ebe50..60414c878 100644 --- a/tests/devel/Makefile.in +++ b/tests/devel/Makefile.in @@ -127,6 +127,7 @@ MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ MAKEINFO = @MAKEINFO@ MPFR_CFLAGS = @MPFR_CFLAGS@ +MPFR_LIBM = @MPFR_LIBM@ MPFR_LIBS = @MPFR_LIBS@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ diff --git a/tests/misc/Makefile.in b/tests/misc/Makefile.in index 03e42b5ba..19c324514 100644 --- a/tests/misc/Makefile.in +++ b/tests/misc/Makefile.in @@ -127,6 +127,7 @@ MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ MAKEINFO = @MAKEINFO@ MPFR_CFLAGS = @MPFR_CFLAGS@ +MPFR_LIBM = @MPFR_LIBM@ MPFR_LIBS = @MPFR_LIBS@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ diff --git a/tests/mpbsd/Makefile.in b/tests/mpbsd/Makefile.in index c3217f21d..0ba9bf2d0 100644 --- a/tests/mpbsd/Makefile.in +++ b/tests/mpbsd/Makefile.in @@ -127,6 +127,7 @@ MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ MAKEINFO = @MAKEINFO@ MPFR_CFLAGS = @MPFR_CFLAGS@ +MPFR_LIBM = @MPFR_LIBM@ MPFR_LIBS = @MPFR_LIBS@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ diff --git a/tests/mpf/Makefile.in b/tests/mpf/Makefile.in index 0a0d49582..4af06a4d2 100644 --- a/tests/mpf/Makefile.in +++ b/tests/mpf/Makefile.in @@ -127,6 +127,7 @@ MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ MAKEINFO = @MAKEINFO@ MPFR_CFLAGS = @MPFR_CFLAGS@ +MPFR_LIBM = @MPFR_LIBM@ MPFR_LIBS = @MPFR_LIBS@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ diff --git a/tests/mpn/Makefile.in b/tests/mpn/Makefile.in index 1fa63c547..3daa958c0 100644 --- a/tests/mpn/Makefile.in +++ b/tests/mpn/Makefile.in @@ -127,6 +127,7 @@ MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ MAKEINFO = @MAKEINFO@ MPFR_CFLAGS = @MPFR_CFLAGS@ +MPFR_LIBM = @MPFR_LIBM@ MPFR_LIBS = @MPFR_LIBS@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ diff --git a/tests/mpq/Makefile.in b/tests/mpq/Makefile.in index 0972064a1..001f1f807 100644 --- a/tests/mpq/Makefile.in +++ b/tests/mpq/Makefile.in @@ -127,6 +127,7 @@ MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ MAKEINFO = @MAKEINFO@ MPFR_CFLAGS = @MPFR_CFLAGS@ +MPFR_LIBM = @MPFR_LIBM@ MPFR_LIBS = @MPFR_LIBS@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ diff --git a/tests/mpz/Makefile.in b/tests/mpz/Makefile.in index 2146a9171..8db287afe 100644 --- a/tests/mpz/Makefile.in +++ b/tests/mpz/Makefile.in @@ -128,6 +128,7 @@ MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ MAKEINFO = @MAKEINFO@ MPFR_CFLAGS = @MPFR_CFLAGS@ +MPFR_LIBM = @MPFR_LIBM@ MPFR_LIBS = @MPFR_LIBS@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ diff --git a/tests/rand/Makefile.in b/tests/rand/Makefile.in index 1ca0381a1..c7b2d3596 100644 --- a/tests/rand/Makefile.in +++ b/tests/rand/Makefile.in @@ -127,6 +127,7 @@ MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ MAKEINFO = @MAKEINFO@ MPFR_CFLAGS = @MPFR_CFLAGS@ +MPFR_LIBM = @MPFR_LIBM@ MPFR_LIBS = @MPFR_LIBS@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ diff --git a/tune/Makefile.in b/tune/Makefile.in index a79780114..fcb86f3e7 100644 --- a/tune/Makefile.in +++ b/tune/Makefile.in @@ -147,6 +147,7 @@ MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ MAKEINFO = @MAKEINFO@ MPFR_CFLAGS = @MPFR_CFLAGS@ +MPFR_LIBM = @MPFR_LIBM@ MPFR_LIBS = @MPFR_LIBS@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ |