Java Vector Normalize vectorNorm(float[] v)

Here you can find the source of vectorNorm(float[] v)

Description

Calculate the norm of a vector

License

Open Source License

Parameter

Parameter Description

Return

norm

Declaration

public static float vectorNorm(float[] v) 

Method Source Code

//package com.java2s;

public class Main {
    /**//from w  ww. jav  a  2 s  . c  o m
     * Calculate the norm of a vector
     *
     * @param v, a float vector
     * @return norm
     */
    public static float vectorNorm(float[] v) {
        float result = 0;
        for (float aV : v) {
            result += aV * aV;
        }
        result = (float) Math.sqrt(result);
        return result;
    }
}

Related

  1. vectorNorm(double[] v)
  2. vectorNorm(double[] vector)
  3. vectorNorm(final double[] vector)
  4. vectorNormalize(double[] v)
  5. vectorNorms(boolean[] in, int veclen)