#include <Ranlux64Engine.h>
- Author
Definition at line 49 of file Ranlux64Engine.h.
CLHEP::Ranlux64Engine::Ranlux64Engine |
( |
std::istream & |
is | ) |
|
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)
CLHEP::Ranlux64Engine::Ranlux64Engine |
( |
long |
seed, |
|
|
int |
lux = 1 |
|
) |
| |
Definition at line 125 of file Ranlux64Engine.cc.
129 long seedlist[2]={
seed,0};
131 advance ( 2*
lux + 1 );
void setSeeds(const long *seeds, int lux=1)
static constexpr double lux
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 constexpr double lux
static void getTheTableSeeds(long *seeds, int index)
CLHEP::Ranlux64Engine::~Ranlux64Engine |
( |
| ) |
|
|
virtual |
std::string CLHEP::Ranlux64Engine::beginTag |
( |
| ) |
|
|
static |
static std::string CLHEP::Ranlux64Engine::engineName |
( |
| ) |
|
|
inlinestatic |
double CLHEP::Ranlux64Engine::flat |
( |
| ) |
|
|
virtual |
void CLHEP::Ranlux64Engine::flatArray |
( |
const int |
size, |
|
|
double * |
vect |
|
) |
| |
|
virtual |
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)
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)
int CLHEP::Ranlux64Engine::getLuxury |
( |
| ) |
const |
|
inline |
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) {
668 is >> carry; is >> index;
669 is >> luxury; is >> pDiscard;
670 pDozens = pDiscard / 12;
671 endIters = pDiscard % 12;
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)
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)
std::string CLHEP::Ranlux64Engine::name |
( |
| ) |
const |
|
virtual |
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
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)
void CLHEP::Ranlux64Engine::restoreStatus |
( |
const char |
filename[] = "Ranlux64.conf" | ) |
|
|
virtual |
Implements CLHEP::HepRandomEngine.
Definition at line 540 of file Ranlux64Engine.cc.
542 std::ifstream inFile( filename, std::ios::in);
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) {
568 inFile >> randoms[i];
570 inFile >> carry; inFile >> index;
571 inFile >> luxury; inFile >> pDiscard;
572 pDozens = pDiscard / 12;
573 endIters = pDiscard % 12;
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)
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
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) ){
397 pDiscard = (
lux >= 12) ? (
lux-12) : lux_levels[1];
399 pDiscard = lux_levels[luxury];
401 pDozens = pDiscard / 12;
402 endIters = pDiscard % 12;
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()
static constexpr double lux
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) ){
486 pDiscard = (
lux >= 12) ? (
lux-12) : lux_levels[1];
488 pDiscard = lux_levels[luxury];
490 pDozens = pDiscard / 12;
491 endIters = pDiscard % 12;
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)
static constexpr double lux
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 = "
589 << pDiscard << std::endl;
590 std::cout <<
"----------------------------------------" << std::endl;
const unsigned int CLHEP::Ranlux64Engine::VECTOR_STATE_SIZE = 30 |
|
static |
The documentation for this class was generated from the following files: