[Libreoffice-commits] core.git: sc/inc
Mike Kaganski (via logerrit)
logerrit at kemper.freedesktop.org
Sat May 8 14:28:42 UTC 2021
sc/inc/kahan.hxx | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
New commits:
commit c10ce2698a3b001d22db3d33f2f43513cc49ebda
Author: Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Sat May 8 15:28:11 2021 +0200
Commit: Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Sat May 8 16:28:08 2021 +0200
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 at collabora.com>
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
{
More information about the Libreoffice-commits
mailing list