[
https://issues.apache.org/jira/browse/NUMBERS-163?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17362985#comment-17362985
]
Gilles Sadowski commented on NUMBERS-163:
-----------------------------------------
I would have suggested the {{Accumulator}} inner class myself, on the a priori
that the alternative was less efficient. I recall having suggested inner
classes where [~mattjuntunen] didn't want them. ;)
But now it seems that such a class could just be redundant.
{quote}You can have different implementations of LinearCombination.
{quote}
Yes (I seem to recall I raised that point somewhere else).
By maintaining the "static" API, we prevent the flexibility (IIUC).
{quote}What would one do with an instance of LinearCombination besides get the
double value from it? In that case, why even have an instance at all?
{quote}
To add it to another instance; thus providing the accumulation functionality
(without an additional name).
Note: An accumulator class may still be needed in the context of a
[collector|https://docs.oracle.com/javase/8/docs/api/java/util/stream/Collector.html]
but it could perhaps be private (?).
> 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: 20m
> 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)