diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2021-05-08 15:28:11 +0200 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-05-08 16:28:08 +0200 |
commit | c10ce2698a3b001d22db3d33f2f43513cc49ebda (patch) | |
tree | bc116f000aec8b50c35c276dcdd60d0a261b2188 /sc | |
parent | e5750bacf680177447134ca6409967ed4b00e434 (diff) |
Simplify multiplication and division
Use operators that take double for unification
Change-Id: I5ef6f8a684f35dffbd639435415547d6dc96ed58
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115208
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/kahan.hxx | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/sc/inc/kahan.hxx b/sc/inc/kahan.hxx index dffd74d13f0f..49c7922b3c79 100644 --- a/sc/inc/kahan.hxx +++ b/sc/inc/kahan.hxx @@ -9,6 +9,8 @@ #pragma once +#include <cmath> + /** * This class provides LO with Kahan summation algorithm * About this algorithm: https://en.wikipedia.org/wiki/Kahan_summation_algorithm @@ -135,11 +137,7 @@ public: inline KahanSum operator*(const KahanSum& fTimes) const { - KahanSum fSum(m_fSum * fTimes.m_fSum); - fSum += m_fSum * fTimes.m_fError; - fSum += m_fError * fTimes.m_fSum; - fSum += m_fError * fTimes.m_fError; - return fSum; + return *this * fTimes.m_fSum + *this * fTimes.m_fError; } constexpr KahanSum operator*(double fTimes) const @@ -149,12 +147,7 @@ public: return fSum; } - inline KahanSum operator/(const KahanSum& fDivides) const - { - KahanSum fSum(m_fSum / fDivides.get()); - fSum += m_fError / fDivides.get(); - return fSum; - } + inline KahanSum operator/(const KahanSum& fDivides) const { return *this / fDivides.get(); } constexpr KahanSum operator/(double fTimes) const { |