# <numeric>
<numeric>
# ``
* * *
Include the [STL](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_index.html#STL)
standard header **``**
to define several template functions useful for computing numeric values.
The descriptions of these templates employ a number of
[conventions](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_lib_stl.html#Algorithm%20Conventions)
common to all algorithms.
namespace std {
template
Ty accumulate(InIt first, InIt last, Ty val);
template
Ty accumulate(InIt first, InIt last, Ty val, Fn2 func);
template
Ty inner_product(InIt1 first1, InIt1 last1,
Init2 first2, Ty val);
template
Ty inner_product(InIt1 first1, InIt1 last1,
Init2 first2, Ty val, Fn21 func1, Fn22 func2);
template
OutIt partial_sum(InIt first, InIt last,
OutIt result);
template
OutIt partial_sum(InIt first, InIt last,
OutIt result, Fn2 func);
template
OutIt adjacent_difference(InIt first, InIt last,
OutIt result);
template
OutIt adjacent_difference(InIt first, InIt last,
OutIt result, Fn2 func);
} // namespace stdCopy to clipboard
## `accumulate`
template
Ty accumulate(InIt first, InIt last, Ty val);
template
Ty accumulate(InIt first, InIt last, Ty val, Fn2 func);Copy to clipboard
The first template function repeatedly replaces `val`
with `val + *I`, for each value of the `InIt`
iterator `I` in the interval `[first, last)`.
It then returns `val`.
The second template function repeatedly replaces `val`
with `func(val, *I)`, for each value of the `InIt`
iterator `I` in the interval `[first, last)`.
It then returns `val`.
## `adjacent_difference`
template
OutIt adjacent_difference(InIt first, InIt last,
OutIt result);
template
OutIt adjacent_difference(InIt first, InIt last,
OutIt result, Fn2 func);Copy to clipboard
The first template function stores successive values beginning
at `result`, for each value of the `InIt`
iterator `I` in the interval `[first, last)`.
The first value `val` stored (if any)
is `*I`. Each subsequent value
stored is `*I - val`, and `val` is replaced
by `*I`.
The function returns `result` incremented
`last - first` times.
The second template function stores successive values beginning
at `result`, for each value of the `InIt`
iterator `I` in the interval `[first, last)`.
The first value `val` stored (if any)
is `*I`. Each subsequent value
stored is `func(*I, val)`, and `val` is replaced
by `*I`.
The function returns `result` incremented
`last - first` times.
## `inner_product`
template
Ty inner_product(InIt1 first1, InIt1 last1,
Init2 first2, Ty val);
template
Ty inner_product(InIt1 first1, InIt1 last1,
Init2 first2, Ty val, Fn21 func1, Fn22 func2);Copy to clipboard
The first template function repeatedly replaces `val`
with `val + (*I1 * *I2)`, for each value of the `InIt1`
iterator `I1` in the interval `[first1, last2)`.
In each case, the `InIt2` iterator `I2` equals
`first2 + (I1 - first1)`.
The function returns `val`.
The second template function repeatedly replaces `val`
with `func1(val, func2(*I1, *I2))`,
for each value of the `InIt1`
iterator `I1` in the interval `[first1, last2)`.
In each case, the `InIt2` iterator `I2` equals
`first2 + (I1 - first1)`.
The function returns `val`.
## `partial_sum`
template
OutIt partial_sum(InIt first, InIt last,
OutIt result);
template
OutIt partial_sum(InIt first, InIt last,
OutIt result, Fn2 func);Copy to clipboard
The first template function stores successive values beginning
at `result`, for each value of the `InIt`
iterator `I` in the interval `[first, last)`.
The first value `val` stored (if any)
is `*I`. Each subsequent value `val`
stored is `val + *I`.
The function returns `result` incremented
`last - first` times.
The second template function stores successive values beginning
at `result`, for each value of the `InIt`
iterator `I` in the interval `[first, last)`.
The first value `val` stored (if any)
is `*I`. Each subsequent value `val`
stored is `func(val, *I)`.
The function returns `result` incremented
`last - first` times.
* * *
See also the
**[Table of Contents](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_index.html#Table%20of%20Contents)** and the
**[Index](https://docs.qualcomm.com/doc/80-N3040-23/topic/_cpp_index.html)**.
*[Copyright](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_crit_pjp.html) © 1992-2006by P.J. Plauger. Portions derived from work[copyright](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_crit_hp.html) © 1994by Hewlett-Packard Company. All rights reserved.*
Last Published: Oct 06, 2026
Previous Topic
Next Topic