Geant4-11
Data Structures | Public Member Functions | Static Public Member Functions | Static Protected Member Functions | Protected Attributes | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes
CLHEP::MixMaxRng Class Reference

#include <MixMaxRng.h>

Inheritance diagram for CLHEP::MixMaxRng:
CLHEP::HepRandomEngine

Data Structures

struct  rng_state_st
 

Public Member Functions

double flat ()
 
void flatArray (const int size, double *vect)
 
bool get (const std::vector< unsigned long > &v)
 
virtual std::istream & get (std::istream &is)
 
long getSeed () const
 
const long * getSeeds () const
 
bool getState (const std::vector< unsigned long > &v)
 
virtual std::istream & getState (std::istream &is)
 
 MixMaxRng ()
 
 MixMaxRng (const MixMaxRng &rng)
 
 MixMaxRng (long seed)
 
 MixMaxRng (std::istream &is)
 
std::string name () const
 
 operator double ()
 
 operator float ()
 
 operator unsigned int ()
 
bool operator!= (const HepRandomEngine &engine)
 
MixMaxRngoperator= (const MixMaxRng &rng)
 
bool operator== (const HepRandomEngine &engine)
 
std::vector< unsigned long > put () const
 
virtual std::ostream & put (std::ostream &os) const
 
void restoreStatus (const char filename[]="MixMaxRngState.conf")
 
void saveStatus (const char filename[]="MixMaxRngState.conf") const
 
void setSeed (long seed, int dum=0)
 
void setSeeds (const long *seeds, int seedNum=0)
 
void showStatus () const
 
 ~MixMaxRng ()
 

Static Public Member Functions

static std::string beginTag ()
 
static std::string engineName ()
 
static HepRandomEnginenewEngine (const std::vector< unsigned long > &v)
 
static HepRandomEnginenewEngine (std::istream &is)
 

Static Protected Member Functions

static bool checkFile (std::istream &file, const std::string &filename, const std::string &classname, const std::string &methodname)
 
static double exponent_bit_32 ()
 
static double mantissa_bit_12 ()
 
static double mantissa_bit_24 ()
 
static double mantissa_bit_32 ()
 
static double nearlyTwoToMinus_54 ()
 
static double twoToMinus_32 ()
 
static double twoToMinus_48 ()
 
static double twoToMinus_49 ()
 
static double twoToMinus_53 ()
 

Protected Attributes

long theSeed
 
const long * theSeeds
 

Private Types

typedef struct rng_state_st rng_state_t
 

Private Member Functions

myuint_t apply_bigskip (myuint_t *Vout, myuint_t *Vin, myID_t clusterID, myID_t machineID, myID_t runID, myID_t streamID)
 
MixMaxRng Branch ()
 
void BranchInplace (int id)
 
double convert1double (myuint_t u)
 
myuint_t fmodmulM61 (myuint_t cum, myuint_t s, myuint_t a)
 
double generate (int i)
 
myuint_t get_next ()
 
double get_next_float ()
 
double get_next_float_packbits ()
 
double iterate ()
 
myuint_t iterate_raw_vec (myuint_t *Y, myuint_t sumtotOld)
 
 MixMaxRng (myID_t clusterID, myID_t machineID, myID_t runID, myID_t streamID)
 
myuint_t MOD_MULSPEC (myuint_t k)
 
myuint_t modadd (myuint_t foo, myuint_t bar)
 
myuint_t MULWU (myuint_t k)
 
myuint_t precalc ()
 
void print_state () const
 
void seed64 (myuint_t seedval)
 
void seed_spbox (myuint_t)
 
void seed_uniquestream (myID_t clusterID, myID_t machineID, myID_t runID, myID_t streamID)
 
void seed_vielbein (unsigned int i)
 

Static Private Member Functions

static constexpr int rng_get_N ()
 
static constexpr long long int rng_get_SPECIAL ()
 
static constexpr int rng_get_SPECIALMUL ()
 

Private Attributes

rng_state_t S
 

Static Private Attributes

static constexpr int BITS =61
 
static constexpr double INV_M61 =0.43368086899420177360298E-18
 
static constexpr myuint_t M61 =2305843009213693951ULL
 
static const int N = 17
 
static constexpr long long int SPECIAL = ((N==17)? 0 : ((N==240)? 487013230256099140ULL:0) )
 
static constexpr long long int SPECIALMUL = ((N==17)? 36: ((N==240)? 51 :53) )
 
static constexpr unsigned int VECTOR_STATE_SIZE = 2*N+4
 

Detailed Description

Definition at line 49 of file MixMaxRng.h.

Member Typedef Documentation

◆ rng_state_t

Definition at line 182 of file MixMaxRng.h.

Constructor & Destructor Documentation

◆ MixMaxRng() [1/5]

CLHEP::MixMaxRng::MixMaxRng ( std::istream &  is)

Definition at line 69 of file MixMaxRng.cc.

71{
72 get(is);
73}
virtual std::istream & get(std::istream &is)
Definition: MixMaxRng.cc:384

References get().

◆ MixMaxRng() [2/5]

CLHEP::MixMaxRng::MixMaxRng ( )

Definition at line 55 of file MixMaxRng.cc.

57{
58 int numEngines = ++numberOfEngines;
59 setSeed(static_cast<long>(numEngines));
60}
void setSeed(long seed, int dum=0)
Definition: MixMaxRng.cc:214
CLHEP_ATOMIC_INT_TYPE numberOfEngines(0)

References CLHEP::anonymous_namespace{MixMaxRng.cc}::numberOfEngines(), and setSeed().

◆ MixMaxRng() [3/5]

CLHEP::MixMaxRng::MixMaxRng ( long  seed)

Definition at line 62 of file MixMaxRng.cc.

64{
65 theSeed=seed;
66 setSeed(seed);
67}

References setSeed(), and CLHEP::HepRandomEngine::theSeed.

◆ ~MixMaxRng()

CLHEP::MixMaxRng::~MixMaxRng ( )

Definition at line 75 of file MixMaxRng.cc.

76{
77}

◆ MixMaxRng() [4/5]

CLHEP::MixMaxRng::MixMaxRng ( const MixMaxRng rng)

Definition at line 79 of file MixMaxRng.cc.

80 : HepRandomEngine(rng)
81{
82 S.V = rng.S.V;
83 S.sumtot= rng.S.sumtot;
84 S.counter= rng.S.counter;
85}
rng_state_t S
Definition: MixMaxRng.h:183
std::array< myuint_t, N > V
Definition: MixMaxRng.h:177

References CLHEP::MixMaxRng::rng_state_st::counter, S, CLHEP::MixMaxRng::rng_state_st::sumtot, and CLHEP::MixMaxRng::rng_state_st::V.

◆ MixMaxRng() [5/5]

CLHEP::MixMaxRng::MixMaxRng ( myID_t  clusterID,
myID_t  machineID,
myID_t  runID,
myID_t  streamID 
)
private

Member Function Documentation

◆ apply_bigskip()

myuint_t CLHEP::MixMaxRng::apply_bigskip ( myuint_t Vout,
myuint_t Vin,
myID_t  clusterID,
myID_t  machineID,
myID_t  runID,
myID_t  streamID 
)
private

Definition at line 599 of file MixMaxRng.cc.

