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

intsumElems(boolean[] inputRow)
sum Elems
int r = 0;
for (boolean b : inputRow) {
    if (b)
        r += 1;
return r;
doublesumFast(final double... values)
Numerically naive implementation of sum which is faster than MathUtils.sum() and sumNaive() Generally exhibits rounding error which grows with the length of the sum Note that it may not agree with other implementations due to optimizations which change the order of iteration which can affect the rounding error.
double ret = 0;
final int unroll = 4; 
final int len = values.length - values.length % unroll;
int i = 0;
for (; i < len; i += unroll)
    ret += values[i] + values[i + 1] + values[i + 2] + values[i + 3];
for (; i < values.length; i++)
    ret += values[i];
...
longsumIntArray(int[] a)
sum Int Array
int sum = 0;
for (int i : a) {
    sum += i;
return sum;
intsumIntArray(int[] array)
Sums an array of integers and returns it.
int sum = 0;
for (int i : array)
    sum += i;
return sum;
intsumInts(int... numbers)
sum Ints
int result = 0;
for (Integer i : numbers) {
    result += i;
return result;
IntegersumList(int[] paramList)
sum List
if (paramList == null || paramList.length == 0)
    return 0;
Integer sum = 0;
for (Integer integer : paramList) {
    sum += integer;
return sum;
double[]sumLLL(double a[], double b[], int bBegin, int bEnd)
sum LLL
return sum(a, 0, b, bBegin, bEnd - bBegin, a);
doublesumLog(double[] logs)
sum Log
double max = max(logs);
double norm = 0.0;
for (int i = 0; i < logs.length; i++) {
    norm += Math.exp(logs[i] - max);
norm = Math.log(norm) + max;
return norm;
doublesumLog10(double[] log10values)
sum Log
return Math.pow(10.0, log10sumLog10(log10values));
longsumLong(int[] array)
sum Long
long sum = 0;
for (int e : array) {
    sum += e;
return sum;