7#include <initializer_list>
23template <
typename t>
struct uniform_distribution_selector;
25template <>
struct uniform_distribution_selector<
uint_t>
27 typedef std::uniform_int_distribution<uint_t> distribution_type;
30template <>
struct uniform_distribution_selector<
int_t>
32 typedef std::uniform_int_distribution<int_t> distribution_type;
35template <>
struct uniform_distribution_selector<
lint_t>
37 typedef std::uniform_int_distribution<lint_t> distribution_type;
40template <>
struct uniform_distribution_selector<
real_t>
42 typedef std::uniform_real_distribution<real_t> distribution_type;
45template <>
struct uniform_distribution_selector<
float_t>
47 typedef std::uniform_real_distribution<float_t> distribution_type;
60 typedef std::pair<out_type, out_type> range_type;
80 out_type sample(
uint_t seed);
85 range_type range()
const {
return range_; }
92template <
typename OutType>
94 typename UniformDist<OutType>::out_type
b)
95 : range_(
a,
b), distribution_(
a,
b)
99template <
typename OutType>
100UniformDist<OutType>::UniformDist(
typename UniformDist<OutType>::range_type range)
105template <
typename OutType>
typename UniformDist<OutType>::out_type UniformDist<OutType>::sample()
109 std::random_device
rd;
112 std::mt19937
gen(
rd());
114 return distribution_(
gen);
117template <
typename OutType>
118typename UniformDist<OutType>::out_type UniformDist<OutType>::sample(
uint_t seed)
121 std::mt19937
gen(seed);
122 return distribution_(
gen);
156 std::vector<real_t>
probabilities()
const {
return distribution_.probabilities(); }
160 std::discrete_distribution<out_type> distribution_;
163template <
typename OutType,
typename WeightType>
164template <
typename VectorType>
170template <
typename OutType,
typename WeightType>
172 std::initializer_list<WeightType>
weights)
177template <
typename OutType,
typename WeightType>
183 std::random_device
rd;
186 std::mt19937
gen(
rd());
187 return distribution_(
gen);
190template <
typename OutType,
typename WeightType>
195 std::mt19937
gen(seed);
196 return distribution_(
gen);
OutT resolve(const std::string &name, const std::map< std::string, std::any > &input)
Definition std_map_utils.h:25
Definition bitrl_consts.h:14
int int_t
integer type
Definition bitrl_types.h:33
long int lint_t
long int type
Definition bitrl_types.h:38
double real_t
real_t
Definition bitrl_types.h:23
std::size_t uint_t
uint_t
Definition bitrl_types.h:43
float float_t
float
Definition bitrl_types.h:28