Here you can find the source of norm2(double[] x)
public static double norm2(double[] x)
//package com.java2s; //License from project: Open Source License public class Main { public static double norm2(double[] x) { double result = innerProduct(x, x); return Math.pow(result, 0.5); }/*www . j a v a 2s .co m*/ public static double innerProduct(double[] x1, double[] x2) { double result = 0; for (int i = 0; i < x1.length; i++) { if (x1[i] == 0.0D || x2[i] == 0.0D) continue; result += x1[i] * x2[i]; } return result; } }