600{
601 /*
602 makes a derived state vector, Vout, from the mother state vector Vin
603 by skipping a large number of steps, determined by the given seeding ID's
604
605 it is mathematically guaranteed that the substreams derived in this way from the SAME (!!!) Vin will not collide provided
606 1) at least one bit of ID is different
607 2) less than 10^100 numbers are drawn from the stream
608 (this is good enough : a single CPU will not exceed this in the lifetime of the universe, 10^19 sec,
609 even if it had a clock cycle of Planch time, 10^44 Hz )
610
611 Caution: never apply this to a derived vector, just choose some mother vector Vin, for example the unit vector by seed_vielbein(X,0),
612 and use it in all your runs, just change runID to get completely nonoverlapping streams of random numbers on a different day.
613
614 clusterID and machineID are provided for the benefit of large organizations who wish to ensure that a simulation
615 which is running in parallel on a large number of clusters and machines will have non-colliding source of random numbers.
616
617 did i repeat it enough times? the non-collision guarantee is absolute, not probabilistic
618
619 */
620
621 const myuint_t skipMat17[128][17] =
623 ;
624
625 const myuint_t* skipMat[128];
626 for (int i=0; i<128; i++) { skipMat[i] = skipMat17[i];}
627
628 myID_t IDvec[4] = {streamID, runID, machineID, clusterID};
629 int r,i,j, IDindex;
630 myID_t id;
631 myuint_t Y[N], cum[N];
632 myuint_t coeff;
633 myuint_t* rowPtr;
634 myuint_t sumtot=0;
635
636 for (i=0; i<N; i++) { Y[i] = Vin[i]; sumtot = modadd( sumtot, Vin[i]); } ;
637 for (IDindex=0; IDindex<4; IDindex++)
638 { // go from lower order to higher order ID
639 id=IDvec[IDindex];
640 //printf("now doing ID at level %d, with ID = %d\n", IDindex, id);
641 r = 0;
642 while (id)
643 {
644 if (id & 1)
645 {
646 rowPtr = (myuint_t*)skipMat[r + IDindex*8*sizeof(myID_t)];
647 for (i=0; i<N; i++){ cum[i] = 0; }
648 for (j=0; j<N; j++)
649 { // j is lag, enumerates terms of the poly
650 // for zero lag Y is already given
651 coeff = rowPtr[j]; // same coeff for all i
652 for (i =0; i<N; i++){
653 cum[i] = fmodmulM61( cum[i], coeff , Y[i] ) ;
654 }
655 sumtot = iterate_raw_vec(Y, sumtot);
656 }
657 sumtot=0;
658 for (i=0; i<N; i++){ Y[i] = cum[i]; sumtot = modadd( sumtot, cum[i]); } ;
659 }
660 id = (id >> 1); r++; // bring up the r-th bit in the ID
661 }
662 }
663 sumtot=0;
664 for (i=0; i<N; i++){ Vout[i] = Y[i]; sumtot = modadd( sumtot, Y[i]); }
665 // returns sumtot, and copy the vector over to Vout
666 return (sumtot) ;
667}
G4double Y(G4double density)
myuint_t iterate_raw_vec(myuint_t *Y, myuint_t sumtotOld)
Definition: MixMaxRng.cc:497
myuint_t fmodmulM61(myuint_t cum, myuint_t s, myuint_t a)
Definition: MixMaxRng.cc:683
myuint_t modadd(myuint_t foo, myuint_t bar)
Definition: MixMaxRng.cc:699
static const int N
Definition: MixMaxRng.h:51
std::uint32_t myID_t
Definition: MixMaxRng.h:46
unsigned long long int myuint_t
Definition: MixMaxRng.h:47

References fmodmulM61(), iterate_raw_vec(), modadd(), N, and Y().

Referenced by seed_uniquestream().

◆ beginTag()

std::string CLHEP::MixMaxRng::beginTag ( )
static

Definition at line 402 of file MixMaxRng.cc.

403{
404 return "MixMaxRng-begin";
405}

◆ Branch()

MixMaxRng CLHEP::MixMaxRng::Branch ( )
private

Definition at line 731 of file MixMaxRng.cc.

732{
733 S.sumtot = iterate_raw_vec(S.V.data(), S.sumtot); S.counter = 1;
734 MixMaxRng tmp=*this;
735 tmp.BranchInplace(0); // daughter id
736 return tmp;
737}

References BranchInplace(), CLHEP::MixMaxRng::rng_state_st::counter, iterate_raw_vec(), S, CLHEP::MixMaxRng::rng_state_st::sumtot, and CLHEP::MixMaxRng::rng_state_st::V.

◆ BranchInplace()

void CLHEP::MixMaxRng::BranchInplace ( int  id)
private

Definition at line 739 of file MixMaxRng.cc.

740{
741 // Dont forget to iterate the mother, when branching the daughter, or else will have collisions!
742 // a 64-bit LCG from Knuth line 26, is used to mangle a vector component
743 constexpr myuint_t MULT64=6364136223846793005ULL;
744 myuint_t tmp=S.V[id];
745 S.V[1] *= MULT64; S.V[id] &= M61;
746 S.sumtot = MIXMAX_MOD_MERSENNE( S.sumtot + S.V[id] - tmp + M61);
747 S.sumtot = iterate_raw_vec(S.V.data(), S.sumtot);// printf("iterating!\n");
748 S.counter = 1;
749}
#define MIXMAX_MOD_MERSENNE(k)
Definition: MixMaxRng.h:121
static constexpr myuint_t M61
Definition: MixMaxRng.h:117

References CLHEP::MixMaxRng::rng_state_st::counter, iterate_raw_vec(), M61, MIXMAX_MOD_MERSENNE, S, CLHEP::MixMaxRng::rng_state_st::sumtot, and CLHEP::MixMaxRng::rng_state_st::V.

Referenced by Branch().

◆ checkFile()

bool CLHEP::HepRandomEngine::checkFile ( std::istream &  file,
const std::string &  filename,
const std::string &  classname,
const std::string &  methodname 
)
staticprotectedinherited

Definition at line 47 of file RandomEngine.cc.

50 {
51 if (!file) {
52 std::cerr << "Failure to find or open file " << filename <<
53 " in " << classname << "::" << methodname << "()\n";
54 return false;
55 }
56 return true;
57}

References geant4_check_module_cycles::file.

Referenced by CLHEP::DualRand::restoreStatus(), CLHEP::HepJamesRandom::restoreStatus(), CLHEP::MTwistEngine::restoreStatus(), CLHEP::RanecuEngine::restoreStatus(), CLHEP::RanluxEngine::restoreStatus(), CLHEP::Ranlux64Engine::restoreStatus(), and CLHEP::RanshiEngine::restoreStatus().

◆ convert1double()

double CLHEP::MixMaxRng::convert1double ( myuint_t  u)
inlineprivate

Definition at line 149 of file MixMaxRng.h.

150 {
151 const double one = 1;
152 const myuint_t onemask = *(myuint_t*)&one;
153 myuint_t tmp = (u>>9) | onemask; // bits between 52 and 62 dont affect the result!
154 double d = *(double*)&tmp;
155 return d-1.0;
156 }

Referenced by generate(), and get_next_float_packbits().

◆ engineName()

