Java Utililty Methods Array Sum

List of utility methods to do Array Sum

Description

The list of methods to do Array Sum are organized into topic(s).

Method

doublesum(final double[] a)
sum
double sum = 0.0;
for (double d : a)
    sum += d;
return sum;
doublesum(final double[] arr)
Returns the sum of the elements in the array.
double result = 0;
for (final double next : arr)
    result += next;
return result;
doublesum(final double[] array)
sum
double count = 0;
for (int j = 0; j < array.length; j++) {
    count += array[j];
return count;
intsum(final double[] decay, final int factor)
Sums up the decay photons at a pixel.
long returnValue = 0;
for (final double d : decay) {
    returnValue += (d / factor);
if (returnValue > Integer.MAX_VALUE) {
    returnValue = Integer.MAX_VALUE;
return (int) returnValue;
...
Doublesum(final Double[] doubles)
Get the sum of an array of doubles.
Double sum = 0.0;
for (int j = 0; j < doubles.length; j++) {
    sum += doubles[j];
return sum;
doublesum(final double[] productMix)
sum
if (productMix == null || productMix.length == 0)
    throw new IllegalArgumentException(Arrays.toString(productMix));
double res = productMix[0];
for (int i = 1; i < productMix.length; i++) {
    res += productMix[i];
return res;
doublesum(final double[] target)
Returns the sum of target.
return sum(target, 0, target.length);
doublesum(final double[] vec)
Computes the sum of the elements of a vector.
assert vec != null;
double s = 0;
for (double i : vec) {
    s += i;
return s;
floatsum(final float[] x)
sum
if (x == null) {
    throw new RuntimeException("diff function encountered null input");
float s = 0f;
for (int i = 0; i < x.length; ++i)
    s += x[i];
return s;
intsum(final int base, final int[] ints)
sum
return sum(base, toIntegerCollection(ints));