Java Utililty Methods Matrix Sum

List of utility methods to do Matrix Sum

Description

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

Method

doublesum(double[][] data, int rows, int cols)
sum
double sum = 0;
for (int i = 0; i < rows; i++) {
    for (int j = 0; j < cols; j++) {
        sum += data[i][j];
return sum;
doublesum(double[][] error)
sum
int m = error.length;
int n = error[0].length;
double sum = 0.0;
for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
        sum += error[i][j];
return sum;
doublesum(double[][] input, int column)
sum
double total = 0;
for (int i = 0; i < input.length; i++) {
    total += input[i][column];
return total;
doublesum(double[][] input, int column)
sum
double total = 0;
for (int i = 0; i < input.length; i++) {
    total += input[i][column];
return total;
double[][]sum(double[][] kernel1, double[][] kernel2)
Sum two kernel matrices
double[][] kernel = new double[kernel1.length][kernel1.length];
for (int i = 0; i < kernel1.length; i++) {
    for (int j = i; j < kernel1[i].length; j++) {
        kernel[i][j] = kernel1[i][j] + kernel2[i][j];
return kernel;
double[]sum(double[][] o)
sum
int cols = o[0].length;
double[] result = new double[cols];
for (double[] row : o) {
    assert (row.length == cols);
    for (int i = 0; i < cols; ++i) {
        result[i] += row[i];
return result;
double[]sum(double[][] X, int axis)
sum
if (axis == 0) {
    return sumAxis0(X);
} else if (axis == 1) {
    return sumAxis1(X);
} else {
    String message = "axis>=2 is not supported in sum method.";
    throw new RuntimeException(message);
voidsum(float[][] a1, float[][] a2)
Element-wise summation of two arrays, output writes over first array
for (int j = 0; j < a1.length; j++) {
    sum(a1[j], a2[j]);
int[]sum(int M[][])
Sum - sum this matrix.
int s[] = new int[M.length];
for (int j = 0; j < M.length; j++) {
    for (int k = 0; k < M[j].length; k++) {
        s[j] += M[j][k];
return s;
intsum(int[][][] X, int[] coords)
sum
int x = coords[0];
int y = coords[1];
int z = coords[2];
int xlow = x == -1 ? 0 : x;
int xhigh = x == -1 ? X.length - 1 : x;
int ylow = y == -1 ? 0 : y;
int yhigh = y == -1 ? X[0].length - 1 : y;
int zlow = z == -1 ? 0 : z;
...