std::string CLHEP::MixMaxRng::engineName ( )
static

Definition at line 252 of file MixMaxRng.cc.

253{
254 return "MixMaxRng";
255}

◆ exponent_bit_32()

static double CLHEP::HepRandomEngine::exponent_bit_32 ( )
inlinestaticprotectedinherited

◆ flat()

double CLHEP::MixMaxRng::flat ( )
inlinevirtual

Implements CLHEP::HepRandomEngine.

Definition at line 65 of file MixMaxRng.h.

65{ return (S.counter<=(N-1)) ? generate(S.counter):iterate(); }
double generate(int i)
Definition: MixMaxRng.cc:272
double iterate()
Definition: MixMaxRng.cc:296

References CLHEP::MixMaxRng::rng_state_st::counter, generate(), iterate(), N, and S.

Referenced by flatArray().

◆ flatArray()

void CLHEP::MixMaxRng::flatArray ( const int  size,
double *  vect 
)
virtual

Implements CLHEP::HepRandomEngine.

Definition at line 326 of file MixMaxRng.cc.

327{
328 // fill_array( S, size, arrayDbl );
329 for (int i=0; i<size; ++i) { vect[i] = flat(); }
330}
double flat()
Definition: MixMaxRng.h:65

References flat().

◆ fmodmulM61()

myuint_t CLHEP::MixMaxRng::fmodmulM61 ( myuint_t  cum,
myuint_t  s,
myuint_t  a 
)
private

Definition at line 683 of file MixMaxRng.cc.

684 {
685 const myuint_t MASK32=0xFFFFFFFFULL;
686 myuint_t o,ph,pl,ah,al;
687 o=(s)*a;
688 ph = ((s)>>32);
689 pl = (s) & MASK32;
690 ah = a>>32;
691 al = a & MASK32;
692 o = (o & M61) + ((ph*ah)<<3) + ((ah*pl+al*ph + ((al*pl)>>32))>>29) ;
693 o += cum;
694 o = (o & M61) + ((o>>61));
695 return o;
696 }
const unsigned long MASK32
Definition: MixMaxRng.cc:44
static constexpr double s
const G4double al
Mysterious coefficient that appears in the wavefunctions.

References G4INCL::DeuteronDensity::anonymous_namespace{G4INCLDeuteronDensity.cc}::al, M61, MASK32, and CLHEP::s.

Referenced by apply_bigskip(), and MOD_MULSPEC().

◆ generate()

double CLHEP::MixMaxRng::generate ( int  i)
private

Definition at line 272 of file MixMaxRng.cc.

273{
274 S.counter++;
275#if defined(__clang__) || defined(__llvm__)
276 return INV_M61*static_cast<double>(S.V[i]);
277#elif defined(__GNUC__) && (__GNUC__ < 7) && (!defined(__ICC)) && defined(__x86_64__) && defined(__SSE2_MATH__)
278 int64_t Z=S.V[i];
279 double F=0.0;
280 //#warning Using the inline assembler
281 /* using SSE inline assemly to zero the xmm register, just before int64 -> double conversion,
282 not necessary in GCC-5 or better, but huge penalty on earlier compilers
283 */
284 __asm__ __volatile__( "pxor %0, %0;"
285 "cvtsi2sdq %1, %0;"
286 :"=x"(F)
287 :"r"(Z)
288 );
289 return F*INV_M61;
290#else
291 //#warning other method
292 return convert1double(S.V[i]); //get_next_float_packbits();
293#endif
294}
const G4int Z[17]
static constexpr double INV_M61
Definition: MixMaxRng.h:118
double convert1double(myuint_t u)
Definition: MixMaxRng.h:149

References convert1double(), CLHEP::MixMaxRng::rng_state_st::counter, INV_M61, S, CLHEP::MixMaxRng::rng_state_st::V, and Z.

Referenced by flat().

◆ get() [1/2]

bool CLHEP::MixMaxRng::get ( const std::vector< unsigned long > &  v)
virtual

Reimplemented from CLHEP::HepRandomEngine.

Definition at line 440 of file MixMaxRng.cc.

441{
442 if ((v[0] & 0xffffffffUL) != engineIDulong<MixMaxRng>()) {
443 std::cerr <<
444 "\nMixMaxRng::get(): vector has wrong ID word - state unchanged\n";
445 return false;
446 }
447 return getState(v);
448}
virtual std::istream & getState(std::istream &is)
Definition: MixMaxRng.cc:407

References getState().

◆ get() [2/2]

std::istream & CLHEP::MixMaxRng::get ( std::istream &  is)
virtual

Reimplemented from CLHEP::HepRandomEngine.

Definition at line 384 of file MixMaxRng.cc.

385{
386 char beginMarker [MarkerLen];
387 is >> std::ws;
388 is.width(MarkerLen); // causes the next read to the char* to be <=
389 // that many bytes, INCLUDING A TERMINATION \0
390 // (Stroustrup, section 21.3.2)
391 is >> beginMarker;
392 if (strcmp(beginMarker,"MixMaxRng-begin")) {
393 is.clear(std::ios::badbit | is.rdstate());
394 std::cerr << "\nInput stream mispositioned or"
395 << "\nMixMaxRng state description missing or"
396 << "\nwrong engine type found." << std::endl;
397 return is;
398 }
399 return getState(is);
400}
static const int MarkerLen
Definition: DualRand.cc:70

References getState(), and CLHEP::MarkerLen.

Referenced by MixMaxRng().

◆ get_next()

myuint_t CLHEP::MixMaxRng::get_next ( )
private

Definition at line 517 of file MixMaxRng.cc.

518{
519 int i;
520 i=S.counter;
521
522 if ((i<=(N-1)) )
523 {
524 S.counter++;
525 return S.V[i];
526 }
527 else
528 {
529 S.sumtot = iterate_raw_vec(S.V.data(), S.sumtot);
530 S.counter=2;
531 return S.V[1];
532 }
533}

References CLHEP::MixMaxRng::rng_state_st::counter, iterate_raw_vec(), N, S, CLHEP::MixMaxRng::rng_state_st::sumtot, and CLHEP::MixMaxRng::rng_state_st::V.

Referenced by get_next_float_packbits().

◆ get_next_float()

double CLHEP::MixMaxRng::get_next_float ( )
inlineprivate

Definition at line 131 of file MixMaxRng.h.

131{ return get_next_float_packbits(); }
double get_next_float_packbits()
Definition: MixMaxRng.cc:547

References get_next_float_packbits().

◆ get_next_float_packbits()

double CLHEP::MixMaxRng::get_next_float_packbits ( )
private

Definition at line 547 of file MixMaxRng.cc.

548{
550 return convert1double(Z);
551}
myuint_t get_next()
Definition: MixMaxRng.cc:517

References convert1double(), get_next(), and Z.

Referenced by get_next_float().

◆ getSeed()

long CLHEP::HepRandomEngine::getSeed ( ) const
inlineinherited

Definition at line 112 of file RandomEngine.h.

112{ return theSeed; }

References CLHEP::HepRandomEngine::theSeed.

◆ getSeeds()

const long * CLHEP::HepRandomEngine::getSeeds ( ) const
inlineinherited

Definition at line 115 of file RandomEngine.h.

115{ return theSeeds; }

