47 #include "RandEngine.h"
51 RandEngine::RandEngine(
long seed) : mx(RAND_MAX)
58 RandEngine::~RandEngine() {}
60 RandEngine::RandEngine(
const RandEngine &p) : mx(RAND_MAX)
65 if ((
this != &p) && (&p)) {
68 for (HepInt i=0; i<p.seq; ++i) flat();
78 if ((
this != &p) && (&p)) {
81 for (HepInt i=0; i<p.seq; ++i) flat();
87 void RandEngine::setSeed(
long seed, HepInt)
90 srand( HepInt(seed) );
94 void RandEngine::setSeeds(
const long* seeds, HepInt)
96 setSeed(seeds ? *seeds : 19780503, 0);
100 void RandEngine::saveStatus()
const
102 ofstream outFile(
"Rand.conf", std::ios::out ) ;
104 if (!outFile.bad()) {
105 outFile << theSeed << endl;
106 outFile << seq << endl;
110 void RandEngine::restoreStatus()
117 ifstream inFile(
"Rand.conf", std::ios::in);
120 if (!inFile.bad() && !inFile.eof()) {
124 for (HepInt i=0; i<count; ++i) flat();
128 void RandEngine::showStatus()
const
131 cout <<
"---------- Rand engine status ----------" << endl;
132 cout <<
" Initial seed = " << theSeed << endl;
133 cout <<
" Shooted sequences = " << seq << endl;
134 cout <<
"----------------------------------------" << endl;
137 HepDouble RandEngine::flat()
147 void RandEngine::flatArray(
const HepInt size, HepDouble* vect)
151 for (i=0; i<size; ++i)
155 #ifndef ST_NO_TEMPLATE_DEF_ARGS
156 void RandEngine::flatArray(vector<HepDouble>& vec)
158 void RandEngine::flatArray(vector<HepDouble,allocator<HepDouble> >& vec)
161 for (
unsigned int i=0; i<vec.size(); ++i)