class MatrixUtils {

  public static double[] sumRows(DoubleMatrix2D A, double[] sums) {
    if (sums == null || A.rows() != sums.length) {
      sums = new double[A.rows()];
    } else {
      Arrays.fill(sums, 0);
    }

    for (int r = 0; r < A.rows(); r++) {
      for (int c = 0; c < A.columns(); c++) {
        sums[r] += A.getQuick(r, c);
      }
    }

    return sums;
  }

}