32 #ifndef VSMC_RNG_EXPONENTIAL_DISTRIBUTION_HPP 33 #define VSMC_RNG_EXPONENTIAL_DISTRIBUTION_HPP 44 template <
typename RealType>
54 template <
typename RealType>
67 template <
typename RNGType>
79 template <
typename RealType,
typename RNGType>
81 RNGType &rng, std::size_t n, RealType *r, RealType lambda)
84 sub(n, static_cast<RealType>(1), r, r);
86 mul(n, -1 / lambda, r, r);
93 template <
typename RealType,
typename RNGType>
95 RNGType &rng, std::size_t n, RealType *r, RealType lambda)
97 static_assert(std::is_floating_point<RealType>::value,
98 "**exponential_distribution** USED WITH RealType OTHER THAN FLOATING " 101 const std::size_t k = 1024;
102 const std::size_t m = n / k;
103 const std::size_t l = n % k;
104 for (std::size_t i = 0; i != m; ++i, r += k)
113 #endif // VSMC_RNG_EXPONENTIAL_DISTRIBUTION_HPP
void mul(std::size_t n, const float *a, const float *b, float *y)
bool exponential_distribution_check_param(RealType lambda)
void exponential_distribution(RNGType &rng, std::size_t n, RealType *r, RealType lambda)
Generating exponential random variates.
void u01_distribution(RNGType &, std::size_t, RealType *)
Generate standard uniform random variates.
result_type lambda() const
Exponential distribution.
void sub(std::size_t n, const float *a, const float *b, float *y)
Standard uniform distribution.
void exponential_distribution_impl(RNGType &rng, std::size_t n, RealType *r, RealType lambda)
void log(std::size_t n, const float *a, float *y)
#define VSMC_DEFINE_RNG_DISTRIBUTION_RAND_1(Name, name, p1)
#define VSMC_DEFINE_RNG_DISTRIBUTION_1(Name, name, p1, v1)