C++ mpi module for stochmagnet_main Package
SM_TRNGStochasticFunctions_MT19937.h
1 #ifndef SM_TRNGStochasticFunctions_MT19937_H
2 #define SM_TRNGStochasticFunctions_MT19937_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 //for seed generator
12 #include "TRNG_UniformIntDistribution.h"
13 
14 //RNG header
15 #include "TRNG_MT19937.h"
16 
24 class SM_TRNGStochasticFunctions_MT19937 : public SM_StochasticFunctions<SM_TRNGStochasticFunctions_MT19937> {
25 
26  // ATTRIBUTES
27 
28 public:
29 
30 
31 
32 private:
33 
34  //type of class
35  typedef TRNG_MT19937 G;
38 
39  //distribution
40  TRNG_NormalDistribution mNormalDistribution;
41  TRNG_Uniform01Distribution mUniform01Distribution;
42 
43  //random number generator
44  G mRNG;
45 
46 
47 protected:
48  // METHODS
49 
50  // CONSTRUCTORS
51 
56  }
57 private:
58 
59 
60 
61 
62  // DESTRUCTORS
63 protected:
64 
68  }
69 
70 
71 
72 public:
73  //MEMORY
74 
88  virtual tMemSize getMemorySize() const {
89  return sizeof(*this)+this->getContentsMemorySize();
90  }
91 
92 
93 public:
94 
95  // CREATE class
99  inline static CORE_UniquePointer<SelfClass> New() {
100  CORE_UniquePointer<SelfClass> p=CORE_UniquePointer<SelfClass>(new SelfClass(),
102 
103  //return the boost stochastic function
104  return p;
105  }
106 
107 
108  // SET &GET methods
109  // =================
110 
114  virtual void setSeed(const tULLInt& seed) override {
115  mRNG.setSeed(seed);
116  }
119  virtual void setSeed() override {
120  mRNG.setSeed();
121  }
122 
127  virtual void jump(const tInteger& jumps,const tULLInt& seed) {
128  this->setSeed(seed);
129  }
130 
131 
132 
133  //RANDOM methods
134  //============
135 
136 
140  inline tReal scNormalRandom() {
141  //CORE_Profiler::StartCallRoutine("SM_TRNGStochasticFunctions_MT19937::templatedNormalRandom()");
142  return mNormalDistribution.random(mRNG);
143  //CORE_Profiler::EndCallRoutine("SM_TRNGStochasticFunctions_MT19937::templatedNormalRandom()");
144  }
148  inline tReal scUniformRandom() {
149  //CORE_Profiler::StartCallRoutine("SM_TRNGStochasticFunctions_MT19937::templatedUniformRandom()");
150  return mUniform01Distribution.random(mRNG);
151  //CORE_Profiler::EndCallRoutine("SM_TRNGStochasticFunctions_MT19937::templatedUniformRandom()");
152  }
153 
154 
155 };
156 
157 
158 #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
void setSeed(const tULInt &seed)
initialize the seed of the random number generator
Definition: RAND_RandomNumberGenerator.h:107
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 a SM_StochasticFunctions using trng normal class wuith MT19937 random number ge...
Definition: SM_TRNGStochasticFunctions_MT19937.h:24
virtual tMemSize getMemorySize() const
return the memory size of the class and the memory size of all its attributes/associations
Definition: SM_TRNGStochasticFunctions_MT19937.h:88
virtual void setSeed() override
void set seed
Definition: SM_TRNGStochasticFunctions_MT19937.h:119
virtual void jump(const tInteger &jumps, const tULLInt &seed)
jump a number of virtual random number generator
Definition: SM_TRNGStochasticFunctions_MT19937.h:127
tReal scNormalRandom()
return a random number
Definition: SM_TRNGStochasticFunctions_MT19937.h:140
static CORE_UniquePointer< SelfClass > New()
build a new instance of default class factory
Definition: SM_TRNGStochasticFunctions_MT19937.h:99
virtual ~SM_TRNGStochasticFunctions_MT19937(void)
destroy
Definition: SM_TRNGStochasticFunctions_MT19937.h:67
SM_TRNGStochasticFunctions_MT19937(void)
create
Definition: SM_TRNGStochasticFunctions_MT19937.h:54
tReal scUniformRandom()
compute a uniform random number in [0,1]
Definition: SM_TRNGStochasticFunctions_MT19937.h:148
virtual void setSeed(const tULLInt &seed) override
void set seed
Definition: SM_TRNGStochasticFunctions_MT19937.h:114
This class generates a random number generator by process The Mersenne twister is a popular random nu...
Definition: TRNG_MT19937.h:20
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