diff options
author | Vlad Yaroslavlev <vladon@vladon.com> | 2022-02-10 16:46:25 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:25 +0300 |
commit | 344ea37b4a345701ab0e67de2266a1c1bd7baf2d (patch) | |
tree | 1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /util/random/lcg_engine.h | |
parent | 706b83ed7de5a473436620367af31fc0ceecde07 (diff) | |
download | ydb-344ea37b4a345701ab0e67de2266a1c1bd7baf2d.tar.gz |
Restoring authorship annotation for Vlad Yaroslavlev <vladon@vladon.com>. Commit 2 of 2.
Diffstat (limited to 'util/random/lcg_engine.h')
-rw-r--r-- | util/random/lcg_engine.h | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/util/random/lcg_engine.h b/util/random/lcg_engine.h index a73d7aa7fc..08cc93c845 100644 --- a/util/random/lcg_engine.h +++ b/util/random/lcg_engine.h @@ -8,7 +8,7 @@ namespace NPrivate { template <typename T> - T LcgAdvance(T seed, T lcgBase, T lcgAddend, T delta) noexcept; + T LcgAdvance(T seed, T lcgBase, T lcgAddend, T delta) noexcept; }; template <typename T, T A, T C> @@ -19,23 +19,23 @@ struct TFastLcgIterator { return x * A + C; } - static inline T IterateMultiple(T x, T delta) noexcept { + static inline T IterateMultiple(T x, T delta) noexcept { return ::NPrivate::LcgAdvance(x, A, C, delta); } }; template <typename T, T A> struct TLcgIterator { - inline TLcgIterator(T seq) noexcept + inline TLcgIterator(T seq) noexcept : C((seq << 1u) | (T)1) // C must be odd { } - inline T Iterate(T x) noexcept { + inline T Iterate(T x) noexcept { return x * A + C; } - inline T IterateMultiple(T x, T delta) noexcept { + inline T IterateMultiple(T x, T delta) noexcept { return ::NPrivate::LcgAdvance(x, A, C, delta); } @@ -44,8 +44,8 @@ struct TLcgIterator { template <class TIterator, class TMixer> struct TLcgRngBase: public TIterator, public TMixer { - using TStateType = decltype(std::declval<TIterator>().Iterate(0)); - using TResultType = decltype(std::declval<TMixer>().Mix(TStateType())); + using TStateType = decltype(std::declval<TIterator>().Iterate(0)); + using TResultType = decltype(std::declval<TMixer>().Mix(TStateType())); template <typename... Args> inline TLcgRngBase(TStateType seed, Args&&... args) @@ -54,11 +54,11 @@ struct TLcgRngBase: public TIterator, public TMixer { { } - inline TResultType GenRand() noexcept { + inline TResultType GenRand() noexcept { return this->Mix(X = this->Iterate(X)); } - inline void Advance(TStateType delta) noexcept { + inline void Advance(TStateType delta) noexcept { X = this->IterateMultiple(X, delta); } |