32 #ifndef MCKL_RANDOM_GEOMETRIC_DISTRIBUTION_HPP 33 #define MCKL_RANDOM_GEOMETRIC_DISTRIBUTION_HPP 44 return p > 0 && p <= 1;
47 template <std::
size_t K,
typename IntType,
typename RNGType>
49 RNGType &rng, std::size_t n, IntType *r,
double p)
53 log(n, s.data(), s.data());
55 floor(n, s.data(), s.data());
56 for (std::size_t i = 0; i != n; ++i) {
57 r[i] = ftoi<IntType>(s[i]);
64 Geometric, geometric, InType,
double, p)
66 template <
typename IntType>
73 Geometric, geometric, IntType,
double, p, 0.5)
84 template <
typename RNGType>
90 param == param_ ? lnpinv_ : 1 /
std::log(1 - param.
p());
93 return internal::ftoi<IntType>(r);
101 #endif // MCKL_RANDOM_GEOMETRIC_DISTRIBUTION_HPP
void mul(std::size_t n, const float *a, const float *b, float *y)
void u01_oc_distribution(RNGType &rng, std::size_t n, RealType *r)
void log(std::size_t n, const float *a, float *y)
Standard uniform distribution on (0, 1].
#define MCKL_DEFINE_RANDOM_DISTRIBUTION_RAND(Name, T)
RealType u01(UIntType u)
Convert uniform unsigned integers to floating points within [0, 1].
#define MCKL_DEFINE_RANDOM_DISTRIBUTION_MEMBER_1(T1, m1)
void floor(std::size_t n, const float *a, float *y)
bool geometric_distribution_check_param(double p)
void geometric_distribution_impl(RNGType &rng, std::size_t n, IntType *r, double p)
#define MCKL_ALIGNMENT
The default alignment for scalar type.
#define MCKL_DEFINE_RANDOM_DISTRIBUTION_BATCH_1(Name, name, T, T1, p1)
#define MCKL_DEFINE_RANDOM_DISTRIBUTION_1(Name, name, T, T1, p1, v1)
#define MCKL_DEFINE_RANDOM_DISTRIBUTION_ASSERT_INT_TYPE(Name, MinBits)