diff options
-rw-r--r-- | INSTALL | 2 | ||||
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | configure.ac | 17 | ||||
-rw-r--r-- | doc/mpc.texi | 2 | ||||
-rw-r--r-- | src/mem.c | 12 | ||||
-rw-r--r-- | tests/random.c | 51 | ||||
-rw-r--r-- | tests/tset.c | 5 |
7 files changed, 18 insertions, 72 deletions
@@ -6,7 +6,7 @@ in the Texinfo documentation (type 'info mpc.info'). 0. You first need to install GMP and MPFR. See <http://gmplib.org/> and <http://www.mpfr.org>. - MPC requires GMP version 4.1.3 or later and MPFR version 2.3.1 or later. + MPC requires GMP version 4.2 or later and MPFR version 2.3.1 or later. 1. In the directory of the MPC archive, type @@ -2,6 +2,7 @@ Recent Changes: - Bug fixes: - log (along branch cut) - Makefile.vc updated (thanks to Mickael Gastineau) + - Minimal gmp version is 4.2 Changes in version 0.6: - New functions: mpc_get_str, mpc_set_str, mpc_strtoc, mpc_set_uj, diff --git a/configure.ac b/configure.ac index 06d3f36..05070b6 100644 --- a/configure.ac +++ b/configure.ac @@ -213,30 +213,25 @@ AC_LINK_IFELSE( AC_MSG_ERROR([libmpfr not found or uses a different ABI.]) ]) -# Check for a recent GMP: we need GMP 4.1.3 because GMP 4.1.2 fails to compile -# on Core 2 with gcc 4.3.2 for example: -# dive_1.c:89: Error: Incorrect register `%edi' used with `q' suffix -# Once we upgrade the minimal GMP version to GMP 4.2, we can simplify the code -# using mp_get_memory_functions in mem.c and that using the gmp_random -# functions in tests/random.c +# Check for a recent GMP AC_MSG_CHECKING(for recent GMP) AC_COMPILE_IFELSE( [AC_LANG_SOURCE( [[ #include "gmp.h" -#if (__GNU_MP_VERSION*100 + __GNU_MP_VERSION_MINOR*10 + __GNU_MP_VERSION_PATCHLEVEL < 413) -# error "min GMP version is 4.1.3" +#if (__GNU_MP_VERSION*100 + __GNU_MP_VERSION_MINOR*10 + __GNU_MP_VERSION_PATCHLEVEL < 420) +# error "Minimal GMP version is 4.2" error #endif ]])], [AC_MSG_RESULT(yes)], [ AC_MSG_RESULT(no) - AC_MSG_ERROR([GMP version >= 4.1.3 required]) + AC_MSG_ERROR([GMP version >= 4.2 required]) ]) # Check for a recent MPFR: we require MPFR 2.3.1 because of a bug in -# mpfr_div_ui which makes mpc_div_ui returns the wrong sign of the zero part +# mpfr_div_ui which makes mpc_div_ui return the wrong sign of the zero part # when applied on a pure real or pure imaginary parameter (see mpfr r4950) AC_MSG_CHECKING(for recent MPFR) AC_COMPILE_IFELSE( @@ -244,7 +239,7 @@ AC_COMPILE_IFELSE( [[ #include "mpfr.h" #if (MPFR_VERSION < MPFR_VERSION_NUM (2,3,1)) -# error "min MPFR version is 2.3.1" +# error "Minimal MPFR version is 2.3.1" error #endif ]])], diff --git a/doc/mpc.texi b/doc/mpc.texi index 36c8402..5244527 100644 --- a/doc/mpc.texi +++ b/doc/mpc.texi @@ -165,7 +165,7 @@ probably a good idea to skim through it. @chapter Installing MPC @cindex Installation -To build MPC, you first have to install GNU MP (version 4.1.3 or higher) and +To build MPC, you first have to install GNU MP (version 4.2 or higher) and GNU MPFR (version 2.3.1 or higher) on your computer. You need a C compiler, preferably GCC, but any reasonable compiler should work. And you need a standard Unix @samp{make} program, plus some other standard Unix utility @@ -25,35 +25,23 @@ MA 02111-1307, USA. */ char * mpc_alloc_str (size_t len) { -#ifdef mp_get_memory_functions /* GMP >= 4.2 */ void * (*allocfunc) (size_t); mp_get_memory_functions (&allocfunc, NULL, NULL); return (char *) ((*allocfunc) (len)); -#else /* GMP < 4.2 */ - return (char *) __gmp_allocate_func (len); -#endif } char * mpc_realloc_str (char * str, size_t oldlen, size_t newlen) { -#ifdef mp_get_memory_functions /* GMP >= 4.2 */ void * (*reallocfunc) (void *, size_t, size_t); mp_get_memory_functions (NULL, &reallocfunc, NULL); return (char *) ((*reallocfunc) (str, oldlen, newlen)); -#else /* GMP < 4.2 */ - return (char *) __gmp_reallocate_func (str, oldlen, newlen); -#endif } void mpc_free_str (char *str) { -#ifdef mp_get_memory_functions /* GMP >= 4.2 */ void (*freefunc) (void *, size_t); mp_get_memory_functions (NULL, NULL, &freefunc); (*freefunc) (str, strlen (str) + 1); -#else /* GMP < 4.2 */ - __gmp_free_func (str, strlen (str) + 1); -#endif } diff --git a/tests/random.c b/tests/random.c index cfd7260..821f68b 100644 --- a/tests/random.c +++ b/tests/random.c @@ -1,6 +1,6 @@ /* Handle seed for random numbers. -Copyright (C) 2008, 2009 Philippe Th\'eveny, Paul Zimmermann +Copyright (C) 2008, 2009 Philippe Th\'eveny, Paul Zimmermann, Andreas Enge This file is part of the MPC Library. @@ -99,45 +99,6 @@ test_end (void) mpfr_free_cache (); } -/* wrapper for gmp_urandomb_ui, which did not exist in old versions of GMP */ -static unsigned long -urandomb_ui (unsigned long N) -{ -#ifdef gmp_urandomb_ui /* does not exist in GMP 4.1.4 */ - return gmp_urandomb_ui (rands, N); -#else - mpz_t R; - unsigned long r; - mpz_init (R); - mpz_urandomb (R, rands, N); - r = mpz_get_ui (R); - mpz_clear (R); - return r; -#endif -} - -/* wrapper for gmp_urandomm_ui, which did not exist in old versions of GMP */ -unsigned long -urandomm_ui (unsigned long N) -{ -#ifdef gmp_urandomm_ui /* does not exist in GMP 4.1.4 */ - return gmp_urandomm_ui (rands, N); -#else - mpz_t R, S; - unsigned long r; - mpz_init_set_ui (S, N); - mpz_init (R); - /* there was a bug in mpz_urandomm up to GMP 4.2.4, when the 1st and 3rd - argument were the same */ - mpz_urandomm (R, rands, S); - r = mpz_get_ui (R); - mpz_clear (R); - mpz_clear (S); - return r; -#endif -} - - /* Set z to a non zero value random value with absolute values of Re(z) and Im(z) either zero (but not both in the same time) or otherwise greater than or equal to 2^{emin-1} and less than 2^emax. @@ -164,10 +125,10 @@ test_default_random (mpc_ptr z, mp_exp_t emin, mp_exp_t emax, { mpc_urandom (z, rands); } while (mpfr_zero_p (MPC_RE (z)) || mpfr_zero_p (MPC_IM (z))); - + if (zero_probability > 256) zero_probability = 256; - r = urandomb_ui (19); + r = gmp_urandomb_ui (rands, 19); if ((r & 0x1FF) < zero_probability || ((r >> 9) & 0x1FF) < zero_probability) { @@ -186,14 +147,14 @@ test_default_random (mpc_ptr z, mp_exp_t emin, mp_exp_t emax, mpfr_set_ui (MPC_IM (z), 0, GMP_RNDN); } if (!mpfr_zero_p (MPC_RE (z))) - mpfr_set_exp (MPC_RE (z), (mp_exp_t) urandomm_ui (range) + emin); + mpfr_set_exp (MPC_RE (z), (mp_exp_t) gmp_urandomm_ui (rands, range) + emin); if (!mpfr_zero_p (MPC_IM (z))) - mpfr_set_exp (MPC_IM (z), (mp_exp_t) urandomm_ui (range) + emin); + mpfr_set_exp (MPC_IM (z), (mp_exp_t) gmp_urandomm_ui (rands, range) + emin); if (negative_probability > 256) negative_probability = 256; - r = urandomb_ui (16); + r = gmp_urandomb_ui (rands, 16); if ((r & 0xFF) < negative_probability) mpfr_neg (MPC_RE (z), MPC_RE (z), GMP_RNDN); if (((r>>8) & 0xFF) < negative_probability) diff --git a/tests/tset.c b/tests/tset.c index 4bc289e..72a9feb 100644 --- a/tests/tset.c +++ b/tests/tset.c @@ -1,6 +1,6 @@ /* tset.c -- Test file for mpc_set_x and mpc_set_x_x functions. -Copyright (C) 2009 Philippe Th\'eveny, Paul Zimmermann +Copyright (C) 2009 Philippe Th\'eveny, Paul Zimmermann, Andreas Enge This file is part of the MPC Library. @@ -304,7 +304,8 @@ check_set_str (mp_exp_t exp_max) mpc_set_prec (got, prec); mpc_set_prec (expected, prec); - base = 2 + (unsigned int) urandomm_ui (35); + base = 2 + (unsigned int) gmp_urandomm_ui (rands, 35); + /* uses external variable rands from random.c */ mpfr_set_nan (MPC_RE (expected)); mpfr_set_inf (MPC_IM (expected), prec % 2 - 1); |