C++ mpi module for stochmagnet_main Package
SM_STDStochasticFunctions.h
1 #ifndef SM_STDStochasticFunctions_H
2 #define SM_STDStochasticFunctions_H
3 
4 //super class header
5 #include "SM_StochasticFunctions.h"
6 
7 //distribution headers
8 #include "RNDSTD_NormalDistribution.h"
9 #include "RNDSTD_UniformRealDistribution.h"
10 
11 
12 //for seed generator
13 #include "RNDSTD_UniformIntDistribution.h"
14 
24 template<class G>
25 class SM_STDStochasticFunctions : public SM_StochasticFunctions<SM_STDStochasticFunctions<G>> {
26 
27  // ATTRIBUTES
28 
29 public:
30 
31 
32 
33 private:
34 
35  //type of class
38 
39 
40  //distribution
41  RNDSTD_NormalDistribution mNormalDistribution;
42  RNDSTD_UniformRealDistribution mUniform01Distribution;
43 
44  //random number generator
45  G mRNG;
46 
47 
48 protected:
49  // METHODS
50 
51  // CONSTRUCTORS
52 
56  mUniform01Distribution.setSupport(0,1);
58  }
59 private:
60 
61 
62 
63 
64  // DESTRUCTORS
65 protected:
66 
70  }
71 
72 
73 
74 public:
75  //MEMORY
76 
90  virtual tMemSize getMemorySize() const {
91  return sizeof(*this)+this->getContentsMemorySize();
92  }
93 
94 
95 public:
96 
97  // CREATE class
101  inline static CORE_UniquePointer<SelfClass> New() {
102  CORE_UniquePointer<SelfClass> p=CORE_UniquePointer<SelfClass>(new SelfClass(),
104 
105  //return the boost stochastic function
106  return p;
107  }
108 
109 
110  // SET &GET methods
111  // =================
112 
113 
114 
118  virtual void setSeed(const tULLInt& seed) override {
119  mRNG.setSeed(seed);
120  }
123  virtual void setSeed() override {
124  mRNG.setSeed();
125  }
126 
127 
128 
133  virtual void jump(const tInteger& jumps,const tULLInt& seed) {
134  this->setSeed(seed);
135  }
136 
137 
138  //Random methods
139  //===============
140 
144  inline tReal scNormalRandom() {
145  //CORE_Profiler::StartCallRoutine("SM_STDStochasticFunctions::templatedNormalRandom()");
146  return mNormalDistribution.random(mRNG);
147  //CORE_Profiler::EndCallRoutine("SM_STDStochasticFunctions::templatedNormalRandom()");
148  }
152  inline tReal scUniformRandom() {
153  //CORE_Profiler::StartCallRoutine("SM_STDStochasticFunctions::templatedUniformRandom()");
154  return mUniform01Distribution.random(mRNG);
155  //CORE_Profiler::EndCallRoutine("SM_STDStochasticFunctions::templatedUniformRandom()");
156  }
157 
158 
159 
160 };
161 
162 #include "RNDSTD_MT19937.h"
164 #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
This class implements a stochastic function with a real uniform law implemented from the boost librar...
Definition: RNDSTD_NormalDistribution.h:16
This class implements a stochastic function with a real uniform law in [0,1[ implemented from the boo...
Definition: RNDSTD_UniformRealDistribution.h:15
void setSupport(const T &a, const T &b)
set the support of the random function
Definition: RNDSTD_UniformRealDistribution.h:107
This class implements virtual methods of SM_StochasticFunctions using math/random/std classes.
Definition: SM_STDStochasticFunctions.h:25
virtual void jump(const tInteger &jumps, const tULLInt &seed)
jump a number of virtual random number generator
Definition: SM_STDStochasticFunctions.h:133
virtual ~SM_STDStochasticFunctions(void)
destroy
Definition: SM_STDStochasticFunctions.h:69
tReal scNormalRandom()
return a random number
Definition: SM_STDStochasticFunctions.h:144
tReal scUniformRandom()
compute a uniform random number in [0,1[
Definition: SM_STDStochasticFunctions.h:152
static CORE_UniquePointer< SelfClass > New()
build a new instance of default class factory
Definition: SM_STDStochasticFunctions.h:101
virtual void setSeed() override
void set seed
Definition: SM_STDStochasticFunctions.h:123
virtual tMemSize getMemorySize() const
return the memory size of the class and the memory size of all its attributes/associations
Definition: SM_STDStochasticFunctions.h:90
virtual void setSeed(const tULLInt &seed) override
void set seed
Definition: SM_STDStochasticFunctions.h:118
SM_STDStochasticFunctions(void)
create
Definition: SM_STDStochasticFunctions.h:55
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