10b57cec5SDimitry Andric// -*- C++ -*- 2349cc55cSDimitry Andric//===----------------------------------------------------------------------===// 30b57cec5SDimitry Andric// 40b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 50b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 60b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 70b57cec5SDimitry Andric// 80b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 90b57cec5SDimitry Andric 100b57cec5SDimitry Andric#ifndef _LIBCPP_NUMERIC 110b57cec5SDimitry Andric#define _LIBCPP_NUMERIC 120b57cec5SDimitry Andric 130b57cec5SDimitry Andric/* 140b57cec5SDimitry Andric numeric synopsis 150b57cec5SDimitry Andric 160b57cec5SDimitry Andricnamespace std 170b57cec5SDimitry Andric{ 180b57cec5SDimitry Andric 190b57cec5SDimitry Andrictemplate <class InputIterator, class T> 20e8d8bef9SDimitry Andric constexpr T // constexpr since C++20 210b57cec5SDimitry Andric accumulate(InputIterator first, InputIterator last, T init); 220b57cec5SDimitry Andric 230b57cec5SDimitry Andrictemplate <class InputIterator, class T, class BinaryOperation> 24e8d8bef9SDimitry Andric constexpr T // constexpr since C++20 250b57cec5SDimitry Andric accumulate(InputIterator first, InputIterator last, T init, BinaryOperation binary_op); 260b57cec5SDimitry Andric 270b57cec5SDimitry Andrictemplate<class InputIterator> 28e8d8bef9SDimitry Andric constexpr typename iterator_traits<InputIterator>::value_type // constexpr since C++20 290b57cec5SDimitry Andric reduce(InputIterator first, InputIterator last); // C++17 300b57cec5SDimitry Andric 310b57cec5SDimitry Andrictemplate<class InputIterator, class T> 32e8d8bef9SDimitry Andric constexpr T // constexpr since C++20 330b57cec5SDimitry Andric reduce(InputIterator first, InputIterator last, T init); // C++17 340b57cec5SDimitry Andric 350b57cec5SDimitry Andrictemplate<class InputIterator, class T, class BinaryOperation> 36e8d8bef9SDimitry Andric constexpr T // constexpr since C++20 370b57cec5SDimitry Andric reduce(InputIterator first, InputIterator last, T init, BinaryOperation binary_op); // C++17 380b57cec5SDimitry Andric 390b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2, class T> 40e8d8bef9SDimitry Andric constexpr T // constexpr since C++20 410b57cec5SDimitry Andric inner_product(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, T init); 420b57cec5SDimitry Andric 430b57cec5SDimitry Andrictemplate <class InputIterator1, class InputIterator2, class T, class BinaryOperation1, class BinaryOperation2> 44e8d8bef9SDimitry Andric constexpr T // constexpr since C++20 450b57cec5SDimitry Andric inner_product(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, 460b57cec5SDimitry Andric T init, BinaryOperation1 binary_op1, BinaryOperation2 binary_op2); 470b57cec5SDimitry Andric 480b57cec5SDimitry Andric 490b57cec5SDimitry Andrictemplate<class InputIterator1, class InputIterator2, class T> 50e8d8bef9SDimitry Andric constexpr T // constexpr since C++20 510b57cec5SDimitry Andric transform_reduce(InputIterator1 first1, InputIterator1 last1, 520b57cec5SDimitry Andric InputIterator2 first2, T init); // C++17 530b57cec5SDimitry Andric 540b57cec5SDimitry Andrictemplate<class InputIterator1, class InputIterator2, class T, class BinaryOperation1, class BinaryOperation2> 55e8d8bef9SDimitry Andric constexpr T // constexpr since C++20 560b57cec5SDimitry Andric transform_reduce(InputIterator1 first1, InputIterator1 last1, 570b57cec5SDimitry Andric InputIterator2 first2, T init, 580b57cec5SDimitry Andric BinaryOperation1 binary_op1, BinaryOperation2 binary_op2); // C++17 590b57cec5SDimitry Andric 600b57cec5SDimitry Andrictemplate<class InputIterator, class T, class BinaryOperation, class UnaryOperation> 61e8d8bef9SDimitry Andric constexpr T // constexpr since C++20 620b57cec5SDimitry Andric transform_reduce(InputIterator first, InputIterator last, T init, 630b57cec5SDimitry Andric BinaryOperation binary_op, UnaryOperation unary_op); // C++17 640b57cec5SDimitry Andric 650b57cec5SDimitry Andrictemplate <class InputIterator, class OutputIterator> 66e8d8bef9SDimitry Andric constexpr OutputIterator // constexpr since C++20 670b57cec5SDimitry Andric partial_sum(InputIterator first, InputIterator last, OutputIterator result); 680b57cec5SDimitry Andric 690b57cec5SDimitry Andrictemplate <class InputIterator, class OutputIterator, class BinaryOperation> 70e8d8bef9SDimitry Andric constexpr OutputIterator // constexpr since C++20 710b57cec5SDimitry Andric partial_sum(InputIterator first, InputIterator last, OutputIterator result, BinaryOperation binary_op); 720b57cec5SDimitry Andric 730b57cec5SDimitry Andrictemplate<class InputIterator, class OutputIterator, class T> 74e8d8bef9SDimitry Andric constexpr OutputIterator // constexpr since C++20 750b57cec5SDimitry Andric exclusive_scan(InputIterator first, InputIterator last, 760b57cec5SDimitry Andric OutputIterator result, T init); // C++17 770b57cec5SDimitry Andric 780b57cec5SDimitry Andrictemplate<class InputIterator, class OutputIterator, class T, class BinaryOperation> 79e8d8bef9SDimitry Andric constexpr OutputIterator // constexpr since C++20 800b57cec5SDimitry Andric exclusive_scan(InputIterator first, InputIterator last, 810b57cec5SDimitry Andric OutputIterator result, T init, BinaryOperation binary_op); // C++17 820b57cec5SDimitry Andric 830b57cec5SDimitry Andrictemplate<class InputIterator, class OutputIterator> 84e8d8bef9SDimitry Andric constexpr OutputIterator // constexpr since C++20 850b57cec5SDimitry Andric inclusive_scan(InputIterator first, InputIterator last, OutputIterator result); // C++17 860b57cec5SDimitry Andric 870b57cec5SDimitry Andrictemplate<class InputIterator, class OutputIterator, class BinaryOperation> 88e8d8bef9SDimitry Andric constexpr OutputIterator // constexpr since C++20 890b57cec5SDimitry Andric inclusive_scan(InputIterator first, InputIterator last, 900b57cec5SDimitry Andric OutputIterator result, BinaryOperation binary_op); // C++17 910b57cec5SDimitry Andric 920b57cec5SDimitry Andrictemplate<class InputIterator, class OutputIterator, class BinaryOperation, class T> 93e8d8bef9SDimitry Andric constexpr OutputIterator // constexpr since C++20 940b57cec5SDimitry Andric inclusive_scan(InputIterator first, InputIterator last, 950b57cec5SDimitry Andric OutputIterator result, BinaryOperation binary_op, T init); // C++17 960b57cec5SDimitry Andric 970b57cec5SDimitry Andrictemplate<class InputIterator, class OutputIterator, class T, 980b57cec5SDimitry Andric class BinaryOperation, class UnaryOperation> 99e8d8bef9SDimitry Andric constexpr OutputIterator // constexpr since C++20 1000b57cec5SDimitry Andric transform_exclusive_scan(InputIterator first, InputIterator last, 1010b57cec5SDimitry Andric OutputIterator result, T init, 1020b57cec5SDimitry Andric BinaryOperation binary_op, UnaryOperation unary_op); // C++17 1030b57cec5SDimitry Andric 1040b57cec5SDimitry Andrictemplate<class InputIterator, class OutputIterator, 1050b57cec5SDimitry Andric class BinaryOperation, class UnaryOperation> 106e8d8bef9SDimitry Andric constexpr OutputIterator // constexpr since C++20 1070b57cec5SDimitry Andric transform_inclusive_scan(InputIterator first, InputIterator last, 1080b57cec5SDimitry Andric OutputIterator result, 1090b57cec5SDimitry Andric BinaryOperation binary_op, UnaryOperation unary_op); // C++17 1100b57cec5SDimitry Andric 1110b57cec5SDimitry Andrictemplate<class InputIterator, class OutputIterator, 1120b57cec5SDimitry Andric class BinaryOperation, class UnaryOperation, class T> 113e8d8bef9SDimitry Andric constexpr OutputIterator // constexpr since C++20 1140b57cec5SDimitry Andric transform_inclusive_scan(InputIterator first, InputIterator last, 1150b57cec5SDimitry Andric OutputIterator result, 1160b57cec5SDimitry Andric BinaryOperation binary_op, UnaryOperation unary_op, 1170b57cec5SDimitry Andric T init); // C++17 1180b57cec5SDimitry Andric 1190b57cec5SDimitry Andrictemplate <class InputIterator, class OutputIterator> 120e8d8bef9SDimitry Andric constexpr OutputIterator // constexpr since C++20 1210b57cec5SDimitry Andric adjacent_difference(InputIterator first, InputIterator last, OutputIterator result); 1220b57cec5SDimitry Andric 1230b57cec5SDimitry Andrictemplate <class InputIterator, class OutputIterator, class BinaryOperation> 124e8d8bef9SDimitry Andric constexpr OutputIterator // constexpr since C++20 1250b57cec5SDimitry Andric adjacent_difference(InputIterator first, InputIterator last, OutputIterator result, BinaryOperation binary_op); 1260b57cec5SDimitry Andric 1270b57cec5SDimitry Andrictemplate <class ForwardIterator, class T> 128e8d8bef9SDimitry Andric constexpr void // constexpr since C++20 129e8d8bef9SDimitry Andric iota(ForwardIterator first, ForwardIterator last, T value); 1300b57cec5SDimitry Andric 1310b57cec5SDimitry Andrictemplate <class M, class N> 1320b57cec5SDimitry Andric constexpr common_type_t<M,N> gcd(M m, N n); // C++17 1330b57cec5SDimitry Andric 1340b57cec5SDimitry Andrictemplate <class M, class N> 1350b57cec5SDimitry Andric constexpr common_type_t<M,N> lcm(M m, N n); // C++17 1360b57cec5SDimitry Andric 137e8d8bef9SDimitry Andrictemplate<class T> 138e8d8bef9SDimitry Andric constexpr T midpoint(T a, T b) noexcept; // C++20 139e8d8bef9SDimitry Andric 140e8d8bef9SDimitry Andrictemplate<class T> 141e8d8bef9SDimitry Andric constexpr T* midpoint(T* a, T* b); // C++20 1420b57cec5SDimitry Andric 143*7a6dacacSDimitry Andric// [numeric.sat], saturation arithmetic 144*7a6dacacSDimitry Andrictemplate<class T> 145*7a6dacacSDimitry Andricconstexpr T add_sat(T x, T y) noexcept; // freestanding, Since C++26 146*7a6dacacSDimitry Andrictemplate<class T> 147*7a6dacacSDimitry Andricconstexpr T sub_sat(T x, T y) noexcept; // freestanding, Since C++26 148*7a6dacacSDimitry Andrictemplate<class T> 149*7a6dacacSDimitry Andricconstexpr T mul_sat(T x, T y) noexcept; // freestanding, Since C++26 150*7a6dacacSDimitry Andrictemplate<class T> 151*7a6dacacSDimitry Andricconstexpr T div_sat(T x, T y) noexcept; // freestanding, Since C++26 152*7a6dacacSDimitry Andrictemplate<class T, class U> 153*7a6dacacSDimitry Andricconstexpr T saturate_cast(U x) noexcept; // freestanding, Since C++26 154*7a6dacacSDimitry Andric 1550b57cec5SDimitry Andric} // std 1560b57cec5SDimitry Andric 1570b57cec5SDimitry Andric*/ 1580b57cec5SDimitry Andric 15981ad6265SDimitry Andric#include <__assert> // all public C++ headers provide the assertion handler 1600b57cec5SDimitry Andric#include <__config> 1610b57cec5SDimitry Andric#include <version> 1620b57cec5SDimitry Andric 1634824e7fdSDimitry Andric#include <__numeric/accumulate.h> 1644824e7fdSDimitry Andric#include <__numeric/adjacent_difference.h> 1654824e7fdSDimitry Andric#include <__numeric/exclusive_scan.h> 1664824e7fdSDimitry Andric#include <__numeric/gcd_lcm.h> 1674824e7fdSDimitry Andric#include <__numeric/inclusive_scan.h> 1684824e7fdSDimitry Andric#include <__numeric/inner_product.h> 1694824e7fdSDimitry Andric#include <__numeric/iota.h> 1704824e7fdSDimitry Andric#include <__numeric/midpoint.h> 1714824e7fdSDimitry Andric#include <__numeric/partial_sum.h> 17206c3fb27SDimitry Andric#include <__numeric/pstl_reduce.h> 17306c3fb27SDimitry Andric#include <__numeric/pstl_transform_reduce.h> 1744824e7fdSDimitry Andric#include <__numeric/reduce.h> 175*7a6dacacSDimitry Andric#include <__numeric/saturation_arithmetic.h> 1764824e7fdSDimitry Andric#include <__numeric/transform_exclusive_scan.h> 1774824e7fdSDimitry Andric#include <__numeric/transform_inclusive_scan.h> 1784824e7fdSDimitry Andric#include <__numeric/transform_reduce.h> 1794824e7fdSDimitry Andric 1800b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 1810b57cec5SDimitry Andric# pragma GCC system_header 1820b57cec5SDimitry Andric#endif 1830b57cec5SDimitry Andric 184bdd1243dSDimitry Andric#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 1855f757f3fSDimitry Andric# include <cmath> 186bdd1243dSDimitry Andric# include <concepts> 187bdd1243dSDimitry Andric# include <functional> 188bdd1243dSDimitry Andric# include <iterator> 189bdd1243dSDimitry Andric# include <type_traits> 190bdd1243dSDimitry Andric#endif 191bdd1243dSDimitry Andric 1920b57cec5SDimitry Andric#endif // _LIBCPP_NUMERIC 193