Geant4-11
Public Member Functions | Static Public Member Functions | Static Public Attributes | Static Protected Member Functions | Protected Attributes | Private Attributes | Static Private Attributes
CLHEP::RanluxEngine Class Reference

#include <RanluxEngine.h>

Inheritance diagram for CLHEP::RanluxEngine:
CLHEP::HepRandomEngine

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)
 
int getLuxury () const
 
long getSeed () const
 
const long * getSeeds () const
 
bool getState (const std::vector< unsigned long > &v)
 
virtual std::istream & getState (std::istream &is)
 
std::string name () const
 
 operator double ()
 
 operator float ()
 
 operator unsigned int ()
 
bool operator!= (const HepRandomEngine &engine)
 
bool operator== (const HepRandomEngine &engine)
 
std::vector< unsigned long > put () const
 
virtual std::ostream & put (std::ostream &os) const
 
 RanluxEngine ()
 
 RanluxEngine (int rowIndex, int colIndex, int lxr)
 
 RanluxEngine (long seed, int lxr=3)
 
 RanluxEngine (std::istream &is)
 
void restoreStatus (const char filename[]="Ranlux.conf")
 
void saveStatus (const char filename[]="Ranlux.conf") const
 
void setSeed (long seed, int lxr=3)
 
void setSeeds (const long *seeds, int lxr=3)
 
void showStatus () const
 
virtual ~RanluxEngine ()
 

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 Public Attributes

static const unsigned int VECTOR_STATE_SIZE = 31
 

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 Attributes

float carry
 
int count24
 
float float_seed_table [24]
 
int i_lag
 
int j_lag
 
int luxury
 
int nskip
 

Static Private Attributes

static const int int_modulus = 0x1000000
 

Detailed Description

Author

Definition at line 44 of file RanluxEngine.h.

Constructor & Destructor Documentation

◆ RanluxEngine() [1/4]

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

Definition at line 122 of file RanluxEngine.cc.

124{
125 is >> *this;
126}

◆ RanluxEngine() [2/4]

CLHEP::RanluxEngine::RanluxEngine ( )

Definition at line 79 of file RanluxEngine.cc.

81{
82 long seed;
83 long seedlist[2]={0,0};
84
85 luxury = 3;
86 int numEngines = numberOfEngines++;
87 int cycle = std::abs(int(numEngines/maxIndex));
88 int curIndex = std::abs(int(numEngines%maxIndex));
89
90 long mask = ((cycle & 0x007fffff) << 8);
91 HepRandom::getTheTableSeeds( seedlist, curIndex );
92 seed = seedlist[0]^mask;
93 setSeed(seed, luxury);
94
95 // setSeeds() wants a zero terminated array!
96 seedlist[0]=theSeed;
97 seedlist[1]=0;
98 setSeeds(seedlist, luxury);
99}
static void getTheTableSeeds(long *seeds, int index)
Definition: Random.cc:254
void setSeeds(const long *seeds, int lxr=3)
void setSeed(long seed, int lxr=3)
CLHEP_ATOMIC_INT_TYPE numberOfEngines(0)

References geant4_check_module_cycles::cycle, CLHEP::HepRandom::getTheTableSeeds(), luxury, CLHEP::anonymous_namespace{RanluxEngine.cc}::maxIndex, CLHEP::anonymous_namespace{RanluxEngine.cc}::numberOfEngines(), setSeed(), setSeeds(), and CLHEP::HepRandomEngine::theSeed.

◆ RanluxEngine() [3/4]

CLHEP::RanluxEngine::RanluxEngine ( long  seed,
int  lxr = 3 
)

Definition at line 65 of file RanluxEngine.cc.

67{
68 long seedlist[2]={0,0};
69
70 luxury = lux;
71 setSeed(seed, luxury);
72
73 // setSeeds() wants a zero terminated array!
74 seedlist[0]=theSeed;
75 seedlist[1]=0;
76 setSeeds(seedlist, luxury);
77}
static constexpr double lux

References CLHEP::lux, luxury, setSeed(), setSeeds(), and CLHEP::HepRandomEngine::theSeed.

◆ RanluxEngine() [4/4]

CLHEP::RanluxEngine::RanluxEngine ( int  rowIndex,
int  colIndex,
int  lxr 
)

