Files
libucore/include/ucore/mersenne_twister.h
T
Nils O. Selåsdal b4f9ecafe2 add C++ guards
2013-06-19 18:48:45 +02:00

35 lines
607 B
C

#ifndef UCORE_MERSENNE_TWISTER_H
#define UCORE_MERSENNE_TWISTER_H
#ifdef __cplusplus
extern "C" {
#endif
/** Context used for the PRNG*/
#define MT_RAND_N 624
typedef struct {
unsigned int x[MT_RAND_N];
int i;
} MTRand;
/** Initialize a Mersenne Twister PRNG context.
* @param seed Starter seed for the PRNG
* @param r context for the PRNG
*/
void mtsrand(int seed, MTRand *r);
/** Generate a new random number.
* Generated range is 0 to UINT_MAX
*
* @param r context for the PRNG
* @return A pseudo random number
*/
unsigned int mtrand(MTRand *r);
#ifdef __cplusplus
}
#endif
#endif