diff options
author | Abseil Team <absl-team@google.com> | 2021-11-22 08:22:28 -0800 |
---|---|---|
committer | Derek Mauro <dmauro@google.com> | 2021-11-22 14:44:20 -0500 |
commit | ec0d76f1d012cc1a4b3b08dfafcfc5237f5ba2c9 (patch) | |
tree | 3ed0065b80edc2f3c10b06e0cc9314118f9caa63 /absl/random/zipf_distribution.h | |
parent | 72c765111173a61de6e4184bb837f855b7869952 (diff) |
Export of internal Abseil changes
--
a0847bf19789c97689f1a8b0133a53b8af5e5caa by Samuel Benzaquen <sbenza@google.com>:
Add support for absl::(u)int128 to random distributions and generators.
PiperOrigin-RevId: 411565479
GitOrigin-RevId: a0847bf19789c97689f1a8b0133a53b8af5e5caa
Change-Id: Ide434bdd93fcab8e90f791796498de14833b667c
Diffstat (limited to 'absl/random/zipf_distribution.h')
-rw-r--r-- | absl/random/zipf_distribution.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/absl/random/zipf_distribution.h b/absl/random/zipf_distribution.h index 22ebc756..ed4038f1 100644 --- a/absl/random/zipf_distribution.h +++ b/absl/random/zipf_distribution.h @@ -23,6 +23,7 @@ #include <type_traits> #include "absl/random/internal/iostream_state_saver.h" +#include "absl/random/internal/traits.h" #include "absl/random/uniform_real_distribution.h" namespace absl { @@ -94,7 +95,7 @@ class zipf_distribution { double hxm_; // h(k + 0.5) double hx0_minus_hxm_; // h(x0) - h(k + 0.5) - static_assert(std::is_integral<IntType>::value, + static_assert(random_internal::IsIntegral<IntType>::value, "Class-template absl::zipf_distribution<> must be " "parameterized using an integral type."); }; @@ -221,7 +222,7 @@ zipf_distribution<IntType>::operator()( const double u = p.hxm_ + v * p.hx0_minus_hxm_; const double x = p.hinv(u); k = rint(x); // std::floor(x + 0.5); - if (k > p.k()) continue; // reject k > max_k + if (k > static_cast<double>(p.k())) continue; // reject k > max_k if (k - x <= p.s_) break; const double h = p.h(k + 0.5); const double r = p.pow_negative_q(p.v_ + k); |