tk::RNG class

Random number generator.

This class uses runtime polymorphism without client-side inheritance: inheritance is confined to the internals of the this class, invisible to client-code. The class exclusively deals with ownership enabling client-side value semantics. Credit goes to Sean Parent at Adobe: https://github.com/sean-parent/sean-parent.github.com/wiki/ Papers-and-Presentations. For example client code that models a RNG, see see tk::MKLRNG or tk::RNGSSE.

Constructors, destructors, conversion operators

template<typename T>
RNG(T x) explicit
Constructor taking an object modeling Concept.
template<typename T>
RNG(std::function<T()> x) explicit
Constructor taking a function pointer to a constructor of an object modeling Concept.
RNG(const RNG& x)
Copy constructor.
RNG(RNG&&) noexcept defaulted
Move constructor.

Public functions

void uniform(int stream, ncomp_t num, double* r) const
Public interface to uniform RNG.
void gaussian(int stream, ncomp_t num, double* r) const
Public interface to Gaussian RNG.
void gaussianmv(int stream, ncomp_t num, ncomp_t d, const double*const mean, const double*const cov, double* r) const
Public interface to multi-variate Gaussian RNG.
void beta(int stream, ncomp_t num, double p, double q, double a, double b, double* r) const
Public interface to beta RNG.
void gamma(int stream, ncomp_t num, double a, double b, double* r) const
Public interface to gamma RNG.
auto nthreads() const -> std::size_t noexcept
Public interface to number of threads accessor.
auto operator=(const RNG& x) -> RNG&
Copy assignment.
auto operator=(RNG&&) noexcept -> RNG& defaulted
Move assignment.

Function documentation

template<typename T>
tk::RNG::RNG(T x) explicit

Constructor taking an object modeling Concept.

Parameters
in Instantiated object of type T given by the template argument.

The object of class T comes pre-constructed.

template<typename T>
tk::RNG::RNG(std::function<T()> x) explicit

Constructor taking a function pointer to a constructor of an object modeling Concept.

Parameters
in Function pointer to a constructor of an object modeling Concept

Passing std::function allows late execution of the constructor, i.e., as late as inside this class' constructor, and thus usage from a factory.