![]() |
CASToR
1.1
Tomographic Reconstruction (PET/SPECT)
|
Singleton class that generate a thread-safe random generator number for openMP
As singleton, it can be called from any class requiring RNGs.
More...
#include <sRandomNumberGenerator.hh>

Public Types | |
| typedef mt19937 | Engine |
| typedef uniform_real_distribution < double > | Distribution |
Public Member Functions | |
| int | Initialize (int a_nbThreads) |
| Instanciate a number of RNG according to the number of threads used in openMP. More... | |
| int | Initialize (int64_t a_seed, int a_nbThreads) |
| double | GenerateRdmNber () |
| Generate a random number for the thread whose index is recovered from the ompenMP function. More... | |
| double | GenerateNonThreadedRdmNber () |
| Generate a random number using the not thread safe random generator, for use in sequential parts of an otherwise multithreaded code. More... | |
| Engine * | GetNonThreadedGenerator () |
| Get the not thread safe random generator, for use in sequential parts of an otherwise multithreaded code. More... | |
| void | SetVerbose (int a_verboseLevel) |
| Set verbosity level. More... | |
Static Public Member Functions | |
| static sRandomNumberGenerator * | GetInstance () |
| Instanciate the singleton object and Initialize member variables if not already done, return a pointer to this object otherwise. More... | |
Private Member Functions | |
| sRandomNumberGenerator () | |
| Constructor of sRandomNumberGenerator. Do nothing by default as it is a singleton clasee. More... | |
| ~sRandomNumberGenerator () | |
| Destructor of sRandomNumberGenerator. Do nothing by default. More... | |
| sRandomNumberGenerator (sRandomNumberGenerator const &) | |
| void | operator= (sRandomNumberGenerator const &) |
Private Attributes | |
| int | m_verbose |
| vector< Engine > | mp_Engines |
| Engine * | mp_NonThreadedEngine |
| Distribution | mp_Distribution |
Static Private Attributes | |
| static sRandomNumberGenerator * | mp_Instance = NULL |
Singleton class that generate a thread-safe random generator number for openMP
As singleton, it can be called from any class requiring RNGs.
Definition at line 23 of file sRandomNumberGenerator.hh.
| typedef uniform_real_distribution<double> sRandomNumberGenerator::Distribution |
Distribution which produces random floating-point values i, uniformly distributed on the interval [a, b)
Definition at line 45 of file sRandomNumberGenerator.hh.
| typedef mt19937 sRandomNumberGenerator::Engine |
Engine using C++11 Mersenne Twister pseudo-random generator of 32-bit numbers
Definition at line 44 of file sRandomNumberGenerator.hh.
|
private |
Constructor of sRandomNumberGenerator. Do nothing by default as it is a singleton clasee.
Definition at line 93 of file sRandomNumberGenerator.hh.

|
private |
Destructor of sRandomNumberGenerator. Do nothing by default.
Definition at line 49 of file sRandomNumberGenerator.cc.
|
private |
| double sRandomNumberGenerator::GenerateNonThreadedRdmNber | ( | ) |
Generate a random number using the not thread safe random generator, for use in sequential parts of an otherwise multithreaded code.
Definition at line 159 of file sRandomNumberGenerator.cc.
| double sRandomNumberGenerator::GenerateRdmNber | ( | ) |
Generate a random number for the thread whose index is recovered from the ompenMP function.
Definition at line 134 of file sRandomNumberGenerator.cc.

|
inlinestatic |
Instanciate the singleton object and Initialize member variables if not already done, return a pointer to this object otherwise.
Definition at line 34 of file sRandomNumberGenerator.hh.


| sRandomNumberGenerator::Engine * sRandomNumberGenerator::GetNonThreadedGenerator | ( | ) |
Get the not thread safe random generator, for use in sequential parts of an otherwise multithreaded code.
Definition at line 180 of file sRandomNumberGenerator.cc.
| int sRandomNumberGenerator::Initialize | ( | int | a_nbThreads | ) |
Instanciate a number of RNG according to the number of threads used in openMP.
| a_nbThreads |
It uses a std::random_device as initial seed for each thread
Definition at line 67 of file sRandomNumberGenerator.cc.

| int sRandomNumberGenerator::Initialize | ( | int64_t | a_seed, |
| int | a_nbThreads | ||
| ) |
Definition at line 98 of file sRandomNumberGenerator.cc.
|
private |
|
inline |
Set verbosity level.
| a_verboseLevel |
Definition at line 93 of file sRandomNumberGenerator.hh.

|
private |
Verbosity Level
Definition at line 118 of file sRandomNumberGenerator.hh.
|
private |
Uniform distribution
Definition at line 122 of file sRandomNumberGenerator.hh.
|
private |
Multithreaded of mt199937 Engines (1 by thread)
Definition at line 119 of file sRandomNumberGenerator.hh.
|
staticprivate |
Unique instance of the singleton class
Definition at line 117 of file sRandomNumberGenerator.hh.
|
private |
Single random generator, not thread safe, for use in sequential parts of multithreaded code, independently of multithreaded generators
Definition at line 120 of file sRandomNumberGenerator.hh.
1.8.6