Theoretica
A C++ numerical and automatic mathematical library
|
A pseudorandom number generator. More...
#include <prng.h>
Public Member Functions | |
PRNG (pseudorandom_function p, uint64_t seed, const std::vector< uint64_t > &s) | |
Construct a PRNG with the given generating algorithm p, seed x and parameters s. | |
PRNG (pseudorandom_function p, const std::vector< uint64_t > &s) | |
Construct a PRNG with the given generating algorithm p and parameters s. More... | |
PRNG (pseudorandom_function p, uint64_t seed) | |
Construct a PRNG with the given generating algorithm and seed. | |
PRNG (uint64_t seed) | |
Construct a PRNG with the default generator and the given seed. | |
void | seed (uint64_t seed) |
Seed the PRNG. | |
uint64_t | next () |
Generate a pseudorandom number. | |
uint64_t | operator() () |
Generate a pseudorandom number. More... | |
void | discard (uint64_t n) |
Discard n numbers from the generator. More... | |
uint64_t | last () const |
Return the last generated number. | |
void | set_function (pseudorandom_function p) |
Set the generating function. | |
pseudorandom_function | get_function () const |
Get the generating function. | |
void | set_param (const std::vector< uint64_t > &v) |
Set the generator's parameters. | |
void | set_param (unsigned int i, uint64_t value) |
Set a specific parameter by index. | |
std::vector< uint64_t > | get_param () const |
Get the generator's parameters. | |
PRNG & | operator>> (uint64_t &n) |
Stream the next generated number. | |
Static Public Member Functions | |
static PRNG | linear_congruential (uint64_t seed=1) |
Returns a standard linear congruential generator. More... | |
static PRNG | xoshiro (const std::vector< uint64_t > &p) |
Returns a Xoshiro256++ generator. More... | |
static PRNG | xoshiro (uint64_t seed=1) |
Returns a Xoshiro256++ generator. More... | |
static PRNG | splitmix64 (uint64_t seed=1) |
Returns a Splitmix64 generator. More... | |
static PRNG | wyrand (uint64_t seed=1, uint64_t p1=2549536629329, uint64_t p2=136137137) |
Returns a Wyrand generator. | |
static PRNG | middlesquare (uint64_t seed, uint64_t offset=765872292751861) |
Returns a Middle-square generator. | |
A pseudorandom number generator.
|
inline |
Construct a PRNG with the given generating algorithm p and parameters s.
The seed will be set to 1.
|
inline |
Discard n numbers from the generator.
Equivalent to calling next() n times.
|
inlinestatic |
Returns a standard linear congruential generator.
seed | The seed to use for the generator (defaults to 1) |
|
inline |
Generate a pseudorandom number.
|
inlinestatic |
Returns a Splitmix64 generator.
seed | The seed to use for the generator |
|
inlinestatic |
Returns a Xoshiro256++ generator.
p | The four state parameters |
|
inlinestatic |
Returns a Xoshiro256++ generator.
seed | The seed to use for the generator |
The four parameters for the Xoshiro256++ algorithm are generated using the Splitmix64 algorithm.