Java Vector Length Get vectorLength(Double[] vector)

Here you can find the source of vectorLength(Double[] vector)

Description

Computes the 2-Norm of a given vector

License

Open Source License

Parameter

Parameter Description
vector a parameter

Return

The 2-Norm of the given vector

Declaration

public static Double vectorLength(Double[] vector) 

Method Source Code

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

    }
}

Related

  1. vectorLength(double[] vector)
  2. vectorLength(double[] vector)
  3. vectorLengthDyDx(double dy, double dx)
  4. vectorLengthSquared(float vx, float vy, float vz)