#include <Ranlux64Engine.h>
- Author
Definition at line 49 of file Ranlux64Engine.h.
◆ Ranlux64Engine() [1/4]
CLHEP::Ranlux64Engine::Ranlux64Engine |
( |
std::istream & |
is | ) |
|
◆ Ranlux64Engine() [2/4]
CLHEP::Ranlux64Engine::Ranlux64Engine |
( |
| ) |
|
Definition at line 105 of file Ranlux64Engine.cc.
109 int numEngines = numberOfEngines++;
110 int cycle = std::abs(
int(numEngines/maxIndex));
111 int curIndex = std::abs(
int(numEngines%maxIndex));
113 long mask = ((cycle & 0x007fffff) << 8);
void setSeeds(const long *seeds, int lux=1)
static void getTheTableSeeds(long *seeds, int index)
◆ Ranlux64Engine() [3/4]
CLHEP::Ranlux64Engine::Ranlux64Engine |
( |
long |
seed, |
|
|
int |
lux = 1 |
|
) |
| |
Definition at line 125 of file Ranlux64Engine.cc.
129 long seedlist[2]={seed,0};
void setSeeds(const long *seeds, int lux=1)
◆ Ranlux64Engine() [4/4]
CLHEP::Ranlux64Engine::Ranlux64Engine |
( |
int |
rowIndex, |
|
|
int |
colIndex, |
|
|
int |
lux |
|
) |
| |
Definition at line 135 of file Ranlux64Engine.cc.
139 int cycle = std::abs(
int(rowIndex/maxIndex));
140 int row = std::abs(
int(rowIndex%maxIndex));
141 long mask = (( cycle & 0x000007ff ) << 20 );
void setSeeds(const long *seeds, int lux=1)
static void getTheTableSeeds(long *seeds, int index)
◆ ~Ranlux64Engine()
CLHEP::Ranlux64Engine::~Ranlux64Engine |
( |
| ) |
|
|
virtual |
◆ advance()
void CLHEP::Ranlux64Engine::advance |
( |
int |
dozens | ) |
|
|
private |
Definition at line 257 of file Ranlux64Engine.cc.
283 for ( k = dozens; k > 0; --k ) {
294 y3 = randoms[ 2] - randoms[ 9];
301 y1 = randoms[ 1] - randoms[ 8];
308 y2 = randoms[ 0] - randoms[ 7];
315 y3 = randoms[11] - randoms[ 6];
322 y1 = randoms[10] - randoms[ 5];
329 y2 = randoms[ 9] - randoms[ 4];
336 y3 = randoms[ 8] - randoms[ 3];
343 y1 = randoms[ 7] - randoms[ 2];
350 y2 = randoms[ 6] - randoms[ 1];
357 y3 = randoms[ 5] - randoms[ 0];
static double twoToMinus_48()
◆ beginTag()
std::string CLHEP::Ranlux64Engine::beginTag |
( |
| ) |
|
|
static |
◆ engineName()
static std::string CLHEP::Ranlux64Engine::engineName |
( |
| ) |
|
|
inlinestatic |
◆ flat()
double CLHEP::Ranlux64Engine::flat |
( |
| ) |
|
|
virtual |
◆ flatArray()
void CLHEP::Ranlux64Engine::flatArray |
( |
const int |
size, |
|
|
double * |
vect |
|
) |
| |
|
virtual |
◆ get() [1/2]
std::istream & CLHEP::Ranlux64Engine::get |
( |
std::istream & |
is | ) |
|
|
virtual |
Reimplemented from CLHEP::HepRandomEngine.
Definition at line 620 of file Ranlux64Engine.cc.
628 if (strcmp(beginMarker,
"Ranlux64Engine-begin")) {
629 is.clear(std::ios::badbit | is.rdstate());
630 std::cerr <<
"\nInput stream mispositioned or" 631 <<
"\nRanlux64Engine state description missing or" 632 <<
"\nwrong engine type found." << std::endl;
static const int MarkerLen
virtual std::istream & getState(std::istream &is)
◆ get() [2/2]
bool CLHEP::Ranlux64Engine::get |
( |
const std::vector< unsigned long > & |
v | ) |
|
|
virtual |
Reimplemented from CLHEP::HepRandomEngine.
Definition at line 684 of file Ranlux64Engine.cc.
685 if ((
v[0] & 0xffffffffUL) != engineIDulong<Ranlux64Engine>()) {
687 "\nRanlux64Engine get:state vector has wrong ID word - state unchanged\n";
virtual std::istream & getState(std::istream &is)
◆ getLuxury()
int CLHEP::Ranlux64Engine::getLuxury |
( |
| ) |
const |
|
inline |
◆ getState() [1/2]
std::istream & CLHEP::Ranlux64Engine::getState |
( |
std::istream & |
is | ) |
|
|
virtual |
Reimplemented from CLHEP::HepRandomEngine.
Definition at line 642 of file Ranlux64Engine.cc.
645 std::vector<unsigned long>
v;
650 is.clear(std::ios::badbit | is.rdstate());
651 std::cerr <<
"\nRanlux64Engine state (vector) description improper." 652 <<
"\ngetState() has failed." 653 <<
"\nInput stream is probably mispositioned now." << std::endl;
665 for (
int i=0; i<12; ++i) {
675 if (strcmp(endMarker,
"Ranlux64Engine-end")) {
676 is.clear(std::ios::badbit | is.rdstate());
677 std::cerr <<
"\nRanlux64Engine state description incomplete." 678 <<
"\nInput stream is probably mispositioned now." << std::endl;
static const int MarkerLen
static const unsigned int VECTOR_STATE_SIZE
bool possibleKeywordInput(IS &is, const std::string &key, T &t)
virtual std::istream & getState(std::istream &is)
◆ getState() [2/2]
bool CLHEP::Ranlux64Engine::getState |
( |
const std::vector< unsigned long > & |
v | ) |
|
|
virtual |
Reimplemented from CLHEP::HepRandomEngine.
Definition at line 693 of file Ranlux64Engine.cc.
696 "\nRanlux64Engine get:state vector has wrong length - state unchanged\n";
699 std::vector<unsigned long> t(2);
700 for (
int i=0; i<12; ++i) {
701 t[0] =
v[2*i+1]; t[1] =
v[2*i+2];
704 t[0] =
v[25]; t[1] =
v[26];
static const unsigned int VECTOR_STATE_SIZE
static double longs2double(const std::vector< unsigned long > &v)
◆ name()
std::string CLHEP::Ranlux64Engine::name |
( |
| ) |
const |
|
virtual |
◆ put() [1/2]
std::ostream & CLHEP::Ranlux64Engine::put |
( |
std::ostream & |
os | ) |
const |
|
virtual |
Reimplemented from CLHEP::HepRandomEngine.
Definition at line 593 of file Ranlux64Engine.cc.
595 char beginMarker[] =
"Ranlux64Engine-begin";
596 os << beginMarker <<
"\nUvec\n";
597 std::vector<unsigned long>
v =
put();
598 for (
unsigned int i=0; i<v.size(); ++i) {
std::vector< unsigned long > put() const
◆ put() [2/2]
std::vector< unsigned long > CLHEP::Ranlux64Engine::put |
( |
| ) |
const |
|
virtual |
Reimplemented from CLHEP::HepRandomEngine.
Definition at line 604 of file Ranlux64Engine.cc.
605 std::vector<unsigned long>
v;
606 v.push_back (engineIDulong<Ranlux64Engine>());
607 std::vector<unsigned long> t;
608 for (
int i=0; i<12; ++i) {
610 v.push_back(t[0]); v.push_back(t[1]);
613 v.push_back(t[0]); v.push_back(t[1]);
614 v.push_back(static_cast<unsigned long>(
index));
615 v.push_back(static_cast<unsigned long>(
luxury));
616 v.push_back(static_cast<unsigned long>(
pDiscard));
static std::vector< unsigned long > dto2longs(double d)
◆ restoreStatus()
void CLHEP::Ranlux64Engine::restoreStatus |
( |
const char |
filename[] = "Ranlux64.conf" | ) |
|
|
virtual |
Implements CLHEP::HepRandomEngine.
Definition at line 540 of file Ranlux64Engine.cc.
544 std::cerr <<
" -- Engine state remains unchanged\n";
548 std::vector<unsigned long>
v;
553 inFile.clear(std::ios::badbit | inFile.rdstate());
554 std::cerr <<
"\nJamesRandom state (vector) description improper." 555 <<
"\nrestoreStatus has failed." 556 <<
"\nInput stream is probably mispositioned now." << std::endl;
565 if (!inFile.bad() && !inFile.eof()) {
567 for (
int i=0; i<12; ++i) {
static bool checkFile(std::istream &file, const std::string &filename, const std::string &classname, const std::string &methodname)
static std::string engineName()
static const unsigned int VECTOR_STATE_SIZE
bool possibleKeywordInput(IS &is, const std::string &key, T &t)
virtual std::istream & getState(std::istream &is)
◆ saveStatus()
void CLHEP::Ranlux64Engine::saveStatus |
( |
const char |
filename[] = "Ranlux64.conf" | ) |
const |
|
virtual |
Implements CLHEP::HepRandomEngine.
Definition at line 528 of file Ranlux64Engine.cc.
530 std::ofstream outFile( filename, std::ios::out ) ;
531 if (!outFile.bad()) {
533 std::vector<unsigned long>
v =
put();
534 for (
unsigned int i=0; i<v.size(); ++i) {
535 outFile << v[i] <<
"\n";
std::vector< unsigned long > put() const
◆ setSeed()
void CLHEP::Ranlux64Engine::setSeed |
( |
long |
seed, |
|
|
int |
lux = 1 |
|
) |
| |
|
virtual |
Implements CLHEP::HepRandomEngine.
Definition at line 380 of file Ranlux64Engine.cc.
388 const int ecuyer_a(53668);
389 const int ecuyer_b(40014);
390 const int ecuyer_c(12211);
391 const int ecuyer_d(2147483563);
393 const int lux_levels[3] = {109, 202, 397};
396 if( (
lux > 2)||(
lux < 0) ){
405 long next_seed = seed;
408 next_seed &= 0xffffffff;
409 while( next_seed >= ecuyer_d ) {
410 next_seed -= ecuyer_d;
413 for(i = 0;i != 24;i++){
414 k_multiple = next_seed / ecuyer_a;
415 next_seed = ecuyer_b * (next_seed - k_multiple * ecuyer_a)
416 - k_multiple * ecuyer_c;
418 next_seed += ecuyer_d;
420 next_seed &= 0xffffffff;
421 init_table[i] = next_seed;
424 if(
sizeof(
long) >= 8 ) {
425 long topbits1, topbits2;
427 topbits1 = ( seed >> 32) & 0xffff ;
428 topbits2 = ( seed >> 48) & 0xffff ;
430 topbits1 = detail::rshift<32>(seed) & 0xffff ;
431 topbits2 = detail::rshift<48>(seed) & 0xffff ;
433 init_table[0] ^= topbits1;
434 init_table[2] ^= topbits2;
439 for(i = 0;i < 12; i++){
static double twoToMinus_48()
static double twoToMinus_32()
◆ setSeeds()
void CLHEP::Ranlux64Engine::setSeeds |
( |
const long * |
seeds, |
|
|
int |
lux = 1 |
|
) |
| |
|
virtual |
Implements CLHEP::HepRandomEngine.
Definition at line 455 of file Ranlux64Engine.cc.
463 const int ecuyer_a = 53668;
464 const int ecuyer_b = 40014;
465 const int ecuyer_c = 12211;
466 const int ecuyer_d = 2147483563;
468 const int lux_levels[3] = {109, 202, 397};
485 if( (
lux > 2)||(
lux < 0) ){
494 long next_seed = *seeds;
498 for( i = 0;(i != 24)&&(*seedptr != 0);i++){
499 init_table[i] = *seedptr & 0xffffffff;
504 next_seed = init_table[i-1];
506 k_multiple = next_seed / ecuyer_a;
507 next_seed = ecuyer_b * (next_seed - k_multiple * ecuyer_a)
508 - k_multiple * ecuyer_c;
510 next_seed += ecuyer_d;
512 next_seed &= 0xffffffff;
513 init_table[i] = next_seed;
517 for(i = 0;i < 12; i++){
static double twoToMinus_48()
static double twoToMinus_32()
void setSeed(long seed, int lux=1)
◆ showStatus()
void CLHEP::Ranlux64Engine::showStatus |
( |
| ) |
const |
|
virtual |
Implements CLHEP::HepRandomEngine.
Definition at line 577 of file Ranlux64Engine.cc.
579 std::cout << std::endl;
580 std::cout <<
"--------- Ranlux engine status ---------" << std::endl;
581 std::cout <<
" Initial seed = " <<
theSeed << std::endl;
582 std::cout <<
" randoms[] = ";
583 for (
int i=0; i<12; ++i) {
584 std::cout <<
randoms[i] << std::endl;
586 std::cout << std::endl;
587 std::cout <<
" carry = " <<
carry <<
", index = " <<
index << std::endl;
588 std::cout <<
" luxury = " <<
luxury <<
" pDiscard = " 590 std::cout <<
"----------------------------------------" << std::endl;
◆ update()
void CLHEP::Ranlux64Engine::update |
( |
| ) |
|
|
private |
Definition at line 167 of file Ranlux64Engine.cc.
220 for ( m = 0, nr = 11, ns = 4; m <
endIters; ++
m, --nr ) {
236 for (m=0; m<12; m++) {
241 for (m=11; m>=0; --
m) {
static double twoToMinus_48()
◆ carry
double CLHEP::Ranlux64Engine::carry |
|
private |
◆ endIters
int CLHEP::Ranlux64Engine::endIters |
|
private |
◆ index
int CLHEP::Ranlux64Engine::index |
|
private |
◆ luxury
int CLHEP::Ranlux64Engine::luxury |
|
private |
◆ pDiscard
int CLHEP::Ranlux64Engine::pDiscard |
|
private |
◆ pDozens
int CLHEP::Ranlux64Engine::pDozens |
|
private |
◆ randoms
double CLHEP::Ranlux64Engine::randoms[12] |
|
private |
◆ VECTOR_STATE_SIZE
const unsigned int CLHEP::Ranlux64Engine::VECTOR_STATE_SIZE = 30 |
|
static |
The documentation for this class was generated from the following files: