#include <MTwistEngine.h>
- Author
Definition at line 35 of file MTwistEngine.h.
CLHEP::MTwistEngine::MTwistEngine |
( |
| ) |
|
Definition at line 64 of file MTwistEngine.cc.
67 int numEngines = numberOfEngines++;
68 int cycle = std::abs(
int(numEngines/maxIndex));
69 int curIndex = std::abs(
int(numEngines%maxIndex));
70 long mask = ((cycle & 0x007fffff) << 8);
73 seedlist[0] = (seedlist[0])^mask;
78 for(
int i=0; i < 2000; ++i )
flat();
void setSeeds(const long *seeds, int)
static void getTheTableSeeds(long *seeds, int index)
CLHEP::MTwistEngine::MTwistEngine |
( |
long |
seed | ) |
|
Definition at line 81 of file MTwistEngine.cc.
84 long seedlist[2]={seed,17587};
87 for(
int i=0; i < 2000; ++i )
flat();
void setSeeds(const long *seeds, int)
CLHEP::MTwistEngine::MTwistEngine |
( |
int |
rowIndex, |
|
|
int |
colIndex |
|
) |
| |
Definition at line 90 of file MTwistEngine.cc.
93 int cycle = std::abs(
int(rowIndex/maxIndex));
94 int row = std::abs(
int(rowIndex%maxIndex));
95 int col = std::abs(
int(colIndex%2));
96 long mask = (( cycle & 0x000007ff ) << 20 );
99 seedlist[0] = (seedlist[col])^mask;
100 seedlist[1] = 690691;
103 for(
int i=0; i < 2000; ++i )
flat();
void setSeeds(const long *seeds, int)
static void getTheTableSeeds(long *seeds, int index)
CLHEP::MTwistEngine::MTwistEngine |
( |
std::istream & |
is | ) |
|
CLHEP::MTwistEngine::~MTwistEngine |
( |
| ) |
|
|
virtual |
std::string CLHEP::MTwistEngine::beginTag |
( |
| ) |
|
|
static |
static std::string CLHEP::MTwistEngine::engineName |
( |
| ) |
|
|
inlinestatic |
double CLHEP::MTwistEngine::flat |
( |
| ) |
|
|
virtual |
Implements CLHEP::HepRandomEngine.
Definition at line 114 of file MTwistEngine.cc.
117 if( count624 >=
N ) {
120 for( i=0; i < NminusM; ++i ) {
121 y = (mt[i] & 0x80000000) | (mt[i+1] & 0x7fffffff);
122 mt[i] = mt[i+M] ^ (y >> 1) ^ ((y & 0x1) ? 0x9908b0df : 0x0 );
125 for( ; i <
N-1 ; ++i ) {
126 y = (mt[i] & 0x80000000) | (mt[i+1] & 0x7fffffff);
127 mt[i] = mt[i-NminusM] ^ (y >> 1) ^ ((y & 0x1) ? 0x9908b0df : 0x0 );
130 y = (mt[i] & 0x80000000) | (mt[0] & 0x7fffffff);
131 mt[i] = mt[M-1] ^ (y >> 1) ^ ((y & 0x1) ? 0x9908b0df : 0x0 );
138 y ^= ((y << 7 ) & 0x9d2c5680);
139 y ^= ((y << 15) & 0xefc60000);
static double nearlyTwoToMinus_54()
static double twoToMinus_32()
static double twoToMinus_53()
void CLHEP::MTwistEngine::flatArray |
( |
const int |
size, |
|
|
double * |
vect |
|
) |
| |
|
virtual |
std::istream & CLHEP::MTwistEngine::get |
( |
std::istream & |
is | ) |
|
|
virtual |
Reimplemented from CLHEP::HepRandomEngine.
Definition at line 322 of file MTwistEngine.cc.
330 if (strcmp(beginMarker,
"MTwistEngine-begin")) {
331 is.clear(std::ios::badbit | is.rdstate());
332 std::cerr <<
"\nInput stream mispositioned or"
333 <<
"\nMTwistEngine state description missing or"
334 <<
"\nwrong engine type found." << std::endl;
static const int MarkerLen
virtual std::istream & getState(std::istream &is)
bool CLHEP::MTwistEngine::get |
( |
const std::vector< unsigned long > & |
v | ) |
|
|
virtual |
Reimplemented from CLHEP::HepRandomEngine.
Definition at line 362 of file MTwistEngine.cc.
363 if ((v[0] & 0xffffffffUL) != engineIDulong<MTwistEngine>()) {
365 "\nMTwistEngine get:state vector has wrong ID word - state unchanged\n";
virtual std::istream & getState(std::istream &is)
std::istream & CLHEP::MTwistEngine::getState |
( |
std::istream & |
is | ) |
|
|
virtual |
Reimplemented from CLHEP::HepRandomEngine.
Definition at line 344 of file MTwistEngine.cc.
348 for (
int i=0; i<624; ++i) is >> mt[i];
353 if (strcmp(endMarker,
"MTwistEngine-end")) {
354 is.clear(std::ios::badbit | is.rdstate());
355 std::cerr <<
"\nMTwistEngine state description incomplete."
356 <<
"\nInput stream is probably mispositioned now." << std::endl;
static const int MarkerLen
bool CLHEP::MTwistEngine::getState |
( |
const std::vector< unsigned long > & |
v | ) |
|
|
virtual |
Reimplemented from CLHEP::HepRandomEngine.
Definition at line 371 of file MTwistEngine.cc.
374 "\nMTwistEngine get:state vector has wrong length - state unchanged\n";
377 for (
int i=0; i<624; ++i) {
static const unsigned int VECTOR_STATE_SIZE
std::string CLHEP::MTwistEngine::name |
( |
| ) |
const |
|
virtual |
CLHEP::MTwistEngine::operator float |
( |
| ) |
|
|
virtual |
Reimplemented from CLHEP::HepRandomEngine.
Definition at line 233 of file MTwistEngine.cc.
236 if( count624 >=
N ) {
239 for( i=0; i < NminusM; ++i ) {
240 y = (mt[i] & 0x80000000) | (mt[i+1] & 0x7fffffff);
241 mt[i] = mt[i+M] ^ (y >> 1) ^ ((y & 0x1) ? 0x9908b0df : 0x0 );
244 for( ; i <
N-1 ; ++i ) {
245 y = (mt[i] & 0x80000000) | (mt[i+1] & 0x7fffffff);
246 mt[i] = mt[i-NminusM] ^ (y >> 1) ^ ((y & 0x1) ? 0x9908b0df : 0x0 );
249 y = (mt[i] & 0x80000000) | (mt[0] & 0x7fffffff);
250 mt[i] = mt[M-1] ^ (y >> 1) ^ ((y & 0x1) ? 0x9908b0df : 0x0 );
257 y ^= ((y << 7 ) & 0x9d2c5680);
258 y ^= ((y << 15) & 0xefc60000);
static double twoToMinus_32()
CLHEP::MTwistEngine::operator unsigned int |
( |
| ) |
|
|
virtual |
Reimplemented from CLHEP::HepRandomEngine.
Definition at line 264 of file MTwistEngine.cc.
267 if( count624 >=
N ) {
270 for( i=0; i < NminusM; ++i ) {
271 y = (mt[i] & 0x80000000) | (mt[i+1] & 0x7fffffff);
272 mt[i] = mt[i+M] ^ (y >> 1) ^ ((y & 0x1) ? 0x9908b0df : 0x0 );
275 for( ; i <
N-1 ; ++i ) {
276 y = (mt[i] & 0x80000000) | (mt[i+1] & 0x7fffffff);
277 mt[i] = mt[i-NminusM] ^ (y >> 1) ^ ((y & 0x1) ? 0x9908b0df : 0x0 );
280 y = (mt[i] & 0x80000000) | (mt[0] & 0x7fffffff);
281 mt[i] = mt[M-1] ^ (y >> 1) ^ ((y & 0x1) ? 0x9908b0df : 0x0 );
288 y ^= ((y << 7 ) & 0x9d2c5680);
289 y ^= ((y << 15) & 0xefc60000);
std::ostream & CLHEP::MTwistEngine::put |
( |
std::ostream & |
os | ) |
const |
|
virtual |
Reimplemented from CLHEP::HepRandomEngine.
Definition at line 295 of file MTwistEngine.cc.
297 char beginMarker[] =
"MTwistEngine-begin";
298 char endMarker[] =
"MTwistEngine-end";
300 int pr = os.precision(20);
301 os <<
" " << beginMarker <<
" ";
303 for (
int i=0; i<624; ++i) {
306 os << count624 <<
" ";
307 os << endMarker <<
"\n";
std::vector< unsigned long > CLHEP::MTwistEngine::put |
( |
| ) |
const |
|
virtual |
Reimplemented from CLHEP::HepRandomEngine.
Definition at line 312 of file MTwistEngine.cc.
313 std::vector<unsigned long> v;
314 v.push_back (engineIDulong<MTwistEngine>());
315 for (
int i=0; i<624; ++i) {
316 v.push_back(static_cast<unsigned long>(mt[i]));
318 v.push_back(count624);
void CLHEP::MTwistEngine::restoreStatus |
( |
const char |
filename[] = "MTwist.conf" | ) |
|
|
virtual |
Implements CLHEP::HepRandomEngine.
Definition at line 199 of file MTwistEngine.cc.
201 std::ifstream inFile( filename, std::ios::in);
203 std::cerr <<
" -- Engine state remains unchanged\n";
207 if (!inFile.bad() && !inFile.eof()) {
209 for (
int i=0; i<624; ++i) inFile >> mt[i];
static bool checkFile(std::istream &file, const std::string &filename, const std::string &classname, const std::string &methodname)
static std::string engineName()
void CLHEP::MTwistEngine::saveStatus |
( |
const char |
filename[] = "MTwist.conf" | ) |
const |
|
virtual |
Implements CLHEP::HepRandomEngine.
Definition at line 188 of file MTwistEngine.cc.
190 std::ofstream outFile( filename, std::ios::out ) ;
191 if (!outFile.bad()) {
192 outFile <<
theSeed << std::endl;
193 for (
int i=0; i<624; ++i) outFile <<std::setprecision(20) << mt[i] <<
" ";
194 outFile << std::endl;
195 outFile << count624 << std::endl;
void CLHEP::MTwistEngine::setSeed |
( |
long |
seed, |
|
|
int |
k |
|
) |
| |
|
virtual |
Implements CLHEP::HepRandomEngine.
Definition at line 151 of file MTwistEngine.cc.
162 mt[0] = (
unsigned int) (
theSeed&0xffffffffUL);
163 for (mti=1; mti<N1; mti++) {
164 mt[mti] = (1812433253UL * (mt[mti-1] ^ (mt[mti-1] >> 30)) + mti);
169 mt[mti] &= 0xffffffffUL;
172 for(
int i=1; i < 624; ++i ) {
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
void CLHEP::MTwistEngine::setSeeds |
( |
const long * |
seeds, |
|
|
int |
k |
|
) |
| |
|
virtual |
Implements CLHEP::HepRandomEngine.
Definition at line 179 of file MTwistEngine.cc.
180 setSeed( (*seeds ? *seeds : 43571346), k );
182 for( i=1; i < 624; ++i ) {
183 mt[i] = ( seeds[1] + mt[i] ) & 0xffffffff;
void setSeed(long seed, int)
void CLHEP::MTwistEngine::showStatus |
( |
| ) |
const |
|
virtual |
Implements CLHEP::HepRandomEngine.
Definition at line 214 of file MTwistEngine.cc.
216 std::cout << std::endl;
217 std::cout <<
"--------- MTwist engine status ---------" << std::endl;
218 std::cout << std::setprecision(20);
219 std::cout <<
" Initial seed = " <<
theSeed << std::endl;
220 std::cout <<
" Current index = " << count624 << std::endl;
221 std::cout <<
" Array status mt[] = " << std::endl;
224 for (
int i=0; i<620; i+=5) {
225 std::cout << mt[i] <<
" " << mt[i+1] <<
" " << mt[i+2] <<
" "
226 << mt[i+3] <<
" " << mt[i+4] <<
"\n";
228 std::cout << mt[620] <<
" " << mt[621] <<
" " << mt[622] <<
" "
229 << mt[623] << std::endl;
230 std::cout <<
"----------------------------------------" << std::endl;
const unsigned int CLHEP::MTwistEngine::VECTOR_STATE_SIZE = 626 |
|
static |
The documentation for this class was generated from the following files: