#include <RanshiEngine.h>
- Author
Definition at line 52 of file RanshiEngine.h.
CLHEP::RanshiEngine::RanshiEngine |
( |
| ) |
|
Definition at line 63 of file RanshiEngine.cc.
65 halfBuff(0), numFlats(0)
67 int numEngines = numberOfEngines++;
70 buffer[i] = (
unsigned int)((numEngines+19780503
L*(i+1))& 0xffffffff);
74 redSpin = (
unsigned int)(
theSeed & 0xffffffff);
76 for( i = 0; i < 10000; ++i)
flat();
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
static constexpr double L
CLHEP::RanshiEngine::RanshiEngine |
( |
std::istream & |
is | ) |
|
CLHEP::RanshiEngine::RanshiEngine |
( |
long |
seed | ) |
|
Definition at line 86 of file RanshiEngine.cc.
88 halfBuff(0), numFlats(0)
90 for (
int i = 0; i < numBuff; ++i) {
91 buffer[i] = (
unsigned int)seed&0xffffffff;
94 redSpin = (
unsigned int)(
theSeed & 0xffffffff);
96 for (j = 0; j < numBuff*20; ++j) {
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
CLHEP::RanshiEngine::RanshiEngine |
( |
int |
rowIndex, |
|
|
int |
colIndex |
|
) |
| |
Definition at line 101 of file RanshiEngine.cc.
103 halfBuff(0), numFlats(0)
106 while( i < numBuff ) {
107 buffer[i] = (
unsigned int)((rowIndex + (i+1)*(colIndex+8))&0xffffffff);
111 redSpin = colIndex & 0xffffffff;
112 for( i = 0; i < 100; ++i)
flat();
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
CLHEP::RanshiEngine::~RanshiEngine |
( |
| ) |
|
|
virtual |
std::string CLHEP::RanshiEngine::beginTag |
( |
| ) |
|
|
static |
static std::string CLHEP::RanshiEngine::engineName |
( |
| ) |
|
|
inlinestatic |
double CLHEP::RanshiEngine::flat |
( |
| ) |
|
|
virtual |
Implements CLHEP::HepRandomEngine.
Definition at line 117 of file RanshiEngine.cc.
118 unsigned int redAngle = (((numBuff/2) - 1) & redSpin) + halfBuff;
119 unsigned int blkSpin =
buffer[redAngle] & 0xffffffff;
120 unsigned int boostResult = blkSpin ^ redSpin;
122 buffer[redAngle] = ((blkSpin << 17) | (blkSpin >> (32-17))) ^ redSpin;
124 redSpin = (blkSpin + numFlats++) & 0xffffffff;
125 halfBuff = numBuff/2 - halfBuff;
static double nearlyTwoToMinus_54()
static double twoToMinus_32()
static double twoToMinus_53()
void CLHEP::RanshiEngine::flatArray |
( |
const int |
size, |
|
|
double * |
vect |
|
) |
| |
|
virtual |
std::istream & CLHEP::RanshiEngine::get |
( |
std::istream & |
is | ) |
|
|
virtual |
Reimplemented from CLHEP::HepRandomEngine.
Definition at line 266 of file RanshiEngine.cc.
273 if (strcmp(beginMarker,
"RanshiEngine-begin")) {
274 is.clear(std::ios::badbit | is.rdstate());
275 std::cerr <<
"\nInput mispositioned or"
276 <<
"\nRanshiEngine state description missing or"
277 <<
"\nwrong engine type found." << std::endl;
static const int MarkerLen
virtual std::istream & getState(std::istream &is)
bool CLHEP::RanshiEngine::get |
( |
const std::vector< unsigned long > & |
v | ) |
|
|
virtual |
Reimplemented from CLHEP::HepRandomEngine.
Definition at line 325 of file RanshiEngine.cc.
326 if ((v[0] & 0xffffffffUL) != engineIDulong<RanshiEngine>()) {
328 "\nRanshiEngine get:state vector has wrong ID word - state unchanged\n";
virtual std::istream & getState(std::istream &is)
std::istream & CLHEP::RanshiEngine::getState |
( |
std::istream & |
is | ) |
|
|
virtual |
Reimplemented from CLHEP::HepRandomEngine.
Definition at line 287 of file RanshiEngine.cc.
289 std::vector<unsigned long> v;
291 for (
unsigned int ivec=0; ivec < VECTOR_STATE_SIZE; ++ivec) {
294 is.clear(std::ios::badbit | is.rdstate());
295 std::cerr <<
"\nRanshiEngine state (vector) description improper."
296 <<
"\ngetState() has failed."
297 <<
"\nInput stream is probably mispositioned now." << std::endl;
309 for (
int i = 0; i < numBuff; ++i) {
312 is >> redSpin >> numFlats >> halfBuff;
316 if (strcmp(endMarker,
"RanshiEngine-end")) {
317 is.clear(std::ios::badbit | is.rdstate());
318 std::cerr <<
"\nRanshiEngine state description incomplete."
319 <<
"\nInput stream is probably mispositioned now." << std::endl;
static const int MarkerLen
bool possibleKeywordInput(IS &is, const std::string &key, T &t)
virtual std::istream & getState(std::istream &is)
bool CLHEP::RanshiEngine::getState |
( |
const std::vector< unsigned long > & |
v | ) |
|
|
virtual |
Reimplemented from CLHEP::HepRandomEngine.
Definition at line 334 of file RanshiEngine.cc.
335 if (v.size() != VECTOR_STATE_SIZE ) {
337 "\nRanshiEngine get:state vector has wrong length - state unchanged\n";
340 for (
int i = 0; i < numBuff; ++i) {
343 redSpin = v[numBuff+1];
344 numFlats = v[numBuff+2];
345 halfBuff = v[numBuff+3];
std::string CLHEP::RanshiEngine::name |
( |
| ) |
const |
|
virtual |
CLHEP::RanshiEngine::operator float |
( |
| ) |
|
|
virtual |
Reimplemented from CLHEP::HepRandomEngine.
Definition at line 220 of file RanshiEngine.cc.
221 unsigned int redAngle = (((numBuff/2) - 1) & redSpin) + halfBuff;
222 unsigned int blkSpin =
buffer[redAngle] & 0xffffffff;
224 buffer[redAngle] = ((blkSpin << 17) | (blkSpin >> (32-17))) ^ redSpin;
226 redSpin = (blkSpin + numFlats++) & 0xffffffff;
227 halfBuff = numBuff/2 - halfBuff;
static double twoToMinus_32()
CLHEP::RanshiEngine::operator unsigned int |
( |
| ) |
|
|
virtual |
Reimplemented from CLHEP::HepRandomEngine.
Definition at line 232 of file RanshiEngine.cc.
233 unsigned int redAngle = (((numBuff/2) - 1) & redSpin) + halfBuff;
234 unsigned int blkSpin =
buffer[redAngle] & 0xffffffff;
236 buffer[redAngle] = ((blkSpin << 17) | (blkSpin >> (32-17))) ^ redSpin;
238 redSpin = (blkSpin + numFlats++) & 0xffffffff;
239 halfBuff = numBuff/2 - halfBuff;
std::ostream & CLHEP::RanshiEngine::put |
( |
std::ostream & |
os | ) |
const |
|
virtual |
Reimplemented from CLHEP::HepRandomEngine.
Definition at line 244 of file RanshiEngine.cc.
245 char beginMarker[] =
"RanshiEngine-begin";
246 os << beginMarker <<
"\nUvec\n";
247 std::vector<unsigned long> v =
put();
248 for (
unsigned int i=0; i<v.size(); ++i) {
std::vector< unsigned long > put() const
std::vector< unsigned long > CLHEP::RanshiEngine::put |
( |
| ) |
const |
|
virtual |
Reimplemented from CLHEP::HepRandomEngine.
Definition at line 254 of file RanshiEngine.cc.
255 std::vector<unsigned long> v;
256 v.push_back (engineIDulong<RanshiEngine>());
257 for (
int i = 0; i < numBuff; ++i) {
258 v.push_back(static_cast<unsigned long>(
buffer[i]));
260 v.push_back(static_cast<unsigned long>(redSpin));
261 v.push_back(static_cast<unsigned long>(numFlats));
262 v.push_back(static_cast<unsigned long>(halfBuff));
void CLHEP::RanshiEngine::restoreStatus |
( |
const char |
filename[] = "RanshiEngine.conf" | ) |
|
|
virtual |
Implements CLHEP::HepRandomEngine.
Definition at line 170 of file RanshiEngine.cc.
171 std::ifstream inFile(filename, std::ios::in);
173 std::cerr <<
" -- Engine state remains unchanged\n";
177 std::vector<unsigned long> v;
179 for (
unsigned int ivec=0; ivec < VECTOR_STATE_SIZE; ++ivec) {
182 inFile.clear(std::ios::badbit | inFile.rdstate());
183 std::cerr <<
"\nRanshiEngine state (vector) description improper."
184 <<
"\nrestoreStatus has failed."
185 <<
"\nInput stream is probably mispositioned now." << std::endl;
196 for (
int i = 0; i < numBuff; ++i) {
199 inFile >> redSpin >> numFlats >> halfBuff;
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)
virtual std::istream & getState(std::istream &is)
static std::string engineName()
void CLHEP::RanshiEngine::saveStatus |
( |
const char |
filename[] = "RanshiEngine.conf" | ) |
const |
|
virtual |
Implements CLHEP::HepRandomEngine.
Definition at line 159 of file RanshiEngine.cc.
160 std::ofstream outFile(filename, std::ios::out);
161 if (!outFile.bad()) {
163 std::vector<unsigned long> v =
put();
164 for (
unsigned int i=0; i<v.size(); ++i) {
165 outFile << v[i] <<
"\n";
std::vector< unsigned long > put() const
void CLHEP::RanshiEngine::setSeed |
( |
long |
seed, |
|
|
int |
|
|
) |
| |
|
virtual |
void CLHEP::RanshiEngine::setSeeds |
( |
const long * |
seeds, |
|
|
int |
|
|
) |
| |
|
virtual |
Implements CLHEP::HepRandomEngine.
Definition at line 142 of file RanshiEngine.cc.
145 while (seeds[i] && i < numBuff) {
149 while (i < numBuff) {
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
void CLHEP::RanshiEngine::showStatus |
( |
| ) |
const |
|
virtual |
Implements CLHEP::HepRandomEngine.
Definition at line 203 of file RanshiEngine.cc.
204 std::cout << std::setprecision(20) << std::endl;
205 std::cout <<
"----------- Ranshi engine status ----------" << std::endl;
206 std::cout <<
"Initial seed = " <<
theSeed << std::endl;
207 std::cout <<
"Current red spin = " << redSpin << std::endl;
208 std::cout <<
"Values produced = " << numFlats << std::endl;
209 std::cout <<
"Side of buffer = " << (halfBuff ?
"upper" :
"lower")
211 std::cout <<
"Current buffer = " << std::endl;
212 for (
int i = 0; i < numBuff; i+=4) {
213 std::cout << std::setw(10) << std::setiosflags(std::ios::right)
214 <<
buffer[i] << std::setw(11) <<
buffer[i+1] << std::setw(11)
215 <<
buffer[i+2] << std::setw(11) <<
buffer[i+3] << std::endl;
217 std::cout <<
"-------------------------------------------" << std::endl;
The documentation for this class was generated from the following files: