[numeric.ops.overview]

# 26 Algorithms library [[algorithms]](./#algorithms)

## 26.9 Header <numeric> synopsis [numeric.ops.overview]

[ð](#header:%3cnumeric%3e)

// mostly freestandingnamespace std {// [[accumulate]](accumulate "26.10.3 Accumulate"), accumulatetemplate<class InputIterator, class T>constexpr T accumulate(InputIterator first, InputIterator last, T init); template<class InputIterator, class T, class BinaryOperation>constexpr T accumulate(InputIterator first, InputIterator last, T init,
 BinaryOperation binary_op); // [[reduce]](reduce "26.10.4 Reduce"), reducetemplate<class InputIterator>constexpr typename iterator_traits<InputIterator>::value_type
 reduce(InputIterator first, InputIterator last); template<class InputIterator, class T>constexpr T reduce(InputIterator first, InputIterator last, T init); template<class InputIterator, class T, class BinaryOperation>constexpr T reduce(InputIterator first, InputIterator last, T init,
 BinaryOperation binary_op); template<class ExecutionPolicy, class ForwardIterator>typename iterator_traits<ForwardIterator>::value_type
 reduce(ExecutionPolicy&& exec, // freestanding-deleted, see [[algorithms.parallel.overloads]](algorithms.parallel.overloads "26.3.5 Parallel algorithm overloads") ForwardIterator first, ForwardIterator last); template<class ExecutionPolicy, class ForwardIterator, class T> T reduce(ExecutionPolicy&& exec, // freestanding-deleted, see [[algorithms.parallel.overloads]](algorithms.parallel.overloads "26.3.5 Parallel algorithm overloads") ForwardIterator first, ForwardIterator last, T init); template<class ExecutionPolicy, class ForwardIterator, class T, class BinaryOperation> T reduce(ExecutionPolicy&& exec, // freestanding-deleted, see [[algorithms.parallel.overloads]](algorithms.parallel.overloads "26.3.5 Parallel algorithm overloads") ForwardIterator first, ForwardIterator last, T init, BinaryOperation binary_op); // [[inner.product]](inner.product "26.10.5 Inner product"), inner producttemplate<class InputIterator1, class InputIterator2, class T>constexpr T inner_product(InputIterator1 first1, InputIterator1 last1,
 InputIterator2 first2, T init); template<class InputIterator1, class InputIterator2, class T, class BinaryOperation1, class BinaryOperation2>constexpr T inner_product(InputIterator1 first1, InputIterator1 last1,
 InputIterator2 first2, T init,
 BinaryOperation1 binary_op1, BinaryOperation2 binary_op2); // [[transform.reduce]](transform.reduce "26.10.6 Transform reduce"), transform reducetemplate<class InputIterator1, class InputIterator2, class T>constexpr T transform_reduce(InputIterator1 first1, InputIterator1 last1,
 InputIterator2 first2, T init); template<class InputIterator1, class InputIterator2, class T, class BinaryOperation1, class BinaryOperation2>constexpr T transform_reduce(InputIterator1 first1, InputIterator1 last1,
 InputIterator2 first2, T init,
 BinaryOperation1 binary_op1, BinaryOperation2 binary_op2); template<class InputIterator, class T, class BinaryOperation, class UnaryOperation>constexpr T transform_reduce(InputIterator first, InputIterator last, T init,
 BinaryOperation binary_op, UnaryOperation unary_op); template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2, class T> T transform_reduce(ExecutionPolicy&& exec, // freestanding-deleted, see [[algorithms.parallel.overloads]](algorithms.parallel.overloads "26.3.5 Parallel algorithm overloads") ForwardIterator1 first1, ForwardIterator1 last1,
 ForwardIterator2 first2, T init); template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2, class T, class BinaryOperation1, class BinaryOperation2> T transform_reduce(ExecutionPolicy&& exec, // freestanding-deleted, see [[algorithms.parallel.overloads]](algorithms.parallel.overloads "26.3.5 Parallel algorithm overloads") ForwardIterator1 first1, ForwardIterator1 last1,
 ForwardIterator2 first2, T init,
 BinaryOperation1 binary_op1, BinaryOperation2 binary_op2); template<class ExecutionPolicy, class ForwardIterator, class T, class BinaryOperation, class UnaryOperation> T transform_reduce(ExecutionPolicy&& exec, // freestanding-deleted, see [[algorithms.parallel.overloads]](algorithms.parallel.overloads "26.3.5 Parallel algorithm overloads") ForwardIterator first, ForwardIterator last, T init,
 BinaryOperation binary_op, UnaryOperation unary_op); // [[partial.sum]](partial.sum "26.10.7 Partial sum"), partial sumtemplate<class InputIterator, class OutputIterator>constexpr OutputIterator
 partial_sum(InputIterator first, InputIterator last,
 OutputIterator result); template<class InputIterator, class OutputIterator, class BinaryOperation>constexpr OutputIterator
 partial_sum(InputIterator first, InputIterator last,
 OutputIterator result, BinaryOperation binary_op); // [[exclusive.scan]](exclusive.scan "26.10.8 Exclusive scan"), exclusive scantemplate<class InputIterator, class OutputIterator, class T>constexpr OutputIterator
 exclusive_scan(InputIterator first, InputIterator last,
 OutputIterator result, T init); template<class InputIterator, class OutputIterator, class T, class BinaryOperation>constexpr OutputIterator
 exclusive_scan(InputIterator first, InputIterator last,
 OutputIterator result, T init, BinaryOperation binary_op); template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2, class T> ForwardIterator2
 exclusive_scan(ExecutionPolicy&& exec, // freestanding-deleted, see [[algorithms.parallel.overloads]](algorithms.parallel.overloads "26.3.5 Parallel algorithm overloads") ForwardIterator1 first, ForwardIterator1 last,
 ForwardIterator2 result, T init); template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2, class T, class BinaryOperation> ForwardIterator2
 exclusive_scan(ExecutionPolicy&& exec, // freestanding-deleted, see [[algorithms.parallel.overloads]](algorithms.parallel.overloads "26.3.5 Parallel algorithm overloads") ForwardIterator1 first, ForwardIterator1 last,
 ForwardIterator2 result, T init, BinaryOperation binary_op); // [[inclusive.scan]](inclusive.scan "26.10.9 Inclusive scan"), inclusive scantemplate<class InputIterator, class OutputIterator>constexpr OutputIterator
 inclusive_scan(InputIterator first, InputIterator last,
 OutputIterator result); template<class InputIterator, class OutputIterator, class BinaryOperation>constexpr OutputIterator
 inclusive_scan(InputIterator first, InputIterator last,
 OutputIterator result, BinaryOperation binary_op); template<class InputIterator, class OutputIterator, class BinaryOperation, class T>constexpr OutputIterator
 inclusive_scan(InputIterator first, InputIterator last,
 OutputIterator result, BinaryOperation binary_op, T init); template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2> ForwardIterator2
 inclusive_scan(ExecutionPolicy&& exec, // freestanding-deleted, see [[algorithms.parallel.overloads]](algorithms.parallel.overloads "26.3.5 Parallel algorithm overloads") ForwardIterator1 first, ForwardIterator1 last,
 ForwardIterator2 result); template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2, class BinaryOperation> ForwardIterator2
 inclusive_scan(ExecutionPolicy&& exec, // freestanding-deleted, see [[algorithms.parallel.overloads]](algorithms.parallel.overloads "26.3.5 Parallel algorithm overloads") ForwardIterator1 first, ForwardIterator1 last,
 ForwardIterator2 result, BinaryOperation binary_op); template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2, class BinaryOperation, class T> ForwardIterator2
 inclusive_scan(ExecutionPolicy&& exec, // freestanding-deleted, see [[algorithms.parallel.overloads]](algorithms.parallel.overloads "26.3.5 Parallel algorithm overloads") ForwardIterator1 first, ForwardIterator1 last,
 ForwardIterator2 result, BinaryOperation binary_op, T init); // [[transform.exclusive.scan]](transform.exclusive.scan "26.10.10 Transform exclusive scan"), transform exclusive scantemplate<class InputIterator, class OutputIterator, class T, class BinaryOperation, class UnaryOperation>constexpr OutputIterator
 transform_exclusive_scan(InputIterator first, InputIterator last,
 OutputIterator result, T init,
 BinaryOperation binary_op, UnaryOperation unary_op); template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2, class T, class BinaryOperation, class UnaryOperation> ForwardIterator2
 transform_exclusive_scan(ExecutionPolicy&& exec, // freestanding-deleted, see [[algorithms.parallel.overloads]](algorithms.parallel.overloads "26.3.5 Parallel algorithm overloads") ForwardIterator1 first, ForwardIterator1 last,
 ForwardIterator2 result, T init,
 BinaryOperation binary_op, UnaryOperation unary_op); // [[transform.inclusive.scan]](transform.inclusive.scan "26.10.11 Transform inclusive scan"), transform inclusive scantemplate<class InputIterator, class OutputIterator, class BinaryOperation, class UnaryOperation>constexpr OutputIterator
 transform_inclusive_scan(InputIterator first, InputIterator last,
 OutputIterator result,
 BinaryOperation binary_op, UnaryOperation unary_op); template<class InputIterator, class OutputIterator, class BinaryOperation, class UnaryOperation, class T>constexpr OutputIterator
 transform_inclusive_scan(InputIterator first, InputIterator last,
 OutputIterator result,
 BinaryOperation binary_op, UnaryOperation unary_op, T init); template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2, class BinaryOperation, class UnaryOperation> ForwardIterator2
 transform_inclusive_scan(ExecutionPolicy&& exec, // freestanding-deleted, see [[algorithms.parallel.overloads]](algorithms.parallel.overloads "26.3.5 Parallel algorithm overloads") ForwardIterator1 first, ForwardIterator1 last,
 ForwardIterator2 result, BinaryOperation binary_op,
 UnaryOperation unary_op); template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2, class BinaryOperation, class UnaryOperation, class T> ForwardIterator2
 transform_inclusive_scan(ExecutionPolicy&& exec, // freestanding-deleted, see [[algorithms.parallel.overloads]](algorithms.parallel.overloads "26.3.5 Parallel algorithm overloads") ForwardIterator1 first, ForwardIterator1 last,
 ForwardIterator2 result,
 BinaryOperation binary_op, UnaryOperation unary_op, T init); // [[adjacent.difference]](adjacent.difference "26.10.12 Adjacent difference"), adjacent differencetemplate<class InputIterator, class OutputIterator>constexpr OutputIterator
 adjacent_difference(InputIterator first, InputIterator last,
 OutputIterator result); template<class InputIterator, class OutputIterator, class BinaryOperation>constexpr OutputIterator
 adjacent_difference(InputIterator first, InputIterator last,
 OutputIterator result, BinaryOperation binary_op); template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2> ForwardIterator2
 adjacent_difference(ExecutionPolicy&& exec, // freestanding-deleted, see [[algorithms.parallel.overloads]](algorithms.parallel.overloads "26.3.5 Parallel algorithm overloads") ForwardIterator1 first, ForwardIterator1 last,
 ForwardIterator2 result); template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2, class BinaryOperation> ForwardIterator2
 adjacent_difference(ExecutionPolicy&& exec, // freestanding-deleted, see [[algorithms.parallel.overloads]](algorithms.parallel.overloads "26.3.5 Parallel algorithm overloads") ForwardIterator1 first, ForwardIterator1 last,
 ForwardIterator2 result, BinaryOperation binary_op); // [[numeric.iota]](numeric.iota "26.10.13 Iota"), iotatemplate<class ForwardIterator, class T>constexpr void iota(ForwardIterator first, ForwardIterator last, T value); namespace ranges {template<class O, class T>using [iota_result](#lib:iota_result "26.9 Header <numeric> synopsis [numeric.ops.overview]") = out_value_result<O, T>; template<[input_or_output_iterator](iterator.concept.iterator#concept:input_or_output_iterator "24.3.4.6 Concept input_­or_­output_­iterator [iterator.concept.iterator]") O, [sentinel_for](iterator.concept.sentinel#concept:sentinel_for "24.3.4.7 Concept sentinel_­for [iterator.concept.sentinel]")<O> S, [weakly_incrementable](iterator.concept.winc#concept:weakly_incrementable "24.3.4.4 Concept weakly_­incrementable [iterator.concept.winc]") T>requires [indirectly_writable](iterator.concept.writable#concept:indirectly_writable "24.3.4.3 Concept indirectly_­writable [iterator.concept.writable]")<O, const T&>constexpr iota_result<O, T> iota(O first, S last, T value); template<[weakly_incrementable](iterator.concept.winc#concept:weakly_incrementable "24.3.4.4 Concept weakly_­incrementable [iterator.concept.winc]") T, [output_range](range.refinements#concept:output_range "25.4.6 Other range refinements [range.refinements]")<const T&> R>constexpr iota_result<borrowed_iterator_t<R>, T> iota(R&& r, T value); }// [[numeric.ops.gcd]](numeric.ops.gcd "26.10.14 Greatest common divisor"), greatest common divisortemplate<class M, class N>constexpr common_type_t<M, N> gcd(M m, N n); // [[numeric.ops.lcm]](numeric.ops.lcm "26.10.15 Least common multiple"), least common multipletemplate<class M, class N>constexpr common_type_t<M, N> lcm(M m, N n); // [[numeric.ops.midpoint]](numeric.ops.midpoint "26.10.16 Midpoint"), midpointtemplate<class T>constexpr T midpoint(T a, T b) noexcept; template<class T>constexpr T* midpoint(T* a, T* b); // [[numeric.sat]](numeric.sat "26.10.17 Saturation arithmetic"), saturation arithmetictemplate<class T>constexpr T add_sat(T x, T y) noexcept; template<class T>constexpr T sub_sat(T x, T y) noexcept; template<class T>constexpr T mul_sat(T x, T y) noexcept; template<class T>constexpr T div_sat(T x, T y) noexcept; template<class T, class U>constexpr T saturate_cast(U x) noexcept;}