References CLHEP::HepRandomEngine::theSeeds.

◆ getState() [1/2]

bool CLHEP::MixMaxRng::getState ( const std::vector< unsigned long > &  v)
virtual

Reimplemented from CLHEP::HepRandomEngine.

Definition at line 450 of file MixMaxRng.cc.

451{
452 if (v.size() != VECTOR_STATE_SIZE ) {
453 std::cerr <<
454 "\nMixMaxRng::getState(): vector has wrong length - state unchanged\n";
455 return false;
456 }
457 for (int i=1; i<2*rng_get_N() ; i=i+2) {
458 S.V[i/2]= ( (v[i] & MASK32) | ( (myuint_t)(v[i+1]) << 32 ) );
459 // unpack from a data structure which is 32-bit on some platforms
460 }
461 S.counter = v[2*rng_get_N()+1];
462 precalc();
463 if ( ( (v[2*rng_get_N()+2] & MASK32)
464 | ( (myuint_t)(v[2*rng_get_N()+3]) << 32 ) ) != S.sumtot) {
465 std::cerr << "\nMixMaxRng::getState(): vector has wrong checksum!"
466 << "\nInput vector is probably mispositioned now.\n";
467 return false;
468 }
469 return true;
470}
myuint_t precalc()
Definition: MixMaxRng.cc:535
static constexpr int rng_get_N()
Definition: MixMaxRng.cc:257
static constexpr unsigned int VECTOR_STATE_SIZE
Definition: MixMaxRng.h:119

References CLHEP::MixMaxRng::rng_state_st::counter, MASK32, precalc(), rng_get_N(), S, CLHEP::MixMaxRng::rng_state_st::sumtot, CLHEP::MixMaxRng::rng_state_st::V, and VECTOR_STATE_SIZE.

◆ getState() [2/2]

std::istream & CLHEP::MixMaxRng::getState ( std::istream &  is)
virtual

Reimplemented from CLHEP::HepRandomEngine.

Definition at line 407 of file MixMaxRng.cc.

408{
409 char endMarker[MarkerLen];
410 is >> theSeed;
411 for (int i=0; i<rng_get_N(); ++i) is >> S.V[i];
412 is >> S.counter;
413 myuint_t checksum;
414 is >> checksum;
415 is >> std::ws;
416 is.width(MarkerLen);
417 is >> endMarker;
418 if (strcmp(endMarker,"MixMaxRng-end")) {
419 is.clear(std::ios::badbit | is.rdstate());
420 std::cerr << "\nMixMaxRng state description incomplete."
421 << "\nInput stream is probably mispositioned now.\n";
422 return is;
423 }
424 if ( S.counter < 0 || S.counter > rng_get_N() ) {
425 std::cerr << "\nMixMaxRng::getState(): "
426 << "vector read wrong value of counter from file!"
427 << "\nInput stream is probably mispositioned now.\n";
428 return is;
429 }
430 precalc();
431 if ( checksum != S.sumtot) {
432 std::cerr << "\nMixMaxRng::getState(): "
433 << "checksum disagrees with value stored in file!"
434 << "\nInput stream is probably mispositioned now.\n";
435 return is;
436 }
437 return is;
438}

References CLHEP::MixMaxRng::rng_state_st::counter, CLHEP::MarkerLen, precalc(), rng_get_N(), S, CLHEP::MixMaxRng::rng_state_st::sumtot, CLHEP::HepRandomEngine::theSeed, and CLHEP::MixMaxRng::rng_state_st::V.

Referenced by get().

◆ iterate()

double CLHEP::MixMaxRng::iterate ( )
private

Definition at line 296 of file MixMaxRng.cc.

297{
298 myuint_t* Y=S.V.data();
299 myuint_t tempP, tempV;
300 Y[0] = ( tempV = S.sumtot);
301 myuint_t sumtot = Y[0], ovflow = 0; // will keep a running sum of all new elements
302 tempP = 0; // will keep a partial sum of all old elements
303 myuint_t tempPO;
304 tempPO = MULWU(tempP); tempP = modadd(tempP, Y[1] ); tempV = MIXMAX_MOD_MERSENNE(tempV+tempP+tempPO); Y[1] = tempV; sumtot += tempV; if (sumtot < tempV) {ovflow++;};
305 tempPO = MULWU(tempP); tempP = modadd(tempP, Y[2] ); tempV = MIXMAX_MOD_MERSENNE(tempV+tempP+tempPO); Y[2] = tempV; sumtot += tempV; if (sumtot < tempV) {ovflow++;};
306 tempPO = MULWU(tempP); tempP = modadd(tempP, Y[3] ); tempV = MIXMAX_MOD_MERSENNE(tempV+tempP+tempPO); Y[3] = tempV; sumtot += tempV; if (sumtot < tempV) {ovflow++;};
307 tempPO = MULWU(tempP); tempP = modadd(tempP, Y[4] ); tempV = MIXMAX_MOD_MERSENNE(tempV+tempP+tempPO); Y[4] = tempV; sumtot += tempV; if (sumtot < tempV) {ovflow++;};
308 tempPO = MULWU(tempP); tempP = modadd(tempP, Y[5] ); tempV = MIXMAX_MOD_MERSENNE(tempV+tempP+tempPO); Y[5] = tempV; sumtot += tempV; if (sumtot < tempV) {ovflow++;};
309 tempPO = MULWU(tempP); tempP = modadd(tempP, Y[6] ); tempV = MIXMAX_MOD_MERSENNE(tempV+tempP+tempPO); Y[6] = tempV; sumtot += tempV; if (sumtot < tempV) {ovflow++;};
310 tempPO = MULWU(tempP); tempP = modadd(tempP, Y[7] ); tempV = MIXMAX_MOD_MERSENNE(tempV+tempP+tempPO); Y[7] = tempV; sumtot += tempV; if (sumtot < tempV) {ovflow++;};
311 tempPO = MULWU(tempP); tempP = modadd(tempP, Y[8] ); tempV = MIXMAX_MOD_MERSENNE(tempV+tempP+tempPO); Y[8] = tempV; sumtot += tempV; if (sumtot < tempV) {ovflow++;};
312 tempPO = MULWU(tempP); tempP = modadd(tempP, Y[9] ); tempV = MIXMAX_MOD_MERSENNE(tempV+tempP+tempPO); Y[9] = tempV; sumtot += tempV; if (sumtot < tempV) {ovflow++;};
313 tempPO = MULWU(tempP); tempP = modadd(tempP, Y[10]); tempV = MIXMAX_MOD_MERSENNE(tempV+tempP+tempPO); Y[10] = tempV; sumtot += tempV; if (sumtot < tempV) {ovflow++;};
314 tempPO = MULWU(tempP); tempP = modadd(tempP, Y[11]); tempV = MIXMAX_MOD_MERSENNE(tempV+tempP+tempPO); Y[11] = tempV; sumtot += tempV; if (sumtot < tempV) {ovflow++;};
315 tempPO = MULWU(tempP); tempP = modadd(tempP, Y[12]); tempV = MIXMAX_MOD_MERSENNE(tempV+tempP+tempPO); Y[12] = tempV; sumtot += tempV; if (sumtot < tempV) {ovflow++;};
316 tempPO = MULWU(tempP); tempP = modadd(tempP, Y[13]); tempV = MIXMAX_MOD_MERSENNE(tempV+tempP+tempPO); Y[13] = tempV; sumtot += tempV; if (sumtot < tempV) {ovflow++;};
317 tempPO = MULWU(tempP); tempP = modadd(tempP, Y[14]); tempV = MIXMAX_MOD_MERSENNE(tempV+tempP+tempPO); Y[14] = tempV; sumtot += tempV; if (sumtot < tempV) {ovflow++;};
318 tempPO = MULWU(tempP); tempP = modadd(tempP, Y[15]); tempV = MIXMAX_MOD_MERSENNE(tempV+tempP+tempPO); Y[15] = tempV; sumtot += tempV; if (sumtot < tempV) {ovflow++;};
319 tempPO = MULWU(tempP); tempP = modadd(tempP, Y[16]); tempV = MIXMAX_MOD_MERSENNE(tempV+tempP+tempPO); Y[16] = tempV; sumtot += tempV; if (sumtot < tempV) {ovflow++;};
320 S.sumtot = MIXMAX_MOD_MERSENNE(MIXMAX_MOD_MERSENNE(sumtot) + (ovflow <<3 ));
321
322 S.counter=2;
323 return double(S.V[1])*INV_M61;
324}
myuint_t MULWU(myuint_t k)
Definition: MixMaxRng.cc:492

