[ 
https://issues.apache.org/jira/browse/NUMBERS-163?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17365006#comment-17365006
 ] 

Gilles Sadowski commented on NUMBERS-163:
-----------------------------------------

Attached
 * "FMA.java" (additional factory method)
 * "Sum.java"

To prevent API bloat in the upcoming release, we should remove the 
{{LinearCombination}} and {{Summation}} classes given that they are syntactic 
sugar for the more versatile {{FMA}} class (name TBD if "FMA" is confusing).
I wouldn't add {{Sum}} for the same reason (and because of its "mixed bag" 
feeling of addition and product).
Those now seem fairly application-dependent. E.g. one may need
{code:java}
public double linearCombination(double[] a, double[] b) { /* ... */ }
{code}
while another would rather have
{code:java}
public double scalarProduct(Vector3D a, Vector3D b) { /* ... */ }
{code}

There are no failures with {{SumTest}} (using {{Sum}} as implemented in the 
attached file); but I didn't check that all cases were covered by that test 
suite. IOW, if you agree with the above, a review of {{FMA}} is necessary and a 
test suite yet to be written...

> 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
>         Attachments: FMA.java, Sum.java
>
>          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)

Reply via email to