@Override public final double sum() { /* * In the arrays allocated for the collect operation, index 0 * holds the high-order bits of the running sum, index 1 holds * the low-order bits of the sum computed via compensated * summation, and index 2 holds the simple sum used to compute * the proper result if the stream contains infinite values of * the same sign. */ double[] summation = collect(() -> new double[3], (ll, d) -> { Collectors.sumWithCompensation(ll, d); ll[2] += d; }, (ll, rr) -> { Collectors.sumWithCompensation(ll, rr[0]); Collectors.sumWithCompensation(ll, rr[1]); ll[2] += rr[2]; }); return Collectors.computeFinalSum(summation); }
@Override public final double sum() { /* * In the arrays allocated for the collect operation, index 0 * holds the high-order bits of the running sum, index 1 holds * the low-order bits of the sum computed via compensated * summation, and index 2 holds the simple sum used to compute * the proper result if the stream contains infinite values of * the same sign. */ double[] summation = collect(() -> new double[3], (ll, d) -> { Collectors.sumWithCompensation(ll, d); ll[2] += d; }, (ll, rr) -> { Collectors.sumWithCompensation(ll, rr[0]); Collectors.sumWithCompensation(ll, rr[1]); ll[2] += rr[2]; }); return Collectors.computeFinalSum(summation); }
() -> new double[3], (a, t) -> { double val = mapper.applyAsDouble(t); sumWithCompensation(a, val); a[2] += val;}, (a, b) -> { sumWithCompensation(a, b[0]); a[2] += b[2]; return sumWithCompensation(a, b[1]); }, a -> computeFinalSum(a), CH_NOID);
(a, t) -> { double val = mapper.applyAsDouble(t); sumWithCompensation(a, val); a[2]++; a[3]+= val;}, (a, b) -> { sumWithCompensation(a, b[0]); sumWithCompensation(a, b[1]); a[2] += b[2]; a[3] += b[3]; return a; }, a -> (a[2] == 0) ? 0.0d : (computeFinalSum(a) / a[2]), CH_NOID);
() -> new double[3], (a, t) -> { double val = mapper.applyAsDouble(t); sumWithCompensation(a, val); a[2] += val;}, (a, b) -> { sumWithCompensation(a, b[0]); a[2] += b[2]; return sumWithCompensation(a, b[1]); }, a -> computeFinalSum(a), CH_NOID);
(a, t) -> { double val = mapper.applyAsDouble(t); sumWithCompensation(a, val); a[2]++; a[3]+= val;}, (a, b) -> { sumWithCompensation(a, b[0]); sumWithCompensation(a, b[1]); a[2] += b[2]; a[3] += b[3]; return a; }, a -> (a[2] == 0) ? 0.0d : (computeFinalSum(a) / a[2]), CH_NOID);
(ll, d) -> { ll[2]++; Collectors.sumWithCompensation(ll, d); ll[3] += d; }, (ll, rr) -> { Collectors.sumWithCompensation(ll, rr[0]); Collectors.sumWithCompensation(ll, rr[1]); ll[2] += rr[2]; ll[3] += rr[3];
(ll, d) -> { ll[2]++; Collectors.sumWithCompensation(ll, d); ll[3] += d; }, (ll, rr) -> { Collectors.sumWithCompensation(ll, rr[0]); Collectors.sumWithCompensation(ll, rr[1]); ll[2] += rr[2]; ll[3] += rr[3];