Java Array Normalize norm2(double[] vector)

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

Description

Get the norm of a 2 dimension vector

License

Apache License

Parameter

Parameter Description
Vector A double[x,y]

Return

the norm

Declaration

public static double norm2(double[] vector) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**//  w  w w.  j av a  2 s.co  m
     * Get the norm of a 2 dimension vector
     * @param Vector A double[x,y]
     * @return the norm
     */
    public static double norm2(double[] vector) {
        return distance(vector, new double[] { 0, 0 });
    }

    /**
     * Measure distance between a and b
     * @param Point A double[x,y]
     * @param Point B double[x,y]
     * @return distance between A and B
     */
    public static double distance(double[] a, double[] b) {
        return Math.sqrt(Math.pow(a[0] - b[0], 2)
                + Math.pow(a[1] - b[1], 2));
    }
}

Related

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