1*700637cbSDimitry Andric// -*- C++ -*- 2*700637cbSDimitry Andric//===----------------------------------------------------------------------===// 3*700637cbSDimitry Andric// 4*700637cbSDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5*700637cbSDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 6*700637cbSDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7*700637cbSDimitry Andric// 8*700637cbSDimitry Andric//===----------------------------------------------------------------------===// 9*700637cbSDimitry Andric 10*700637cbSDimitry Andric#ifndef _LIBCPP___CXX03_NUMERIC 11*700637cbSDimitry Andric#define _LIBCPP___CXX03_NUMERIC 12*700637cbSDimitry Andric 13*700637cbSDimitry Andric/* 14*700637cbSDimitry Andric numeric synopsis 15*700637cbSDimitry Andric 16*700637cbSDimitry Andricnamespace std 17*700637cbSDimitry Andric{ 18*700637cbSDimitry Andric 19*700637cbSDimitry Andrictemplate <class InputIterator, class T> 20*700637cbSDimitry Andric constexpr T // constexpr since C++20 21*700637cbSDimitry Andric accumulate(InputIterator first, InputIterator last, T init); 22*700637cbSDimitry Andric 23*700637cbSDimitry Andrictemplate <class InputIterator, class T, class BinaryOperation> 24*700637cbSDimitry Andric constexpr T // constexpr since C++20 25*700637cbSDimitry Andric accumulate(InputIterator first, InputIterator last, T init, BinaryOperation binary_op); 26*700637cbSDimitry Andric 27*700637cbSDimitry Andrictemplate<class InputIterator> 28*700637cbSDimitry Andric constexpr typename iterator_traits<InputIterator>::value_type // constexpr since C++20 29*700637cbSDimitry Andric reduce(InputIterator first, InputIterator last); // C++17 30*700637cbSDimitry Andric 31*700637cbSDimitry Andrictemplate<class InputIterator, class T> 32*700637cbSDimitry Andric constexpr T // constexpr since C++20 33*700637cbSDimitry Andric reduce(InputIterator first, InputIterator last, T init); // C++17 34*700637cbSDimitry Andric 35*700637cbSDimitry Andrictemplate<class InputIterator, class T, class BinaryOperation> 36*700637cbSDimitry Andric constexpr T // constexpr since C++20 37*700637cbSDimitry Andric reduce(InputIterator first, InputIterator last, T init, BinaryOperation binary_op); // C++17 38*700637cbSDimitry Andric 39*700637cbSDimitry Andrictemplate <class InputIterator1, class InputIterator2, class T> 40*700637cbSDimitry Andric constexpr T // constexpr since C++20 41*700637cbSDimitry Andric inner_product(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, T init); 42*700637cbSDimitry Andric 43*700637cbSDimitry Andrictemplate <class InputIterator1, class InputIterator2, class T, class BinaryOperation1, class BinaryOperation2> 44*700637cbSDimitry Andric constexpr T // constexpr since C++20 45*700637cbSDimitry Andric inner_product(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, 46*700637cbSDimitry Andric T init, BinaryOperation1 binary_op1, BinaryOperation2 binary_op2); 47*700637cbSDimitry Andric 48*700637cbSDimitry Andric 49*700637cbSDimitry Andrictemplate<class InputIterator1, class InputIterator2, class T> 50*700637cbSDimitry Andric constexpr T // constexpr since C++20 51*700637cbSDimitry Andric transform_reduce(InputIterator1 first1, InputIterator1 last1, 52*700637cbSDimitry Andric InputIterator2 first2, T init); // C++17 53*700637cbSDimitry Andric 54*700637cbSDimitry Andrictemplate<class InputIterator1, class InputIterator2, class T, class BinaryOperation1, class BinaryOperation2> 55*700637cbSDimitry Andric constexpr T // constexpr since C++20 56*700637cbSDimitry Andric transform_reduce(InputIterator1 first1, InputIterator1 last1, 57*700637cbSDimitry Andric InputIterator2 first2, T init, 58*700637cbSDimitry Andric BinaryOperation1 binary_op1, BinaryOperation2 binary_op2); // C++17 59*700637cbSDimitry Andric 60*700637cbSDimitry Andrictemplate<class InputIterator, class T, class BinaryOperation, class UnaryOperation> 61*700637cbSDimitry Andric constexpr T // constexpr since C++20 62*700637cbSDimitry Andric transform_reduce(InputIterator first, InputIterator last, T init, 63*700637cbSDimitry Andric BinaryOperation binary_op, UnaryOperation unary_op); // C++17 64*700637cbSDimitry Andric 65*700637cbSDimitry Andrictemplate <class InputIterator, class OutputIterator> 66*700637cbSDimitry Andric constexpr OutputIterator // constexpr since C++20 67*700637cbSDimitry Andric partial_sum(InputIterator first, InputIterator last, OutputIterator result); 68*700637cbSDimitry Andric 69*700637cbSDimitry Andrictemplate <class InputIterator, class OutputIterator, class BinaryOperation> 70*700637cbSDimitry Andric constexpr OutputIterator // constexpr since C++20 71*700637cbSDimitry Andric partial_sum(InputIterator first, InputIterator last, OutputIterator result, BinaryOperation binary_op); 72*700637cbSDimitry Andric 73*700637cbSDimitry Andrictemplate<class InputIterator, class OutputIterator, class T> 74*700637cbSDimitry Andric constexpr OutputIterator // constexpr since C++20 75*700637cbSDimitry Andric exclusive_scan(InputIterator first, InputIterator last, 76*700637cbSDimitry Andric OutputIterator result, T init); // C++17 77*700637cbSDimitry Andric 78*700637cbSDimitry Andrictemplate<class InputIterator, class OutputIterator, class T, class BinaryOperation> 79*700637cbSDimitry Andric constexpr OutputIterator // constexpr since C++20 80*700637cbSDimitry Andric exclusive_scan(InputIterator first, InputIterator last, 81*700637cbSDimitry Andric OutputIterator result, T init, BinaryOperation binary_op); // C++17 82*700637cbSDimitry Andric 83*700637cbSDimitry Andrictemplate<class InputIterator, class OutputIterator> 84*700637cbSDimitry Andric constexpr OutputIterator // constexpr since C++20 85*700637cbSDimitry Andric inclusive_scan(InputIterator first, InputIterator last, OutputIterator result); // C++17 86*700637cbSDimitry Andric 87*700637cbSDimitry Andrictemplate<class InputIterator, class OutputIterator, class BinaryOperation> 88*700637cbSDimitry Andric constexpr OutputIterator // constexpr since C++20 89*700637cbSDimitry Andric inclusive_scan(InputIterator first, InputIterator last, 90*700637cbSDimitry Andric OutputIterator result, BinaryOperation binary_op); // C++17 91*700637cbSDimitry Andric 92*700637cbSDimitry Andrictemplate<class InputIterator, class OutputIterator, class BinaryOperation, class T> 93*700637cbSDimitry Andric constexpr OutputIterator // constexpr since C++20 94*700637cbSDimitry Andric inclusive_scan(InputIterator first, InputIterator last, 95*700637cbSDimitry Andric OutputIterator result, BinaryOperation binary_op, T init); // C++17 96*700637cbSDimitry Andric 97*700637cbSDimitry Andrictemplate<class InputIterator, class OutputIterator, class T, 98*700637cbSDimitry Andric class BinaryOperation, class UnaryOperation> 99*700637cbSDimitry Andric constexpr OutputIterator // constexpr since C++20 100*700637cbSDimitry Andric transform_exclusive_scan(InputIterator first, InputIterator last, 101*700637cbSDimitry Andric OutputIterator result, T init, 102*700637cbSDimitry Andric BinaryOperation binary_op, UnaryOperation unary_op); // C++17 103*700637cbSDimitry Andric 104*700637cbSDimitry Andrictemplate<class InputIterator, class OutputIterator, 105*700637cbSDimitry Andric class BinaryOperation, class UnaryOperation> 106*700637cbSDimitry Andric constexpr OutputIterator // constexpr since C++20 107*700637cbSDimitry Andric transform_inclusive_scan(InputIterator first, InputIterator last, 108*700637cbSDimitry Andric OutputIterator result, 109*700637cbSDimitry Andric BinaryOperation binary_op, UnaryOperation unary_op); // C++17 110*700637cbSDimitry Andric 111*700637cbSDimitry Andrictemplate<class InputIterator, class OutputIterator, 112*700637cbSDimitry Andric class BinaryOperation, class UnaryOperation, class T> 113*700637cbSDimitry Andric constexpr OutputIterator // constexpr since C++20 114*700637cbSDimitry Andric transform_inclusive_scan(InputIterator first, InputIterator last, 115*700637cbSDimitry Andric OutputIterator result, 116*700637cbSDimitry Andric BinaryOperation binary_op, UnaryOperation unary_op, 117*700637cbSDimitry Andric T init); // C++17 118*700637cbSDimitry Andric 119*700637cbSDimitry Andrictemplate <class InputIterator, class OutputIterator> 120*700637cbSDimitry Andric constexpr OutputIterator // constexpr since C++20 121*700637cbSDimitry Andric adjacent_difference(InputIterator first, InputIterator last, OutputIterator result); 122*700637cbSDimitry Andric 123*700637cbSDimitry Andrictemplate <class InputIterator, class OutputIterator, class BinaryOperation> 124*700637cbSDimitry Andric constexpr OutputIterator // constexpr since C++20 125*700637cbSDimitry Andric adjacent_difference(InputIterator first, InputIterator last, OutputIterator result, BinaryOperation binary_op); 126*700637cbSDimitry Andric 127*700637cbSDimitry Andrictemplate <class ForwardIterator, class T> 128*700637cbSDimitry Andric constexpr void // constexpr since C++20 129*700637cbSDimitry Andric iota(ForwardIterator first, ForwardIterator last, T value); 130*700637cbSDimitry Andric 131*700637cbSDimitry Andrictemplate <class M, class N> 132*700637cbSDimitry Andric constexpr common_type_t<M,N> gcd(M m, N n); // C++17 133*700637cbSDimitry Andric 134*700637cbSDimitry Andrictemplate <class M, class N> 135*700637cbSDimitry Andric constexpr common_type_t<M,N> lcm(M m, N n); // C++17 136*700637cbSDimitry Andric 137*700637cbSDimitry Andrictemplate<class T> 138*700637cbSDimitry Andric constexpr T midpoint(T a, T b) noexcept; // C++20 139*700637cbSDimitry Andric 140*700637cbSDimitry Andrictemplate<class T> 141*700637cbSDimitry Andric constexpr T* midpoint(T* a, T* b); // C++20 142*700637cbSDimitry Andric 143*700637cbSDimitry Andric// [numeric.sat], saturation arithmetic 144*700637cbSDimitry Andrictemplate<class T> 145*700637cbSDimitry Andricconstexpr T add_sat(T x, T y) noexcept; // freestanding, Since C++26 146*700637cbSDimitry Andrictemplate<class T> 147*700637cbSDimitry Andricconstexpr T sub_sat(T x, T y) noexcept; // freestanding, Since C++26 148*700637cbSDimitry Andrictemplate<class T> 149*700637cbSDimitry Andricconstexpr T mul_sat(T x, T y) noexcept; // freestanding, Since C++26 150*700637cbSDimitry Andrictemplate<class T> 151*700637cbSDimitry Andricconstexpr T div_sat(T x, T y) noexcept; // freestanding, Since C++26 152*700637cbSDimitry Andrictemplate<class T, class U> 153*700637cbSDimitry Andricconstexpr T saturate_cast(U x) noexcept; // freestanding, Since C++26 154*700637cbSDimitry Andric 155*700637cbSDimitry Andric} // std 156*700637cbSDimitry Andric 157*700637cbSDimitry Andric*/ 158*700637cbSDimitry Andric 159*700637cbSDimitry Andric#include <__cxx03/__config> 160*700637cbSDimitry Andric 161*700637cbSDimitry Andric#include <__cxx03/__numeric/accumulate.h> 162*700637cbSDimitry Andric#include <__cxx03/__numeric/adjacent_difference.h> 163*700637cbSDimitry Andric#include <__cxx03/__numeric/inner_product.h> 164*700637cbSDimitry Andric#include <__cxx03/__numeric/iota.h> 165*700637cbSDimitry Andric#include <__cxx03/__numeric/partial_sum.h> 166*700637cbSDimitry Andric 167*700637cbSDimitry Andric#include <__cxx03/version> 168*700637cbSDimitry Andric 169*700637cbSDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 170*700637cbSDimitry Andric# pragma GCC system_header 171*700637cbSDimitry Andric#endif 172*700637cbSDimitry Andric 173*700637cbSDimitry Andric#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) 174*700637cbSDimitry Andric# include <__cxx03/limits> 175*700637cbSDimitry Andric#endif 176*700637cbSDimitry Andric 177*700637cbSDimitry Andric#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) 178*700637cbSDimitry Andric# include <__cxx03/climits> 179*700637cbSDimitry Andric# include <__cxx03/cmath> 180*700637cbSDimitry Andric# include <__cxx03/cstdint> 181*700637cbSDimitry Andric# include <__cxx03/functional> 182*700637cbSDimitry Andric# include <__cxx03/iterator> 183*700637cbSDimitry Andric# include <__cxx03/new> 184*700637cbSDimitry Andric# include <__cxx03/type_traits> 185*700637cbSDimitry Andric#endif 186*700637cbSDimitry Andric 187*700637cbSDimitry Andric#endif // _LIBCPP___CXX03_NUMERIC 188