Initial request for review of JDK-8006572 DoubleStream.sum()/average() implementations that reduce numerical errors
joe.darcy at oracle.com
Thu Nov 14 08:08:19 UTC 2013
Please take an initial look over a fix for
JDK-8006572 DoubleStream.sum() & DoubleSummaryStats implementations
that reduce numerical errors
The basic approach is to use compensated summation
to computed streams-related sum and average statistics in the various
locations that this can be done.
All existing streams tests pass and new newly-written test passes too.
I believe the DoubleSummaryStatistics.java portion, including the test,
is fully review-worthy. In the test, for the sample computation in
question, the naive summation implementation had a error of 500,000 ulps
compared to 2 ups with the new implementation.
Two other locations I've found where this summation technique should be
used are in
DoublePipeline is the primary implementation class of DoubleStream.
For Collectors, the proposed code is a fairly clear adaptation of how
the current code passes state around; there is not currently a dedicated
test for the new summation technique in this location.
I'm new to the streams API so for DoublePipeline I don't know the
idiomatic way to phrase the collect I want to perform over the code.
(Based on my current understanding, I believe I want to perform a
collect rather than a reduce since for the compensated summation I need
to maintain some additional state.) Guidance here welcome.
More information about the core-libs-dev