32 #ifndef VSMC_RNG_CAUCHY_DISTRIBUTION_HPP 33 #define VSMC_RNG_CAUCHY_DISTRIBUTION_HPP 44 template <
typename RealType>
54 template <
typename RealType>
62 return std::numeric_limits<result_type>::lowest();
70 template <
typename RNGType>
76 param.
b() *
std::tan(const_pi<result_type>() * (1 - u01(rng)));
83 template <
typename RealType,
typename RNGType>
85 RNGType &rng, std::size_t n, RealType *r, RealType a, RealType b)
88 sub(n, static_cast<RealType>(1), r, r);
89 mul(n, const_pi<RealType>(), r, r);
91 for (std::size_t i = 0; i != n; ++i)
99 template <
typename RealType,
typename RNGType>
101 RNGType &rng, std::size_t n, RealType *r, RealType a, RealType b)
103 static_assert(std::is_floating_point<RealType>::value,
104 "**cauchy_distribution** USED WITH RealType OTHER THAN FLOATING POINT " 107 const std::size_t k = 1024;
108 const std::size_t m = n / k;
109 const std::size_t l = n % k;
110 for (std::size_t i = 0; i != m; ++i, r += k)
119 #endif // VSMC_RNG_CAUCHY_DISTRIBUTION_HPP
bool cauchy_distribution_check_param(RealType, RealType b)
void mul(std::size_t n, const float *a, const float *b, float *y)
#define VSMC_DEFINE_RNG_DISTRIBUTION_2(Name, name, p1, v1, p2, v2)
void cauchy_distribution_impl(RNGType &rng, std::size_t n, RealType *r, RealType a, RealType b)
void cauchy_distribution(RNGType &rng, std::size_t n, RealType *r, RealType a, RealType b)
Generating cauchy random variates.
void u01_distribution(RNGType &, std::size_t, RealType *)
Generate standard uniform random variates.
void sub(std::size_t n, const float *a, const float *b, float *y)
Standard uniform distribution.
#define VSMC_DEFINE_RNG_DISTRIBUTION_RAND_2(Name, name, p1, p2)
void tan(std::size_t n, const float *a, float *y)