48 return std::numeric_limits<result_type>::min();
56 return std::numeric_limits<result_type>::max();
77 void seed(uint64_t init_seed) {
79 inc_ = (init_seed << 1) | 1;
81 state_ += 0x853c49e6748fea9bULL;
90 const uint64_t old_state =
state_;
92 state_ = old_state * 6364136223846793005ULL + (
inc_ | 1);
94 const uint32_t xorshifted =
95 static_cast<uint32_t
>(((old_state >> 18u) ^ old_state) >> 27u);
96 const uint32_t rot =
static_cast<uint32_t
>(old_state >> 59u);
97 return (xorshifted >> rot) | (xorshifted << ((-rot) & 31));
105 for (
unsigned long long i = 0; i < z; ++i) {
123 return !(lhs == rhs);
A 32-bit Permuted Congruential Generator (pcg32).
uint64_t state_
The internal state of the generator.
uint32_t result_type
The result type of the generator, required by the UniformRandomBitGenerator concept.
void seed(uint64_t init_seed)
Seeds the random number generator.
static constexpr result_type min()
Returns the minimum value the generator can produce.
friend bool operator==(const Pcg32 &lhs, const Pcg32 &rhs)
Checks if two generators have the same internal state.
void discard(unsigned long long z)
Discards a specified number of values from the sequence.
result_type operator()()
Generates the next random number in the sequence.
Pcg32()
Default constructor. Initializes the generator with a default seed.
friend bool operator!=(const Pcg32 &lhs, const Pcg32 &rhs)
Checks if two generators have different internal states.
static constexpr result_type max()
Returns the maximum value the generator can produce.
Pcg32(uint64_t seed)
Constructs the generator with a specific seed.
uint64_t inc_
The stream selector, which determines the sequence. Must be odd.