Java Matrix Sum sum(double[][] error)

Here you can find the source of sum(double[][] error)

Description

sum

License

Open Source License

Declaration


public static double sum(double[][] error) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {

    public static double sum(double[][] error) {
        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];//from  w ww. j  av  a 2  s . com
            }
        }
        return sum;
    }

    public static double[][] sum(double[][][][] errors, int j) {
        int m = errors[0][j].length;
        int n = errors[0][j][0].length;
        double[][] result = new double[m][n];
        for (int mi = 0; mi < m; mi++) {
            for (int nj = 0; nj < n; nj++) {
                double sum = 0;
                for (int i = 0; i < errors.length; i++)
                    sum += errors[i][j][mi][nj];
                result[mi][nj] = sum;
            }
        }
        return result;
    }
}

Related

  1. sum(double[][] data, int rows, int cols)
  2. sum(double[][] input, int column)
  3. sum(double[][] input, int column)
  4. sum(double[][] kernel1, double[][] kernel2)
  5. sum(double[][] o)