Definition at line 101 of file RanluxEngine.cc.

103{
104 long seed;
105 long seedlist[2]={0,0};
106
107 luxury = lux;
108 int cycle = std::abs(int(rowIndex/maxIndex));
109 int row = std::abs(int(rowIndex%maxIndex));
110 int col = std::abs(int(colIndex%2));
111 long mask = (( cycle & 0x000007ff ) << 20 );
112 HepRandom::getTheTableSeeds( seedlist, row );
113 seed = ( seedlist[col] )^mask;
114 setSeed(seed, luxury);
115
116 // setSeeds() wants a zero terminated array!
117 seedlist[0]=theSeed;
118 seedlist[1]=0;
119 setSeeds(seedlist, luxury);
120}

References geant4_check_module_cycles::cycle, CLHEP::HepRandom::getTheTableSeeds(), CLHEP::lux, luxury, CLHEP::anonymous_namespace{RanluxEngine.cc}::maxIndex, setSeed(), setSeeds(), and CLHEP::HepRandomEngine::theSeed.

◆ ~RanluxEngine()

CLHEP::RanluxEngine::~RanluxEngine ( )
virtual

Definition at line 128 of file RanluxEngine.cc.

128{}

Member Function Documentation

◆ beginTag()

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

Definition at line 477 of file RanluxEngine.cc.

477 {
478 return "RanluxEngine-begin";
479}

◆ 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(), restoreStatus(), CLHEP::Ranlux64Engine::restoreStatus(), and CLHEP::RanshiEngine::restoreStatus().

◆ engineName()

static std::string CLHEP::RanluxEngine::engineName ( )
inlinestatic

Definition at line 103 of file RanluxEngine.h.

103{return "RanluxEngine";}

Referenced by restoreStatus().

◆ exponent_bit_32()

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

◆ flat()

double CLHEP::RanluxEngine::flat ( )
virtual

Implements CLHEP::HepRandomEngine.

Definition at line 314 of file RanluxEngine.cc.

314 {
315
316 float next_random;
317 float uni;
318 int i;
319
321 if(uni < 0. ){
322 uni += 1.0;
324 }else{
325 carry = 0.;
326 }
327
328 float_seed_table[i_lag] = uni;
329 i_lag --;
330 j_lag --;
331 if(i_lag < 0) i_lag = 23;
332 if(j_lag < 0) j_lag = 23;
333
334 if( uni < mantissa_bit_12() ){
336 if( uni == 0) uni = mantissa_bit_24() * mantissa_bit_24();
337 }
338 next_random = uni;
339 count24 ++;
340
341// every 24th number generation, several random numbers are generated
342// and wasted depending upon the luxury level.
343
344 if(count24 == 24 ){
345 count24 = 0;
346 for( i = 0; i != nskip ; i++){
348 if(uni < 0. ){
349 uni += 1.0;
351 }else{
352 carry = 0.;
353 }
354 float_seed_table[i_lag] = uni;
355 i_lag --;
356 j_lag --;
357 if(i_lag < 0)i_lag = 23;
358 if(j_lag < 0) j_lag = 23;
359 }
360 }
361 return (double) next_random;
362}
static double mantissa_bit_12()
static double mantissa_bit_24()
float float_seed_table[24]
Definition: RanluxEngine.h:114

References carry, count24, float_seed_table, i_lag, j_lag, CLHEP::HepRandomEngine::mantissa_bit_12(), CLHEP::HepRandomEngine::mantissa_bit_24(), and nskip.

◆ flatArray()

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

Implements CLHEP::HepRandomEngine.

Definition at line 364 of file RanluxEngine.cc.

