Here you can find the source of sum(double[][] o)
public static double[] sum(double[][] o)
//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; } }