diff options
author | Alexander Fokin <apfokin@gmail.com> | 2022-02-10 16:45:38 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:38 +0300 |
commit | 863a59a65247c24db7cb06789bc5cf79d04da32f (patch) | |
tree | 139dc000c8cd4a40f5659e421b7c75135d080307 /util/generic/ymath.cpp | |
parent | f64e95a9eb9ab03240599eb9581c5a9102426a96 (diff) | |
download | ydb-863a59a65247c24db7cb06789bc5cf79d04da32f.tar.gz |
Restoring authorship annotation for Alexander Fokin <apfokin@gmail.com>. Commit 1 of 2.
Diffstat (limited to 'util/generic/ymath.cpp')
-rw-r--r-- | util/generic/ymath.cpp | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/util/generic/ymath.cpp b/util/generic/ymath.cpp index 31270728f4..d6a0038b5d 100644 --- a/util/generic/ymath.cpp +++ b/util/generic/ymath.cpp @@ -26,9 +26,9 @@ double Erf(double x) { return f; } -#endif // _MSC_VER +#endif // _MSC_VER -double LogGammaImpl(double x) { +double LogGammaImpl(double x) { static constexpr double lnSqrt2Pi = 0.91893853320467274178; // log(sqrt(2.0 * PI)) static constexpr double coeff9 = 1.0 / 1188.0; static constexpr double coeff7 = -1.0 / 1680.0; @@ -37,20 +37,20 @@ double LogGammaImpl(double x) { static constexpr double coeff1 = 1.0 / 12.0; if ((x == 1.0) || (x == 2.0)) { - return 0.0; // 0! = 1 + return 0.0; // 0! = 1 } - double bonus = 0.0; - while (x < 3.0) { - bonus -= log(x); - x += 1.0; - } - double lnX = log(x); - double sqrXInv = 1.0 / (x * x); - double res = coeff9 * sqrXInv + coeff7; - res = res * sqrXInv + coeff5; - res = res * sqrXInv + coeff3; - res = res * sqrXInv + coeff1; - res /= x; - res += x * lnX - x + lnSqrt2Pi - 0.5 * lnX; - return res + bonus; + double bonus = 0.0; + while (x < 3.0) { + bonus -= log(x); + x += 1.0; + } + double lnX = log(x); + double sqrXInv = 1.0 / (x * x); + double res = coeff9 * sqrXInv + coeff7; + res = res * sqrXInv + coeff5; + res = res * sqrXInv + coeff3; + res = res * sqrXInv + coeff1; + res /= x; + res += x * lnX - x + lnSqrt2Pi - 0.5 * lnX; + return res + bonus; } |