Go to the documentation of this file.
15 #ifndef ABSL_RANDOM_BERNOULLI_DISTRIBUTION_H_
16 #define ABSL_RANDOM_BERNOULLI_DISTRIBUTION_H_
22 #include "absl/base/optimization.h"
23 #include "absl/random/internal/fast_uniform_bits.h"
24 #include "absl/random/internal/iostream_state_saver.h"
44 assert(
p >= 0.0 &&
p <= 1.0);
50 return p1.
p() == p2.
p();
53 return p1.
p() != p2.
p();
69 template <
typename URBG>
74 template <
typename URBG>
101 template <
typename URBG>
107 template <
typename CharT,
typename Traits>
109 std::basic_ostream<CharT, Traits>& os,
117 template <
typename CharT,
typename Traits>
119 std::basic_istream<CharT, Traits>& is,
122 auto p = random_internal::read_floating_point<double>(is);
129 template <
typename URBG>
162 const double q =
static_cast<double>(c) /
kP32;
180 const double left =
p - q;
185 const double here = left *
kP32;
192 if (here == 0)
return false;
200 #endif // ABSL_RANDOM_BERNOULLI_DISTRIBUTION_H_
friend bool operator==(const bernoulli_distribution &d1, const bernoulli_distribution &d2)
static bool Generate(double p, URBG &g)
result_type() max() const
friend bool operator!=(const bernoulli_distribution &d1, const bernoulli_distribution &d2)
istream_state_saver< std::basic_istream< CharT, Traits > > make_istream_state_saver(std::basic_istream< CharT, Traits > &is, std::ios_base::fmtflags flags=std::ios_base::dec|std::ios_base::scientific|std::ios_base::skipws)
ABSL_NAMESPACE_BEGIN std::ostream & operator<<(std::ostream &os, absl::LogSeverity s)
bool operator()(URBG &g, const param_type ¶m)
void param(const param_type ¶m)
#define ABSL_NAMESPACE_END
result_type() min() const
#define ABSL_NAMESPACE_BEGIN
unsigned __int64 uint64_t
friend bool operator==(const param_type &p1, const param_type &p2)
static constexpr uint64_t kP32
bernoulli_distribution(double p)
#define ABSL_PREDICT_TRUE(x)
constexpr uint128 operator>>(uint128 lhs, int amount)
friend bool operator!=(const param_type &p1, const param_type &p2)
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)
bernoulli_distribution(param_type p)
grpc
Author(s):
autogenerated on Fri May 16 2025 02:57:46