summaryrefslogtreecommitdiff
path: root/tests/rand-test.c
AgeCommit message (Collapse)AuthorFilesLines
2004-01-10Add the init_by_array functionality from the reference implementation ofGeorge Lebl1-1/+59
Fri Dec 19 11:49:21 2003 George Lebl <jirka@5z.com> * glib/grand.c glib/grand.h (g_rand_new) (g_rand_new_with_seed) (g_rand_new_with_seed_array) (g_rand_set_seed_array): Add the init_by_array functionality from the reference implementation of the mersenne twister (mt19937ar.c) and change the naming to fit with the rest of the grand API. New functions are g_rand_new_with_seed_array, g_rand_set_seed_array. This is only reliable/tested for the 2.2 version of the seeding as that's what the reference implementation uses. Also modify g_rand_new to get 4 longs from /dev/urandom since that will always be available anyway and we get more entropy and if /dev/urandom is unavailable use also 4 longs for seeding using secs, usecs, getpid and getppid. For version 2.0 use only a simple seed again but be more careful about seeding with secs/usecs in this case. * glib/grand.c glib/grand.h (g_rand_copy): Add g_rand_copy function to copy the current state of the random number generator. * glib/grand.c (g_rand_new): Add testing for EINTR when reading from /dev/urandom * tests/rand-test.c: add testing of the array seeding stuff against the reference implementation, plus add statistical sanity check to see that the values outputted are truly kind of random. And check that g_rand_copy truly copies the state by checking a few terms.
2002-11-26Improved the seeding algorithm. Old behaviour can be achived by settingSebastian Wilhelmi1-20/+20
2002-11-26 Sebastian Wilhelmi <wilhelmi@ira.uka.de> * glib/grand.c, gthread/gthread-impl.c, tests/rand-test.c: Improved the seeding algorithm. Old behaviour can be achived by setting envvar G_RANDOM_VERSION to "2.0". (#99262) * docs/reference/glib/glib-docs.sgml, docs/reference/glib/Makefile.am: Renamed docs/reference/glib/changes-2.0.sgml to docs/reference/glib/changes.sgml and added section for changes from 2.0 to 2.2 (Also corrected 1.0 to 1.2). * README.in, docs/reference/glib/running.sgml, docs/reference/glib/tmpl/random_numbers.sgml, docs/reference/glib/changes.sgml: Added notes about the new seeding algorithm.
2002-07-04Added #undef G_DISABLE_ASSERT and #undef G_LOG_DOMAIN throughout theSebastian Wilhelmi1-0/+3
2002-07-04 Sebastian Wilhelmi <wilhelmi@ira.uka.de> * tests/*.c: Added #undef G_DISABLE_ASSERT and #undef G_LOG_DOMAIN throughout the files, which didn't already have them. (#87312)
2001-05-31Fix to stupid bug in g_random_boolean, also both functions now return 1 orSebastian Wilhelmi1-0/+16
2001-05-31 Sebastian Wilhelmi <wilhelmi@ira.uka.de> * grand.h (g_random_boolean, g_rand_boolean): Fix to stupid bug in g_random_boolean, also both functions now return 1 or 0 instead of 1<<15 or 0.
1999-04-12Moved struct declaration up. Style fixes.Sebastian Wilhelmi1-3/+18
1999-04-12 Sebastian Wilhelmi <wilhelmi@ira.uka.de> * glib.h: Moved struct declaration up. Style fixes. * grand.c: Style fixes. Only try to open /dev/random once. * tests/rand-test.c (main): New tests; Slight bug fix.
1999-04-09New files to implement the Mersenne Twister Pseudo Random NumberSebastian Wilhelmi1-0/+43
1999-04-09 Sebastian Wilhelmi <wilhelmi@ira.uka.de> * grand.c, tests/rand-test.c: New files to implement the Mersenne Twister Pseudo Random Number Generator. * glib.h, AUTHORS, Makefile.am, tests/Makefile.am: Changed accordingly.