Geant4-11
Public Member Functions | Private Attributes
CLHEP::DualRand::IntegerCong Class Reference

Public Member Functions

void get (std::istream &is)
 
bool get (std::vector< unsigned long >::const_iterator &iv)
 
 IntegerCong ()
 
 IntegerCong (unsigned int seed, int streamNumber)
 
 operator unsigned int ()
 
void put (std::ostream &os) const
 
void put (std::vector< unsigned long > &v) const
 

Private Attributes

unsigned int addend
 
unsigned int multiplier
 
unsigned int state
 

Detailed Description

Definition at line 122 of file DualRand.h.

Constructor & Destructor Documentation

◆ IntegerCong() [1/2]

CLHEP::DualRand::IntegerCong::IntegerCong ( )

Definition at line 446 of file DualRand.cc.

447: state((unsigned int)3758656018U),
448 multiplier(66565),
449 addend(12341)
450{
451}

◆ IntegerCong() [2/2]

CLHEP::DualRand::IntegerCong::IntegerCong ( unsigned int  seed,
int  streamNumber 
)

Definition at line 453 of file DualRand.cc.

454: state(seed),
455 multiplier(65536 + 1024 + 5 + (8 * 1017 * streamNumber)),
456 addend(12341)
457{
458 // As to the multiplier, the following comment was made:
459 // We want our multipliers larger than 2^16, and equal to
460 // 1 mod 4 (for max. period), but not equal to 1 mod 8
461 // (for max. potency -- the smaller and higher dimension the
462 // stripes, the better)
463
464 // All of these will have fairly long periods. Depending on the choice
465 // of stream number, some of these will be quite decent when considered
466 // as independent random engines, while others will be poor. Thus these
467 // should not be used as stand-alone engines; but when combined with a
468 // generator known to be good, they allow creation of millions of good
469 // independent streams, without fear of two streams accidentally hitting
470 // nearby places in the good random sequence.
471}

Member Function Documentation

◆ get() [1/2]

void CLHEP::DualRand::IntegerCong::get ( std::istream &  is)

Definition at line 495 of file DualRand.cc.

495 {
496 char beginMarker [MarkerLen];
497 char endMarker [MarkerLen];
498
499 is >> std::ws;
500 is.width(MarkerLen); // causes the next read to the char* to be <=
501 // that many bytes, INCLUDING A TERMINATION \0
502 // (Stroustrup, section 21.3.2)
503 is >> beginMarker;
504 if (strcmp(beginMarker,"IntegerCong-begin")) {
505 is.clear(std::ios::badbit | is.rdstate());
506 std::cerr << "\nInput mispositioned or"
507 << "\nIntegerCong state description missing or"
508 << "\nwrong engine type found." << std::endl;
509 }
510 is >> state >> multiplier >> addend;
511 is >> std::ws;
512 is.width(MarkerLen);
513 is >> endMarker;
514 if (strcmp(endMarker,"IntegerCong-end")) {
515 is.clear(std::ios::badbit | is.rdstate());
516 std::cerr << "\nIntegerCong state description incomplete."
517 << "\nInput stream is probably mispositioned now." << std::endl;
518 }
519}
static const int MarkerLen
Definition: DualRand.cc:70

References CLHEP::MarkerLen.

Referenced by CLHEP::DualRand::getState(), and CLHEP::DualRand::restoreStatus().

◆ get() [2/2]

bool CLHEP::DualRand::IntegerCong::get ( std::vector< unsigned long >::const_iterator &  iv)

Definition at line 522 of file DualRand.cc.

522 {
523 state = *iv++;
524 multiplier = *iv++;
525 addend = *iv++;
526 return true;
527}

◆ operator unsigned int()

CLHEP::DualRand::IntegerCong::operator unsigned int ( )

Definition at line 473 of file DualRand.cc.

473 {
474 return state = (state * multiplier + addend) & 0xffffffff;
475}

◆ put() [1/2]

void CLHEP::DualRand::IntegerCong::put ( std::ostream &  os) const

Definition at line 477 of file DualRand.cc.

477 {
478 char beginMarker[] = "IntegerCong-begin";
479 char endMarker[] = "IntegerCong-end";
480
481 int pr=os.precision(20);
482 os << " " << beginMarker << " ";
483 os << state << " " << multiplier << " " << addend;
484 os << " " << endMarker << " ";
485 os << std::endl;
486 os.precision(pr);
487}

Referenced by CLHEP::DualRand::put(), and CLHEP::DualRand::showStatus().

◆ put() [2/2]

void CLHEP::DualRand::IntegerCong::put ( std::vector< unsigned long > &  v) const

Definition at line 489 of file DualRand.cc.

489 {
490 v.push_back(static_cast<unsigned long>(state));
491 v.push_back(static_cast<unsigned long>(multiplier));
492 v.push_back(static_cast<unsigned long>(addend));
493}

Field Documentation

◆ addend

unsigned int CLHEP::DualRand::IntegerCong::addend
private

Definition at line 132 of file DualRand.h.

◆ multiplier

unsigned int CLHEP::DualRand::IntegerCong::multiplier
private

Definition at line 132 of file DualRand.h.

◆ state

unsigned int CLHEP::DualRand::IntegerCong::state
private

Definition at line 132 of file DualRand.h.


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