22 #define _rdtsc() __rdtsc() 24 #elif defined(__GNUC__) && (defined(__x86_64__) || defined(__i386__)) 28 #include <x86intrin.h> 30 #elif defined(__GNUC__) && defined(__ARM_NEON__) 36 #elif defined(__GNUC__) && defined(__IWMMXT__) 42 #elif (defined(__GNUC__) || defined(__xlC__)) && (defined(__VEC__) || defined(__ALTIVEC__)) 48 #elif defined(__GNUC__) && defined(__SPE__) 61 static inline std::uint64_t
62 rotl(
const std::uint64_t x,
int k)
64 return (x << k) | (x >> (64 - k));
78 std::uint64_t base = _rdtsc();
79 std::uint64_t seed = base & 0xff;
80 for (
int i = 1; i < 8; i++) {
81 std::this_thread::yield();
82 seed |= ((_rdtsc() - base) & 0xff) << (i << 3);
97 std::random_device rd;
98 if (
sizeof(
result_type) >
sizeof(std::random_device::result_type))
115 rng64(std::uint64_t seed = 1) : state{seed} {}
119 std::uint64_t z = (state += UINT64_C(0x9E3779B97F4A7C15));
120 z = (z ^ (z >> 30)) * UINT64_C(0xBF58476D1CE4E5B9);
121 z = (z ^ (z >> 27)) * UINT64_C(0x94D049BB133111EB);
122 return z ^ (z >> 31);
136 rng128(std::uint64_t seed[2]) : state{seed[0], seed[1]} {}
138 rng128(std::uint64_t s0, std::uint64_t s1) : state{s0, s1} {}
152 const uint64_t s0 = state[0];
153 uint64_t s1 = state[1];
154 const uint64_t value = s0 + s1;
157 state[0] = rotl(s0, 55) ^ s1 ^ (s1 << 14);
158 state[1] = rotl(s1, 36);
168 static const std::uint64_t j[] = {0xbeac0467eba5facb, 0xd86b048b86aa9922};
170 std::uint64_t s0 = 0, s1 = 0;
171 for (std::size_t i = 0; i <
sizeof j /
sizeof j[0]; i++) {
172 for (
int b = 0; b < 64; b++) {
173 if ((j[i] & UINT64_C(1) << b) != 0) {
result_type operator()()
Definition: xoroshiro128.hpp:150
result_type operator()()
Definition: xoroshiro128.hpp:95
rng128(std::uint64_t seed[2])
Definition: xoroshiro128.hpp:136
void jump()
Definition: xoroshiro128.hpp:166
Definition: xoroshiro128.hpp:109
Definition: xoroshiro128.hpp:130
result_type operator()()
Definition: xoroshiro128.hpp:117
result_type operator()()
Definition: xoroshiro128.hpp:76
static constexpr result_type max()
Definition: xoroshiro128.hpp:148
std::uint64_t result_type
Definition: xoroshiro128.hpp:93
Definition: xoroshiro128.hpp:91
std::uint64_t result_type
Definition: xoroshiro128.hpp:132
static constexpr result_type min()
Definition: xoroshiro128.hpp:147
std::uint64_t result_type
Definition: xoroshiro128.hpp:74
rng128(std::uint64_t seed=1)
Definition: xoroshiro128.hpp:140
std::uint64_t result_type
Definition: xoroshiro128.hpp:111
Definition: xoroshiro128.hpp:56
rng64(std::uint64_t seed=1)
Definition: xoroshiro128.hpp:115
rng128(std::uint64_t s0, std::uint64_t s1)
Definition: xoroshiro128.hpp:138
Definition: xoroshiro128.hpp:72
std::uint64_t state
Definition: xoroshiro128.hpp:113