public static VectorAccumulator asSumAccumulator(final double neutral) {
        return new VectorAccumulator() {
            private BigDecimal result = BigDecimal.valueOf(neutral);

            @Override
            public void update(int i, double value) {
                result = result.add(BigDecimal.valueOf(value));
            }

            @Override
            public double accumulate() {
                double value = result.setScale(Vectors.ROUND_FACTOR, RoundingMode.CEILING).doubleValue();
                result = BigDecimal.valueOf(neutral);
                return value;
            }
        };
    }
public static VectorAccumulator asSumAccumulator ( final double neutral ) { return new VectorAccumulator ( ) { private BigDecimal result = BigDecimal . valueOf ( neutral ) ; @ Override public void update ( int i , double value ) { result = result . add ( BigDecimal . valueOf ( value ) ) ; } @ Override public double accumulate ( ) { double value = result . setScale ( Vectors . ROUND_FACTOR , RoundingMode . CEILING ) . doubleValue ( ) ; result = BigDecimal . valueOf ( neutral ) ; return value ; } } ; }
Creates a sum vector accumulator that calculates the sum of all elements in the vector.

@param neutral the neutral value

@return a sum accumulator