Java Array Normalize norm(final double[] vec)

Here you can find the source of norm(final double[] vec)

Description

Returns the euclidean norm of a vector.

License

Open Source License

Parameter

Parameter Description
vec the vector.

Return

the euclidean norm of vector vec.

Declaration

public static double norm(final double[] vec) 

Method Source Code

//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);
    }
}

Related

  1. norm(double[] array)
  2. norm(double[] data)
  3. norm(double[] v)
  4. norm(double[] vector)
  5. norm(double[] vector, int n)
  6. norm(final double[] x)
  7. norm(float[] data)
  8. norm(int D, double vec[])
  9. norm2(double[] vec)