365{
366 float next_random;
367 float uni;
368 int i;
369 int index;
370
371 for (index=0; index<size; ++index) {
373 if(uni < 0. ){
374 uni += 1.0;
376 }else{
377 carry = 0.;
378 }
379
380 float_seed_table[i_lag] = uni;
381 i_lag --;
382 j_lag --;
383 if(i_lag < 0) i_lag = 23;
384 if(j_lag < 0) j_lag = 23;
385
386 if( uni < mantissa_bit_12() ){
388 if( uni == 0) uni = mantissa_bit_24() * mantissa_bit_24();
389 }
390 next_random = uni;
391 vect[index] = (double)next_random;
392 count24 ++;
393
394// every 24th number generation, several random numbers are generated
395// and wasted depending upon the luxury level.
396
397 if(count24 == 24 ){
398 count24 = 0;
399 for( i = 0; i != nskip ; i++){
401 if(uni < 0. ){
402 uni += 1.0;
404 }else{
405 carry = 0.;
406 }
407 float_seed_table[i_lag] = uni;
408 i_lag --;
409 j_lag --;
410 if(i_lag < 0)i_lag = 23;
411 if(j_lag < 0) j_lag = 23;
412 }
413 }
414 }
415}

References carry, count24, float_seed_table, i_lag, j_lag, CLHEP::HepRandomEngine::mantissa_bit_12(), CLHEP::HepRandomEngine::mantissa_bit_24(), and nskip.

◆ get() [1/2]

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

Reimplemented from CLHEP::HepRandomEngine.

Definition at line 522 of file RanluxEngine.cc.

522 {
523 if ((v[0] & 0xffffffffUL) != engineIDulong<RanluxEngine>()) {
524 std::cerr <<
525 "\nRanluxEngine get:state vector has wrong ID word - state unchanged\n";
526 return false;
527 }
528 return getState(v);
529}
virtual std::istream & getState(std::istream &is)

References getState().

◆ get() [2/2]

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

Reimplemented from CLHEP::HepRandomEngine.

Definition at line 459 of file RanluxEngine.cc.

460{
461 char beginMarker [MarkerLen];
462 is >> std::ws;
463 is.width(MarkerLen); // causes the next read to the char* to be <=
464 // that many bytes, INCLUDING A TERMINATION \0
465 // (Stroustrup, section 21.3.2)
466 is >> beginMarker;
467 if (strcmp(beginMarker,"RanluxEngine-begin")) {
468 is.clear(std::ios::badbit | is.rdstate());
469 std::cerr << "\nInput stream mispositioned or"
470 << "\nRanluxEngine state description missing or"
471 << "\nwrong engine type found." << std::endl;
472 return is;
473 }
474 return getState(is);
475}
static const int MarkerLen
Definition: DualRand.cc:70

References getState(), and CLHEP::MarkerLen.

◆ getLuxury()

int CLHEP::RanluxEngine::getLuxury ( ) const
inline

Definition at line 90 of file RanluxEngine.h.

90{ return luxury; }

References luxury.

Referenced by G4WorkerRunManager::G4WorkerRunManager(), and G4UserWorkerThreadInitialization::SetupRNGEngine().

◆ 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::RanluxEngine::getState ( const std::vector< unsigned long > &  v)
virtual

Reimplemented from CLHEP::HepRandomEngine.

Definition at line 531 of file RanluxEngine.cc.

531 {
532 if (v.size() != VECTOR_STATE_SIZE ) {
533 std::cerr <<
534 "\nRanluxEngine get:state vector has wrong length - state unchanged\n";
535 return false;
536 }
537 for (int i=0; i<24; ++i) {
538 float_seed_table[i] = v[i+1]*mantissa_bit_24();
539 }
540 i_lag = v[25];
541 j_lag = v[26];
542 carry = v[27]*mantissa_bit_24();
543 count24 = v[28];
544 luxury = v[29];
545 nskip = v[30];
546 return true;
547}
static const unsigned int VECTOR_STATE_SIZE
Definition: RanluxEngine.h:109

References carry, count24, float_seed_table, i_lag, j_lag, luxury, CLHEP::HepRandomEngine::mantissa_bit_24(), nskip, and VECTOR_STATE_SIZE.

◆ getState() [2/2]

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

Reimplemented from CLHEP::HepRandomEngine.

Definition at line 481 of file RanluxEngine.cc.

