CX Framework
Cross-platform C utility framework
Loading...
Searching...
No Matches

Functions

void pcgSeed (PcgState *rng, uint64 initstate, uint64 initseq)
 
void pcgAutoSeed (PcgState *rng)
 

Detailed Description

Functions for initializing PCG generator state.

Function Documentation

◆ pcgAutoSeed()

void pcgAutoSeed ( PcgState rng)

Seeds the random number generator using cryptographic-quality entropy

Uses the operating system's cryptographic random number generator (e.g., /dev/urandom, CryptGenRandom, or getrandom()) to obtain high-quality random seeds. Falls back to time-based seeding if the OS random source is unavailable.

This is the recommended seeding method for most use cases where reproducibility is not required. Note that stream selection is not meaningful when using non-deterministic seeding, so the stream is also randomly chosen.

Parameters
rngPointer to uninitialized PCG state

◆ pcgSeed()

void pcgSeed ( PcgState rng,
uint64  initstate,
uint64  initseq 
)

Seeds the random number generator with an initial state and sequence

This function initializes the RNG with deterministic values, allowing for reproducible random sequences. The sequence parameter selects one of 2^63 possible independent random streams.

Use this when you need reproducible results or want to select a specific stream for parallel random number generation.

Parameters
rngPointer to uninitialized PCG state
initstateInitial state value (seed)
initseqSequence selector (stream) - determines which independent random sequence to use