Java Array Length Get length(final double[] a)

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

Description

get the length of a.

License

Open Source License

Parameter

Parameter Description
a a parameter

Declaration

public static double length(final double[] a) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from www  .  jav a 2s  .c  om*/
     * get the length of a.
     * 
     * @param a
     */
    public static double length(final double[] a) {
        return Math.sqrt(squareLength(a));
    }

    /**
     * get the squared length of a.
     * 
     * @param a
     */
    public static double squareLength(final double[] a) {
        final int rows = rows(a);
        double squ_len = 0.0;
        for (int i = 0; i < rows; ++i)
            squ_len += a[i] * a[i];
        return squ_len;
    }

    public static int rows(final double[] a) {
        return a.length;
    }

    public static int rows(final double[][] A) {
        return A.length;
    }
}

Related

  1. length(byte[] array)
  2. length(double[] a)
  3. length(double[] point)
  4. length(double[] v)
  5. length(double[] x)
  6. length(final Object[] array)
  7. length(final T[]... arrays)
  8. length(float[] color)
  9. length(int[] tail)