10 template<
typename UInt, UInt a, UInt c, UInt m >
13 RNGT( ) : x(), key() { seed(123451); }
14 RNGT(
const UInt s ) : x(), key() { seed(s); }
15 void seed(
const UInt s ) { key= (s << 1) | 1; x= key; }
17 RNGT& index(
const UInt i )
30 add= add * tmul + tadd;
33 tadd= tmul * tadd + tadd;
42 unsigned sample( ) { x= (a*x+c) % m;
return unsigned(x); }
44 unsigned sample_range(
const unsigned range )
48 unsigned divisor= ((-range) / range) + 1;
49 if(divisor == 0)
return 0;
53 unsigned x= sample() / divisor;
54 if(x < range)
return x;
59 unsigned operator() ( ) {
return sample(); }
60 static constexpr
unsigned min( ) {
return 0; }
61 static constexpr
unsigned max( ) {
return unsigned(m-1); }
62 typedef unsigned result_type;
70 typedef RNGT<uint32_t, 48271u, 0u, (1u << 31) -1>
RNG0;