32 #ifndef VSMC_RNG_U01_DISTRIBUTION_HPP 33 #define VSMC_RNG_U01_DISTRIBUTION_HPP 48 template <
typename RealType,
typename Left,
typename Right>
49 class U01LRDistribution
71 template <
typename CharT,
typename Traits>
73 std::basic_ostream<CharT, Traits> &os,
const param_type &)
78 template <
typename CharT,
typename Traits>
80 std::basic_istream<CharT, Traits> &is,
param_type &)
94 template <
typename RNGType>
98 typename std::conditional<internal::RNGBits<RNGType>::value >= 64,
100 using flt_type =
typename std::conditional<
101 std::is_same<result_type, float>::value ||
102 std::is_same<result_type, double>::value,
110 template <
typename RNGType>
116 template <
typename RNGType>
119 u01_lr_distribution<RealType, Left, Right>(rng, n, r);
122 template <
typename RNGType>
124 RNGType &rng, std::size_t n,
result_type *r,
const param_type &)
126 u01_lr_distribution<RealType, Left, Right>(rng, n, r);
141 template <
typename CharT,
typename Traits>
143 std::basic_ostream<CharT, Traits> &os,
149 template <
typename CharT,
typename Traits>
151 std::basic_istream<CharT, Traits> &is,
160 template <
typename RealType =
double>
165 template <
typename RealType =
double>
170 template <
typename RealType =
double>
175 template <
typename RealType =
double>
180 template <
typename RealType =
double>
186 template <std::size_t K,
typename RealType,
typename Left,
typename Right,
192 for (std::size_t i = 0; i != n; ++i)
200 template <
typename RealType,
typename Left,
typename Right,
typename RNGType>
203 const std::size_t k = 1000;
204 const std::size_t m = n / k;
205 const std::size_t l = n % k;
206 for (std::size_t i = 0; i != m; ++i, r += k) {
207 internal::u01_lr_distribution_impl<k, RealType, Left, Right>(
210 internal::u01_lr_distribution_impl<k, RealType, Left, Right>(rng, l, r);
215 template <
typename RealType,
typename RNGType>
218 u01_lr_distribution<RealType, Closed, Closed>(rng, n, r);
223 template <
typename RealType,
typename RNGType>
226 u01_lr_distribution<RealType, Closed, Open>(rng, n, r);
231 template <
typename RealType,
typename RNGType>
234 u01_lr_distribution<RealType, Open, Closed>(rng, n, r);
239 template <
typename RealType,
typename RNGType>
242 u01_lr_distribution<RealType, Open, Open>(rng, n, r);
247 template <
typename RealType,
typename RNGType>
253 template <
typename RealType,
typename RNGType,
typename Left,
typename Right>
255 std::size_t n, RealType *r)
262 #endif // VSMC_RNG_U01_HPP
Standard uniform distribution with open/closed variants.
result_type operator()(RNGType &rng, const param_type &)
void u01_oo_distribution(RNGType &rng, std::size_t n, RealType *r)
Generate standard uniform random variates on open-open interval.
void u01_lr_distribution_impl(RNGType &rng, std::size_t n, RealType *r)
void rng_rand(RNGType &rng, BernoulliDistribution< IntType > &dist, std::size_t n, IntType *r)
friend std::basic_istream< CharT, Traits > & operator>>(std::basic_istream< CharT, Traits > &is, param_type &)
void u01_distribution(RNGType &, std::size_t, RealType *)
Generate standard uniform random variates.
friend bool operator==(const U01LRDistribution< RealType, Left, Right > &, const U01LRDistribution< RealType, Left, Right > &)
U01LRDistribution(const param_type &)
friend std::basic_istream< CharT, Traits > & operator>>(std::basic_istream< CharT, Traits > &is, U01LRDistribution< RealType, Left, Right > &)
void u01_lr_distribution(RNGType &, std::size_t, RealType *)
Generate standard uniform random variates with open/closed variants.
void u01_co_distribution(RNGType &rng, std::size_t n, RealType *r)
Generate standard uniform random variates on closed-open interval.
void operator()(RNGType &rng, std::size_t n, result_type *r)
void operator()(RNGType &rng, std::size_t n, result_type *r, const param_type &)
friend bool operator==(const param_type &, const param_type &)
friend std::basic_ostream< CharT, Traits > & operator<<(std::basic_ostream< CharT, Traits > &os, const param_type &)
friend bool operator!=(const param_type &, const param_type &)
friend bool operator!=(const U01LRDistribution< RealType, Left, Right > &, const U01LRDistribution< RealType, Left, Right > &)
result_type operator()(RNGType &rng)
void u01_cc_distribution(RNGType &rng, std::size_t n, RealType *r)
Generate standard uniform random variates on closed-closed interval.
void uniform_bits_distribution(RNGType &, std::size_t, UIntType *)
void u01_oc_distribution(RNGType &rng, std::size_t n, RealType *r)
Generate standard uniform random variates on open-closed interval.
friend std::basic_ostream< CharT, Traits > & operator<<(std::basic_ostream< CharT, Traits > &os, const U01LRDistribution< RealType, Left, Right > &)