List of utility methods to do Matrix Sum
int | sumRow(int[][] table, int column) sum Row int sum = 0; for (int r = 0; r < table.length; r++) { sum += table[r][column]; return sum; |
double[] | sums(double[][] input) Return an array of the sums for each column in the 2D input double[] theSums = new double[input[0].length]; for (int r = 0; r < input.length; r++) { for (int c = 0; c < input[r].length; c++) { theSums[c] += input[r][c]; return theSums; |
double | sumSpecificIndices(double[] input, int[][] indices, int columnInIndices) sum Specific Indices double total = 0; for (int i = 0; i < indices.length; i++) { total += input[indices[i][columnInIndices]]; return total; |
float | sumSq(float[][] arr) Calculate the sum of the squared values of a 2D array. float sum = 0; for (int i = 0; i < arr.length; i++) sum += sumSq(arr[i]); return sum; |