partial_sum

Syntax:

    #include <numeric>
    output_iterator partial_sum( input_iterator start, input_iterator end, output_iterator result );
    output_iterator partial_sum( input_iterator start, input_iterator end, output_iterator result, BinOp p );

The partial_sum() function calculates the partial sum of a range defined by [start,end), storing the output at result.

start is assigned to *result, the sum of *start and *(start + 1) is assigned to *(result + 1), etc.

partial_sum() runs in linear time.

Related Topics: accumulate, adjacent_difference, count, inner_product