code: public static double[] cumsum (double[] vector) {
          // Initialize the return value:
          final double[] retval = new double[vector.length];
  
          // Iterate and cumulate:
          retval[0] = vector[0];
          for (int i = 1; i < retval.length; i++) {
              retval[i] = vector[i] + retval[i - 1];
          }
  
          // Done, return:
          return retval;
      }
docs: Computes the cumulative sums of a given vector.
  
  @param vector Vector which the cumulative sums to be computed of.
  @return Cumulative sums of the vector.