32 #ifndef MCKL_RANDOM_PHILOX_HPP 33 #define MCKL_RANDOM_PHILOX_HPP 55 #ifndef MCKL_PHILOX_ROUNDS 56 #define MCKL_PHILOX_ROUNDS 10 64 template <
typename T, std::
size_t K, std::
size_t Rounds,
typename Constants>
67 template <
typename T, std::
size_t K, std::
size_t Rounds,
typename Constants>
70 template <
typename T, std::
size_t K, std::
size_t Rounds,
typename Constants>
72 #else // MCKL_USE_AVX2 73 template <
typename T, std::
size_t K, std::
size_t Rounds,
typename Constants>
74 using PhiloxGeneratorImpl =
76 #endif // MCKL_USE_AVX2 91 static_assert(std::is_unsigned<T>::value,
92 "**PhiloxGenerator** used with T other than unsigned integer types");
94 static_assert(K != 0 && K % 2 == 0,
95 "**PhiloxGenerator** used with K other than multiples of 2");
98 Rounds != 0,
"**PhiloxGenerator** used with rounds equal to zero");
104 static constexpr std::size_t
size() {
return sizeof(T) * K; }
113 plain, cipher, key_);
116 template <
typename ResultType>
123 template <
typename ResultType>
134 return gen1.key_ == gen2.key_;
141 return !(gen1 == gen2);
144 template <
typename CharT,
typename Traits>
146 std::basic_ostream<CharT, Traits> &os,
158 template <
typename CharT,
typename Traits>
160 std::basic_istream<CharT, Traits> &is,
168 gen_tmp.key_.fill(0);
169 is >> std::ws >> gen_tmp.key_;
172 gen = std::move(gen_tmp);
184 template <
typename ResultType,
typename T, std::size_t K,
192 template <
typename ResultType>
197 template <
typename ResultType>
202 template <
typename ResultType>
207 template <
typename ResultType>
244 #endif // MCKL_RANDOM_PHILOX_HPP
Counter based RNG engine.
static void eval(const void *plain, void *cipher, const std::array< T, K/2 > &key)
Default Philox constants.
friend std::basic_ostream< CharT, Traits > & operator<<(std::basic_ostream< CharT, Traits > &os, const PhiloxGenerator< T, K, Rounds, Constants > &gen)
static constexpr std::size_t size()
void operator()(ctr_type &ctr, ResultType *r) const
void operator()(ctr_type &ctr, std::size_t n, ResultType *r) const
#define MCKL_PHILOX_ROUNDS
PhiloxGenerator default rounds.
friend std::basic_istream< CharT, Traits > & operator>>(std::basic_istream< CharT, Traits > &is, PhiloxGenerator< T, K, Rounds, Constants > &gen)
void reset(const key_type &key)
friend bool operator!=(const PhiloxGenerator< T, K, Rounds, Constants > &gen1, const PhiloxGenerator< T, K, Rounds, Constants > &gen2)
typename internal::CounterImpl< T, K >::type Counter
A counter type with the same width as std::array<T, K> but with possibly fewer elements.
friend bool operator==(const PhiloxGenerator< T, K, Rounds, Constants > &gen1, const PhiloxGenerator< T, K, Rounds, Constants > &gen2)
void operator()(const void *plain, void *cipher) const
std::array< T, K/2 > key_type
PhiloxGeneratorAVX2Impl< T, K, Rounds, Constants > PhiloxGeneratorImpl