Here you can find the source of vectorNorm(double[] vector)
public static double vectorNorm(double[] vector)
//package com.java2s; /*/* www . j a v a 2s. c o m*/ * Created on 12.12.2004 * * COPYRIGHT NOTICE * * Copyright (C) 2005 DFKI GmbH, Germany * Developed by Benedikt Fries, Matthias Klusch * * The code is free for non-commercial use only. * You can redistribute it and/or modify it under the terms * of the Mozilla Public License version 1.1 as * published by the Mozilla Foundation at * http://www.mozilla.org/MPL/MPL-1.1.txt */ public class Main { public static double vectorNorm(double[] vector) { return Math.sqrt(vectorDotProduct(vector, vector)); } public static double vectorNorm(int[] vector) { return Math.sqrt(vectorDotProduct(vector, vector)); } public static double vectorDotProduct(double[] v1, double[] v2) { if (v1.length != v2.length) return 0; double sum = 0; for (int i = 0; i < v1.length; i++) sum += v1[i] * v2[i]; return sum; } public static double vectorDotProduct(int[] v1, int[] v2) { if (v1.length != v2.length) return 0; double sum = 0; for (int i = 0; i < v1.length; i++) sum += v1[i] * v2[i]; return sum; } }