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

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

Description

sum

License

Open Source License

Declaration

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

Method Source Code

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

public class Main {
    public static double[] sum(double[][] o) {
        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];/*from w  w w  .  ja  v  a 2 s . c o m*/
            }
        }

        return result;
    }

    public static double sum(double[] values) {
        double sum = 0.0;
        for (double value : values) {
            sum += value;
        }

        return sum;
    }
}

Related

  1. sum(double[][] data, int rows, int cols)
  2. sum(double[][] error)
  3. sum(double[][] input, int column)
  4. sum(double[][] input, int column)
  5. sum(double[][] kernel1, double[][] kernel2)
  6. sum(double[][] X, int axis)
  7. sum(float[][] a1, float[][] a2)
  8. sum(int M[][])
  9. sum(int[][][] X, int[] coords)