summaryrefslogtreecommitdiff
path: root/tests/random.c
diff options
context:
space:
mode:
authorenge <enge@211d60ee-9f03-0410-a15a-8952a2c7a4e4>2009-06-04 10:15:49 +0000
committerenge <enge@211d60ee-9f03-0410-a15a-8952a2c7a4e4>2009-06-04 10:15:49 +0000
commit93896138577e3b4154d657fcc184727ef35f2c23 (patch)
treedbbe0f05057509885da70076fe28425064e8e1d2 /tests/random.c
parentb0f7c483f6802a9d4b452b9614528101dc43a848 (diff)
downloadmpc-93896138577e3b4154d657fcc184727ef35f2c23.tar.gz
upgraded version requirement to gmp 4.2 and removed workarounds for older
gmp versions git-svn-id: svn://scm.gforge.inria.fr/svn/mpc/trunk@547 211d60ee-9f03-0410-a15a-8952a2c7a4e4
Diffstat (limited to 'tests/random.c')
-rw-r--r--tests/random.c51
1 files changed, 6 insertions, 45 deletions
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)