482{
483 if ( possibleKeywordInput ( is, "Uvec", theSeed ) ) {
484 std::vector<unsigned long> v;
485 unsigned long uu;
486 for (unsigned int ivec=0; ivec < VECTOR_STATE_SIZE; ++ivec) {
487 is >> uu;
488 if (!is) {
489 is.clear(std::ios::badbit | is.rdstate());
490 std::cerr << "\nRanluxEngine state (vector) description improper."
491 << "\ngetState() has failed."
492 << "\nInput stream is probably mispositioned now." << std::endl;
493 return is;
494 }
495 v.push_back(uu);
496 }
497 getState(v);
498 return (is);
499 }
500
501// is >> theSeed; Removed, encompassed by possibleKeywordInput()
502
503 char endMarker [MarkerLen];
504 for (int i=0; i<24; ++i) {
505 is >> float_seed_table[i];
506 }
507 is >> i_lag; is >> j_lag;
508 is >> carry; is >> count24;
509 is >> luxury; is >> nskip;
510 is >> std::ws;
511 is.width(MarkerLen);
512 is >> endMarker;
513 if (strcmp(endMarker,"RanluxEngine-end")) {
514 is.clear(std::ios::badbit | is.rdstate());
515 std::cerr << "\nRanluxEngine state description incomplete."
516 << "\nInput stream is probably mispositioned now." << std::endl;
517 return is;
518 }
519 return is;
520}
bool possibleKeywordInput(IS &is, const std::string &key, T &t)
Definition: RandomEngine.h:166

References carry, count24, float_seed_table, getState(), i_lag, j_lag, luxury, CLHEP::MarkerLen, nskip, CLHEP::possibleKeywordInput(), CLHEP::HepRandomEngine::theSeed, and VECTOR_STATE_SIZE.

Referenced by get(), getState(), and restoreStatus().

◆ mantissa_bit_12()

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

Referenced by flat(), and flatArray().

◆ mantissa_bit_24()

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

◆ mantissa_bit_32()

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

◆ name()

std::string CLHEP::RanluxEngine::name ( ) const
virtual

◆ 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::RanluxEngine::operator double ( )
virtual

Reimplemented from CLHEP::HepRandomEngine.

Definition at line 417 of file RanluxEngine.cc.

417 {
418 return flat();
419}

References G4AblaRandom::flat().

◆ operator float()

CLHEP::RanluxEngine::operator float ( )
virtual

Reimplemented from CLHEP::HepRandomEngine.

Definition at line 421 of file RanluxEngine.cc.

421 {
422 return float( flat() );
423}

References G4AblaRandom::flat().

◆ operator unsigned int()

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

Reimplemented from CLHEP::HepRandomEngine.

Definition at line 425 of file RanluxEngine.cc.

425 {
426 return ((unsigned int)(flat() * exponent_bit_32()) & 0xffffffff) |
427 (((unsigned int)(float_seed_table[i_lag]*exponent_bit_32())>>16) & 0xff);
428 // needed because Ranlux doesn't fill all bits of the double
429 // which therefore doesn't fill all bits of the integer.
430}
static double exponent_bit_32()

References G4AblaRandom::flat().

◆ operator!=()

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

◆ operator==()

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

◆ put() [1/2]

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

Reimplemented from CLHEP::HepRandomEngine.

Definition at line 443 of file RanluxEngine.cc.

443 {
444 std::vector<unsigned long> v;
445 v.push_back (engineIDulong<RanluxEngine>());
446 for (int i=0; i<24; ++i) {
447 v.push_back
448 (static_cast<unsigned long>(float_seed_table[i]/mantissa_bit_24()));
449 }
450 v.push_back(static_cast<unsigned long>(i_lag));
451 v.push_back(static_cast<unsigned long>(j_lag));
452 v.push_back(static_cast<unsigned long>(carry/mantissa_bit_24()));
453 v.push_back(static_cast<unsigned long>(count24));
454 v.push_back(static_cast<unsigned long>(luxury));
455 v.push_back(static_cast<unsigned long>(nskip));
456 return v;
457}

References carry, count24, float_seed_table, i_lag, j_lag, luxury, CLHEP::HepRandomEngine::mantissa_bit_24(), and nskip.

Referenced by put(), and saveStatus().

◆ put() [2/2]

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

Reimplemented from CLHEP::HepRandomEngine.

Definition at line 432 of file RanluxEngine.cc.

433{
434 char beginMarker[] = "RanluxEngine-begin";
435 os << beginMarker << "\nUvec\n";
436 std::vector<unsigned long> v = put();
437 for (unsigned int i=0; i<v.size(); ++i) {
438 os << v[i] << "\n";
439 }
440 return os;
441}
std::vector< unsigned long > put() const

