[Libreoffice-bugs] [Bug 137679] Implement a Kahan summation algorithm to reduce the numerical error in the total

bugzilla-daemon at bugs.documentfoundation.org bugzilla-daemon at bugs.documentfoundation.org
Sat May 15 16:32:01 UTC 2021


https://bugs.documentfoundation.org/show_bug.cgi?id=137679

--- Comment #66 from dante19031999 at gmail.com ---
(In reply to b. from comment #65)
> Created attachment 172026 [details]
> testsheet Neumaier Kahan–Babuška working well
> 
> hello @Dante, 
> 
> did some 'poking around', and - think - have found proof that better results
> are possible, 
> 
> would you mind having a look into the attached file, explanations in the
> sheet explanation, 
> 
> trying NeumaierSum from
> https://en.wikipedia.org/wiki/Kahan_summation_algorithm in a calc sheet,
> works, not 100%, but avoids the '12,45' fail. 
> 
> (as with all work / suggestions from me ... recheck at least twice!, i'm
> human and may fail) 
> 
> regards, 
> 
> b.

I could say I'm a precision freak and always try to get the best possible
result even if at expenses of calculation time. However calc philosophy is the
opposite.
I did try to use Klein sum. You can check this first patch:
https://gerrit.libreoffice.org/c/core/+/114567
However it was considered overkill and downgraded to Neumanier sum.

So now I'm left with some doubts. Why Neumanier with calc and Neumanier with
C++ differ. I've rechecked all the code involved in the sum and seems
legitimate.

My theory is that the problem is in the SSE2 code.
For summing columns in theory you use the SSE2 which uses raw Kahan.
It's here: https://gerrit.libreoffice.org/c/core/+/115113

However using Neumanier in there is beyond my capacities.
Would suggest to create a new tdf for it.
That way someone who understands it could fix it.

Sorry to disappoint again.

This is the sum code:
    void add(double x_i)
    {
        double t = m_fSum + x_i;
        if (std::abs(m_fSum) >= std::abs(x_i))
            m_fError += (m_fSum - t) + x_i;
        else
            m_fError += (x_i - t) + m_fSum;
        m_fSum = t;
    }

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/libreoffice-bugs/attachments/20210515/afd218ce/attachment-0001.htm>


More information about the Libreoffice-bugs mailing list