forked from stevedekorte/basekit
/
RandomGen.h
38 lines (26 loc) · 874 Bytes
/
RandomGen.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef RANDOMGEN_DEFINED
#define RANDOMGEN_DEFINED 1
#ifdef __cplusplus
extern "C" {
#endif
#include "Common.h"
#define RANDOMGEN_N 624
typedef struct
{
unsigned long mt[RANDOMGEN_N]; // the array for the state vector
int mti; // mti==N+1 means mt[N] is not initialized
double y2; // guassian
int use_last; // guassian
} RandomGen;
BASEKIT_API RandomGen *RandomGen_new(void);
BASEKIT_API void RandomGen_free(RandomGen *self);
BASEKIT_API void RandomGen_setSeed(RandomGen *self, unsigned long seed);
BASEKIT_API void RandomGen_chooseRandomSeed(RandomGen *self);
// generates a random number on between 0.0 and 1.0
BASEKIT_API double RandomGen_randomDouble(RandomGen *self);
BASEKIT_API int RandomGen_randomInt(RandomGen *self);
BASEKIT_API double RandomGen_gaussian(RandomGen *self, double mean, double standardDeviation);
#ifdef __cplusplus
}
#endif
#endif