CASToR  1.0
Tomographic Reconstruction (PET/SPECT)
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
sRNG Class Reference

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 <sRNG.hh>

Collaboration diagram for sRNG:
Collaboration graph
[legend]

List of all members.

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.
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.
double GenerateNonThreadedRdmNber ()
 Generate a random number using the not thread safe random generator, for use in sequential parts of an otherwise multithreaded code.
EngineGetNonThreadedGenerator ()
 Get the not thread safe random generator, for use in sequential parts of an otherwise multithreaded code.
void SetVerbose (int a_verboseLevel)
 Set verbosity level.

Static Public Member Functions

static sRNGGetInstance ()
 Instanciate the singleton object and Initialize member variables if not already done, return a pointer to this object otherwise.

Private Member Functions

 sRNG ()
 Constructor of sRNG. Do nothing by default as it is a singleton clasee.
 ~sRNG ()
 Destructor of sRNG. Do nothing by default.
 sRNG (sRNG const &)
void operator= (sRNG const &)

Private Attributes

int m_verbose
vector< Enginemp_Engines
Enginemp_NonThreadedEngine
Distribution mp_Distribution

Static Private Attributes

static sRNGmp_Instance = NULL

Detailed Description

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 sRNG.hh.


Member Typedef Documentation

typedef uniform_real_distribution<double> sRNG::Distribution

Distribution which produces random floating-point values i, uniformly distributed on the interval [a, b)

Definition at line 45 of file sRNG.hh.

typedef mt19937 sRNG::Engine

Engine using C++11 Mersenne Twister pseudo-random generator of 32-bit numbers

Definition at line 44 of file sRNG.hh.


Constructor & Destructor Documentation

sRNG::sRNG ( ) [private]

Constructor of sRNG. Do nothing by default as it is a singleton clasee.

Definition at line 93 of file sRNG.hh.

Here is the caller graph for this function:

sRNG::~sRNG ( ) [private]

Destructor of sRNG. Do nothing by default.

Definition at line 49 of file sRNG.cc.

sRNG::sRNG ( sRNG const &  ) [private]

Member Function Documentation

Generate a random number using the not thread safe random generator, for use in sequential parts of an otherwise multithreaded code.

Returns:
double random number

Definition at line 159 of file sRNG.cc.

Generate a random number for the thread whose index is recovered from the ompenMP function.

Returns:
a random generated number in [0. ; 1.)

Definition at line 134 of file sRNG.cc.

Here is the caller graph for this function:

static sRNG * sRNG::GetInstance ( ) [inline, static]

Instanciate the singleton object and Initialize member variables if not already done, return a pointer to this object otherwise.

Returns:
instance of the sRNG singleton

Definition at line 34 of file sRNG.hh.

Here is the call graph for this function:

Here is the caller graph for this function:

Get the not thread safe random generator, for use in sequential parts of an otherwise multithreaded code.

Returns:
double random number

Definition at line 180 of file sRNG.cc.

int sRNG::Initialize ( int  a_nbThreads)

Instanciate a number of RNG according to the number of threads used in openMP.

Parameters:
a_nbThreads

It uses a std::random_device as initial seed for each thread

Returns:
0 if success, positive value otherwise

Definition at line 67 of file sRNG.cc.

Here is the caller graph for this function:

int sRNG::Initialize ( int64_t  a_seed,
int  a_nbThreads 
)

Definition at line 98 of file sRNG.cc.

void sRNG::operator= ( sRNG const &  ) [private]
void sRNG::SetVerbose ( int  a_verboseLevel) [inline]

Set verbosity level.

Parameters:
a_verboseLevel

Definition at line 93 of file sRNG.hh.

Here is the caller graph for this function:


Member Data Documentation

int sRNG::m_verbose [private]

Verbosity Level

Definition at line 118 of file sRNG.hh.

Uniform distribution

Definition at line 122 of file sRNG.hh.

vector<Engine> sRNG::mp_Engines [private]

Multithreaded of mt199937 Engines (1 by thread)

Definition at line 119 of file sRNG.hh.

sRNG * sRNG::mp_Instance = NULL [static, private]

Unique instance of the singleton class

Definition at line 117 of file sRNG.hh.

Single random generator, not thread safe, for use in sequential parts of multithreaded code, independently of multithreaded generators

Definition at line 120 of file sRNG.hh.


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Typedefs Defines