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