References put().

◆ restoreStatus()

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

Implements CLHEP::HepRandomEngine.

Definition at line 264 of file RanluxEngine.cc.

265{
266 std::ifstream inFile( filename, std::ios::in);
267 if (!checkFile ( inFile, filename, engineName(), "restoreStatus" )) {
268 std::cerr << " -- Engine state remains unchanged\n";
269 return;
270 }
271 if ( possibleKeywordInput ( inFile, "Uvec", theSeed ) ) {
272 std::vector<unsigned long> v;
273 unsigned long xin;
274 for (unsigned int ivec=0; ivec < VECTOR_STATE_SIZE; ++ivec) {
275 inFile >> xin;
276 if (!inFile) {
277 inFile.clear(std::ios::badbit | inFile.rdstate());
278 std::cerr << "\nRanluxEngine state (vector) description improper."
279 << "\nrestoreStatus has failed."
280 << "\nInput stream is probably mispositioned now." << std::endl;
281 return;
282 }
283 v.push_back(xin);
284 }
285 getState(v);
286 return;
287 }
288
289 if (!inFile.bad() && !inFile.eof()) {
290// inFile >> theSeed; removed -- encompased by possibleKeywordInput
291 for (int i=0; i<24; ++i)
292 inFile >> float_seed_table[i];
293 inFile >> i_lag; inFile >> j_lag;
294 inFile >> carry; inFile >> count24;
295 inFile >> luxury; inFile >> nskip;
296 }
297}
static bool checkFile(std::istream &file, const std::string &filename, const std::string &classname, const std::string &methodname)
Definition: RandomEngine.cc:47
static std::string engineName()
Definition: RanluxEngine.h:103

References carry, CLHEP::HepRandomEngine::checkFile(), count24, engineName(), float_seed_table, getState(), i_lag, j_lag, luxury, nskip, CLHEP::possibleKeywordInput(), CLHEP::HepRandomEngine::theSeed, and VECTOR_STATE_SIZE.

◆ saveStatus()

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

Implements CLHEP::HepRandomEngine.

Definition at line 252 of file RanluxEngine.cc.

253{
254 std::ofstream outFile( filename, std::ios::out ) ;
255 if (!outFile.bad()) {
256 outFile << "Uvec\n";
257 std::vector<unsigned long> v = put();
258 for (unsigned int i=0; i<v.size(); ++i) {
259 outFile << v[i] << "\n";
260 }
261 }
262}

References put().

◆ setSeed()

void CLHEP::RanluxEngine::setSeed ( long  seed,
int  lxr = 3 
)
virtual

Implements CLHEP::HepRandomEngine.

Definition at line 130 of file RanluxEngine.cc.

130 {
131
132// The initialisation is carried out using a Multiplicative
133// Congruential generator using formula constants of L'Ecuyer
134// as described in "A review of pseudorandom number generators"
135// (Fred James) published in Computer Physics Communications 60 (1990)
136// pages 329-344
137
138 const int ecuyer_a = 53668;
139 const int ecuyer_b = 40014;
140 const int ecuyer_c = 12211;
141 const int ecuyer_d = 2147483563;
142
143 const int lux_levels[5] = {0,24,73,199,365};
144
145 long int_seed_table[24];
146 long next_seed = seed;
147 long k_multiple;
148 int i;
149
150// number of additional random numbers that need to be 'thrown away'
151// every 24 numbers is set using luxury level variable.
152
153 theSeed = seed;
154 if( (lux > 4)||(lux < 0) ){
155 if(lux >= 24){
156 nskip = lux - 24;
157 }else{
158 nskip = lux_levels[3]; // corresponds to default luxury level
159 }
160 }else{
161 luxury = lux;
162 nskip = lux_levels[luxury];
163 }
164
165
166 for(i = 0;i != 24;i++){
167 k_multiple = next_seed / ecuyer_a;
168 next_seed = ecuyer_b * (next_seed - k_multiple * ecuyer_a)
169 - k_multiple * ecuyer_c ;
170 if(next_seed < 0)next_seed += ecuyer_d;
171 int_seed_table[i] = next_seed % int_modulus;
172 }
173
174 for(i = 0;i != 24;i++)
175 float_seed_table[i] = int_seed_table[i] * mantissa_bit_24();
176
177 i_lag = 23;
178 j_lag = 9;
179 carry = 0. ;
180
181 if( float_seed_table[23] == 0. ) carry = mantissa_bit_24();
182
183 count24 = 0;
184}
static const int int_modulus
Definition: RanluxEngine.h:118

