28 #ifndef INCLUDED_XOROSHIRO128P_H 29 #define INCLUDED_XOROSHIRO128P_H 39 static inline uint64_t
rotl(
const uint64_t x,
const int k) {
40 return (x << k) | (x >> (64 - k));
48 const uint64_t s0 = state[0];
49 uint64_t s1 = state[1];
50 const uint64_t result = s0 + s1;
53 state[0] =
rotl(s0, 55) ^ s1 ^ (s1 << 14);
54 state[1] =
rotl(s1, 36);
65 static const uint64_t JUMP[] = { 0xbeac0467eba5facb, 0xd86b048b86aa9922 };
69 for(
unsigned int i = 0; i <
sizeof (JUMP) /
sizeof (*JUMP); ++i) {
70 for(
unsigned int b = 0; b < 64; ++b) {
71 if (JUMP[i] & UINT64_C(1) << b) {
87 uint64_t z = (*state += 0x9e3779b97f4a7c15);
88 z = (z ^ (z >> 30)) * 0xbf58476d1ce4e5b9;
89 z = (z ^ (z >> 27)) * 0x94d049bb133111eb;
103 #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:86
static void xoroshiro128p_seed(uint64_t *state, const uint64_t seed)
Seed the 128 bit state from a 64 bit seed.
Definition: xoroshiro128p.h:95
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:39
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:47
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:64