List of utility methods to do Array Sum
int | sum(final int[] terms, final int start, final int len) sum int s = 0; final int iSz = start + len; for (int i = start; i < iSz; i++) { s += terms[i]; return s; |
int | sum(final int[] values) Computes the sum of an array of integers. int t = 0; for (int i : values) { t += i; return t; |
int | sum(final int[] values, final int... indice) sum int result = 0; for (int i = 0; i < indice.length; i++) { result += values[indice[i]]; return result; |
long | sum(final long... values) sum long result = 0; for (final long value : values) result += value; return result; |
float | sum(float[] a, int off, int length) sum double d = 0.0; final int stop = off + length; while (off < stop) d += a[off++]; return (float) d; |
float | sum(float[] array) Sums all elements of array float sum = 0; for (int i = 0; i < array.length; i++) { sum += array[i]; return sum; |
float | sum(float[] distribution) sum float result = 0; for (float val : distribution) result += val; return result; |
float | sum(float[] items, int offset, int length) sum float sum = 0; for (int i = offset; i < offset + length; i++) sum += items[i]; return sum; |
double | sum(float[] vector) sum double sum = 0; for (double d : vector) sum += d; return sum; |
long | sum(int... values) Calculate the sum of the values from the specified array. long r = 0; for (int v : values) { r += v; return r; |