28 #ifndef INCLUDED_XOROSHIRO128P_H 29 #define INCLUDED_XOROSHIRO128P_H 40 static inline uint64_t
rotl(
const uint64_t x,
const int k)
42 return (x << k) | (x >> (64 - k));
51 const uint64_t s0 = state[0];
52 uint64_t s1 = state[1];
53 const uint64_t result = s0 + s1;
56 state[0] =
rotl(s0, 55) ^ s1 ^ (s1 << 14);
57 state[1] =
rotl(s1, 36);
69 static const uint64_t JUMP[] = { 0xbeac0467eba5facb, 0xd86b048b86aa9922 };
73 for (
unsigned int i = 0; i <
sizeof(JUMP) /
sizeof(*JUMP); ++i) {
74 for (
unsigned int b = 0; b < 64; ++b) {
75 if (JUMP[i] & UINT64_C(1) << b) {
93 uint64_t z = (*state += 0x9e3779b97f4a7c15);
94 z = (z ^ (z >> 30)) * 0xbf58476d1ce4e5b9;
95 z = (z ^ (z >> 27)) * 0x94d049bb133111eb;
110 #endif // Include guard static uint64_t splitmix64_next(uint64_t *state)
step of the SPLITMIX64 RNG; only used internally for seeding This RNG isn't as good as XOROSHIRO128+...
Definition: xoroshiro128p.h:91
static void xoroshiro128p_seed(uint64_t *state, const uint64_t seed)
Seed the 128 bit state from a 64 bit seed.
Definition: xoroshiro128p.h:101
static uint64_t rotl(const uint64_t x, const int k)
rotating left shift helper According to the original authors, this will on most platforms reduce to a...
Definition: xoroshiro128p.h:40
static uint64_t xoroshiro128p_next(uint64_t *state)
generate the next random number and update the state. This is the workhorse, here! ...
Definition: xoroshiro128p.h:49
static void xoroshiro128p_jump(uint64_t *state)
Advance the internal state by 2^64 steps; useful when coordinating multiple independent RNGs This is ...
Definition: xoroshiro128p.h:67