code: public static double[] colSums(double[][] data) {
          double[] x = data[0].clone();
  
          for (int i = 1; i < data.length; i++) {
              for (int j = 0; j < x.length; j++) {
                  x[j] += data[i][j];
              }
          }
  
          return x;
      }
docs: Returns the column sums for a matrix.