6#include <Common/primitive_type.h>
48 explicit Pcg32(uint64 initialSequence);
54 Pcg32(uint64 initialSequence, uint64 initialState);
60 uint32 generateUInt32();
62 inline static constexpr uint64 DEFAULT_STATE = 0x853C49E6748FEA9Bull;
63 inline static constexpr uint64 DEFAULT_STREAM_ID = 0xDA3E39CB94B95BDBull;
64 inline static constexpr uint64 MULTIPLIER = 0x5851F42D4C957F2Dull;
66 uint64 m_state = DEFAULT_STATE;
69 uint64 m_increment = DEFAULT_STREAM_ID;
76inline Pcg32::Pcg32(
const uint64 initialSequence,
const uint64 initialState)
82 m_increment = (initialSequence << 1u) | 1u;
85 m_state += initialState;
91 return generateUInt32();
96 uint64 curMult = MULTIPLIER;
97 uint64 curPlus = m_increment;
100 uint64 delta = distance;
106 accPlus = accPlus * curMult + curPlus;
108 curPlus = (curMult + 1) * curPlus;
112 m_state = accMult * m_state + accPlus;
115inline uint32 Pcg32::generateUInt32()
118 const uint64 oldState = m_state;
119 m_state = oldState * MULTIPLIER + m_increment;
121 uint32 xorShifted =
static_cast<uint32
>(((oldState >> 18u) ^ oldState) >> 27u);
122 uint32 rot =
static_cast<uint32
>(oldState >> 59u);
123 return (xorShifted >> rot) | (xorShifted << ((~rot + 1u) & 31));
PCG-32 generator. This is the pcg32 generator in O'Neill's original pcg-cpp implementation....
Definition Pcg32.h:44
void impl_jumpAhead(uint64 distance)
Definition Pcg32.h:94
Pcg32(uint64 initialSequence)
Definition Pcg32.h:72
uint32 impl_generate()
Definition Pcg32.h:89
PH_DEFINE_INLINE_RULE_OF_5_MEMBERS(Pcg32)
Math functions and utilities.
Definition TransformInfo.h:10
uint64 moremur_bit_mix_64(uint64 v)
A MurmurHash3-style bit mixer that outperforms the original by quite some margin. 64-bit version.
Definition hash.ipp:104