openGPMP
Open Source Mathematics Package
Classes | Functions
gpmp::core::rndm Namespace Reference

Classes

class  LCG
 Linear Congruential Generator. More...
 

Functions

uint32_t rotr32 (uint32_t x, unsigned r)
 
uint32_t pcg32 (void)
 
void pcg32_init (uint64_t seed)
 

Function Documentation

◆ pcg32()

uint32_t gpmp::core::rndm::pcg32 ( void  )

Definition at line 138 of file random.cpp.

138  {
139  uint64_t x = __PCG_STATE;
140  unsigned count = (unsigned)(x >> 59); // 59 = 64 - 5
141 
143  x ^= x >> 18; // 18 = (64 - 27)/2
144  return rotr32((uint32_t)(x >> 27), count); // 27 = 32 - 5
145 }
uint32_t rotr32(uint32_t x, unsigned r)
Definition: random.cpp:134
static uint64_t const __PCG_MULTPLR
Definition: random.hpp:62
static uint64_t __PCG_STATE
Definition: random.hpp:61
static uint64_t const __PCG_INCR
Definition: random.hpp:63

References __PCG_INCR, __PCG_MULTPLR, __PCG_STATE, and rotr32().

Referenced by pcg32_init().

◆ pcg32_init()

void gpmp::core::rndm::pcg32_init ( uint64_t  seed)

Definition at line 147 of file random.cpp.

147  {
148  __PCG_STATE = seed + __PCG_INCR;
149  (void)pcg32();
150 }
uint32_t pcg32(void)
Definition: random.cpp:138

References __PCG_INCR, __PCG_STATE, and pcg32().

◆ rotr32()

uint32_t gpmp::core::rndm::rotr32 ( uint32_t  x,
unsigned  r 
)

Definition at line 134 of file random.cpp.

134  {
135  return x >> r | x << (-r & 31);
136 }

Referenced by pcg32().