Java Array Length Get length(double[] point)

Here you can find the source of length(double[] point)

Description

length

License

Open Source License

Declaration

public static double length(double[] point) 

Method Source Code

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

public class Main {
    public static double length(double[] point) {
        return Math.sqrt(stScalarProd(point, point));
    }/*  w w w  .  ja v a  2 s .  c  o m*/

    /**
     * Standard Skalarprodukt to UnitMatrix.
     * 
     * @param a first vector
     * @param b second vector
     * @return <a,b>
     */
    public static double stScalarProd(double[] a, double[] b) {
        if (a.length != b.length)
            throw new IllegalArgumentException("Multiplied two Vectors of different length.");

        double sum = 0;
        for (int i = 0; i < a.length; i++) {
            sum += a[i] * b[i];
        }
        return sum;
    }
}

Related

  1. arrayLength(Object o)
  2. arrayLength(Object[] ar)
  3. length(byte[] array)
  4. length(byte[] array)
  5. length(double[] a)
  6. length(double[] v)
  7. length(double[] x)
  8. length(final double[] a)
  9. length(final Object[] array)