Java Array Normalize norm2(double[] vec)

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

Description

returns the norm2 of an array

License

Open Source License

Parameter

Parameter Description
vec a parameter

Declaration

public static double norm2(double[] vec) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*ww w . j  av a2 s  . c  om*/
     * returns the norm2 of an array
     * @param vec
     * @return
     */
    public static double norm2(double[] vec) {
        double result = 0.0;
        for (int i = 0; i < vec.length; ++i)
            result += Math.pow(vec[i], 2);
        return Math.pow(result, 0.5);
    }
}

Related

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