References CLHEP::MixMaxRng::rng_state_st::counter, INV_M61, MIXMAX_MOD_MERSENNE, modadd(), MULWU(), S, CLHEP::MixMaxRng::rng_state_st::sumtot, CLHEP::MixMaxRng::rng_state_st::V, and Y().

Referenced by flat().

◆ iterate_raw_vec()

myuint_t CLHEP::MixMaxRng::iterate_raw_vec ( myuint_t Y,
myuint_t  sumtotOld 
)
private

Definition at line 497 of file MixMaxRng.cc.

498{
499 // operates with a raw vector, uses known sum of elements of Y
500 int i;
501
502 myuint_t tempP, tempV;
503 Y[0] = ( tempV = sumtotOld);
504 myuint_t sumtot = Y[0], ovflow = 0; // will keep a running sum of all new elements
505 tempP = 0; // will keep a partial sum of all old elements
506 for (i=1; (i<N); i++)
507 {
508 myuint_t tempPO = MULWU(tempP);
509 tempP = modadd(tempP, Y[i]);
510 tempV = MIXMAX_MOD_MERSENNE(tempV+tempP+tempPO); // new Y[i] = old Y[i] + old partial * m
511 Y[i] = tempV;
512 sumtot += tempV; if (sumtot < tempV) {ovflow++;}
513 }
514 return MIXMAX_MOD_MERSENNE(MIXMAX_MOD_MERSENNE(sumtot) + (ovflow <<3 ));
515}

References MIXMAX_MOD_MERSENNE, modadd(), MULWU(), N, and Y().

Referenced by apply_bigskip(), Branch(), BranchInplace(), and get_next().

◆ mantissa_bit_12()

static double CLHEP::HepRandomEngine::mantissa_bit_12 ( )
inlinestaticprotectedinherited

◆ mantissa_bit_24()

static double CLHEP::HepRandomEngine::mantissa_bit_24 ( )
inlinestaticprotectedinherited

◆ mantissa_bit_32()

static double CLHEP::HepRandomEngine::mantissa_bit_32 ( )
inlinestaticprotectedinherited

◆ MOD_MULSPEC()

myuint_t CLHEP::MixMaxRng::MOD_MULSPEC ( myuint_t  k)
private

Definition at line 472 of file MixMaxRng.cc.

473{
474 switch (N)
475 {
476 case 17:
477 return 0;
478 break;
479 case 8:
480 return 0;
481 break;
482 case 240:
483 return fmodmulM61( 0, SPECIAL , (k) );
484 break;
485 default:
486 std::cerr << "MIXMAX ERROR: " << "Disallowed value of parameter N\n";
487 std::terminate();
488 break;
489 }
490}
static constexpr long long int SPECIAL
Definition: MixMaxRng.h:113

References fmodmulM61(), N, and SPECIAL.

◆ modadd()

myuint_t CLHEP::MixMaxRng::modadd ( myuint_t  foo,
myuint_t  bar 
)
private

Definition at line 699 of file MixMaxRng.cc.

700{
701#if defined(__x86_64__) && defined(__GNUC__) && (!defined(__ICC))
702 //#warning Using assembler routine in modadd
703 myuint_t out;
704 /* Assembler trick suggested by Andrzej Görlich */
705 __asm__ ("addq %2, %0; "
706 "btrq $61, %0; "
707 "adcq $0, %0; "
708 :"=r"(out)
709 :"0"(foo), "r"(bar)
710 );
711 return out;
712#else
713 return MIXMAX_MOD_MERSENNE(foo+bar);
714#endif
715}
static constexpr double bar

References CLHEP::bar, and MIXMAX_MOD_MERSENNE.

Referenced by apply_bigskip(), iterate(), and iterate_raw_vec().

◆ MULWU()

myuint_t CLHEP::MixMaxRng::MULWU ( myuint_t  k)
private

Definition at line 492 of file MixMaxRng.cc.

493{
494 return (( (k)<<(SPECIALMUL) & M61) ^ ( (k) >> (BITS-SPECIALMUL)) );
495}
static constexpr int BITS
Definition: MixMaxRng.h:116
static constexpr long long int SPECIALMUL
Definition: MixMaxRng.h:114

References BITS, M61, and SPECIALMUL.

Referenced by iterate(), and iterate_raw_vec().

◆ name()

std::string CLHEP::MixMaxRng::name ( ) const
inlinevirtual

Implements CLHEP::HepRandomEngine.

Definition at line 104 of file MixMaxRng.h.

104{ return "MixMaxRng"; }

Referenced by source.g4viscp.G4Scene::create_scene(), mcscore.MCParticle::printout(), and source.g4viscp.G4Scene::update_scene().

◆ nearlyTwoToMinus_54()

static double CLHEP::HepRandomEngine::nearlyTwoToMinus_54 ( )
inlinestaticprotectedinherited

◆ newEngine() [1/2]

HepRandomEngine * CLHEP::HepRandomEngine::newEngine ( const std::vector< unsigned long > &  v)
staticinherited

Definition at line 96 of file RandomEngine.cc.

96 {
98}
static HepRandomEngine * newEngine(std::istream &is)

References CLHEP::EngineFactory::newEngine().

◆ newEngine() [2/2]

HepRandomEngine * CLHEP::HepRandomEngine::newEngine ( std::istream &  is)
staticinherited

Definition at line 91 of file RandomEngine.cc.

91 {
92 return EngineFactory::newEngine(is);
93}

References CLHEP::EngineFactory::newEngine().

Referenced by CLHEP::StaticRandomStates::restore().

◆ operator double()

CLHEP::MixMaxRng::operator double ( )
virtual

Reimplemented from CLHEP::HepRandomEngine.

Definition at line 332 of file MixMaxRng.cc.

333{
334 return flat();
335}

References G4AblaRandom::flat().

◆ operator float()

CLHEP::MixMaxRng::operator float ( )
virtual

