A pseudorandom number generator.
More...
#include <prng.h>
|
| 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, 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.
|
|
void | discard (uint64_t n) |
| Discard n numbers from the generator.
|
|
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 PRNG | linear_congruential (uint64_t seed=1) |
| Returns a standard linear congruential generator.
|
|
static PRNG | xoshiro (const std::vector< uint64_t > &p) |
| Returns a Xoshiro256++ generator.
|
|
static PRNG | xoshiro (uint64_t seed=1) |
| Returns a Xoshiro256++ generator.
|
|
static PRNG | splitmix64 (uint64_t seed=1) |
| Returns a Splitmix64 generator.
|
|
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.
◆ discard()
void theoretica::PRNG::discard |
( |
uint64_t |
n | ) |
|
|
inline |
Discard n numbers from the generator.
Equivalent to calling next() n times.
◆ linear_congruential()
static PRNG theoretica::PRNG::linear_congruential |
( |
uint64_t |
seed = 1 | ) |
|
|
inlinestatic |
Returns a standard linear congruential generator.
- Parameters
-
seed | The seed to use for the generator (defaults to 1) |
- Returns
- A standard linear congruential PRNG object
◆ operator()()
uint64_t theoretica::PRNG::operator() |
( |
| ) |
|
|
inline |
Generate a pseudorandom number.
- See also
- next()
◆ splitmix64()
static PRNG theoretica::PRNG::splitmix64 |
( |
uint64_t |
seed = 1 | ) |
|
|
inlinestatic |
Returns a Splitmix64 generator.
- Parameters
-
seed | The seed to use for the generator |
- Returns
- A splitmix64 pseudorandom number generator
◆ xoshiro() [1/2]
static PRNG theoretica::PRNG::xoshiro |
( |
const std::vector< uint64_t > & |
p | ) |
|
|
inlinestatic |
Returns a Xoshiro256++ generator.
- Parameters
-
p | The four state parameters |
- Returns
- A Xoshiro256++ pseudorandom number generator
◆ xoshiro() [2/2]
static PRNG theoretica::PRNG::xoshiro |
( |
uint64_t |
seed = 1 | ) |
|
|
inlinestatic |
Returns a Xoshiro256++ generator.
- Parameters
-
seed | The seed to use for the generator |
- Returns
- A Xoshiro256++ pseudorandom number generator
The four parameters for the Xoshiro256++ algorithm are generated using the Splitmix64 algorithm.
The documentation for this class was generated from the following file: