Go to the documentation of this file.
15 #ifndef ABSL_RANDOM_INTERNAL_PCG_ENGINE_H_
16 #define ABSL_RANDOM_INTERNAL_PCG_ENGINE_H_
18 #include <type_traits>
20 #include "absl/base/config.h"
21 #include "absl/meta/type_traits.h"
22 #include "absl/numeric/bits.h"
23 #include "absl/numeric/int128.h"
24 #include "absl/random/internal/fastmath.h"
25 #include "absl/random/internal/iostream_state_saver.h"
29 namespace random_internal {
40 template <
typename Params,
typename Mix>
42 static_assert(std::is_same<
typename Params::state_type,
43 typename Mix::state_type>::
value,
44 "Class-template absl::pcg_engine must be parameterized by "
45 "Params and Mix with identical state_type");
48 "Class-template absl::pcg_engine must be parameterized by "
49 "an unsigned Mix::result_type");
69 template <
class SeedSequence,
92 template <
class SeedSequence>
107 template <
class CharT,
class Traits>
109 std::basic_ostream<CharT, Traits>&>
111 std::basic_ostream<CharT, Traits>& os,
115 helper.write(pcg_engine::params_type::multiplier(), os);
117 helper.write(pcg_engine::params_type::increment(), os);
119 helper.write(engine.
state_, os);
123 template <
class CharT,
class Traits>
125 std::basic_ostream<CharT, Traits>&>
127 std::basic_ostream<CharT, Traits>& os,
130 os << pcg_engine::params_type::multiplier() << os.fill();
131 os << pcg_engine::params_type::increment() << os.fill();
136 template <
class CharT,
class Traits>
138 std::basic_istream<CharT, Traits>&>
140 std::basic_istream<CharT, Traits>& is,
143 auto mult = helper.read(is);
144 auto inc = helper.read(is);
145 auto tmp = helper.read(is);
146 if (mult != pcg_engine::params_type::multiplier() ||
147 inc != pcg_engine::params_type::increment()) {
149 is.setstate(is.rdstate() | std::ios_base::failbit);
157 template <
class CharT,
class Traits>
159 std::basic_istream<CharT, Traits>&>
161 std::basic_istream<CharT, Traits>& is,
165 if (mult != pcg_engine::params_type::multiplier() ||
166 inc != pcg_engine::params_type::increment()) {
168 is.setstate(is.rdstate() | std::ios_base::failbit);
181 return s * Params::multiplier() + Params::increment();
202 template <
class SeedSequence>
206 sizeof(
state_type) /
sizeof(sequence_result_type);
212 tmp <<= (
sizeof(sequence_result_type) * 8);
221 template <u
int64_t kMultA, u
int64_t kMultB, u
int64_t kIncA, u
int64_t kIncB>
224 #if ABSL_HAVE_INTRINSIC_INT128
227 return (
static_cast<__uint128_t
>(
a) << 64) |
b;
247 #if ABSL_HAVE_INTRINSIC_INT128
256 #if ABSL_HAVE_INTRINSIC_INT128
271 template <u
int64_t kMult, u
int64_t kInc>
295 0x5851f42d4c957f2d, 0x14057b7ef767814f>,
308 #endif // ABSL_RANDOM_INTERNAL_PCG_ENGINE_H_
pcg_engine(SeedSequence &&seq)
static const int kBufferSize
static constexpr state_type lcg(state_type s)
pcg_engine & operator=(const pcg_engine &)=default
friend absl::enable_if_t<(sizeof(state_type)<=8), std::basic_istream< CharT, Traits > & > operator>>(std::basic_istream< CharT, Traits > &is, pcg_engine &engine)
OPENSSL_EXPORT pem_password_cb void * u
typename std::enable_if< B, T >::type enable_if_t
#define ABSL_NAMESPACE_END
static constexpr state_type make_u128(uint64_t a, uint64_t b)
static constexpr result_type() max()
static constexpr state_type multiplier()
constexpr uint64_t Uint128High64(uint128 v)
#define ABSL_NAMESPACE_BEGIN
constexpr uint64_t Uint128Low64(uint128 v)
constexpr ABSL_NAMESPACE_BEGIN uint128 MakeUint128(uint64_t high, uint64_t low)
uint64_t operator()(state_type state)
pcg_engine(uint64_t seed_value=0)
const typedef int * result_type
absl::enable_if_t< !std::is_convertible< SeedSequence, uint64_t >::value, void > seed(SeedSequence &&seq)
unsigned __int64 uint64_t
bool operator==(const pcg_engine &other) const
friend absl::enable_if_t<(sizeof(state_type)==16), std::basic_istream< CharT, Traits > & > operator>>(std::basic_istream< CharT, Traits > &is, pcg_engine &engine)
static constexpr state_type increment()
typename Mix::state_type state_type
uint32_t operator()(uint64_t state)
void reseed(SeedSequence &seq)
bool operator!=(const pcg_engine &other) const
void seed(uint64_t seed_value=0)
pcg_engine< random_internal::pcg128_params< 0x2360ed051fc65da4ull, 0x4385df649fccf645ull, 0x5851f42d4c957f2d, 0x14057b7ef767814f >, random_internal::pcg_xsl_rr_128_64 > pcg64_2018_engine
static uint64_t Mix(uint64_t v0, uint64_t v1)
static constexpr state_type increment()
void discard(uint64_t count)
static constexpr result_type() min()
state_type advance(state_type s, uint64_t n) const
friend absl::enable_if_t<(sizeof(state_type)==16), std::basic_ostream< CharT, Traits > & > operator<<(std::basic_ostream< CharT, Traits > &os, const pcg_engine &engine)
ForwardIterator rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator last)
static constexpr state_type multiplier()
ostream_state_saver< std::basic_ostream< CharT, Traits > > make_ostream_state_saver(std::basic_ostream< CharT, Traits > &os, std::ios_base::fmtflags flags=std::ios_base::dec|std::ios_base::left|std::ios_base::scientific)
constexpr ABSL_MUST_USE_RESULT std::enable_if< std::is_unsigned< T >::value, T >::type rotr(T x, int s) noexcept
typename Mix::result_type result_type
static struct rpc_state state
grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:41