C++ mpi module for stochmagnet_main Package
SM_TRNGStochasticFunctions.h
1 #ifndef SM_TRNGStochasticFunctions_H
2 #define SM_TRNGStochasticFunctions_H
3 
4 //super class header
5 #include "SM_StochasticFunctions.h"
6 
7 //distribution headers
8 #include "TRNG_NormalDistribution.h"
9 #include "TRNG_Uniform01Distribution.h"
10 
11 
21 template<class G>
22 class SM_TRNGStochasticFunctions : public SM_StochasticFunctions<SM_TRNGStochasticFunctions<G>> {
23 
24  // ATTRIBUTES
25 
26 public:
27 
28 
29 
30 private:
31 
32  //type of class
35 
36 
37  //distribution
38  TRNG_NormalDistribution mNormalDistribution;
39  TRNG_Uniform01Distribution mUniform01Distribution;
40 
41  //random number generator
42  G mRNG;
43 
44 
45 protected:
46  // METHODS
47 
48  // CONSTRUCTORS
49 
54  }
55 private:
56 
57 
58 
59 
60  // DESTRUCTORS
61 protected:
62 
66  }
67 
68 
69 
70 public:
71  //MEMORY
72 
86  virtual tMemSize getMemorySize() const {
87  return sizeof(*this)+this->getContentsMemorySize();
88  }
89 
90 
91 public:
92 
93  // CREATE class
97  inline static CORE_UniquePointer<SelfClass> New() {
98  CORE_UniquePointer<SelfClass> p=CORE_UniquePointer<SelfClass>(new SelfClass(),
100 
101  //return the boost stochastic function
102  return p;
103  }
104 
105 
106  // SET &GET methods
107  // =================
108 
109 
113  virtual void setSeed(const tULLInt& seed) override {
114  mRNG.setSeed(seed);
115  }
118  virtual void setSeed() override {
119  mRNG.setSeed();
120  }
125  virtual void jump(const tInteger& nJumps,const tULLInt& seed) {
126  mRNG.jump(nJumps);
127  }
128 
129 
130  //RANDOM methods
131  //============
132 
133 
137  inline tReal scNormalRandom() {
138  //CORE_Profiler::StartCallRoutine("SM_TRNGStochasticFunctions::templatedNormalRandom()");
139  return mNormalDistribution.random(mRNG);
140  //CORE_Profiler::EndCallRoutine("SM_TRNGStochasticFunctions::templatedNormalRandom()");
141  }
142 
146  inline tReal scUniformRandom() {
147  //CORE_Profiler::StartCallRoutine("SM_TRNGStochasticFunctions::templatedUniformRandom()");
148  return mUniform01Distribution.random(mRNG);
149  //CORE_Profiler::EndCallRoutine("SM_TRNGStochasticFunctions::templatedUniformRandom()");
150  }
151 
152 
153 
154 
155 
156 };
157 
158 
159 #include "TRNG_LCG64.h"
160 #include "TRNG_YARN2.h"
161 #include "TRNG_MRG2.h"
162 #include "TRNG_MRG3.h"
163 #include "TRNG_MRG3s.h"
164 #include "TRNG_MRG4.h"
165 #include "TRNG_MRG5.h"
166 #include "TRNG_MRG5s.h"
167 
176 
177 #endif
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:113
virtual tMemSize getContentsMemorySize() const
return nthe memory size of the included associations
Definition: CORE_Object.h:278
T random(RAND_RandomNumberGenerator< T1, G, D1 > &generator)
random a number
Definition: RAND_RandomNumberDistribution.h:116
static void SetIsThreadSafe(const tBoolean &b)
set if the sochastic function is thread safe
Definition: SM_StochasticFunctionsInterface.h:134
This class describes a stochastic functions with templated methods.
Definition: SM_StochasticFunctions.h:25
This class implements virtiual methods of SM_StochasticFunctions using trng normal class.
Definition: SM_TRNGStochasticFunctions.h:22
virtual void setSeed() override
set seed
Definition: SM_TRNGStochasticFunctions.h:118
virtual void setSeed(const tULLInt &seed) override
void set seed
Definition: SM_TRNGStochasticFunctions.h:113
tReal scNormalRandom()
return a random number
Definition: SM_TRNGStochasticFunctions.h:137
virtual tMemSize getMemorySize() const
return the memory size of the class and the memory size of all its attributes/associations
Definition: SM_TRNGStochasticFunctions.h:86
tReal scUniformRandom()
return a random number in [0,1]
Definition: SM_TRNGStochasticFunctions.h:146
SM_TRNGStochasticFunctions(void)
create
Definition: SM_TRNGStochasticFunctions.h:52
virtual ~SM_TRNGStochasticFunctions(void)
destroy
Definition: SM_TRNGStochasticFunctions.h:65
static CORE_UniquePointer< SelfClass > New()
build a new instance of default class factory
Definition: SM_TRNGStochasticFunctions.h:97
virtual void jump(const tInteger &nJumps, const tULLInt &seed)
jump a number of virtual random number generator
Definition: SM_TRNGStochasticFunctions.h:125
This class generates a normal distribution with random number generator class G.
Definition: TRNG_NormalDistribution.h:16
This class generates an uniform random distribution in [0,1[ with random number generator class G.
Definition: TRNG_Uniform01Distribution.h:16