Numeric (and accumulators)
Joe Darcy
joe.darcy at oracle.com
Mon Sep 17 08:59:22 PDT 2012
On 9/17/2012 8:37 AM, Brian Goetz wrote:
>>> These guys also need companion classes that are mutable,
>>
>> Like for example Atomic{Integer,Long}? :-)
>
> So, writing out the complete set of candidate numeric types that have
> been proposed (we can prune them later):
>
> - New interface BoxedPrimitive extends Number (Joe)
> - New interface Numeric<BoxedPrimitive> (Doug)
> - Mutable implementation classes of Numeric (Brian)
> - Complete the set of atomic implementation classes (Doug)
> - Accumulator classes (Doug)
>
> I'll just say that we don't need to get caught up in premature
> either/or; if all of these are worth having, we can have them.
>
>> public abstract class LongAccumulator implements Numeric<Long> {
>
> I like these. I believe that they all assume commutative combination
> functions, not simply associative (what are sometimes called abelian
> monoids, rather than ordinary monoids)?
For a "DoubleAccumulator", I'll just note that a good implementation
will need to maintain some internal state. To have a reasonably good
chance of getting a robustly accurate double sum, extra work is needed
over just "sum += d[i++]." One pretty simply approach is called
compensated summation. People have also looked at sorting the input, etc.
-Joe
More information about the lambda-libs-spec-experts
mailing list