37 #ifndef EGS_RANDOM_GENERATOR_
38 #define EGS_RANDOM_GENERATOR_
48 rngBlock.
addSingleInput(
"type",
true,
"Algorithm used for RNG. Defaults to ranmar", {
"ranmar"});
49 rngBlock.
addSingleInput(
"initial seeds",
true,
"Two integers that represent the inital seed. The same input file running on the same computer will give idential results for the same seeds, and statistically independent for different seeds. Parallel runs automatically vary the seeds for each job.");
50 rngBlock.
addSingleInput(
"high resolution",
false,
"Defaults to no. Microscale simulations may require high resolution RNG.", {
"No",
"Yes"});
53 inline void addRngDefinitionBlock(
const std::shared_ptr<EGS_InputStruct> &blockPtr) {
55 addRngDefinitionBlockImpl(*rngBlock);
58 inline void addRngDefinitionBlock(
const std::shared_ptr<EGS_BlockInput> &blockPtr) {
60 addRngDefinitionBlockImpl(*blockPtr);
63 inline string addRngDefinitionExample() {
66 :start rng definition:
132 inline EGS_Float getUniform() {
134 fillArray(np,rarray);
145 EGS_I64 numbersGenerated()
const {
154 EGS_I64 numbersUsed()
const {
155 return ip<np ? count - np + ip : count;
167 inline void getAzimuth(EGS_Float &cphi, EGS_Float &sphi) {
169 EGS_Float xphi,xphi2,yphi,yphi2,rhophi;
171 xphi = 2*getUniform() - 1;
175 rhophi = xphi2 + yphi2;
178 cphi = (xphi2 - yphi2)/rhophi;
179 sphi = 2*xphi*yphi/rhophi;
181 EGS_Float phi = 2*M_PI*getUniform();
190 inline EGS_Float getGaussian() {
195 EGS_Float r = sqrt(-2*log(1-getUniform()));
196 EGS_Float cphi, sphi;
197 getAzimuth(cphi,sphi);
238 virtual void fillArray(
int n, EGS_Float *array) = 0;
256 bool storeState(ostream &data);
257 bool setState(istream &data);
258 bool addState(istream &data);
259 void resetCounter() {
271 virtual void saveState() = 0;
274 virtual void resetState() = 0;
277 virtual int rngSize()
const = 0;
285 virtual void describeRNG()
const {};
303 virtual bool storePrivateState(ostream &data) = 0;
312 virtual bool setPrivateState(istream &data) = 0;
316 void allocate(
int n);
319 int baseSize()
const {
320 return 2*
sizeof(EGS_I32) +
sizeof(EGS_I64) +
sizeof(bool) +
321 sizeof(EGS_Float) + np*
sizeof(EGS_Float);
Base random number generator class. All random number generators should be derived from this class.
Global egspp functions header file.
Defines the EGS_EXPORT and EGS_LOCAL macros.
#define EGS_EXPORT
Export symbols from the egspp library.
Attempts to fix broken math header files.