diff options
author | yazevnul <yazevnul@yandex-team.ru> | 2022-02-10 16:46:46 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:46 +0300 |
commit | 8cbc307de0221f84c80c42dcbe07d40727537e2c (patch) | |
tree | 625d5a673015d1df891e051033e9fcde5c7be4e5 /util/random/common_ops.h | |
parent | 30d1ef3941e0dc835be7609de5ebee66958f215a (diff) | |
download | ydb-8cbc307de0221f84c80c42dcbe07d40727537e2c.tar.gz |
Restoring authorship annotation for <yazevnul@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/random/common_ops.h')
-rw-r--r-- | util/random/common_ops.h | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/util/random/common_ops.h b/util/random/common_ops.h index 602eede351..373046cdce 100644 --- a/util/random/common_ops.h +++ b/util/random/common_ops.h @@ -4,31 +4,31 @@ #include <util/system/yassert.h> namespace NPrivate { - constexpr double ToRandReal1(const ui32 x) noexcept { + constexpr double ToRandReal1(const ui32 x) noexcept { return x * (double)(1.0 / 4294967295.0); } - constexpr double ToRandReal2(const ui32 x) noexcept { + constexpr double ToRandReal2(const ui32 x) noexcept { return x * (double)(1.0 / 4294967296.0); } - constexpr double ToRandReal3(const ui32 x) noexcept { + constexpr double ToRandReal3(const ui32 x) noexcept { return ((double)x + 0.5) * (double)(1.0 / 4294967296.0); } - constexpr double ToRandReal1(const ui64 x) noexcept { + constexpr double ToRandReal1(const ui64 x) noexcept { return (x >> 11) * (double)(1.0 / 9007199254740991.0); } - constexpr double ToRandReal2(const ui64 x) noexcept { + constexpr double ToRandReal2(const ui64 x) noexcept { return (x >> 11) * (double)(1.0 / 9007199254740992.0); } - constexpr double ToRandReal3(const ui64 x) noexcept { + constexpr double ToRandReal3(const ui64 x) noexcept { return ((x >> 12) + 0.5) * (double)(1.0 / 4503599627370496.0); } - constexpr double ToRandReal4(const ui64 x) noexcept { + constexpr double ToRandReal4(const ui64 x) noexcept { return double(x * (double)(1.0 / 18446744073709551616.0L)); } @@ -38,7 +38,7 @@ namespace NPrivate { } template <class T> - static constexpr ui64 ToRand64(T&&, ui64 x) noexcept { + static constexpr ui64 ToRand64(T&&, ui64 x) noexcept { return x; } @@ -47,7 +47,7 @@ namespace NPrivate { */ template <class T, class TRandGen> static T GenUniform(T max, TRandGen&& gen) { - Y_VERIFY(max > 0, "Invalid random number range [0, 0)"); + Y_VERIFY(max > 0, "Invalid random number range [0, 0)"); const T randmax = gen.RandMax() - gen.RandMax() % max; T rand; @@ -63,7 +63,7 @@ namespace NPrivate { template <class TRandType, class T> struct TCommonRNG { using TResult = TRandType; - using result_type = TRandType; + using result_type = TRandType; inline T& Engine() noexcept { return static_cast<T&>(*this); @@ -72,11 +72,11 @@ struct TCommonRNG { static constexpr TResult _Min = TResult(0); static constexpr TResult _Max = TResult(-1); - static constexpr TResult RandMax() noexcept { + static constexpr TResult RandMax() noexcept { return _Max; } - static constexpr TResult RandMin() noexcept { + static constexpr TResult RandMin() noexcept { return _Min; } @@ -120,11 +120,11 @@ struct TCommonRNG { return Engine().GenRand(); } - static constexpr TResult max() noexcept { + static constexpr TResult max() noexcept { return T::RandMax(); } - static constexpr TResult min() noexcept { + static constexpr TResult min() noexcept { return T::RandMin(); } }; |