9 #ifndef ApproxMVBB_RandomGenerator_hpp 10 #define ApproxMVBB_RandomGenerator_hpp 14 #include ApproxMVBB_TypeDefs_INCLUDE_FILE 16 #include <type_traits> 23 namespace RandomGenerators{
43 void seed(uint64_t seed);
44 uint64_t operator()();
48 static constexpr
result_type min(){
return std::numeric_limits<result_type>::min(); }
49 static constexpr
result_type max(){
return std::numeric_limits<result_type>::max(); }
74 void seed(uint64_t seed);
76 uint64_t operator()();
85 static constexpr
result_type min(){
return std::numeric_limits<result_type>::min(); }
86 static constexpr
result_type max(){
return std::numeric_limits<result_type>::max(); }
111 void seed(uint64_t seed);
113 uint64_t operator()();
122 static constexpr
result_type min(){
return std::numeric_limits<result_type>::min(); }
123 static constexpr
result_type max(){
return std::numeric_limits<result_type>::max(); }
133 m_nRange = m_max - m_min + 1;
138 return ((
double)g() / ((
double)(G::max()-G::min()) + 1.0)) * m_nRange + m_min;
152 m_nRange = m_max - m_min + 1;
157 return ((T)g() / (T)(G::max()-G::min())) * m_nRange + m_min;
169 #ifdef ApproxMVBB_BUILD_TESTS 170 #warning "ApproxMVBB: Using non-standart uniform distributions for testing!" 189 namespace RandomGenerators{
197 uint64_t z = (
x += UINT64_C(0x9E3779B97F4A7C15));
198 z = (z ^ (z >> 30)) * UINT64_C(0xBF58476D1CE4E5B9);
199 z = (z ^ (z >> 27)) * UINT64_C(0x94D049BB133111EB);
200 return z ^ (z >> 31);
221 const uint64_t s0 = s[1];
224 s[1] = s1 ^ s0 ^ (s1 >> 18) ^ (s0 >> 5);
231 static const uint64_t JUMP[] = { 0x8a5cd789635d2dff, 0x121fd2155c472f96 };
235 for(
unsigned int i = 0; i <
sizeof(JUMP) /
sizeof (*JUMP); i++)
236 for(
int b = 0; b < 64; b++) {
237 if (JUMP[i] & 1ULL << b) {
268 const uint64_t s0 = s[p];
269 uint64_t s1 = s[p = (p + 1) & 15];
271 s[p] = s1 ^ s0 ^ (s1 >> 11) ^ (s0 >> 30);
272 return s[p] * UINT64_C(1181783497276652981);
281 static const uint64_t JUMP[] = { 0x84242f96eca9c41d,
282 0xa3c65b8776f96855, 0x5b34a39f070b5837, 0x4489affce4f31a1e,
283 0x2ffeeb0a48316f40, 0xdc2d9891fe68c022, 0x3659132bb12fea70,
284 0xaac17d8efa43cab8, 0xc4cb815590989b13, 0x5ee975283d71c93b,
285 0x691548c86c1bd540, 0x7910c41d10a1e6a5, 0x0b5fc64563b3e2a8,
286 0x047f7684e9fc949d, 0xb99181f2d8f685ca, 0x284600e3f30e38c3
289 uint64_t t[16] = { 0 };
290 for(
unsigned int i = 0; i <
sizeof(JUMP) /
sizeof (*JUMP); i++)
291 for(
int b = 0; b < 64; b++) {
292 if (JUMP[i] & 1ULL << b)
293 for(
int j = 0; j < 16; j++)
294 t[j] ^= s[(j + p) & 15];
298 for(
int j = 0; j < 16; j++)
299 s[(j + p) & 15] = t[j];
static constexpr result_type max()
SplitMix64(const SplitMix64 &gen)=default
These are some container definitions.
std::uniform_real_distribution< T > DefaultUniformRealDistribution
static constexpr result_type min()
static constexpr result_type min()
#define ApproxMVBB_STATIC_ASSERT(B)
static const uint64_t defaultSeed
static constexpr result_type max()
std::uniform_int_distribution< T > DefaultUniformUIntDistribution
static constexpr result_type max()
static constexpr result_type min()