Main docs: https://pigweed.dev/pw_random.
◆ Get() [1/2]
void pw::random::XorShiftStarRng64::Get |
( |
ByteSpan |
dest | ) |
|
|
inlinefinalvirtual |
Populates the destination buffer with a randomly generated value.
This generator uses entropy-seeded PRNG to never exhaust its random number pool.
Implements pw::random::RandomGenerator.
◆ Get() [2/2]
virtual void pw::random::RandomGenerator::Get |
( |
ByteSpan |
dest | ) |
|
|
pure virtual |
Populates the destination buffer with a randomly generated value.
- Parameters
-
[out] | dest | The destination buffer. |
Implemented in pw::random::XorShiftStarRng64.
◆ GetInt()
template<class T >
void pw::random::RandomGenerator::GetInt |
( |
T & |
dest, |
|
|
const T & |
exclusive_upper_bound |
|
) |
| |
|
inline |
Calculates a uniformly distributed random number in the range [0, exclusive_upper_bound)
.
This avoids modulo biasing. Uniformity is only guaranteed if the underlying generator generates uniform data. Uniformity is achieved by generating new random numbers until one is generated in the desired range (with optimizations).
- Parameters
-
[out] | dest | The destination to populate the random number into. |
[in] | exclusive_upper_bound | The largest number that can be populated into dest , exclusive. |
◆ InjectEntropyBits() [1/2]
void pw::random::XorShiftStarRng64::InjectEntropyBits |
( |
uint32_t |
data, |
|
|
uint_fast8_t |
num_bits |
|
) |
| |
|
inlinefinalvirtual |
Injects entropy by rotating the state by the number of entropy bits before XORing the entropy with the current state.
This technique ensures that seeding the random value with single bits will progressively fill the state with more entropy.
Implements pw::random::RandomGenerator.
◆ InjectEntropyBits() [2/2]
virtual void pw::random::RandomGenerator::InjectEntropyBits |
( |
uint32_t |
data, |
|
|
uint_fast8_t |
num_bits |
|
) |
| |
|
pure virtual |
Injects entropy into the pool.
- Parameters
-
[in] | data | Up to 32 bits of random entropy data. |
[in] | num_bits | The number of bits of entropy. If less than 32 , entropy is assumed to be stored in the least significant bits of data . |
Implemented in pw::random::XorShiftStarRng64.