References carry, count24, float_seed_table, i_lag, int_modulus, j_lag, CLHEP::lux, luxury, CLHEP::HepRandomEngine::mantissa_bit_24(), nskip, and CLHEP::HepRandomEngine::theSeed.

Referenced by RanluxEngine(), and setSeeds().

◆ setSeeds()

void CLHEP::RanluxEngine::setSeeds ( const long *  seeds,
int  lxr = 3 
)
virtual

Implements CLHEP::HepRandomEngine.

Definition at line 186 of file RanluxEngine.cc.

186 {
187
188 const int ecuyer_a = 53668;
189 const int ecuyer_b = 40014;
190 const int ecuyer_c = 12211;
191 const int ecuyer_d = 2147483563;
192
193 const int lux_levels[5] = {0,24,73,199,365};
194 int i;
195 long int_seed_table[24];
196 long k_multiple,next_seed;
197 const long *seedptr;
198
199 theSeeds = seeds;
200 seedptr = seeds;
201
202 if(seeds == 0){
204 theSeeds = &theSeed;
205 return;
206 }
207
208 theSeed = *seeds;
209
210// number of additional random numbers that need to be 'thrown away'
211// every 24 numbers is set using luxury level variable.
212
213 if( (lux > 4)||(lux < 0) ){
214 if(lux >= 24){
215 nskip = lux - 24;
216 }else{
217 nskip = lux_levels[3]; // corresponds to default luxury level
218 }
219 }else{
220 luxury = lux;
221 nskip = lux_levels[luxury];
222 }
223
224 for( i = 0;(i != 24)&&(*seedptr != 0);i++){
225 int_seed_table[i] = *seedptr % int_modulus;
226 seedptr++;
227 }
228
229 if(i != 24){
230 next_seed = int_seed_table[i-1];
231 for(;i != 24;i++){
232 k_multiple = next_seed / ecuyer_a;
233 next_seed = ecuyer_b * (next_seed - k_multiple * ecuyer_a)
234 - k_multiple * ecuyer_c ;
235 if(next_seed < 0)next_seed += ecuyer_d;
236 int_seed_table[i] = next_seed % int_modulus;
237 }
238 }
239
240 for(i = 0;i != 24;i++)
241 float_seed_table[i] = int_seed_table[i] * mantissa_bit_24();
242
243 i_lag = 23;
244 j_lag = 9;
245 carry = 0. ;
246
247 if( float_seed_table[23] == 0. ) carry = mantissa_bit_24();
248
249 count24 = 0;
250}

References carry, count24, float_seed_table, i_lag, int_modulus, j_lag, CLHEP::lux, luxury, CLHEP::HepRandomEngine::mantissa_bit_24(), nskip, setSeed(), CLHEP::HepRandomEngine::theSeed, and CLHEP::HepRandomEngine::theSeeds.

Referenced by RanluxEngine().

◆ showStatus()

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

Implements CLHEP::HepRandomEngine.

Definition at line 299 of file RanluxEngine.cc.

300{
301 std::cout << std::endl;
302 std::cout << "--------- Ranlux engine status ---------" << std::endl;
303 std::cout << " Initial seed = " << theSeed << std::endl;
304 std::cout << " float_seed_table[] = ";
305 for (int i=0; i<24; ++i)
306 std::cout << float_seed_table[i] << " ";
307 std::cout << std::endl;
308 std::cout << " i_lag = " << i_lag << ", j_lag = " << j_lag << std::endl;
309 std::cout << " carry = " << carry << ", count24 = " << count24 << std::endl;
310 std::cout << " luxury = " << luxury << " nskip = " << nskip << std::endl;
311 std::cout << "----------------------------------------" << std::endl;
312}

References carry, count24, float_seed_table, i_lag, j_lag, luxury, nskip, and CLHEP::HepRandomEngine::theSeed.

◆ 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

