partial_sum

C++ Reference

partial_sum
Syntax:
  #include <numeric>
  iterator partial_sum( iterator start, iterator end, iterator result );
  iterator partial_sum( iterator start, iterator end, 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: