1 /* Portable, threadsafe, 64-bit Mersenne Twister random number generator. 2 */ 3 #ifndef eslRAND64_INCLUDED 4 #define eslRAND64_INCLUDED 5 #include "esl_config.h" 6 7 #include <stdint.h> 8 #include <stdio.h> 9 10 typedef struct { 11 int mti; // current position in mt[] table 12 uint64_t mt[312]; // state of the Mersenne Twister 13 uint64_t seed; // seed used to initialize the RNG 14 } ESL_RAND64; 15 16 17 extern ESL_RAND64 *esl_rand64_Create (uint64_t seed); 18 extern int esl_rand64_Init (ESL_RAND64 *rng, uint64_t seed); 19 extern uint64_t esl_rand64_GetSeed(ESL_RAND64 *rng); 20 extern void esl_rand64_Destroy(ESL_RAND64 *rng); 21 22 extern uint64_t esl_rand64(ESL_RAND64 *rng); 23 extern uint64_t esl_rand64_Roll(ESL_RAND64 *rng, uint64_t n); // 0..n-1 24 extern double esl_rand64_double(ESL_RAND64 *rng); // [0,1) 25 extern double esl_rand64_double_closed(ESL_RAND64 *rng); // [0,1] 26 extern double esl_rand64_double_open(ESL_RAND64 *rng); // (0,1) 27 28 extern int esl_rand64_Deal(ESL_RAND64 *rng, int64_t m, int64_t n, int64_t *deal); 29 30 extern int esl_rand64_Dump(FILE *fp, ESL_RAND64 *rng); 31 32 #endif // eslRAND64_INCLUDED 33