55 static const int N = 17;
71 if (counter >=
N) iterate();
72 return INV_M61*
static_cast<double>(V[counter++]);
78 void flatArray (
const int size,
double* vect);
81 inline void setSeed(
long longSeed,
int = 0 )
87 void setSeeds(
const long * seeds,
int seedNum=0);
93 void saveStatus(
const char filename[] =
"MixMaxRngState.conf" )
const;
96 void restoreStatus(
const char filename[] =
"MixMaxRngState.conf" );
103 inline operator double() {
return flat(); }
106 inline operator float() {
return float(
flat() ); }
109 inline operator unsigned int() {
return static_cast<unsigned int>(get_next()); }
113 virtual std::ostream &
put (std::ostream & os)
const;
114 virtual std::istream &
get (std::istream & is);
116 virtual std::istream &
getState ( std::istream & is );
118 std::string
name()
const {
return "MixMaxRng"; }
121 std::vector<unsigned long>
put ()
const;
122 bool get (
const std::vector<unsigned long> & vec);
123 bool getState (
const std::vector<unsigned long> & vec);
127 static constexpr long long int SPECIAL = 0;
128 static constexpr long long int SPECIALMUL= 36;
129 static constexpr int BITS=61;
130 static constexpr myuint_t M61=2305843009213693951ULL;
131 static constexpr double INV_M61=0.43368086899420177360298E-18;
132 static constexpr unsigned int VECTOR_STATE_SIZE = 2*
N+4;
136 return ((((k)) & M61) + (((k)) >> BITS) );
139 static constexpr int rng_get_N();
142 void print_state()
const;
147 void BranchInplace(
int id);
150 inline void seed64(
myuint_t seedval)
152 seed_uniquestream( 0, 0, (
myID_t)(seedval>>32), (
myID_t)seedval );
155 inline void iterate()
158 V[0] = ( tempV = sumtot );
159 myuint_t insumtot = V[0], ovflow = 0;
162 tempPO = MULWU(tempP); tempP = modadd(tempP, V[1] ); tempV = MIXMAX_MOD_MERSENNE(tempV+tempP+tempPO); V[1] = tempV; insumtot += tempV;
if (insumtot < tempV) {++ovflow;}
163 tempPO = MULWU(tempP); tempP = modadd(tempP, V[2] ); tempV = MIXMAX_MOD_MERSENNE(tempV+tempP+tempPO); V[2] = tempV; insumtot += tempV;
if (insumtot < tempV) {++ovflow;}
164 tempPO = MULWU(tempP); tempP = modadd(tempP, V[3] ); tempV = MIXMAX_MOD_MERSENNE(tempV+tempP+tempPO); V[3] = tempV; insumtot += tempV;
if (insumtot < tempV) {++ovflow;}
165 tempPO = MULWU(tempP); tempP = modadd(tempP, V[4] ); tempV = MIXMAX_MOD_MERSENNE(tempV+tempP+tempPO); V[4] = tempV; insumtot += tempV;
if (insumtot < tempV) {++ovflow;}
166 tempPO = MULWU(tempP); tempP = modadd(tempP, V[5] ); tempV = MIXMAX_MOD_MERSENNE(tempV+tempP+tempPO); V[5] = tempV; insumtot += tempV;
if (insumtot < tempV) {++ovflow;}
167 tempPO = MULWU(tempP); tempP = modadd(tempP, V[6] ); tempV = MIXMAX_MOD_MERSENNE(tempV+tempP+tempPO); V[6] = tempV; insumtot += tempV;
if (insumtot < tempV) {++ovflow;}
168 tempPO = MULWU(tempP); tempP = modadd(tempP, V[7] ); tempV = MIXMAX_MOD_MERSENNE(tempV+tempP+tempPO); V[7] = tempV; insumtot += tempV;
if (insumtot < tempV) {++ovflow;}
169 tempPO = MULWU(tempP); tempP = modadd(tempP, V[8] ); tempV = MIXMAX_MOD_MERSENNE(tempV+tempP+tempPO); V[8] = tempV; insumtot += tempV;
if (insumtot < tempV) {++ovflow;}
170 tempPO = MULWU(tempP); tempP = modadd(tempP, V[9] ); tempV = MIXMAX_MOD_MERSENNE(tempV+tempP+tempPO); V[9] = tempV; insumtot += tempV;
if (insumtot < tempV) {++ovflow;}
171 tempPO = MULWU(tempP); tempP = modadd(tempP, V[10]); tempV = MIXMAX_MOD_MERSENNE(tempV+tempP+tempPO); V[10] = tempV; insumtot += tempV;
if (insumtot < tempV) {++ovflow;}
172 tempPO = MULWU(tempP); tempP = modadd(tempP, V[11]); tempV = MIXMAX_MOD_MERSENNE(tempV+tempP+tempPO); V[11] = tempV; insumtot += tempV;
if (insumtot < tempV) {++ovflow;}
173 tempPO = MULWU(tempP); tempP = modadd(tempP, V[12]); tempV = MIXMAX_MOD_MERSENNE(tempV+tempP+tempPO); V[12] = tempV; insumtot += tempV;
if (insumtot < tempV) {++ovflow;}
174 tempPO = MULWU(tempP); tempP = modadd(tempP, V[13]); tempV = MIXMAX_MOD_MERSENNE(tempV+tempP+tempPO); V[13] = tempV; insumtot += tempV;
if (insumtot < tempV) {++ovflow;}
175 tempPO = MULWU(tempP); tempP = modadd(tempP, V[14]); tempV = MIXMAX_MOD_MERSENNE(tempV+tempP+tempPO); V[14] = tempV; insumtot += tempV;
if (insumtot < tempV) {++ovflow;}
176 tempPO = MULWU(tempP); tempP = modadd(tempP, V[15]); tempV = MIXMAX_MOD_MERSENNE(tempV+tempP+tempPO); V[15] = tempV; insumtot += tempV;
if (insumtot < tempV) {++ovflow;}
177 tempPO = MULWU(tempP); tempP = modadd(tempP, V[16]); tempV = MIXMAX_MOD_MERSENNE(tempV+tempP+tempPO); V[16] = tempV; insumtot += tempV;
if (insumtot < tempV) {++ovflow;}
178 sumtot = MIXMAX_MOD_MERSENNE(MIXMAX_MOD_MERSENNE(insumtot) + (ovflow <<3 ));
186 return (( (k)<<(SPECIALMUL) & M61) ^ ( (k) >> (BITS-SPECIALMUL)) );
192 return MIXMAX_MOD_MERSENNE(xfoo+xbar);
195#if defined(__x86_64__)