Reimplemented from CLHEP::HepRandomEngine.

Definition at line 337 of file MixMaxRng.cc.

338{
339 return float( flat() );
340}

References G4AblaRandom::flat().

◆ operator unsigned int()

CLHEP::MixMaxRng::operator unsigned int ( )
virtual

Reimplemented from CLHEP::HepRandomEngine.

Definition at line 342 of file MixMaxRng.cc.

343{
344 return static_cast<unsigned int>(get_next());
345 // clhep_get_next returns a 64-bit integer, of which the lower 61 bits
346 // are random and upper 3 bits are zero
347}

◆ operator!=()

bool CLHEP::HepRandomEngine::operator!= ( const HepRandomEngine engine)
inlineinherited

◆ operator=()

MixMaxRng & CLHEP::MixMaxRng::operator= ( const MixMaxRng rng)

Definition at line 87 of file MixMaxRng.cc.

88{
89 // Check assignment to self
90 //
91 if (this == &rng) { return *this; }
92
93 // Copy base class data
94 //
95 HepRandomEngine::operator=(rng);
96
97 S.V = rng.S.V;
98 S.sumtot= rng.S.sumtot;
99 S.counter= rng.S.counter;
100
101 return *this;
102}

References CLHEP::MixMaxRng::rng_state_st::counter, S, CLHEP::MixMaxRng::rng_state_st::sumtot, and CLHEP::MixMaxRng::rng_state_st::V.

◆ operator==()

bool CLHEP::HepRandomEngine::operator== ( const HepRandomEngine engine)
inlineinherited

◆ precalc()

myuint_t CLHEP::MixMaxRng::precalc ( )
private

Definition at line 535 of file MixMaxRng.cc.

536{
537 int i;
538 myuint_t temp;
539 temp = 0;
540 for (i=0; i < N; i++){
541 temp = MIXMAX_MOD_MERSENNE(temp + S.V[i]);
542 }
543 S.sumtot = temp;
544 return temp;
545}

References MIXMAX_MOD_MERSENNE, N, S, CLHEP::MixMaxRng::rng_state_st::sumtot, and CLHEP::MixMaxRng::rng_state_st::V.

Referenced by getState(), and restoreStatus().

◆ print_state()

void CLHEP::MixMaxRng::print_state ( ) const
private

Definition at line 717 of file MixMaxRng.cc.

718{
719 int j;
720 std::cout << "mixmax state, file version 1.0\n";
721 std::cout << "N=" << rng_get_N() << "; V[N]={";
722 for (j=0; (j< (rng_get_N()-1) ); j++) {
723 std::cout << S.V[j] << ", ";
724 }
725 std::cout << S.V[rng_get_N()-1];
726 std::cout << "}; ";
727 std::cout << "counter= " << S.counter;
728 std::cout << "sumtot= " << S.sumtot << "\n";
729}

References CLHEP::MixMaxRng::rng_state_st::counter, rng_get_N(), S, CLHEP::MixMaxRng::rng_state_st::sumtot, and CLHEP::MixMaxRng::rng_state_st::V.

Referenced by restoreStatus(), and showStatus().

◆ put() [1/2]

std::vector< unsigned long > CLHEP::MixMaxRng::put ( ) const
virtual

Reimplemented from CLHEP::HepRandomEngine.

Definition at line 367 of file MixMaxRng.cc.

368{
369 std::vector<unsigned long> v;
370 v.push_back (engineIDulong<MixMaxRng>());
371 for (int i=0; i<rng_get_N(); ++i)
372 {
373 v.push_back(static_cast<unsigned long>(S.V[i] & MASK32));
374 // little-ended order on all platforms
375 v.push_back(static_cast<unsigned long>(S.V[i] >> 32 ));
376 // pack uint64 into a data structure which is 32-bit on some platforms
377 }
378 v.push_back(static_cast<unsigned long>(S.counter));
379 v.push_back(static_cast<unsigned long>(S.sumtot & MASK32));
380 v.push_back(static_cast<unsigned long>(S.sumtot >> 32));
381 return v;
382}

References CLHEP::MixMaxRng::rng_state_st::counter, MASK32, rng_get_N(), S, CLHEP::MixMaxRng::rng_state_st::sumtot, and CLHEP::MixMaxRng::rng_state_st::V.

◆ put() [2/2]

std::ostream & CLHEP::MixMaxRng::put ( std::ostream &  os) const
virtual

Reimplemented from CLHEP::HepRandomEngine.

Definition at line 349 of file MixMaxRng.cc.

350{
351 char beginMarker[] = "MixMaxRng-begin";
352 char endMarker[] = "MixMaxRng-end";
353
354 int pr = os.precision(24);
355 os << beginMarker << " ";
356 os << theSeed << "\n";
357 for (int i=0; i<rng_get_N(); ++i) {
358 os << S.V[i] << "\n";
359 }
360 os << S.counter << "\n";
361 os << S.sumtot << "\n";
362 os << endMarker << "\n";
363 os.precision(pr);
364 return os;
365}

References CLHEP::MixMaxRng::rng_state_st::counter, rng_get_N(), S, CLHEP::MixMaxRng::rng_state_st::sumtot, CLHEP::HepRandomEngine::theSeed, and CLHEP::MixMaxRng::rng_state_st::V.

◆ restoreStatus()

void CLHEP::MixMaxRng::restoreStatus ( const char  filename[] = "MixMaxRngState.conf")
virtual

Implements CLHEP::HepRandomEngine.

Definition at line 124 of file MixMaxRng.cc.

125{
126 // a function for reading the state from a file
127 FILE* fin;
128 if( ( fin = fopen(filename, "r") ) )
129 {
130 char l=0;
131 while ( l != '{' ) { // 0x7B = "{"
132 l=fgetc(fin); // proceed until hitting opening bracket
133 }
134 ungetc(' ', fin);
135 }
136 else
137 {
138 fprintf(stderr, "mixmax -> read_state: error reading file %s\n", filename);
139 throw std::runtime_error("Error in reading state file");
140 }
141
142 myuint_t vecVal;
143 //printf("mixmax -> read_state: starting to read state from file\n");
144 if (!fscanf(fin, "%llu", &S.V[0]) )
145 {
146 fprintf(stderr, "mixmax -> read_state: error reading file %s\n", filename);
147 throw std::runtime_error("Error in reading state file");
148 }
149
150 int i;
151 for( i = 1; i < rng_get_N(); i++)
152 {
153 if (!fscanf(fin, ", %llu", &vecVal) )
154 {
155 fprintf(stderr, "mixmax -> read_state: error reading vector component i=%d from file %s\n", i, filename);
156 throw std::runtime_error("Error in reading state file");
157 }
158 if( vecVal <= MixMaxRng::M61 )
159 {
160 S.V[i] = vecVal;
161 }
162 else
163 {
164 fprintf(stderr, "mixmax -> read_state: Invalid state vector value= %llu"
165 " ( must be less than %llu ) "
166 " obtained from reading file %s\n"
167 , vecVal, MixMaxRng::M61, filename);
168 }
169 }
170
171 int counter;
172 if (!fscanf( fin, "}; counter=%i; ", &counter))
173 {
174 fprintf(stderr, "mixmax -> read_state: error reading counter from file %s\n", filename);
175 throw std::runtime_error("Error in reading state file");
176 }
177 if( counter <= rng_get_N() )
178 {
179 S.counter= counter;
180 }
181 else
182 {
183 fprintf(stderr, "mixmax -> read_state: Invalid counter = %d"
184 " Must be 0 <= counter < %u\n" , counter, rng_get_N());
185 print_state();
186 throw std::runtime_error("Error in reading state counter");
187 }
188 precalc();
189 myuint_t sumtot;
190 if (!fscanf( fin, "sumtot=%llu\n", &sumtot))
191 {
192 fprintf(stderr, "mixmax -> read_state: error reading checksum from file %s\n", filename);
193 throw std::runtime_error("Error in reading state file");
194 }
195
196 if (S.sumtot != sumtot)
197 {
198 fprintf(stderr, "mixmax -> checksum error while reading state from file %s - corrupted?\n", filename);
199 throw std::runtime_error("Error in reading state checksum");
200 }
201 fclose(fin);
202}
void print_state() const
Definition: MixMaxRng.cc:717

