TF++, Miscellaneous classes and modules in C++:

◆ RNGgaussian()

tfxx::numeric::RNGgaussian::RNGgaussian ( const double &  std = 1.,
const double &  mean = 0.,
const char *  type = "default" 
)
explicit

initialize random number generator

Definition at line 52 of file rng.cc.

References MR, TFXX_assert, TFXX_Xassert, and type().

54  :
55  Mstd(std), Mmean(mean)
56  {
57  if (std::string(type) == "default")
58  {
59  gsl_rng_env_setup();
60  const gsl_rng_type* T=gsl_rng_default;
61  MR=gsl_rng_alloc(T);
62  TFXX_assert(MR!=NULL, "gsl_rng_alloc(T) failed to initialize RNG");
63  }
64  else
65  {
66  const gsl_rng_type* T=NULL;
67  const gsl_rng_type **t, **t0;
68  t0 = gsl_rng_types_setup ();
69 
70  for (t = t0; *t != 0; t++)
71  {
72  if (std::string((*t)->name)==std::string(type)) { T=(*t); }
73  }
74  TFXX_Xassert(T!=NULL, type, UTException);
75  MR=gsl_rng_alloc(T);
76  TFXX_assert(MR!=NULL, "gsl_rng_alloc(T) failed to initialize RNG");
77  }
78  this->set(gsl_rng_default_seed);
79  }
#define TFXX_assert(C, M)
Check an assertion and report by throwing an exception.
Definition: error.h:175
STL namespace.
double Mstd
store standard deviation and mean value
Definition: rng.h:107
double mean() const
return mean
Definition: rng.h:100
std::string type() const
return type of random number generator
Definition: rng.h:94
#define TFXX_Xassert(C, M, E)
Check an assertion and report by throwing an exception.
Definition: error.h:166
gsl_rng * MR
pointer to RNG
Definition: rng.h:109
Here is the call graph for this function: