diff options
author | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2010-09-15 02:50:32 +0000 |
---|---|---|
committer | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2010-09-15 02:50:32 +0000 |
commit | 0b23908acd8e0115b2786236df83a0ff558b81ac (patch) | |
tree | 4d3b04f7819f0453e75836135541825d27304d61 /tests/trandom.c | |
parent | 5f7a7b56ea85dc2fda07f6dc6d956400fdc2d597 (diff) | |
download | mpfr-0b23908acd8e0115b2786236df83a0ff558b81ac.tar.gz |
[urandomb.c] modified to leave the GMP random generator in the same state,
independent of GMP_NUMB_BITS
[trandom.c] test of the above
[urandom.c] added FIXME's
[turandom.c] check we leave the GMP random generator in the same state,
independent of GMP_NUMB_BITS. Currently this fails on 64-bit
computers.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@7133 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/trandom.c')
-rw-r--r-- | tests/trandom.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/trandom.c b/tests/trandom.c index 09968fe1b..1a977f283 100644 --- a/tests/trandom.c +++ b/tests/trandom.c @@ -103,6 +103,36 @@ test_urandomb (long nbtests, mpfr_prec_t prec, int verbose) return; } +/* Problem reported by Carl Witty: check mpfr_urandomb give similar results + on 32-bit and 64-bit machines. + We assume the default GMP random generator does not depend on the machine + word size, not on the GMP version. +*/ +static void +bug20100914 (void) +{ + mpfr_t x; + gmp_randstate_t s; + + gmp_randinit_default (s); + gmp_randseed_ui (s, 42); + mpfr_init2 (x, 17); + mpfr_urandomb (x, s); + if (mpfr_cmp_str1 (x, "0.895943") != 0) + { + mpfr_printf ("Error in bug20100914, got %Rf, expected 0.895943\n", x); + exit (1); + } + mpfr_urandomb (x, s); + if (mpfr_cmp_str1 (x, "0.848824") != 0) + { + mpfr_printf ("Error in bug20100914, got %Rf, expected 0.848824\n", x); + exit (1); + } + mpfr_clear (x); + gmp_randclear (s); +} + int main (int argc, char *argv[]) { @@ -135,6 +165,8 @@ main (int argc, char *argv[]) test_urandomb (nbtests, 2, 0); } + bug20100914 (); + tests_end_mpfr (); return 0; } |