Deterministic ORB5 pseudo-random stream and seed jump operations.
More...
#include "random_generator.hpp"
|
| static void | decimal_to_seed (const std::string &decimal, std::array< int, SEED_SIZE > &seed) |
| | Convert decimal digits to the eight-digit base-2^14 seed.
|
| |
| static void | next_seed (int n0, std::array< int, SEED_SIZE > &seed) |
| | Jump a seed along the primary independent stream family.
|
| |
| static void | next_seed3 (int n0, int n1, int n2, std::array< int, SEED_SIZE > &seed) |
| | Apply signed jumps in three hierarchical stream dimensions.
|
| |
| static void | random_array (std::vector< Real > &y, int n, int &p, std::vector< Real > &r) |
| | Draw an array of dimensionless uniform variates.
|
| |
| static void | random_gauss (std::vector< Real > &y, int n, int &p, std::vector< Real > &r) |
| | Draw standard-normal variates using the Box–Muller transform.
|
| |
| static void | random_init (const std::array< int, SEED_SIZE > &seed, int &p, std::vector< Real > &r) |
| | Initialize a pseudo-random stream from a deterministic seed.
|
| |
| static void | random_orb (int &p, std::vector< Real > &r, Real &random2) |
| | Draw one dimensionless uniform variate from the stream.
|
| |
| static void | seed_to_decimal (const std::array< int, SEED_SIZE > &seed, std::string &decimal) |
| | Format a base-2^14 seed as a fixed-width decimal field.
|
| |
|
| static constexpr int | B = 16384 |
| | Seed radix, 2^14.
|
| |
| static constexpr Real | DEL = 1.0 / (1ULL << 14) |
| | Reciprocal seed radix, 2^-14.
|
| |
| static constexpr Real | MULT = 1.0 * (1ULL << 23) |
| | Legacy single-precision scale, 2^23.
|
| |
| static constexpr int | RAN_K = 100 |
| | Values retained in a stream batch.
|
| |
| static constexpr int | SEED_SIZE = 8 |
| | Base-2^14 digits in a seed.
|
| |
| static constexpr Real | ULP = 1.0 / (1ULL << 47) |
| | Stream perturbation, 2^-47.
|
| |
| static constexpr Real | ULP2 = 1.0 / (1ULL << 48) |
| | Uniform half-ULP offset, 2^-48.
|
| |
Deterministic ORB5 pseudo-random stream and seed jump operations.
This class preserves the original base-2^14 seed representation and lagged-Fibonacci stream so marker loading and stochastic operators can reproduce reference sequences. A stream consists of a 100-value state vector r and cursor p; callers must pass both back on every draw. Output uniforms are dimensionless and shifted away from exact zero, and Gaussian output is standard normal (zero mean, unit variance).
◆ decimal_to_seed()
| static void orb5x::RandomGenerator::decimal_to_seed |
( |
const std::string & |
decimal, |
|
|
std::array< int, SEED_SIZE > & |
seed |
|
) |
| |
|
static |
Convert decimal digits to the eight-digit base-2^14 seed.
- Parameters
-
| [in] | decimal | Text whose non-decimal characters are ignored. |
| [out] | seed | Converted seed, least-significant radix digit first. |
◆ next_seed()
| static void orb5x::RandomGenerator::next_seed |
( |
int |
n0, |
|
|
std::array< int, SEED_SIZE > & |
seed |
|
) |
| |
|
static |
Jump a seed along the primary independent stream family.
- Parameters
-
| [in] | n0 | Signed jump count; positive advances and negative reverses. |
| [in,out] | seed | Seed transformed in place; unchanged when n0 == 0. |
◆ next_seed3()
| static void orb5x::RandomGenerator::next_seed3 |
( |
int |
n0, |
|
|
int |
n1, |
|
|
int |
n2, |
|
|
std::array< int, SEED_SIZE > & |
seed |
|
) |
| |
|
static |
Apply signed jumps in three hierarchical stream dimensions.
- Parameters
-
| [in] | n0 | Primary-dimension jump count. |
| [in] | n1 | Secondary-dimension jump count. |
| [in] | n2 | Tertiary-dimension jump count. |
| [in,out] | seed | Seed transformed in order n2, n1, then n0. |
◆ random_array()
| static void orb5x::RandomGenerator::random_array |
( |
std::vector< Real > & |
y, |
|
|
int |
n, |
|
|
int & |
p, |
|
|
std::vector< Real > & |
r |
|
) |
| |
|
static |
Draw an array of dimensionless uniform variates.
- Parameters
-
| [out] | y | Resized to n and filled in stream order. |
| [in] | n | Number of requested values; non-positive requests do nothing. |
| [in,out] | p | Stream cursor. |
| [in,out] | r | Stream state. |
◆ random_gauss()
| static void orb5x::RandomGenerator::random_gauss |
( |
std::vector< Real > & |
y, |
|
|
int |
n, |
|
|
int & |
p, |
|
|
std::vector< Real > & |
r |
|
) |
| |
|
static |
Draw standard-normal variates using the Box–Muller transform.
- Parameters
-
| [out] | y | Resized to n; values are dimensionless with mean zero and variance one in distribution. |
| [in] | n | Number of requested values; non-positive requests do nothing. |
| [in,out] | p | Stream cursor. |
| [in,out] | r | Stream state. |
◆ random_init()
| static void orb5x::RandomGenerator::random_init |
( |
const std::array< int, SEED_SIZE > & |
seed, |
|
|
int & |
p, |
|
|
std::vector< Real > & |
r |
|
) |
| |
|
static |
Initialize a pseudo-random stream from a deterministic seed.
- Parameters
-
| [in] | seed | Eight base-2^14 seed digits. |
| [out] | p | Cursor set to RAN_K, causing the first draw to refresh the batch. |
| [out] | r | Stream state resized to RAN_K dimensionless values. |
◆ random_orb()
| static void orb5x::RandomGenerator::random_orb |
( |
int & |
p, |
|
|
std::vector< Real > & |
r, |
|
|
Real & |
random2 |
|
) |
| |
|
static |
Draw one dimensionless uniform variate from the stream.
- Parameters
-
| [in,out] | p | Current batch cursor, advanced by one. |
| [in,out] | r | State vector initialized by random_init(). |
| [out] | random2 | Uniform variate shifted by 2^-48, nominally in (0,1). |
◆ seed_to_decimal()
| static void orb5x::RandomGenerator::seed_to_decimal |
( |
const std::array< int, SEED_SIZE > & |
seed, |
|
|
std::string & |
decimal |
|
) |
| |
|
static |
Format a base-2^14 seed as a fixed-width decimal field.
- Parameters
-
| [in] | seed | Seed digits, each expected in [0,B). |
| [in,out] | decimal | Its incoming length selects output field width; the content is replaced by right-aligned decimal text. |
| constexpr int orb5x::RandomGenerator::B = 16384 |
|
staticconstexpr |
◆ DEL
| constexpr Real orb5x::RandomGenerator::DEL = 1.0 / (1ULL << 14) |
|
staticconstexpr |
Reciprocal seed radix, 2^-14.
◆ MULT
| constexpr Real orb5x::RandomGenerator::MULT = 1.0 * (1ULL << 23) |
|
staticconstexpr |
Legacy single-precision scale, 2^23.
◆ RAN_K
| constexpr int orb5x::RandomGenerator::RAN_K = 100 |
|
staticconstexpr |
Values retained in a stream batch.
◆ SEED_SIZE
| constexpr int orb5x::RandomGenerator::SEED_SIZE = 8 |
|
staticconstexpr |
Base-2^14 digits in a seed.
◆ ULP
| constexpr Real orb5x::RandomGenerator::ULP = 1.0 / (1ULL << 47) |
|
staticconstexpr |
Stream perturbation, 2^-47.
◆ ULP2
| constexpr Real orb5x::RandomGenerator::ULP2 = 1.0 / (1ULL << 48) |
|
staticconstexpr |
Uniform half-ULP offset, 2^-48.
The documentation for this class was generated from the following file: