Here you can find the source of normalize2(double[] x)
public static void normalize2(double[] x)
//package com.java2s; //License from project: BSD License public class Main { public static void normalize2(double[] x) { double sum = 0; for (int i = 0; i < x.length; i++) if (!Double.isNaN(x[i])) sum += x[i] * x[i];/*w w w .j a v a2 s . com*/ if (sum == 0) return; double f = 1.0 / Math.sqrt(sum); for (int i = 0; i < x.length; i++) if (!Double.isNaN(x[i])) x[i] *= f; } }