List of utility methods to do Array Sum
double | sumOfArray(final double[] array) Calculate the sum of an array of doubles. double sum = 0.0d; for (final double d : array) { sum += d; return sum; |
double | sumOfMeanDifferencesOnePoint(double[] vector) Used for calculating top part of simple regression for beta 1 double mean = sum(vector) / vector.length; double ret = 0; for (int i = 0; i < vector.length; i++) { double vec1Diff = Math.pow(vector[i] - mean, 2); ret += vec1Diff; return ret; |
double | sumOfMinimum(double[] a, double[] b) sum Of Minimum if (a.length != b.length) { throw new IndexOutOfBoundsException("The length of two arrays must be equal"); double s = 0.0; for (int i = 0, n = a.length; i < n; i++) { s += a[i] < b[i] ? a[i] : b[i]; return s; ... |
double | sumOfProducts(double[]... nums) This returns the sum of products for the given numbers. if (nums == null || nums.length < 1) return 0; double sum = 0; for (int i = 0; i < nums.length; i++) { double[] column = column(i, nums); sum += times(column); return sum; ... |
int | sumOverVector(float[] a) sum Over Vector int sum = 0; for (int i = 0; i < a.length; i++) sum += a[i]; return sum; |
double | sumProd(double[] v1, double[] v2, int i_, int n_) Calculates sum of products of n elements in input arrays, up to position i double total = 0; for (int i = i_, n = 0; n < n_; i = i > 0 ? i - 1 : v1.length - 1, n++) { total += v1[i] * v2[i]; return total; |
int | sumRightShifts(int num, int... shifts) sum Right Shifts if (shifts == null) { return num; int sum = 0; for (int shift : shifts) { sum += num >>> shift; return sum; ... |
double | sumSquared(double[] a) sum Squared double result = 0.0; for (int i = 0; i < a.length; i++) { result += a[i] * a[i]; return result; |
double | sumToDouble(float[] array) Sum all numbers from array. double sum = 0; for (float x : array) { sum += x; return sum; |
long | sumToLong(byte[] array) Sum all numbers from array. long sum = 0; for (byte x : array) { sum += x; return sum; |