◆ carry

float CLHEP::RanluxEngine::carry
private

Definition at line 116 of file RanluxEngine.h.

Referenced by flat(), flatArray(), getState(), put(), restoreStatus(), setSeed(), setSeeds(), and showStatus().

◆ count24

int CLHEP::RanluxEngine::count24
private

Definition at line 117 of file RanluxEngine.h.

Referenced by flat(), flatArray(), getState(), put(), restoreStatus(), setSeed(), setSeeds(), and showStatus().

◆ float_seed_table

float CLHEP::RanluxEngine::float_seed_table[24]
private

Definition at line 114 of file RanluxEngine.h.

Referenced by flat(), flatArray(), getState(), put(), restoreStatus(), setSeed(), setSeeds(), and showStatus().

◆ i_lag

int CLHEP::RanluxEngine::i_lag
private

Definition at line 115 of file RanluxEngine.h.

Referenced by flat(), flatArray(), getState(), put(), restoreStatus(), setSeed(), setSeeds(), and showStatus().

◆ int_modulus

const int CLHEP::RanluxEngine::int_modulus = 0x1000000
staticprivate

Definition at line 118 of file RanluxEngine.h.

Referenced by setSeed(), and setSeeds().

◆ j_lag

int CLHEP::RanluxEngine::j_lag
private

Definition at line 115 of file RanluxEngine.h.

Referenced by flat(), flatArray(), getState(), put(), restoreStatus(), setSeed(), setSeeds(), and showStatus().

◆ luxury

int CLHEP::RanluxEngine::luxury
private

◆ nskip

int CLHEP::RanluxEngine::nskip
private

Definition at line 113 of file RanluxEngine.h.

Referenced by flat(), flatArray(), getState(), put(), restoreStatus(), setSeed(), setSeeds(), and showStatus().

◆ 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(), CLHEP::MixMaxRng::getState(), CLHEP::MTwistEngine::getState(), CLHEP::RanecuEngine::getState(), CLHEP::Ranlux64Engine::getState(), getState(), CLHEP::RanshiEngine::getState(), CLHEP::HepJamesRandom::HepJamesRandom(), CLHEP::MixMaxRng::MixMaxRng(), CLHEP::RanecuEngine::put(), CLHEP::MixMaxRng::put(), CLHEP::MTwistEngine::put(), CLHEP::RanecuEngine::RanecuEngine(), RanluxEngine(), CLHEP::RanluxppEngine::RanluxppEngine(), CLHEP::RanshiEngine::RanshiEngine(), CLHEP::DualRand::restoreStatus(), CLHEP::HepJamesRandom::restoreStatus(), CLHEP::MTwistEngine::restoreStatus(), CLHEP::RanecuEngine::restoreStatus(), restoreStatus(), CLHEP::Ranlux64Engine::restoreStatus(), CLHEP::RanshiEngine::restoreStatus(), CLHEP::MTwistEngine::saveStatus(), CLHEP::RanecuEngine::setIndex(), CLHEP::RanecuEngine::setSeed(), CLHEP::HepJamesRandom::setSeed(), CLHEP::MixMaxRng::setSeed(), CLHEP::RanluxppEngine::setSeed(), CLHEP::Ranlux64Engine::setSeed(), setSeed(), CLHEP::DualRand::setSeed(), CLHEP::MTwistEngine::setSeed(), CLHEP::RanecuEngine::setSeeds(), CLHEP::Ranlux64Engine::setSeeds(), setSeeds(), CLHEP::MixMaxRng::setSeeds(), CLHEP::RanshiEngine::setSeeds(), CLHEP::DualRand::showStatus(), CLHEP::HepJamesRandom::showStatus(), CLHEP::MTwistEngine::showStatus(), CLHEP::RanecuEngine::showStatus(), CLHEP::Ranlux64Engine::showStatus(), showStatus(), and CLHEP::RanshiEngine::showStatus().

◆ theSeeds

const long* CLHEP::HepRandomEngine::theSeeds
protectedinherited

◆ VECTOR_STATE_SIZE

const unsigned int CLHEP::RanluxEngine::VECTOR_STATE_SIZE = 31
static

Definition at line 109 of file RanluxEngine.h.

Referenced by getState(), and restoreStatus().


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