Java Array Length Get length(double[] a)

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

Description

length

License

Open Source License

Parameter

Parameter Description
a The array to calculate the average for.

Return

The average over all elements in the array.

Declaration

public static double length(double[] a) 

Method Source Code

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

public class Main {
    /**//from  w  w w .j a  v a  2 s. c  om
     * @param a The array to calculate the average for.
     * @return The average over all elements in the array.
     */
    public static double length(double[] a) {
        double c = 0;
        for (int i = 0; i < a.length; i++)
            c += a[i] * a[i];
        return Math.sqrt(c);
    }
}

Related

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