You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gilles Sadowski (Jira)" <ji...@apache.org> on 2021/06/13 13:28:00 UTC

[jira] [Comment Edited] (NUMBERS-163) Summation and LinearCombination Accumulators

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

Gilles Sadowski edited comment on NUMBERS-163 at 6/13/21, 1:27 PM:
-------------------------------------------------------------------

{code:java}
public class LinearCombination implements DoubleSupplier { /* ... */ }

LinearCombination t = LinearCombination.of(a1, y1, b1, z1);
LinearCombination u = LinearCombination.of(t, b2, z2);

double result = u.getAsDouble();
{code}
I have a commit ready for factory methods to replace the static functions, and the "DoubleSupplier" (with updated unit tests). OK to "git push" to "master"?


was (Author: erans):
{code}
public class LinearCombination implements DoubleSupplier { /* ... */ }

LinearCombination t = LinearCombination.of(a1, y1, b1, z1);
LinearCombination u = LinearCombination.of(t, b2, z2);

double result = u.get();
{code}


> 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
>
> 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)