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