#include <RanluxEngine.h>
- Author
Definition at line 45 of file RanluxEngine.h.
◆ RanluxEngine() [1/4]
CLHEP::RanluxEngine::RanluxEngine |
( |
std::istream & |
is | ) |
|
◆ RanluxEngine() [2/4]
CLHEP::RanluxEngine::RanluxEngine |
( |
| ) |
|
Definition at line 76 of file RanluxEngine.cc.
80 long seedlist[2]={0,0};
83 int numEngines = numberOfEngines++;
84 int cycle = std::abs(
int(numEngines/maxIndex));
85 int curIndex = std::abs(
int(numEngines%maxIndex));
87 long mask = ((cycle & 0x007fffff) << 8);
89 seed = seedlist[0]^
mask;
void setSeeds(const long *seeds, int lux=3)
void setSeed(long seed, int lux=3)
static void getTheTableSeeds(long *seeds, int index)
◆ RanluxEngine() [3/4]
CLHEP::RanluxEngine::RanluxEngine |
( |
long |
seed, |
|
|
int |
lux = 3 |
|
) |
| |
Definition at line 62 of file RanluxEngine.cc.
65 long seedlist[2]={0,0};
void setSeeds(const long *seeds, int lux=3)
void setSeed(long seed, int lux=3)
◆ RanluxEngine() [4/4]
CLHEP::RanluxEngine::RanluxEngine |
( |
int |
rowIndex, |
|
|
int |
colIndex, |
|
|
int |
lux |
|
) |
| |
Definition at line 98 of file RanluxEngine.cc.
102 long seedlist[2]={0,0};
105 int cycle = std::abs(
int(rowIndex/maxIndex));
106 int row = std::abs(
int(rowIndex%maxIndex));
107 int col = std::abs(
int(colIndex%2));
108 long mask = (( cycle & 0x000007ff ) << 20 );
110 seed = ( seedlist[
col] )^mask;
void setSeeds(const long *seeds, int lux=3)
void setSeed(long seed, int lux=3)
static void getTheTableSeeds(long *seeds, int index)
◆ ~RanluxEngine()
CLHEP::RanluxEngine::~RanluxEngine |
( |
| ) |
|
|
virtual |
◆ beginTag()
std::string CLHEP::RanluxEngine::beginTag |
( |
| ) |
|
|
static |
◆ engineName()
static std::string CLHEP::RanluxEngine::engineName |
( |
| ) |
|
|
inlinestatic |
◆ flat()
double CLHEP::RanluxEngine::flat |
( |
| ) |
|
|
virtual |
Implements CLHEP::HepRandomEngine.
Definition at line 311 of file RanluxEngine.cc.
343 for( i = 0; i !=
nskip ; i++){
358 return (
double) next_random;
static double mantissa_bit_24()
static double mantissa_bit_12()
float float_seed_table[24]
◆ flatArray()
void CLHEP::RanluxEngine::flatArray |
( |
const int |
size, |
|
|
double * |
vect |
|
) |
| |
|
virtual |
Implements CLHEP::HepRandomEngine.
Definition at line 361 of file RanluxEngine.cc.
368 for (index=0; index<size; ++
index) {
388 vect[
index] = (double)next_random;
396 for( i = 0; i !=
nskip ; i++){
static double mantissa_bit_24()
static double mantissa_bit_12()
float float_seed_table[24]
◆ get() [1/2]
std::istream & CLHEP::RanluxEngine::get |
( |
std::istream & |
is | ) |
|
|
virtual |
Reimplemented from CLHEP::HepRandomEngine.
Definition at line 448 of file RanluxEngine.cc.
456 if (strcmp(beginMarker,
"RanluxEngine-begin")) {
457 is.clear(std::ios::badbit | is.rdstate());
458 std::cerr <<
"\nInput stream mispositioned or" 459 <<
"\nRanluxEngine state description missing or" 460 <<
"\nwrong engine type found." << std::endl;
static const int MarkerLen
virtual std::istream & getState(std::istream &is)
◆ get() [2/2]
bool CLHEP::RanluxEngine::get |
( |
const std::vector< unsigned long > & |
v | ) |
|
|
virtual |
Reimplemented from CLHEP::HepRandomEngine.
Definition at line 511 of file RanluxEngine.cc.
512 if ((
v[0] & 0xffffffffUL) != engineIDulong<RanluxEngine>()) {
514 "\nRanluxEngine get:state vector has wrong ID word - state unchanged\n";
virtual std::istream & getState(std::istream &is)
◆ getLuxury()
int CLHEP::RanluxEngine::getLuxury |
( |
| ) |
const |
|
inline |
◆ getState() [1/2]
std::istream & CLHEP::RanluxEngine::getState |
( |
std::istream & |
is | ) |
|
|
virtual |
Reimplemented from CLHEP::HepRandomEngine.
Definition at line 470 of file RanluxEngine.cc.
473 std::vector<unsigned long>
v;
478 is.clear(std::ios::badbit | is.rdstate());
479 std::cerr <<
"\nRanluxEngine state (vector) description improper." 480 <<
"\ngetState() has failed." 481 <<
"\nInput stream is probably mispositioned now." << std::endl;
493 for (
int i=0; i<24; ++i) {
502 if (strcmp(endMarker,
"RanluxEngine-end")) {
503 is.clear(std::ios::badbit | is.rdstate());
504 std::cerr <<
"\nRanluxEngine state description incomplete." 505 <<
"\nInput stream is probably mispositioned now." << std::endl;
static const int MarkerLen
bool possibleKeywordInput(IS &is, const std::string &key, T &t)
float float_seed_table[24]
virtual std::istream & getState(std::istream &is)
static const unsigned int VECTOR_STATE_SIZE
◆ getState() [2/2]
bool CLHEP::RanluxEngine::getState |
( |
const std::vector< unsigned long > & |
v | ) |
|
|
virtual |
Reimplemented from CLHEP::HepRandomEngine.
Definition at line 520 of file RanluxEngine.cc.
523 "\nRanluxEngine get:state vector has wrong length - state unchanged\n";
526 for (
int i=0; i<24; ++i) {
static double mantissa_bit_24()
float float_seed_table[24]
static const unsigned int VECTOR_STATE_SIZE
◆ name()
std::string CLHEP::RanluxEngine::name |
( |
| ) |
const |
|
virtual |
◆ operator unsigned int()
CLHEP::RanluxEngine::operator unsigned int |
( |
| ) |
|
|
virtual |
◆ put() [1/2]
std::ostream & CLHEP::RanluxEngine::put |
( |
std::ostream & |
os | ) |
const |
|
virtual |
Reimplemented from CLHEP::HepRandomEngine.
Definition at line 421 of file RanluxEngine.cc.
423 char beginMarker[] =
"RanluxEngine-begin";
424 os << beginMarker <<
"\nUvec\n";
425 std::vector<unsigned long>
v =
put();
426 for (
unsigned int i=0; i<v.size(); ++i) {
std::vector< unsigned long > put() const
◆ put() [2/2]
std::vector< unsigned long > CLHEP::RanluxEngine::put |
( |
| ) |
const |
|
virtual |
Reimplemented from CLHEP::HepRandomEngine.
Definition at line 432 of file RanluxEngine.cc.
433 std::vector<unsigned long>
v;
434 v.push_back (engineIDulong<RanluxEngine>());
435 for (
int i=0; i<24; ++i) {
439 v.push_back(static_cast<unsigned long>(
i_lag));
440 v.push_back(static_cast<unsigned long>(
j_lag));
442 v.push_back(static_cast<unsigned long>(
count24));
443 v.push_back(static_cast<unsigned long>(
luxury));
444 v.push_back(static_cast<unsigned long>(
nskip));
static double mantissa_bit_24()
float float_seed_table[24]
◆ restoreStatus()
void CLHEP::RanluxEngine::restoreStatus |
( |
const char |
filename[] = "Ranlux.conf" | ) |
|
|
virtual |
Implements CLHEP::HepRandomEngine.
Definition at line 261 of file RanluxEngine.cc.
265 std::cerr <<
" -- Engine state remains unchanged\n";
269 std::vector<unsigned long>
v;
274 inFile.clear(std::ios::badbit | inFile.rdstate());
275 std::cerr <<
"\nRanluxEngine state (vector) description improper." 276 <<
"\nrestoreStatus has failed." 277 <<
"\nInput stream is probably mispositioned now." << std::endl;
286 if (!inFile.bad() && !inFile.eof()) {
288 for (
int i=0; i<24; ++i)
static std::string engineName()
static bool checkFile(std::istream &file, const std::string &filename, const std::string &classname, const std::string &methodname)
bool possibleKeywordInput(IS &is, const std::string &key, T &t)
float float_seed_table[24]
virtual std::istream & getState(std::istream &is)
static const unsigned int VECTOR_STATE_SIZE
◆ saveStatus()
void CLHEP::RanluxEngine::saveStatus |
( |
const char |
filename[] = "Ranlux.conf" | ) |
const |
|
virtual |
Implements CLHEP::HepRandomEngine.
Definition at line 249 of file RanluxEngine.cc.
251 std::ofstream outFile( filename, std::ios::out ) ;
252 if (!outFile.bad()) {
254 std::vector<unsigned long>
v =
put();
255 for (
unsigned int i=0; i<v.size(); ++i) {
256 outFile << v[i] <<
"\n";
std::vector< unsigned long > put() const
◆ setSeed()
void CLHEP::RanluxEngine::setSeed |
( |
long |
seed, |
|
|
int |
lux = 3 |
|
) |
| |
|
virtual |
Implements CLHEP::HepRandomEngine.
Definition at line 127 of file RanluxEngine.cc.
135 const int ecuyer_a = 53668;
136 const int ecuyer_b = 40014;
137 const int ecuyer_c = 12211;
138 const int ecuyer_d = 2147483563;
140 const int lux_levels[5] = {0,24,73,199,365};
142 long int_seed_table[24];
143 long next_seed = seed;
151 if( (
lux > 4)||(
lux < 0) ){
155 nskip = lux_levels[3];
163 for(i = 0;i != 24;i++){
164 k_multiple = next_seed / ecuyer_a;
165 next_seed = ecuyer_b * (next_seed - k_multiple * ecuyer_a)
166 - k_multiple * ecuyer_c ;
167 if(next_seed < 0)next_seed += ecuyer_d;
171 for(i = 0;i != 24;i++)
static const int int_modulus
static double mantissa_bit_24()
float float_seed_table[24]
◆ setSeeds()
void CLHEP::RanluxEngine::setSeeds |
( |
const long * |
seeds, |
|
|
int |
lux = 3 |
|
) |
| |
|
virtual |
Implements CLHEP::HepRandomEngine.
Definition at line 183 of file RanluxEngine.cc.
185 const int ecuyer_a = 53668;
186 const int ecuyer_b = 40014;
187 const int ecuyer_c = 12211;
188 const int ecuyer_d = 2147483563;
190 const int lux_levels[5] = {0,24,73,199,365};
192 long int_seed_table[24];
193 long k_multiple,next_seed;
210 if( (
lux > 4)||(
lux < 0) ){
214 nskip = lux_levels[3];
221 for( i = 0;(i != 24)&&(*seedptr != 0);i++){
227 next_seed = int_seed_table[i-1];
229 k_multiple = next_seed / ecuyer_a;
230 next_seed = ecuyer_b * (next_seed - k_multiple * ecuyer_a)
231 - k_multiple * ecuyer_c ;
232 if(next_seed < 0)next_seed += ecuyer_d;
237 for(i = 0;i != 24;i++)
static const int int_modulus
static double mantissa_bit_24()
void setSeed(long seed, int lux=3)
float float_seed_table[24]
◆ showStatus()
void CLHEP::RanluxEngine::showStatus |
( |
| ) |
const |
|
virtual |
Implements CLHEP::HepRandomEngine.
Definition at line 296 of file RanluxEngine.cc.
298 std::cout << std::endl;
299 std::cout <<
"--------- Ranlux engine status ---------" << std::endl;
300 std::cout <<
" Initial seed = " <<
theSeed << std::endl;
301 std::cout <<
" float_seed_table[] = ";
302 for (
int i=0; i<24; ++i)
304 std::cout << std::endl;
305 std::cout <<
" i_lag = " <<
i_lag <<
", j_lag = " <<
j_lag << std::endl;
306 std::cout <<
" carry = " <<
carry <<
", count24 = " <<
count24 << std::endl;
307 std::cout <<
" luxury = " <<
luxury <<
" nskip = " <<
nskip << std::endl;
308 std::cout <<
"----------------------------------------" << std::endl;
float float_seed_table[24]
◆ carry
float CLHEP::RanluxEngine::carry |
|
private |
◆ count24
int CLHEP::RanluxEngine::count24 |
|
private |
◆ float_seed_table
float CLHEP::RanluxEngine::float_seed_table[24] |
|
private |
◆ i_lag
int CLHEP::RanluxEngine::i_lag |
|
private |
◆ int_modulus
const int CLHEP::RanluxEngine::int_modulus = 0x1000000 |
|
staticprivate |
◆ j_lag
int CLHEP::RanluxEngine::j_lag |
|
private |
◆ luxury
int CLHEP::RanluxEngine::luxury |
|
private |
◆ nskip
int CLHEP::RanluxEngine::nskip |
|
private |
◆ VECTOR_STATE_SIZE
const unsigned int CLHEP::RanluxEngine::VECTOR_STATE_SIZE = 31 |
|
static |
The documentation for this class was generated from the following files: