37 #ifndef EGS_RANDOM_GENERATOR_
38 #define EGS_RANDOM_GENERATOR_
105 fillArray(np,rarray);
126 return ip<np ? count - np + ip : count;
140 register EGS_Float xphi,xphi2,yphi,yphi2,rhophi;
142 xphi = 2*getUniform() - 1;
146 rhophi = xphi2 + yphi2;
149 cphi = (xphi2 - yphi2)/rhophi;
150 sphi = 2*xphi*yphi/rhophi;
152 EGS_Float phi = 2*M_PI*getUniform();
166 EGS_Float r = sqrt(-2*log(1-getUniform()));
167 EGS_Float cphi, sphi;
168 getAzimuth(cphi,sphi);
209 virtual void fillArray(
int n, EGS_Float *array) = 0;
227 bool storeState(ostream &data);
228 bool setState(istream &data);
229 bool addState(istream &data);
230 void resetCounter() {
242 virtual void saveState() = 0;
245 virtual void resetState() = 0;
248 virtual int rngSize()
const = 0;
274 virtual bool storePrivateState(ostream &data) = 0;
283 virtual bool setPrivateState(istream &data) = 0;
287 void allocate(
int n);
291 return 2*
sizeof(EGS_I32) +
sizeof(EGS_I64) +
sizeof(bool) +
292 sizeof(EGS_Float) + np*
sizeof(EGS_Float);
#define EGS_EXPORT
Export symbols from the egspp library.
virtual ~EGS_RandomGenerator()
Destructor.
void getAzimuth(EGS_Float &cphi, EGS_Float &sphi)
Sets cphi and sphi to the cosine and sine of a random angle uniformely distributed between 0 and ...
int baseSize() const
The memory needed to store the base state.
Global egspp functions header file.
EGS_I64 numbersUsed() const
Returns the number of random numbers used so far.
EGS_RandomGenerator(const EGS_RandomGenerator &r)
Copy constructor.
Base random number generator class. All random number generators should be derived from this class...
EGS_I64 numbersGenerated() const
Returns the number of random numbers generated so far.
Attempts to fix broken math header files.
EGS_Float getGaussian()
Returns a Gaussian distributed random number with mean zero and standard deviation 1...
virtual void describeRNG() const
Describe this RNG.
EGS_Float getUniform()
Returns a random number uniformly distributed between zero (inclusive) and 1 (exclusive).
int ip
pointer to the next rarray element in the sequence
Defines the EGS_EXPORT and EGS_LOCAL macros.
int np
size of the array rarray
EGS_Float * rarray
array with random numbers of size np.