Here you can find the source of norm(final double[] vec)
Parameter | Description |
---|---|
vec | the vector. |
public static double norm(final double[] vec)
//package com.java2s; //License from project: Open Source License public class Main { /**//from w w w.ja v a2 s . c o m * Returns the euclidean norm of a vector. * @param vec the vector. * @return the euclidean norm of vector vec. * */ public static double norm(final double[] vec) { assert vec != null; double s = 0; for (double i : vec) { s += Math.pow(i, 2); } return Math.sqrt(s); } }