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

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

Functions

int32_t c_rand64_init (void)
 
void c_rand64_deinit (void)
 
void c_rand64_seed (uint64_t seed)
 
uint64_t c_rand64_int (void)
 
double c_rand64 (void)
 
double c_rand64_normal (void)
 

Detailed Description

Pseudo-random number generator functions using 64-bit MT19937 by Matsumoto and Nishimura (2000). Equivalent to C++ std::mt19937_64 implementation.

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

Function Documentation

◆ c_rand64_init()

int32_t c_rand64_init ( void  )

Initialize memory for 64-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 199 of file CAENRandom.c.

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

◆ c_rand64_deinit()

void c_rand64_deinit ( void  )

Free memory for 64-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 215 of file CAENRandom.c.

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

◆ c_rand64_seed()

void c_rand64_seed ( uint64_t  seed)

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

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

Definition at line 240 of file CAENRandom.c.

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

◆ c_rand64_int()

uint64_t c_rand64_int ( void  )

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

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

Definition at line 312 of file CAENRandom.c.

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

◆ c_rand64()

double c_rand64 ( void  )

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

Returns
the generated number

Definition at line 336 of file CAENRandom.c.

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

◆ c_rand64_normal()

double c_rand64_normal ( void  )

Get a pseudo-random number normally distributed (zero mean, unit variance), Implements the Box-Muller transform with numbers from c_rand64_int().

Returns
the generated number

Definition at line 341 of file CAENRandom.c.

Here is the call graph for this function: