16#ifndef INCLUDED_XOROSHIRO128P_H
17#define INCLUDED_XOROSHIRO128P_H
30static inline uint64_t
rotl(
const uint64_t x,
const int k)
32 return (x << k) | (x >> (64 - k));
41 const uint64_t s0 = state[0];
42 uint64_t s1 = state[1];
43 const uint64_t result = s0 + s1;
46 state[0] =
rotl(s0, 55) ^ s1 ^ (s1 << 14);
47 state[1] =
rotl(s1, 36);
59 static const uint64_t JUMP[] = { 0xbeac0467eba5facb, 0xd86b048b86aa9922 };
63 for (
unsigned int i = 0; i <
sizeof(JUMP) /
sizeof(*JUMP); ++i) {
64 for (
unsigned int b = 0; b < 64; ++b) {
65 if (JUMP[i] & UINT64_C(1) << b) {
83 uint64_t z = (*state += 0x9e3779b97f4a7c15);
84 z = (z ^ (z >> 30)) * 0xbf58476d1ce4e5b9;
85 z = (z ^ (z >> 27)) * 0x94d049bb133111eb;
static void xoroshiro128p_seed(uint64_t *state, const uint64_t seed)
Seed the 128 bit state from a 64 bit seed.
Definition: xoroshiro128p.h:91
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:81
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:57
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:30
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:39