32 #ifndef MCKL_RANDOM_TESTU01_HPP 33 #define MCKL_RANDOM_TESTU01_HPP 62 bool empty()
const {
return gen_ ==
nullptr; }
65 template <
typename RNGType,
typename U01Type>
66 void reset(
const std::string &name,
bool parallel =
false)
68 parallel ?
reset(name, u01_mt<RNGType, U01Type, 1024, 8>) :
69 reset(name, u01_st<RNGType, U01Type, 4096>);
73 template <
typename RNGType,
typename U01Type, std::
size_t N, std::
size_t M>
74 void reset(
const std::string &name,
bool parallel =
false)
76 parallel ?
reset(name, u01_mt<RNGType, U01Type, N, M>) :
77 reset(name, u01_st<RNGType, U01Type, N>);
81 void reset(
const std::string &name,
double (*
u01)())
85 ::unif01_CreateExternGen01(const_cast<char *>(name.c_str()),
u01);
92 ::unif01_DeleteExternGen01(gen_);
97 ::unif01_Gen *
gen()
const {
return gen_; }
100 template <
typename Battery>
114 template <
typename BatteryRepeat>
118 battery_repeat(gen_, rep.data());
128 template <
typename BatteryRepeat,
typename InputIter>
130 BatteryRepeat &&battery_repeat, InputIter first, InputIter last,
int n)
133 battery_repeat(gen_, rep.data());
141 template <
typename RNGType,
typename U01Type, std::
size_t N, std::
size_t M>
142 static double u01_mt()
145 static std::size_t index = N * M;
148 static bool init =
false;
151 if (index == N * M) {
157 double *r = result.data();
158 for (std::size_t i = 0; i != M; ++i, r += N) {
159 RNGType rng(std::move(rs[i]));
162 rs[i] = std::move(rng);
167 return result[index++];
170 template <
typename RNGType,
typename U01Type, std::
size_t N>
171 static double u01_st()
174 static std::size_t index = N;
185 return result[index++];
190 template <
typename InputIter>
191 static Vector<int> repeat(InputIter first, InputIter last,
int n)
194 for (InputIter iter = first; iter != last; ++iter) {
196 rep[
static_cast<std::size_t
>(*iter)] += n;
205 #endif // MCKL_RANDOM_TESTU01_HPP
void reset(const std::string &name, bool parallel=false)
Reset the TestU01 generator to specified RNG and distribution.
void reset(const std::string &name, double(*u01)())
Reset the TestU01 generator to specified distribution.
#define MCKL_PUSH_CLANG_WARNING(warning)
TestU01 & operator=(const TestU01 &)=delete
std::vector< T, Alloc > Vector
std::vector with Allocator as the default allocator
::unif01_Gen * gen() const
Get the TestU01 generator.
RealType u01(UIntType u)
Convert uniform unsigned integers to floating points within [0, 1].
void operator()(Battery &&battery)
Apply a battery that accepts a unif01_Gen pointer as input.
bool empty() const
Return true if the TestU01 generator is not set or released.
void reset(const std::string &name, bool parallel=false)
Reset the TestU01 generator to specified RNG and distribution.
Perform TestU01 tests on different RNG and U01 types.
void operator()(BatteryRepeat &&battery_repeat, int n)
Apply a battery that accepts a unif01_Gen pointer as the first input, and an array of type int that s...
void rand(RNGType &rng, ArcsineDistribution< RealType > &distribution, std::size_t N, RealType *r)
#define MCKL_POP_CLANG_WARNING
static TestU01 & instance()
void operator()(BatteryRepeat &&battery_repeat, InputIter first, InputIter last, int n)
Apply a battery that accepts a unif01_Gen pointer as the first input, and an array of type int that s...
void release()
Release the TestU01 generator.
RNG default seed generator.