14 PCG32( ) : x(), x0(), key() { seed(0x853c49e6748fea9b, b); }
15 PCG32(
const uint64_t s,
const uint64_t ss= b ) : x(), x0(), key() { seed(s, ss); }
17 void seed(
const uint64_t s,
const uint64_t ss= b )
26 PCG32& index(
const uint64_t i )
41 add= add * tmul + tadd;
44 tadd= tmul * tadd + tadd;
59 uint32_t tmp= ((xx >> 18u) ^ xx) >> 27u;
60 uint32_t r= xx >> 59u;
61 return (tmp >> r) | (tmp << ((~r + 1u) & 31));
64 unsigned sample_range(
const unsigned range )
68 unsigned divisor= ((-range) / range) + 1;
69 if(divisor == 0)
return 0;
73 unsigned x= sample() / divisor;
74 if(x < range)
return x;
79 unsigned operator() ( ) {
return sample(); }
80 static constexpr
unsigned min( ) {
return 0; }
81 static constexpr
unsigned max( ) {
return ~unsigned(0); }
82 typedef unsigned result_type;
84 static constexpr uint64_t a= 0x5851f42d4c957f2d;
85 static constexpr uint64_t b= 0xda3e39cb94b95bdb;
97 PCG32I( ) : x(), key() { seed(0x46b56677u, 2891336453u); }
98 PCG32I(
const unsigned s,
const unsigned ss= 2891336453u ) : x(), key() { seed(s, ss); }
100 void seed(
const unsigned s,
const unsigned ss )
112 x= x * 747796405u + key;
114 unsigned tmp= ((x >> ((x >> 28u) + 4u)) ^ x) * 277803737u;
115 return (tmp >> 22u) ^ tmp;
118 unsigned sample_range(
const unsigned range )
122 unsigned divisor= ((-range) / range) + 1;
123 if(divisor == 0)
return 0;
127 unsigned x= sample() / divisor;
128 if(x < range)
return x;
133 unsigned operator() ( ) {
return sample(); }
134 static constexpr
unsigned min( ) {
return 0; }
135 static constexpr
unsigned max( ) {
return ~unsigned(0); }
136 typedef unsigned result_type;