From e7b93adb75337f17a5351f72c09bad7fabc3cf45 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 4 Sep 2016 17:04:41 +0100 Subject: [PATCH] rearranging deckchairs on the HMS Random Numbers. --- src/util/rand.c | 4 +--- src/util/rng.h | 18 +++++------------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/src/util/rand.c b/src/util/rand.c index 73879656c..d98b9b8f9 100644 --- a/src/util/rand.c +++ b/src/util/rand.c @@ -18,6 +18,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include "rand.h" +#include "mtrand.h" #include "rng.h" #include @@ -67,9 +68,6 @@ bool chance(double x) return rng_double() < x; } -extern double genrand_real2(void); - - typedef struct random_source { double (*double_source) (void); } random_source; diff --git a/src/util/rng.h b/src/util/rng.h index a3033b419..c16433200 100644 --- a/src/util/rng.h +++ b/src/util/rng.h @@ -10,25 +10,17 @@ #ifndef UTIL_RNG_H #define UTIL_RNG_H +#define RNG_MT + #ifdef __cplusplus extern "C" { #endif -#define RNG_MT + /* generates a random number on [0,1)-real-interval */ + double rng_injectable_double(void); #ifdef RNG_MT - /* initializes mt[N] with a seed */ - extern void init_genrand(unsigned long s); - - /* generates a random number on [0,0xffffffff]-interval */ - extern unsigned long genrand_int32(void); - - /* generates a random number on [0,1)-real-interval */ - extern double rng_injectable_double(void); - - /* generates a random number on [0,0x7fffffff]-interval */ - long genrand_int31(void); - +# include "mtrand.h" # define rng_init(seed) init_genrand(seed) # define rng_int (int)genrand_int31 # define rng_uint (unsigned int)genrand_int32