CAEN Utility  2.0.2
Utilities for CAEN projects
CAENRandom.c File Reference

Pseudo-random number generator implemented on MT19937. More...

#include <CAENRandom.h>
#include <math.h>
#include <inttypes.h>
#include <CAENLogger.h>
#include <CAENMultiplatform.h>
Include dependency graph for CAENRandom.c:

Go to the source code of this file.

Data Structures

struct  _initializedstuff
 
struct  _librarystate
 
struct  _statevector
 
struct  _integer
 
struct  _internalstate
 

Functions

int32_t c_rand32_init (void)
 
void c_rand32_deinit (void)
 
int32_t c_rand64_init (void)
 
void c_rand64_deinit (void)
 
void c_rand32_seed (uint32_t seed)
 
void c_rand64_seed (uint64_t seed)
 
static void _twist32 (void)
 
static void _twist64 (void)
 
uint32_t c_rand32_int (void)
 
uint64_t c_rand64_int (void)
 
double c_rand (void)
 
double c_rand64 (void)
 
double c_rand64_normal (void)
 

Variables

static const c_locallogger_t __locallogger = { ( "CAENRandomLog.txt" ), ( "CAENRandom.c" ) }
 
static struct _librarystate lState
 Library state. More...
 
static struct _internalstate iState
 Internal state. More...
 
static const struct _integer kW
 The number of bits of each word in the state sequence. More...
 
static const struct _integer kM
 The shift size used on twists to transform the values. More...
 
static const struct _integer kN
 The number of elements in the state sequence (degree of recurrence). More...
 
static const struct _integer kA
 The XOR mask applied as the linear function on each twist. More...
 
static const struct _integer kB
 The XOR mask used as parameter b in the tempering process of the generation algorithm. More...
 
static const struct _integer kC
 The XOR mask used as parameter c in the tempering process of the generation algorithm. More...
 
static const struct _integer kD
 The XOR mask used as parameter d in the tempering process of the generation algorithm. More...
 
static const struct _integer kS
 The shift size of parameter s used in the tempering process of the generation algorithm. More...
 
static const struct _integer kT
 The shift size of parameter t used in the tempering process of the generation algorithm. More...
 
static const struct _integer kU
 The shift size of parameter u used in the tempering process of the generation algorithm. More...
 
static const struct _integer kL
 The shift size of parameter l used in the tempering process of the generation algorithm. More...
 
static const struct _integer kF
 The initialization multiplier used to seed the state sequence when a single value is used as seed. More...
 
static const struct _integer kDefaultSeed
 The default seed used on construction or seeding. More...
 
static const struct _integer kLowerMask
 The mask with 31 1's, where 31 is the number of bits that mark the separation point of words on each twist. More...
 

Detailed Description

Pseudo-random number generator implemented on MT19937.

Author
Giovanni Cerretani

Definition in file CAENRandom.c.

Function Documentation

◆ _twist32()

static void _twist32 ( void  )
static

Definition at line 255 of file CAENRandom.c.

Here is the caller graph for this function:

◆ _twist64()

static void _twist64 ( void  )
static

Definition at line 274 of file CAENRandom.c.

Here is the caller graph for this function:

Variable Documentation

◆ __locallogger

const c_locallogger_t __locallogger = { ( "CAENRandomLog.txt" ), ( "CAENRandom.c" ) }
static

Definition at line 45 of file CAENRandom.c.

◆ lState

struct _librarystate lState
static

Library state.

Definition at line 83 of file CAENRandom.c.

◆ iState

struct _internalstate iState
static

Internal state.

Definition at line 84 of file CAENRandom.c.

◆ kW

const struct _integer kW
static
Initial value:
= {
UINT32_C(32),
}

The number of bits of each word in the state sequence.

Definition at line 90 of file CAENRandom.c.

◆ kM

const struct _integer kM
static
Initial value:
= {
UINT32_C(397),
}

The shift size used on twists to transform the values.

Definition at line 96 of file CAENRandom.c.

◆ kN

const struct _integer kN
static
Initial value:
= {
UINT32_C(624),
}

The number of elements in the state sequence (degree of recurrence).

Definition at line 102 of file CAENRandom.c.

◆ kA

const struct _integer kA
static
Initial value:
= {
UINT32_C(0x9908b0df),
}

The XOR mask applied as the linear function on each twist.

Definition at line 108 of file CAENRandom.c.

◆ kB

const struct _integer kB
static
Initial value:
= {
UINT32_C(0x9d2c5680),
}

The XOR mask used as parameter b in the tempering process of the generation algorithm.

Definition at line 114 of file CAENRandom.c.

◆ kC

const struct _integer kC
static
Initial value:
= {
UINT32_C(0xefc60000),
}

The XOR mask used as parameter c in the tempering process of the generation algorithm.

Definition at line 120 of file CAENRandom.c.

◆ kD

const struct _integer kD
static
Initial value:
= {
UINT32_C(0xffffffff),
}

The XOR mask used as parameter d in the tempering process of the generation algorithm.

Definition at line 126 of file CAENRandom.c.

◆ kS

const struct _integer kS
static
Initial value:
= {
UINT32_C(7),
}

The shift size of parameter s used in the tempering process of the generation algorithm.

Definition at line 132 of file CAENRandom.c.

◆ kT

const struct _integer kT
static
Initial value:
= {
UINT32_C(15),
}

The shift size of parameter t used in the tempering process of the generation algorithm.

Definition at line 138 of file CAENRandom.c.

◆ kU

const struct _integer kU
static
Initial value:
= {
UINT32_C(11),
}

The shift size of parameter u used in the tempering process of the generation algorithm.

Definition at line 144 of file CAENRandom.c.

◆ kL

const struct _integer kL
static
Initial value:
= {
UINT32_C(18),
}

The shift size of parameter l used in the tempering process of the generation algorithm.

Definition at line 150 of file CAENRandom.c.

◆ kF

const struct _integer kF
static
Initial value:
= {
UINT32_C(1812433253),
}

The initialization multiplier used to seed the state sequence when a single value is used as seed.

Definition at line 156 of file CAENRandom.c.

◆ kDefaultSeed

const struct _integer kDefaultSeed
static
Initial value:
= {
UINT32_C(5489),
}

The default seed used on construction or seeding.

Definition at line 162 of file CAENRandom.c.

◆ kLowerMask

const struct _integer kLowerMask
static
Initial value:
= {
UINT32_C(0x7fffffff),
}

The mask with 31 1's, where 31 is the number of bits that mark the separation point of words on each twist.

Definition at line 168 of file CAENRandom.c.