40 const unsigned long MASK32=0xffffffff;
56 int numEngines = ++numberOfEngines;
58 setSeed(static_cast<long>(numEngines));
91 if (
this == &rng) {
return *
this; }
95 HepRandomEngine::operator=(rng);
110 FILE *fh= fopen(filename,
"w");
127 std::cout << std::endl;
128 std::cout <<
"------- MixMaxRng engine status -------" << std::endl;
130 std::cout <<
" Current state vector is:" << std::endl;
131 fRngState->
fh=stdout;
133 std::cout <<
"---------------------------------------" << std::endl;
141 if(
sizeof(
long) > 4)
142 seed0=
static_cast<unsigned long>(longSeed) &
MASK32 ;
155 unsigned long seed0, seed1= 0, seed2= 0, seed3= 0;
158 seed0=
static_cast<unsigned long>(Seeds[0]) &
MASK32;
159 seed1=
static_cast<unsigned long>(Seeds[1]) &
MASK32;
164 seed0=
static_cast<unsigned long>(Seeds[0]) &
MASK32;
165 if( seedNum > 1){ seed1=
static_cast<unsigned long>(Seeds[1]) &
MASK32; }
166 if( seedNum > 2){ seed2=
static_cast<unsigned long>(Seeds[2]) &
MASK32; }
169 seed0=
static_cast<unsigned long>(Seeds[0]) &
MASK32;
170 seed1=
static_cast<unsigned long>(Seeds[1]) &
MASK32;
171 seed2=
static_cast<unsigned long>(Seeds[2]) &
MASK32;
172 seed3=
static_cast<unsigned long>(Seeds[3]) &
MASK32;
188 for (
int i=0; i<size; ++i) { vect[i] =
flat(); }
191 MixMaxRng::operator
unsigned int()
193 return static_cast<unsigned int>(
get_next(fRngState));
200 char beginMarker[] =
"MixMaxRng-begin";
201 char endMarker[] =
"MixMaxRng-end";
203 int pr = os.precision(24);
204 os << beginMarker <<
" ";
207 os << fRngState->
V[i] <<
"\n";
209 os << fRngState->
counter <<
"\n";
210 os << fRngState->
sumtot <<
"\n";
211 os << endMarker <<
"\n";
218 std::vector<unsigned long>
v;
219 v.push_back (engineIDulong<MixMaxRng>());
221 v.push_back(static_cast<unsigned long>(fRngState->
V[i] &
MASK32));
223 v.push_back(static_cast<unsigned long>(fRngState->
V[i] >> 32 ));
226 v.push_back(static_cast<unsigned long>(fRngState->
counter));
227 v.push_back(static_cast<unsigned long>(fRngState->
sumtot &
MASK32));
228 v.push_back(static_cast<unsigned long>(fRngState->
sumtot >> 32));
240 if (strcmp(beginMarker,
"MixMaxRng-begin")) {
241 is.clear(std::ios::badbit | is.rdstate());
242 std::cerr <<
"\nInput stream mispositioned or"
243 <<
"\nMixMaxRng state description missing or"
244 <<
"\nwrong engine type found." << std::endl;
252 return "MixMaxRng-begin";
259 for (
int i=0; i<rng_get_N(); ++i) is >> fRngState->
V[i];
266 if (strcmp(endMarker,
"MixMaxRng-end")) {
267 is.clear(std::ios::badbit | is.rdstate());
268 std::cerr <<
"\nMixMaxRng state description incomplete."
269 <<
"\nInput stream is probably mispositioned now.\n";
273 std::cerr <<
"\nMixMaxRng::getState(): "
274 <<
"vector read wrong value of counter from file!"
275 <<
"\nInput stream is probably mispositioned now.\n";
279 if ( checksum != fRngState->
sumtot) {
280 std::cerr <<
"\nMixMaxRng::getState(): "
281 <<
"checksum disagrees with value stored in file!"
282 <<
"\nInput stream is probably mispositioned now.\n";
290 if ((v[0] & 0xffffffffUL) != engineIDulong<MixMaxRng>()) {
292 "\nMixMaxRng::get(): vector has wrong ID word - state unchanged\n";
302 "\nMixMaxRng::getState(): vector has wrong length - state unchanged\n";
306 fRngState->
V[i/2]= ( (v[i] &
MASK32) | ( (
myuint)(v[i+1]) << 32 ) );
313 std::cerr <<
"\nMixMaxRng::getState(): vector has wrong checksum!"
314 <<
"\nInput vector is probably mispositioned now.\n";
void restoreStatus(const char filename[]="MixMaxRngState.conf")
void print_state(rng_state_t *X)
static const int MarkerLen
myuint get_next(rng_state_t *X)
const unsigned long MASK32
virtual std::istream & getState(std::istream &is)
MixMaxRng & operator=(const MixMaxRng &rng)
void setSeeds(const long *seeds, int seedNum=0)
int rng_free(rng_state_t *X)
static std::string beginTag()
void seed_uniquestream(rng_state_t *X, myID_t clusterID, myID_t machineID, myID_t runID, myID_t streamID)
std::vector< unsigned long > put() const
static const unsigned int VECTOR_STATE_SIZE
void seed_spbox(rng_state_t *X, myuint seed)
double get_next_float(rng_state_t *X)
#define CLHEP_ATOMIC_INT_TYPE
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
rng_state_t * rng_alloc()
rng_state_t * rng_copy(myuint *Y)
void flatArray(const int size, double *vect)
void setSeed(long seed, int dum=0)
myuint precalc(rng_state_t *X)
void saveStatus(const char filename[]="MixMaxRngState.conf") const
virtual std::istream & get(std::istream &is)
void read_state(rng_state_t *X, const char filename[])