References CLHEP::MixMaxRng::rng_state_st::counter, M61, precalc(), print_state(), rng_get_N(), S, CLHEP::MixMaxRng::rng_state_st::sumtot, and CLHEP::MixMaxRng::rng_state_st::V.

◆ rng_get_N()

constexpr int CLHEP::MixMaxRng::rng_get_N ( )
staticconstexprprivate

Definition at line 257 of file MixMaxRng.cc.

258{
259 return N;
260}

References N.

Referenced by getState(), print_state(), put(), restoreStatus(), and saveStatus().

◆ rng_get_SPECIAL()

constexpr long long int CLHEP::MixMaxRng::rng_get_SPECIAL ( )
staticconstexprprivate

Definition at line 262 of file MixMaxRng.cc.

263{
264 return SPECIAL;
265}

References SPECIAL.

◆ rng_get_SPECIALMUL()

constexpr int CLHEP::MixMaxRng::rng_get_SPECIALMUL ( )
staticconstexprprivate

Definition at line 267 of file MixMaxRng.cc.

268{
269 return SPECIALMUL;
270}

References SPECIALMUL.

◆ saveStatus()

void CLHEP::MixMaxRng::saveStatus ( const char  filename[] = "MixMaxRngState.conf") const
virtual

Implements CLHEP::HepRandomEngine.

Definition at line 104 of file MixMaxRng.cc.

105{
106 // Create a C file-handle or an object that can accept the same output
107 FILE *fh= fopen(filename, "w");
108 if( fh )
109 {
110 int j;
111 fprintf(fh, "mixmax state, file version 1.0\n" );
112 fprintf(fh, "N=%u; V[N]={", rng_get_N() );
113 for (j=0; (j< (rng_get_N()-1) ); j++) {
114 fprintf(fh, "%llu, ", S.V[j] );
115 }
116 fprintf(fh, "%llu", S.V[rng_get_N()-1] );
117 fprintf(fh, "}; " );
118 fprintf(fh, "counter=%u; ", S.counter );
119 fprintf(fh, "sumtot=%llu;\n", S.sumtot );
120 fclose(fh);
121 }
122}

References CLHEP::MixMaxRng::rng_state_st::counter, rng_get_N(), S, CLHEP::MixMaxRng::rng_state_st::sumtot, and CLHEP::MixMaxRng::rng_state_st::V.

◆ seed64()

void CLHEP::MixMaxRng::seed64 ( myuint_t  seedval)
inlineprivate

Definition at line 138 of file MixMaxRng.h.

138{ seed_uniquestream( 0, 0, (myID_t)(seedval>>32), (myID_t)seedval ); } // seed with one 64-bit seed
void seed_uniquestream(myID_t clusterID, myID_t machineID, myID_t runID, myID_t streamID)
Definition: MixMaxRng.cc:592

References seed_uniquestream().

◆ seed_spbox()

void CLHEP::MixMaxRng::seed_spbox ( myuint_t  seed)
private

Definition at line 571 of file MixMaxRng.cc.

572{
573 // a 64-bit LCG from Knuth line 26, in combination with a bit swap is used to seed
574
575 const myuint_t MULT64=6364136223846793005ULL;
576 int i;
577
578 myuint_t sumtot=0,ovflow=0;
579 if (seed == 0) throw std::runtime_error("try seeding with nonzero seed next time");
580
581 myuint_t l = seed;
582
583 for (i=0; i < N; i++){
584 l*=MULT64; l = (l << 32) ^ (l>>32);
585 S.V[i] = l & M61;
586 sumtot += S.V[(i)]; if (sumtot < S.V[(i)]) {ovflow++;}
587 }
588 S.counter = N; // set the counter to N if iteration should happen right away
589 S.sumtot = MIXMAX_MOD_MERSENNE(MIXMAX_MOD_MERSENNE(sumtot) + (ovflow <<3 ));
590}

References CLHEP::MixMaxRng::rng_state_st::counter, M61, MIXMAX_MOD_MERSENNE, N, S, CLHEP::MixMaxRng::rng_state_st::sumtot, and CLHEP::MixMaxRng::rng_state_st::V.

Referenced by setSeed().

◆ seed_uniquestream()

void CLHEP::MixMaxRng::seed_uniquestream ( myID_t  clusterID,
myID_t  machineID,
myID_t  runID,
myID_t  streamID 
)
private

Definition at line 592 of file MixMaxRng.cc.

593{
594 seed_vielbein(0);
595 S.sumtot = apply_bigskip(S.V.data(), S.V.data(), clusterID, machineID, runID, streamID );
596 S.counter = 1;
597}
myuint_t apply_bigskip(myuint_t *Vout, myuint_t *Vin, myID_t clusterID, myID_t machineID, myID_t runID, myID_t streamID)
Definition: MixMaxRng.cc:599
void seed_vielbein(unsigned int i)
Definition: MixMaxRng.cc:553

References apply_bigskip(), CLHEP::MixMaxRng::rng_state_st::counter, S, seed_vielbein(), CLHEP::MixMaxRng::rng_state_st::sumtot, and CLHEP::MixMaxRng::rng_state_st::V.

Referenced by seed64(), and setSeeds().

◆ seed_vielbein()

void CLHEP::MixMaxRng::seed_vielbein ( unsigned int  i)
private

Definition at line 553 of file MixMaxRng.cc.

554{
555 int i;
556 if (index<N)
557 {
558 for (i=0; i < N; i++){
559 S.V[i] = 0;
560 }
561 S.V[index] = 1;
562 }
563 else
564 {
565 std::terminate();
566 }
567 S.counter = N; // set the counter to N if iteration should happen right away
568 S.sumtot = 1;
569}

References CLHEP::MixMaxRng::rng_state_st::counter, N, S, CLHEP::MixMaxRng::rng_state_st::sumtot, and CLHEP::MixMaxRng::rng_state_st::V.

Referenced by seed_uniquestream().

◆ setSeed()

void CLHEP::MixMaxRng::setSeed ( long  seed,
int  dum = 0 
)
virtual

Implements CLHEP::HepRandomEngine.

Definition at line 214 of file MixMaxRng.cc.

215{
216 //seed_uniquestream(0,0,0,longSeed);
217 theSeed = longSeed;
218 seed_spbox(longSeed);
219}
void seed_spbox(myuint_t)
Definition: MixMaxRng.cc:571

References seed_spbox(), and CLHEP::HepRandomEngine::theSeed.

Referenced by MixMaxRng().

◆ setSeeds()

void CLHEP::MixMaxRng::setSeeds ( const long *  seeds,
int  seedNum = 0 
)
virtual

Implements CLHEP::HepRandomEngine.

Definition at line 225 of file MixMaxRng.cc.

226{
227 myID_t seed0, seed1= 0, seed2= 0, seed3= 0;
228
229 if( seedNum < 1 ) { // Assuming at least 2 seeds in vector...
230 seed0= static_cast<myID_t>(Seeds[0]) & MASK32;
231 seed1= static_cast<myID_t>(Seeds[1]) & MASK32;
232 }
233 else
234 {
235 if( seedNum < 4 ) {
236 seed0= static_cast<myID_t>(Seeds[0]) & MASK32;
237 if( seedNum > 1){ seed1= static_cast<myID_t>(Seeds[1]) & MASK32; }
238 if( seedNum > 2){ seed2= static_cast<myID_t>(Seeds[2]) & MASK32; }
239 }
240 if( seedNum >= 4 ) {
241 seed0= static_cast<myID_t>(Seeds[0]) & MASK32;
242 seed1= static_cast<myID_t>(Seeds[1]) & MASK32;
243 seed2= static_cast<myID_t>(Seeds[2]) & MASK32;
244 seed3= static_cast<myID_t>(Seeds[3]) & MASK32;
245 }
246 }
247 theSeed = Seeds[0];
248 theSeeds = Seeds;
249 seed_uniquestream(seed3, seed2, seed1, seed0);
250}

References MASK32, seed_uniquestream(), CLHEP::HepRandomEngine::theSeed, and CLHEP::HepRandomEngine::theSeeds.

◆ showStatus()

void CLHEP::MixMaxRng::showStatus ( ) const
virtual

Implements CLHEP::HepRandomEngine.

Definition at line 204 of file MixMaxRng.cc.

205{
206 std::cout << std::endl;
207 std::cout << "------- MixMaxRng engine status -------" << std::endl;
208
209 std::cout << " Current state vector is:" << std::endl;
210 print_state();
211 std::cout << "---------------------------------------" << std::endl;
212}

References print_state().

◆ twoToMinus_32()

static double CLHEP::HepRandomEngine::twoToMinus_32 ( )
inlinestaticprotectedinherited

◆ twoToMinus_48()

static double CLHEP::HepRandomEngine::twoToMinus_48 ( )
inlinestaticprotectedinherited

◆ twoToMinus_49()

static double CLHEP::HepRandomEngine::twoToMinus_49 ( )
inlinestaticprotectedinherited

◆ twoToMinus_53()

static double CLHEP::HepRandomEngine::twoToMinus_53 ( )
inlinestaticprotectedinherited

Field Documentation

◆ BITS

constexpr int CLHEP::MixMaxRng::BITS =61
staticconstexprprivate

Definition at line 116 of file MixMaxRng.h.

Referenced by MULWU().

◆ INV_M61

constexpr double CLHEP::MixMaxRng::INV_M61 =0.43368086899420177360298E-18
staticconstexprprivate

Definition at line 118 of file MixMaxRng.h.

Referenced by generate(), and iterate().

◆ M61

constexpr myuint_t CLHEP::MixMaxRng::M61 =2305843009213693951ULL
staticconstexprprivate

Definition at line 117 of file MixMaxRng.h.

Referenced by BranchInplace(), fmodmulM61(), MULWU(), restoreStatus(), and seed_spbox().

◆ N

const int CLHEP::MixMaxRng::N = 17
staticprivate

◆ S

rng_state_t CLHEP::MixMaxRng::S
private

◆ SPECIAL

constexpr long long int CLHEP::MixMaxRng::SPECIAL = ((N==17)? 0 : ((N==240)? 487013230256099140ULL:0) )
staticconstexprprivate

Definition at line 113 of file MixMaxRng.h.

Referenced by MOD_MULSPEC(), and rng_get_SPECIAL().

◆ SPECIALMUL

constexpr long long int CLHEP::MixMaxRng::SPECIALMUL = ((N==17)? 36: ((N==240)? 51 :53) )
staticconstexprprivate

Definition at line 114 of file MixMaxRng.h.

Referenced by MULWU(), and rng_get_SPECIALMUL().

◆ theSeed

long CLHEP::HepRandomEngine::theSeed
protectedinherited

Definition at line 142 of file RandomEngine.h.

Referenced by CLHEP::DualRand::DualRand(), CLHEP::HepRandomEngine::getSeed(), CLHEP::DualRand::getState(), CLHEP::HepJamesRandom::getState(), getState(), CLHEP::MTwistEngine::getState(), CLHEP::RanecuEngine::getState(), CLHEP::Ranlux64Engine::getState(), CLHEP::RanluxEngine::getState(), CLHEP::RanshiEngine::getState(), CLHEP::HepJamesRandom::HepJamesRandom(), MixMaxRng(), CLHEP::RanecuEngine::put(), put(), CLHEP::MTwistEngine::put(), CLHEP::RanecuEngine::RanecuEngine(), CLHEP::RanluxEngine::RanluxEngine(), CLHEP::RanluxppEngine::RanluxppEngine(), CLHEP::RanshiEngine::RanshiEngine(), CLHEP::DualRand::restoreStatus(), CLHEP::HepJamesRandom::restoreStatus(), CLHEP::MTwistEngine::restoreStatus(), CLHEP::RanecuEngine::restoreStatus(), CLHEP::RanluxEngine::restoreStatus(), CLHEP::Ranlux64Engine::restoreStatus(), CLHEP::RanshiEngine::restoreStatus(), CLHEP::MTwistEngine::saveStatus(), CLHEP::RanecuEngine::setIndex(), CLHEP::RanecuEngine::setSeed(), CLHEP::HepJamesRandom::setSeed(), setSeed(), CLHEP::RanluxppEngine::setSeed(), CLHEP::Ranlux64Engine::setSeed(), CLHEP::RanluxEngine::setSeed(), CLHEP::DualRand::setSeed(), CLHEP::MTwistEngine::setSeed(), CLHEP::RanecuEngine::setSeeds(), CLHEP::Ranlux64Engine::setSeeds(), CLHEP::RanluxEngine::setSeeds(), setSeeds(), CLHEP::RanshiEngine::setSeeds(), CLHEP::DualRand::showStatus(), CLHEP::HepJamesRandom::showStatus(), CLHEP::MTwistEngine::showStatus(), CLHEP::RanecuEngine::showStatus(), CLHEP::Ranlux64Engine::showStatus(), CLHEP::RanluxEngine::showStatus(), and CLHEP::RanshiEngine::showStatus().

◆ theSeeds

const long* CLHEP::HepRandomEngine::theSeeds
protectedinherited

◆ VECTOR_STATE_SIZE

constexpr unsigned int CLHEP::MixMaxRng::VECTOR_STATE_SIZE = 2*N+4
staticconstexprprivate

Definition at line 119 of file MixMaxRng.h.

Referenced by getState().


The documentation for this class was generated from the following files: