public static VectorAccumulator asProductFunctionAccumulator(final double neutral,
                                                                 final VectorFunction function) {
        return new VectorAccumulator() {
            private final VectorAccumulator productAccumulator = Vectors.asProductAccumulator(neutral);

            @Override
            public void update(int i, double value) {
                productAccumulator.update(i, function.evaluate(i, value));
            }

            @Override
            public double accumulate() {
                return productAccumulator.accumulate();
            }
        };
    }
public static VectorAccumulator asProductFunctionAccumulator ( final double neutral , final VectorFunction function ) { return new VectorAccumulator ( ) { private final VectorAccumulator productAccumulator = Vectors . asProductAccumulator ( neutral ) ; @ Override public void update ( int i , double value ) { productAccumulator . update ( i , function . evaluate ( i , value ) ) ; } @ Override public double accumulate ( ) { return productAccumulator . accumulate ( ) ; } } ; }
Creates a product function accumulator, that calculates the product of
all elements in the vector after applying given {@code function} to
each of them.

@param neutral the neutral value
@param function the vector function

@return a product function accumulator