vkmEngine 1.0.0
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
Vkm::Engine::Math::Rng Class Reference

PCG32 pseudo-random generator (O'Neill, 2014). More...

#include <random.h>

Public Member Functions

 Rng (uint64_t seed, uint64_t stream=DEFAULT_STREAM)
 Seed with an explicit state and (optionally) stream selector.
void seed (uint64_t seed, uint64_t stream=DEFAULT_STREAM)
 Re-seed in place, discarding the current sequence position.
uint32_t nextU32 ()
 Advance the state and return the next raw 32-bit value.

Detailed Description

PCG32 pseudo-random generator (O'Neill, 2014).

Deterministic and seedable, so each owner can have its own reproducible stream.

Constructor & Destructor Documentation

◆ Rng()

Vkm::Engine::Math::Rng::Rng ( uint64_t seed,
uint64_t stream = DEFAULT_STREAM )
inlineexplicit

Seed with an explicit state and (optionally) stream selector.

Parameters
seedInitial state; any value.
streamSequence selector; same seed, different stream is uncorrelated.

Member Function Documentation

◆ seed()

void Vkm::Engine::Math::Rng::seed ( uint64_t seed,
uint64_t stream = DEFAULT_STREAM )
inline

Re-seed in place, discarding the current sequence position.

Parameters
seedInitial state; any value.
streamSequence selector; see the constructor.

◆ nextU32()

uint32_t Vkm::Engine::Math::Rng::nextU32 ( )
inline

Advance the state and return the next raw 32-bit value.

One LCG step, then PCG's xorshift-then-rotate output permutation.

Returns
A uniform value over the full 32-bit range.

The documentation for this class was generated from the following file: