C++ mpi module for stochmagnet_main Package
SM_BoostStochasticFunctions.h
1 #ifndef SM_BoostStochasticFunctions_H
2 #define SM_BoostStochasticFunctions_H
3 
4 //super class header
5 #include "SM_StochasticFunctions.h"
6 
7 
8 //distribution headers
9 #include "RNDB_NormalDistribution.h"
10 #include "RNDB_Uniform01Distribution.h"
11 
12 //for seed generator
13 #include "RNDB_UniformIntDistribution.h"
14 
24 template<class G>
25 class SM_BoostStochasticFunctions : public SM_StochasticFunctions<SM_BoostStochasticFunctions<G>> {
26 
27  // ATTRIBUTES
28 
29 public:
30 
31 
32 
33 private:
34 
35  //type of class
38 
39 
40  //normal distribution for boost
41  RNDB_NormalDistribution mNormalDistribution;
42  //real uniform distribution in [0,1] for boost
43  RNDB_Uniform01Distribution mUniform01Distribution;
44 
45  //random number generator
46  G mRNG;
47 
48 protected:
49  // METHODS
50 
51  // CONSTRUCTORS
52 
57  }
58 private:
59 
60 
61 
62 
63  // DESTRUCTORS
64 protected:
65 
69  }
70 
71 
72 
73 public:
74  //MEMORY
75 
89  virtual tMemSize getMemorySize() const {
90  return sizeof(*this)+this->getContentsMemorySize();
91  }
92 
93 
94 public:
95 
96  // CREATE class
100  inline static CORE_UniquePointer<SelfClass> New() {
101  CORE_UniquePointer<SelfClass> p=CORE_UniquePointer<SelfClass>(new SelfClass(),
103 
104  //return the boost stochastic function
105  return p;
106  }
107 
108 
109 
110  // SET & GET methods
111  // ===================
112 
113 
117  virtual void setSeed(const tULLInt& seed) override {
118  mRNG.setSeed(seed);
119  }
122  virtual void setSeed() override {
123  mRNG.setSeed();
124  }
125 
130  virtual void jump(const tInteger& nJumps,const tULLInt& seed) override {
131  setSeed(seed);
132  }
133 
134 
135  //RANDOM methods
136  //==============
137 
138 
142  inline tReal scNormalRandom() {
143  //CORE_Profiler::StartCallRoutine("SM_BoostStochasticFunctions::templatedNormalRandom()");
144  return mNormalDistribution.random(mRNG);
145  //CORE_Profiler::EndCallRoutine("SM_BoostStochasticFunctions::templatedNormalRandom()");
146  }
150  inline tReal scUniformRandom() {
151  //CORE_Profiler::StartCallRoutine("SM_BoostStochasticFunctions::templatedUniformRandom()");
152  return mUniform01Distribution.random(mRNG);
153  //CORE_Profiler::EndCallRoutine("SM_BoostStochasticFunctions::templatedUniformRandom()");
154  }
155 
156 
157 };
158 
159 //RNG
160 #include "RNDB_MT19937.h"
162 
163 #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 normal law distribution.
Definition: RNDB_NormalDistribution.h:15
This class implements a an uniform real law distribution in [0,1[ with the boost library.
Definition: RNDB_Uniform01Distribution.h:15
This class implements virtual methods of a SM_StochasticFunctions using math/random/boost classes.
Definition: SM_BoostStochasticFunctions.h:25
virtual void jump(const tInteger &nJumps, const tULLInt &seed) override
jump a number of virtual random number generator or sett the seed if the jump method is not available
Definition: SM_BoostStochasticFunctions.h:130
SM_BoostStochasticFunctions(void)
create
Definition: SM_BoostStochasticFunctions.h:55
tReal scUniformRandom()
compute a uniform random number in [0,1]
Definition: SM_BoostStochasticFunctions.h:150
virtual ~SM_BoostStochasticFunctions(void)
destroy
Definition: SM_BoostStochasticFunctions.h:68
virtual void setSeed(const tULLInt &seed) override
void set seed
Definition: SM_BoostStochasticFunctions.h:117
virtual void setSeed() override
void set seed
Definition: SM_BoostStochasticFunctions.h:122
tReal scNormalRandom()
return a random number
Definition: SM_BoostStochasticFunctions.h:142
static CORE_UniquePointer< SelfClass > New()
build a new instance of default class factory
Definition: SM_BoostStochasticFunctions.h:100
virtual tMemSize getMemorySize() const
return the memory size of the class and the memory size of all its attributes/associations
Definition: SM_BoostStochasticFunctions.h:89
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