OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
RNGStream.h
Go to the documentation of this file.
1 #ifndef RNGSTREAM_H
2 #define RNGSTREAM_H
3 
4 #include <random>
5 
6 class RNGStream
7 {
8 public:
9  static RNGStream* getInstance();
10  static RNGStream* getInstance(unsigned int seed);
11  static void deleteInstance(RNGStream* & generator);
12 
13  static void setGlobalSeed(unsigned int seed);
14 
15  static unsigned int getGlobalSeed();
16 
17  std::mt19937_64 & getGenerator();
18 
19  template <class DISTR>
20  typename DISTR::result_type getNext(DISTR & RNGDist) {
21  return RNGDist(RNGenerator_m);
22  }
23 
24 private:
27  isGlobal_m(true)
28  { }
29 
30  RNGStream(unsigned int seed):
31  RNGenerator_m(seed),
32  isGlobal_m(false)
33  { }
34 
36  { }
37 
39  static unsigned int globalSeed_sm;
40  static unsigned int numGlobalInstances_sm;
41  std::mt19937_64 RNGenerator_m;
42  bool isGlobal_m;
43 
44 };
45 #endif
RNGStream()
Definition: RNGStream.h:25
int seed
The current random seed.
Definition: Options.cpp:41
static unsigned int numGlobalInstances_sm
Definition: RNGStream.h:40
bool isGlobal_m
Definition: RNGStream.h:42
static RNGStream * globalInstance_sm
Definition: RNGStream.h:38
std::mt19937_64 & getGenerator()
Definition: RNGStream.cpp:47
std::mt19937_64 RNGenerator_m
Definition: RNGStream.h:41
static void setGlobalSeed(unsigned int seed)
Definition: RNGStream.cpp:36
static unsigned int getGlobalSeed()
Definition: RNGStream.cpp:43
static unsigned int globalSeed_sm
Definition: RNGStream.h:39
static void deleteInstance(RNGStream *&generator)
Definition: RNGStream.cpp:21
DISTR::result_type getNext(DISTR &RNGDist)
Definition: RNGStream.h:20
RNGStream(unsigned int seed)
Definition: RNGStream.h:30
static RNGStream * getInstance()
Definition: RNGStream.cpp:9
~RNGStream()
Definition: RNGStream.h:35