Skip to content

tenzr::random::Generator

Mutex-protected pseudo-random number generator built on a 64-bit Mersenne twister.

#include <generator.h>

Public Functions

Name
Generator()
Construct a generator seeded from the system randomness source.
Generator(uint64_t seed)
void ManualSeed(uint64_t seed)
void SeedRandom()
Reseed the generator from a non-deterministic source.
uint64_t CurrentSeed() const
uint64_t NextUint64()
double NextDouble()
float NextFloat()
std::mt19937_64 & Engine()

Public Functions Documentation

function Generator

Generator()

Construct a generator seeded from the system randomness source.

function Generator

explicit Generator(
    uint64_t seed
)

Parameters:

  • seed Seed for the underlying engine.

Construct a generator with a deterministic seed.

function ManualSeed

void ManualSeed(
    uint64_t seed
)

Parameters:

  • seed New seed.
  • seed New seed value.

Reseed the generator deterministically. Reseed the engine deterministically.

function SeedRandom

void SeedRandom()

Reseed the generator from a non-deterministic source.

Reseed the engine from std::random_device.

function CurrentSeed

inline uint64_t CurrentSeed() const

Return: Seed the generator was constructed or reseeded with.

function NextUint64

uint64_t NextUint64()

Return:

  • Next 64-bit random word.
  • Pseudorandom 64-bit integer.

Draw the next 64-bit value.

function NextDouble

double NextDouble()

Return: Pseudorandom double.

Draw a uniform double in [0, 1).

function NextFloat

float NextFloat()

Return: Pseudorandom float.

Draw a uniform float in [0, 1).

function Engine

inline std::mt19937_64 & Engine()

Return: Mutable reference to the underlying engine.