C++ main module for stochmagnet Package  1.0
SMS_STDUniformFunction.h
Go to the documentation of this file.
1 #ifndef SMS_STDUniformFunction_H
2 #define SMS_STDUniformFunction_H
3 
5 
6 //header for std::nomal law
7 #include <random>
8 
15 class SMS_STDUniformFunction : public SM_TemplatedStochasticFunction<SMS_STDUniformFunction> {
16  // ATTRIBUTES
17 
18 private:
19  static std::random_device mGenerator;
20  static std::mt19937 mRNGenerator;
21 
22 
23 
24  std::uniform_real_distribution<tReal> *mRandomDistribution;
25 
26 
27 
28 public:
29  // METHODS
30 
31  // CONSTRUCTORS
32 
35 
36 
37 
38  // DESTRUCTORS
39 
40 
43  virtual ~SMS_STDUniformFunction(void) ;
44 
45 
46 
47 public:
48 
49 
56  }
57 
58  public:
59 
60  //MEMORY
74  virtual tMemSize getMemorySize() const {
75  return sizeof(*this)+getContentsMemorySize();
76  }
77 
86  virtual tMemSize getContentsMemorySize() const {
88  mem+=(mRandomDistribution==null)?0:sizeof(*mRandomDistribution);
89 
90  return mem;
91  }
92 
93 
94 private:
97  inline static std::mt19937& getRNGenerator() {
98  return mRNGenerator;
99  };
100 
101  // --------------------
102  // ATTRIBUTES setting
103  // --------------------
104 public:
105  inline void setSupport(const tReal& a,const tReal& b) {
106  setProperties((a+b)/2.,fabs(b-a)/sqrt(12));
107  }
108 
113  virtual void setProperties(const tReal& mean,
114  const tReal& sd) override;
115 
116 
120  virtual void initializeSeed(const tULLInt& seed) override;
121 
125  virtual tReal random() const override {
126  return templatedRandom();
127  }
131  inline tReal templatedRandom() const {
132  return (*mRandomDistribution)(getRNGenerator());
133  }
134 
135 
136 
137 
138 
139 };
140 
141 #endif
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:94
virtual tMemSize getContentsMemorySize() const
return nthe memory size of the included associations
Definition: CORE_Object.h:259
This class implements a stochastic function with a normal law implemented from the boost library.
Definition: SMS_STDUniformFunction.h:15
static std::mt19937 mRNGenerator
Definition: SMS_STDUniformFunction.h:20
static std::mt19937 & getRNGenerator()
get the generator
Definition: SMS_STDUniformFunction.h:97
virtual ~SMS_STDUniformFunction(void)
destroy an object.
Definition: SMS_STDUniformFunction.cpp:18
std::uniform_real_distribution< tReal > * mRandomDistribution
Definition: SMS_STDUniformFunction.h:24
static std::random_device mGenerator
Definition: SMS_STDUniformFunction.h:19
static CORE_UniquePointer< SMS_STDUniformFunction > New()
build a new instance of the stochasticfunction
Definition: SMS_STDUniformFunction.h:53
void setSupport(const tReal &a, const tReal &b)
Definition: SMS_STDUniformFunction.h:105
virtual tMemSize getMemorySize() const
return the memory size of the class and the memory size of all its attributes/associations
Definition: SMS_STDUniformFunction.h:74
tReal templatedRandom() const
random return a random numbers in range
Definition: SMS_STDUniformFunction.h:131
virtual void initializeSeed(const tULLInt &seed) override
initialize the seed
Definition: SMS_STDUniformFunction.cpp:36
virtual tReal random() const override
random return a random numbers in range
Definition: SMS_STDUniformFunction.h:125
virtual void setProperties(const tReal &mean, const tReal &sd) override
set the properties of the stochastic futcion
Definition: SMS_STDUniformFunction.cpp:24
virtual tMemSize getContentsMemorySize() const
return the memory size of the included associations
Definition: SMS_STDUniformFunction.h:86
SMS_STDUniformFunction()
create an object
Definition: SMS_STDUniformFunction.cpp:9
This class describes a templated stochastic function to generate random numbers.
Definition: SM_TemplatedStochasticFunction.h:15
typename std::unique_ptr< T, CORE_Object::Delete > CORE_UniquePointer
Definition: sp.h:8
#define tULLInt
Definition: types.h:58
#define tMemSize
Definition: types.h:166
#define tReal
Definition: types.h:137