gambit is hosted by Hepforge, IPPP Durham
GAMBIT  v1.5.0-252-gf9a3f78
a Global And Modular Bsm Inference Tool

#include <threadsafe_rng.hpp>

Collaboration diagram for Gambit::Random:

Static Public Member Functions

static void create_rng_engine (str, int=-1)
 Choose the engine to use for random number generation, based on the contents of the ini file. More...
 
static double draw ()
 Draw a single uniform random deviate from the interval (0,1) using the chosen RNG engine. More...
 
static Utils::threadsafe_rngrng ()
 Return a threadsafe wrapper for the chosen RNG engine (to be passed to e.g. More...
 

Private Member Functions

 Random ()
 Private constructor makes this a purely managerial class, i.e. unable to be instantiated. More...
 

Static Private Attributes

static Utils::threadsafe_rnglocal_rng = NULL
 Pointer to the actual RNG. More...
 

Detailed Description

Definition at line 125 of file threadsafe_rng.hpp.

Constructor & Destructor Documentation

◆ Random()

Gambit::Random::Random ( )
inlineprivate

Private constructor makes this a purely managerial class, i.e. unable to be instantiated.

Definition at line 143 of file threadsafe_rng.hpp.

143 {};

Member Function Documentation

◆ create_rng_engine()

void Gambit::Random::create_rng_engine ( str  engine,
int  seed = -1 
)
static

Choose the engine to use for random number generation, based on the contents of the ini file.

Definition at line 63 of file threadsafe_rng.cpp.

References ENABLE_ALL_RNGS, Gambit::EOM, LOCAL_INFO, local_rng, Gambit::logger(), Gambit::LogTags::utils, and Gambit::utils_error().

Referenced by draw(), and main().

64  {
65  using namespace std;
66  if (engine == "default")
67  {
68  engine = "mt19937_64 (default)";
69  static Utils::specialised_threadsafe_rng<mt19937_64> ultralocal_rng(seed);
70  local_rng = &ultralocal_rng;
71  }
73  else utils_error().raise(LOCAL_INFO, "Unknown random number generation engine: "+engine+". Please check your yaml file.");
74  logger() << LogTags::utils << "Random number engine " << engine << " selected with ";
75  if (seed == -1) logger() << "hardware random ";
76  logger() << "seed " << seed << "." << EOM;
77  }
EXPORT_SYMBOLS error & utils_error()
Utility errors.
#define LOCAL_INFO
Definition: local_info.hpp:34
STL namespace.
static Utils::threadsafe_rng * local_rng
Pointer to the actual RNG.
const Logging::endofmessage EOM
Explicit const instance of the end of message struct in Gambit namespace.
Definition: logger.hpp:99
Logging::LogMaster & logger()
Function to retrieve a reference to the Gambit global log object.
Definition: logger.cpp:95
#define ENABLE_ALL_RNGS
Here is the call graph for this function:
Here is the caller graph for this function:

◆ draw()

double Gambit::Random::draw ( )
static

Draw a single uniform random deviate from the interval (0,1) using the chosen RNG engine.

Draw a single uniform random deviate in the range (0,1) using the chosen RNG engine.

Definition at line 80 of file threadsafe_rng.cpp.

References create_rng_engine(), local_rng, and rng().

Referenced by Gambit::DarkBit::cascadeMC_sampleSimYield(), Ran::Doub(), Gambit::ColliderBit::getColliderPythia(), Gambit::DarkBit::DecayChain::rand_0_1(), scanner_plugin(), and topnesscompute().

81  {
82  if (local_rng == NULL) create_rng_engine("default", -1);
83  return std::generate_canonical<double, 32>(rng());
84  }
static Utils::threadsafe_rng * local_rng
Pointer to the actual RNG.
static void create_rng_engine(str, int=-1)
Choose the engine to use for random number generation, based on the contents of the ini file...
static Utils::threadsafe_rng & rng()
Return a threadsafe wrapper for the chosen RNG engine (to be passed to e.g.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rng()

static Utils::threadsafe_rng& Gambit::Random::rng ( )
inlinestatic

Member Data Documentation

◆ local_rng

Utils::threadsafe_rng * Gambit::Random::local_rng = NULL
staticprivate

Pointer to the actual RNG.

Pointer to chosen random number generation engine.

Definition at line 143 of file threadsafe_rng.hpp.

Referenced by create_rng_engine(), and draw().


The documentation for this class was generated from the following files: