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 | c73494e681a4e497ae191ada07a55a6bf55885ff (patch) | |
tree | 1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /util/random/lcg_engine.h | |
parent | 6e38f52f898d7c077ddd319800b4014967a5ca76 (diff) | |
download | ydb-c73494e681a4e497ae191ada07a55a6bf55885ff.tar.gz |
Restoring authorship annotation for Evgeny Grechnikov <diamondaz@yandex.ru>. Commit 2 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 0de277cb66..08cc93c845 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; }; |