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/turandom.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/turandom.c')
-rw-r--r-- | tests/turandom.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/turandom.c b/tests/turandom.c index fff1d5187..77da1e4ef 100644 --- a/tests/turandom.c +++ b/tests/turandom.c @@ -153,6 +153,33 @@ test_urandom (long nbtests, mpfr_prec_t prec, mpfr_rnd_t rnd, long bit_index, return; } +/* problem reported by Carl Witty */ +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_urandom (x, s, MPFR_RNDN); + /* the following values are obtained on a 32-bit computer, we should get + the same values on a 64-bit computer */ + if (mpfr_cmp_str1 (x, "0.196152") != 0) + { + mpfr_printf ("Error in bug20100914, got %Rf, expected 0.196152\n", x); + exit (1); + } + mpfr_urandom (x, s, MPFR_RNDN); + if (mpfr_cmp_str1 (x, "0.414497") != 0) + { + mpfr_printf ("Error in bug20100914, got %Rf, expected 0.414497\n", x); + exit (1); + } + mpfr_clear (x); + gmp_randclear (s); +} int main (int argc, char *argv[]) @@ -205,6 +232,8 @@ main (int argc, char *argv[]) } } + bug20100914 (); + tests_end_mpfr (); return 0; } |