diff options
author | Evgeny Grechnikov <diamondaz@yandex.ru> | 2022-02-10 16:46:20 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:20 +0300 |
commit | 6e38f52f898d7c077ddd319800b4014967a5ca76 (patch) | |
tree | f0b2473cfc98506158b8f1d3d387c4f478ade18e /util/random/lcg_engine.h | |
parent | bd085aee9b4f7a0bee302ce687964ffb7098f986 (diff) | |
download | ydb-6e38f52f898d7c077ddd319800b4014967a5ca76.tar.gz |
Restoring authorship annotation for Evgeny Grechnikov <diamondaz@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'util/random/lcg_engine.h')
-rw-r--r-- | util/random/lcg_engine.h | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/util/random/lcg_engine.h b/util/random/lcg_engine.h index 08cc93c845..0de277cb66 100644 --- a/util/random/lcg_engine.h +++ b/util/random/lcg_engine.h @@ -6,11 +6,11 @@ // common engine for lcg-based RNG's // http://en.wikipedia.org/wiki/Linear_congruential_generator -namespace NPrivate { - template <typename T> +namespace NPrivate { + template <typename T> T LcgAdvance(T seed, T lcgBase, T lcgAddend, T delta) noexcept; -}; - +}; + template <typename T, T A, T C> struct TFastLcgIterator { static_assert(C % 2 == 1, "C must be odd"); @@ -18,10 +18,10 @@ struct TFastLcgIterator { static constexpr T Iterate(T x) noexcept { return x * A + C; } - + static inline T IterateMultiple(T x, T delta) noexcept { - return ::NPrivate::LcgAdvance(x, A, C, delta); - } + return ::NPrivate::LcgAdvance(x, A, C, delta); + } }; template <typename T, T A> @@ -36,9 +36,9 @@ struct TLcgIterator { } inline T IterateMultiple(T x, T delta) noexcept { - return ::NPrivate::LcgAdvance(x, A, C, delta); - } - + return ::NPrivate::LcgAdvance(x, A, C, delta); + } + const T C; }; @@ -59,8 +59,8 @@ struct TLcgRngBase: public TIterator, public TMixer { } inline void Advance(TStateType delta) noexcept { - X = this->IterateMultiple(X, delta); - } - + X = this->IterateMultiple(X, delta); + } + TStateType X; }; |