public static VectorAccumulator mkEuclideanNormAccumulator() {
        return new VectorAccumulator() {
            private BigDecimal result = BigDecimal.valueOf(0.0);

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

            @Override
            public double accumulate() {
                double value = result.setScale(Vectors.ROUND_FACTOR, RoundingMode.CEILING).doubleValue();
                result = BigDecimal.valueOf(0.0);
                return Math.sqrt(value);
            }
        };
    }
public static VectorAccumulator mkEuclideanNormAccumulator ( ) { return new VectorAccumulator ( ) { private BigDecimal result = BigDecimal . valueOf ( 0.0 ) ; @ Override public void update ( int i , double value ) { result = result . add ( BigDecimal . valueOf ( value * value ) ) ; } @ Override public double accumulate ( ) { double value = result . setScale ( Vectors . ROUND_FACTOR , RoundingMode . CEILING ) . doubleValue ( ) ; result = BigDecimal . valueOf ( 0.0 ) ; return Math . sqrt ( value ) ; } } ; }
Makes an Euclidean norm accumulator that allows to use
{@link org.la4j.Vector#fold(org.la4j.vector.functor.VectorAccumulator)} method for norm calculation.

@return an Euclidean norm accumulator