CASToR  1.1
Tomographic Reconstruction (PET/SPECT)
 All Classes Files Functions Variables Typedefs Macros Groups Pages
sRandomNumberGenerator.hh
Go to the documentation of this file.
1 
9 #ifndef SRANDOMNUMBERGENERATOR_HH
10 #define SRANDOMNUMBERGENERATOR_HH 1
11 
12 #include "gVariables.hh"
13 #include "sOutputManager.hh"
14 
15 
16 
17 
24 {
25  // -------------------------------------------------------------------
26  // Constructor & Destructor
27  public:
35  {
36  if (mp_Instance == NULL) mp_Instance = new sRandomNumberGenerator();
37  return mp_Instance;
38  }
39 
40 
41  // -------------------------------------------------------------------
42  // Public member functions
43  public:
44  typedef mt19937 Engine;
45  typedef uniform_real_distribution<double> Distribution;
53  int Initialize(int a_nbThreads);
54 
64  int Initialize(int64_t a_seed, int a_nbThreads);
73  double GenerateRdmNber();
93  void SetVerbose(int a_verboseLevel) {m_verbose = a_verboseLevel;};
94 
95 
96  // -------------------------------------------------------------------
97  // Private member functions
98  private:
109  // Prevent the compiler generating methods of copy the object :
111  void operator=(sRandomNumberGenerator const&);
112 
113 
114  // -------------------------------------------------------------------
115  // Data members
116  private:
118  int m_verbose;
119  vector<Engine> mp_Engines;
123 };
124 
125 #endif
126 
This header file is mainly used to declare some macro definitions and all includes needed from the st...
static sRandomNumberGenerator * GetInstance()
Instanciate the singleton object and Initialize member variables if not already done, return a pointer to this object otherwise.
double GenerateRdmNber()
Generate a random number for the thread whose index is recovered from the ompenMP function...
double GenerateNonThreadedRdmNber()
Generate a random number using the not thread safe random generator, for use in sequential parts of a...
void SetVerbose(int a_verboseLevel)
Set verbosity level.
void operator=(sRandomNumberGenerator const &)
int Initialize(int a_nbThreads)
Instanciate a number of RNG according to the number of threads used in openMP.
sRandomNumberGenerator()
Constructor of sRandomNumberGenerator. Do nothing by default as it is a singleton clasee...
Singleton class that generate a thread-safe random generator number for openMP As singleton...
uniform_real_distribution< double > Distribution
Declaration of class sOutputManager.
static sRandomNumberGenerator * mp_Instance
~sRandomNumberGenerator()
Destructor of sRandomNumberGenerator. Do nothing by default.
Engine * GetNonThreadedGenerator()
Get the not thread safe random generator, for use in sequential parts of an otherwise multithreaded c...