Program Listing for File rng.hpp
↰ Return to documentation for file (rcppsw/math/rng.hpp
)
#pragma once
/*******************************************************************************
* Includes
******************************************************************************/
#include "rcppsw/rcppsw.hpp"
#include "rcppsw/math/range.hpp"
#include "rcppsw/patterns/pimpl/pimpl.hpp"
/*******************************************************************************
* Namespaces/Decls
******************************************************************************/
namespace rcppsw::math {
namespace detail {
struct rng_impl;
} /* namespace detail */
/*******************************************************************************
* Class Definitions
******************************************************************************/
class rng final : public patterns::pimpl::pimpl<detail::rng_impl> {
public:
explicit rng(size_t seed);
~rng(void) override;
size_t seed(void) const { return m_seed; }
template <typename T>
T uniform(const T& lb, const T& ub);
template <typename T>
T uniform(const range<T>& c_range) {
return uniform(c_range.lb(), c_range.ub());
}
double gaussian(double mean, double std_dev);
double exponential(double lambda);
bool bernoulli(double p);
private:
/* clang-format off */
size_t m_seed;
/* clang-format on */
};
} /* namespace rcppsw::math */