code: public static double[] colSums (RealMatrix matrix) {
          // Declare and initialize the return value:
          double[] retval = new double[matrix.getColumnDimension()];
  
          // Iterate over columns and compute totals:
          for (int col = 0; col < matrix.getColumnDimension(); col++) {
              for (int row = 0; row < matrix.getRowDimension(); row++) {
                  retval[col] += matrix.getEntry(row, col);
              }
          }
  
          // Done, return col sums:
          return retval;
      }
docs: Returns the sums of columns.
  
  @param matrix The matrix of which the sums of columns to be computed
  @return A double array of column sums