summaryrefslogtreecommitdiff
path: root/sc/source/core
diff options
context:
space:
mode:
authordante <dante19031999@gmail.com>2021-05-01 11:04:21 +0200
committerMike Kaganski <mike.kaganski@collabora.com>2021-05-04 20:34:11 +0200
commit94977bb43d8dc91023bee7afa037f6319c36ccc3 (patch)
tree4147b5553ee0c1d2bcfa66692288d73b881625f8 /sc/source/core
parenta9f46b72df15c3540044a4441b926a1de9df5d2f (diff)
tdf#137679 Use kahan summation for ScInterpreter::lcl_IterateInverse
Change-Id: I02e108ac70ddd4ea8d8d97eb4f5fbc8996dd4bd1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114966 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sc/source/core')
-rw-r--r--sc/source/core/tool/interpr3.cxx26
1 files changed, 15 insertions, 11 deletions
diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx
index 17fe63381362..c339a68dd80f 100644
--- a/sc/source/core/tool/interpr3.cxx
+++ b/sc/source/core/tool/interpr3.cxx
@@ -84,32 +84,36 @@ static double lcl_IterateInverse( const ScDistFunc& rFunction, double fAx, doubl
// find enclosing interval
+ KahanSum fkAx = fAx;
+ KahanSum fkBx = fBx;
double fAy = rFunction.GetValue(fAx);
double fBy = rFunction.GetValue(fBx);
- double fTemp;
+ KahanSum fTemp;
unsigned short nCount;
for (nCount = 0; nCount < 1000 && !lcl_HasChangeOfSign(fAy,fBy); nCount++)
{
if (std::abs(fAy) <= std::abs(fBy))
{
- fTemp = fAx;
- fAx += 2.0 * (fAx - fBx);
- if (fAx < 0.0)
- fAx = 0.0;
- fBx = fTemp;
+ fTemp = fkAx;
+ fkAx += (fkAx - fkBx) * 2.0;
+ if (fkAx < 0.0)
+ fkAx = 0.0;
+ fkBx = fTemp;
fBy = fAy;
- fAy = rFunction.GetValue(fAx);
+ fAy = rFunction.GetValue(fkAx.get());
}
else
{
- fTemp = fBx;
- fBx += 2.0 * (fBx - fAx);
- fAx = fTemp;
+ fTemp = fkBx;
+ fkBx += (fkBx - fkAx) * 2.0;
+ fkAx = fTemp;
fAy = fBy;
- fBy = rFunction.GetValue(fBx);
+ fBy = rFunction.GetValue(fkBx.get());
}
}
+ fAx = fkAx.get();
+ fBx = fkBx.get();
if (fAy == 0.0)
return fAx;
if (fBy == 0.0)