The random number generation engine generation subsystem. More...
Typedefs | |
using | Engine = std::mt19937_64 |
The engine type returned by genEngine() below. More... | |
using | Result = typename Engine::result_type |
The type of the results generated by engines from genEngine() as well as the seed type used to initialise the engine-generation engine. More... | |
Functions | |
void | disableReproducible () |
Sets the global seed to zero, causing non-reproducible generation of random number engines by genEngine() . More... | |
Engine | genEngine () |
Returns a random number generation engine. More... | |
Result | genValue () |
Generates a single value from the internal LCG, mainly useful for debugging. More... | |
Result const & | getSeed () |
Returns the seed used by the internal LCG. More... | |
Result | initReproducible (Result const seed_=0) |
Initialises the global generating random number engine. More... | |
bool | isReproducible () |
Returns true if the global seed is non-zero and no threading is used. More... | |
Variables | |
std::linear_congruential_engine< Result, 6364136223846793005ULL, 1442695040888963407ULL, 18446744073709551615ULL > | engine {std::random_device()()} |
Engine used to generate seeds for genEngine() below. More... | |
std::mutex | mtx_engine |
Mutex protecting genEngine (and engine) below if seed is non-zero. More... | |
Result | seed {0} |
global seed, if zero, none was set and genEngine() is non-deterministic More... | |
The random number generation engine generation subsystem.
The idea is as follows:
If Random::seed is zero, it acquires a non-deterministic seed to initialise the engine it returns. If Random::seed is non-zero, it locks a mutex and uses the next result from a global random number generation engine to initialise the new engine. It then returns that new engine.
Threading::*Num
values are set to 1, i.e. no threading takes place.