`<numeric>`

Include the STL
standard header ** <numeric>**
to define several template functions useful for computing numeric values.
The descriptions of these templates employ a number of
conventions
common to all algorithms.

namespace std { template<class InIt, class Ty> Tyaccumulate(InIt first, InIt last, Ty val); template<class InIt, class Ty, class Fn2> Tyaccumulate(InIt first, InIt last, Ty val, Fn2 func); template<class InIt1, class InIt2, class Ty> Tyinner_product(InIt1 first1, InIt1 last1, Init2 first2, Ty val); template<class InIt1, class InIt2, class Ty, class Fn21, class Fn22> Tyinner_product(InIt1 first1, InIt1 last1, Init2 first2, Ty val, Fn21 func1, Fn22 func2); template<class InIt, class OutIt> OutItpartial_sum(InIt first, InIt last, OutIt result); template<class InIt, class OutIt, class Fn2> OutItpartial_sum(InIt first, InIt last, OutIt result, Fn2 func); template<class InIt, class OutIt> OutItadjacent_difference(InIt first, InIt last, OutIt result); template<class InIt, class OutIt, class Fn2> OutItadjacent_difference(InIt first, InIt last, OutIt result, Fn2 func); } // namespace std

`accumulate`

template<class InIt, class Ty> Tyaccumulate(InIt first, InIt last, Ty val); template<class InIt, class Ty, class Fn2> Tyaccumulate(InIt first, InIt last, Ty val, Fn2 func);

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<class InIt, class OutIt> OutItadjacent_difference(InIt first, InIt last, OutIt result); template<class InIt, class OutIt, class Fn2> OutItadjacent_difference(InIt first, InIt last, OutIt result, Fn2 func);

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<class InIt1, class InIt2, class Ty> Tyinner_product(InIt1 first1, InIt1 last1, Init2 first2, Ty val); template<class InIt1, class InIt2, class Ty, class Fn21, class Fn22> Tyinner_product(InIt1 first1, InIt1 last1, Init2 first2, Ty val, Fn21 func1, Fn22 func2);

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<class InIt, class OutIt> OutItpartial_sum(InIt first, InIt last, OutIt result); template<class InIt, class OutIt, class Fn2> OutItpartial_sum(InIt first, InIt last, OutIt result, Fn2 func);

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** and the
**Index**.

*
Copyright © 1992-2006
by P.J. Plauger. Portions derived from work
copyright © 1994
by Hewlett-Packard Company. All rights reserved.*

Last modified: 2013-12-21