cpp/algorithm/transform exclusive scan

Transforms each element in the range with, then computes an exclusive prefix sum operation using  over the resulting range, with  as the initial value, and writes the results to the range beginning at. "exclusive" means that the i-th input element is not included in the i-th sum.

Formally, assigns through each iterator in  the value of the generalized noncommutative sum of  for every  in  over ,

where generalized noncommutative sum $GNSUM(op, a 1, ..., a N)$ is defined as follows:
 * if $N = 1$, $a 1$
 * if $N > 1$, $op(GNSUM(op, a 1, ..., a K), GNSUM(op, a M, ..., a N))$ for any K where $1 < K + 1 = M ≤ N$

In other words, the summation operations may be performed in arbitrary order, and the behavior is nondeterministic if is not associative.

Overload is executed according to.

and shall not invalidate iterators (including the end iterators) or subranges, nor modify elements in the ranges  or. Otherwise, the behavior is undefined.

Return value
Iterator to the element past the last element written.

Complexity
$O(last - first)$ applications of each of and.