[
https://issues.apache.org/jira/browse/NUMBERS-163?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17364398#comment-17364398
]
Matt Juntunen commented on NUMBERS-163:
---------------------------------------
bq. With the above API, is it possible to implement the combined functionality
of LinearCombination and Summation, with the same accuracy?
I picture {{fma}} and the dot2s/sum2s algorithms that we use for
{{LinearCombination}} and {{Summation}} as separate but complementary
functions. {{FMA}} is a single, well-defined operation that produces a highly
accurate double value from 3 inputs. Any computed round off errors are lost at
the end of the computation when the high precision result is converted back to
a double. In contrast, the dot2s/sum2s algorithms accept any number of inputs
and propagate round-off errors throughout the entire computation. So, I do not
see {{fma}} playing a role in the changes discussed here.
I've created a [draft PR|https://github.com/apache/commons-numbers/pull/96]
containing the {{Sum}} class I outlined earlier. I believe the class itself is
complete. I just need to write/update the unit tests and add performance
benchmarks. Please let me know what you think.
> Summation and LinearCombination Accumulators
> --------------------------------------------
>
> Key: NUMBERS-163
> URL: https://issues.apache.org/jira/browse/NUMBERS-163
> Project: Commons Numbers
> Issue Type: New Feature
> Reporter: Matt Juntunen
> Priority: Major
> Time Spent: 0.5h
> Remaining Estimate: 0h
>
> It would be useful to have simple accumulator classes in {{Summation}} and
> {{LinearCombination}} to perform extended precision operations on arbitrary
> collections of values without requiring conversion to {{double[]}}. Ex:
> {code:java}
> Summation.Accumulator sum= Summation.accumulator(1d);
> sum.add(x)
> .add(y)
> .add(z)
> .add(w);
> double sumResult = sum.get();
> LinearCombination.Accumulator comb = LinearCombination.accumulator(1d);
> comb.add(x, scale)
> .add(y, scale)
> .add(z, scale)
> .add(w, scale);
> double combResult = comb.get();
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)