CAEN Utility  2.0.2
Utilities for CAEN projects
Pseudo-random generator MT19937

Pseudo-random number generator functions using 32-bit MT19937 by Matsumoto and Nishimura (1998). Equivalent to C++ std::mt19937 implementation. More...

Functions

int32_t c_rand32_init (void)
 
void c_rand32_deinit (void)
 
void c_rand32_seed (uint32_t seed)
 
uint32_t c_rand32_int (void)
 
double c_rand (void)
 

Detailed Description

Pseudo-random number generator functions using 32-bit MT19937 by Matsumoto and Nishimura (1998). Equivalent to C++ std::mt19937 implementation.

Precondition
When seeded with 5489, the 10000th consecutive invocation produces the value 4123659995, as required by the C++11 standard.

Function Documentation

◆ c_rand32_init()

int32_t c_rand32_init ( void  )

Initialize memory for 32-bit MT19937. If already initialized, nothing is done.

Returns
c_Utility_ErrorCode_Success (0) in case of success. Error codes specified in c_Utility_ErrorCode_t.
Warning
No need to call it manually, as done by this library at load.

Definition at line 173 of file CAENRandom.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ c_rand32_deinit()

void c_rand32_deinit ( void  )

Free memory for 32-bit MT19937. If already deinitialized, nothing is done.

Warning
No need to call it manually, as done by this library at close.

Definition at line 189 of file CAENRandom.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ c_rand32_seed()

void c_rand32_seed ( uint32_t  seed)

Re-initializes the internal state sequence to pseudo-random values.

Precondition
If not initialized, it calls c_rand32_init().
Parameters
[in]seeda seed

Definition at line 225 of file CAENRandom.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ c_rand32_int()

uint32_t c_rand32_int ( void  )

Get a randon integer number in range [0, UINT32_MAX]

Precondition
If not seeded, it calls c_rand32_seed() with the default seed (5489).
Returns
the generated number

Definition at line 293 of file CAENRandom.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ c_rand()

double c_rand ( void  )

Get a pseudo-random number in range [0, 1) as double Wrapper to c_rand32_int() * 2-32

Returns
the generated number

Definition at line 331 of file CAENRandom.c.

Here is the call graph for this function: