List of usage examples for org.apache.commons.math3.util MathArrays safeNorm
public static double safeNorm(double[] v)
From source file:nars.predict.RNNBeliefPrediction.java
public static double[] normalize(double[] x) { double d = MathArrays.safeNorm(x); if (d == 0)//ww w . j a v a 2 s.c o m return x; for (int i = 0; i < x.length; i++) x[i] /= d; return x; }