Stride Reference Manual  1.0
RNG.h
Go to the documentation of this file.
1 /*
2  * RNG.h
3  *
4  * Created on: Apr 20, 2017
5  * Author: elise
6  */
7 
8 #pragma once
9 
10 #include <trng/mrg2.hpp>
11 #include <trng/uniform01_dist.hpp>
12 
13 namespace stride {
14 
15 class RNG {
16 private:
17  RNG() {
18  m_uniform_dist = trng::uniform01_dist<double>();
19  }
20 
21  RNG(const RNG&);
22 
23  RNG& operator=(const RNG&);
24 
25 public:
26  static RNG& getInstance() {
27  static RNG instance;
28  return instance;
29  }
30 
31  double nextDouble() {
32  return m_uniform_dist(m_engine);
33  }
34 
35 private:
36  trng::mrg2 m_engine;
37  trng::uniform01_dist<double> m_uniform_dist;
38 };
39 
40 }
Time Dependent Person DataType.
Definition: NoBehaviour.h:17
RNG()
Definition: RNG.h:17
static RNG & getInstance()
Definition: RNG.h:26
trng::mrg2 m_engine
The random number engine.
Definition: RNG.h:36
RNG & operator=(const RNG &)
double nextDouble()
Definition: RNG.h:31
trng::uniform01_dist< double > m_uniform_dist
The random distribution.
Definition: RNG.h:37