rearranging deckchairs on the HMS Random Numbers.

This commit is contained in:
Enno Rehling 2016-09-04 17:04:41 +01:00
parent 388ea174ef
commit e7b93adb75
2 changed files with 6 additions and 16 deletions

View File

@ -18,6 +18,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <platform.h>
#include "rand.h"
#include "mtrand.h"
#include "rng.h"
#include <assert.h>
@ -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;

View File

@ -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