Java Array Sum sum(final double[] vec)

Here you can find the source of sum(final double[] vec)

Description

Computes the sum of the elements of a vector.

License

Open Source License

Parameter

Parameter Description
array the array, to be summed.

Return

the sum of the elements of the vector.

Declaration

public static double sum(final double[] vec) 

Method Source Code

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

public class Main {
    /**//from  w  ww.  j a v  a 2s  .  co  m
    * Computes the sum of the elements of a vector.
    * @param array  the array, to be summed.
    * @return       the sum of the elements of the vector.
    */
    public static double sum(final double[] vec) {
        assert vec != null;

        double s = 0;
        for (double i : vec) {
            s += i;
        }
        return s;
    }
}

Related

  1. sum(final double[] arr)
  2. sum(final double[] array)
  3. sum(final double[] decay, final int factor)
  4. sum(final Double[] doubles)
  5. sum(final double[] target)
  6. sum(final float[] x)
  7. sum(final int[] terms, final int start, final int len)
  8. sum(final int[] values)
  9. sum(final int[] values, final int... indice)