Here you can find the source of vectorLength(Double[] vector)
Parameter | Description |
---|---|
vector | a parameter |
public static Double vectorLength(Double[] vector)
//package com.java2s; public class Main { /**/*ww w . ja v a 2s .com*/ * Computes the 2-Norm of a given vector * * @param vector * @return The 2-Norm of the given vector */ public static Double vectorLength(Double[] vector) { Double sum = 0.0; for (Double d : vector) { sum += Math.pow(d, 2); } sum = Math.sqrt(sum); return sum; } }