code: public static MatrixAccumulator asSumFunctionAccumulator(final double neutral, final MatrixFunction function) {
          return new MatrixAccumulator() {
              private final MatrixAccumulator sumAccumulator = Matrices.asSumAccumulator(neutral);
  
              @Override
              public void update(int i, int j, double value) {
                  sumAccumulator.update(i, j, function.evaluate(i, j, value));
              }
  
              @Override
              public double accumulate() {
                  return sumAccumulator.accumulate();
              }
          };
      }
docs: Creates a sum function accumulator, that calculates the sum of all
  elements in the matrix after applying given {@code function} to each of them.
  
  @param neutral the neutral value
  @param function the matrix function
  
  @return a sum function accumulator