Warning, /include/c++/v1/numeric is written in an unsupported language. File is not indexed.
0001 // -*- C++ -*-
0002 //===----------------------------------------------------------------------===//
0003 //
0004 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0005 // See https://llvm.org/LICENSE.txt for license information.
0006 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0007 //
0008 //===----------------------------------------------------------------------===//
0009
0010 #ifndef _LIBCPP_NUMERIC
0011 #define _LIBCPP_NUMERIC
0012
0013 /*
0014 numeric synopsis
0015
0016 namespace std
0017 {
0018
0019 template <class InputIterator, class T>
0020 constexpr T // constexpr since C++20
0021 accumulate(InputIterator first, InputIterator last, T init);
0022
0023 template <class InputIterator, class T, class BinaryOperation>
0024 constexpr T // constexpr since C++20
0025 accumulate(InputIterator first, InputIterator last, T init, BinaryOperation binary_op);
0026
0027 template<class InputIterator>
0028 constexpr typename iterator_traits<InputIterator>::value_type // constexpr since C++20
0029 reduce(InputIterator first, InputIterator last); // C++17
0030
0031 template<class InputIterator, class T>
0032 constexpr T // constexpr since C++20
0033 reduce(InputIterator first, InputIterator last, T init); // C++17
0034
0035 template<class InputIterator, class T, class BinaryOperation>
0036 constexpr T // constexpr since C++20
0037 reduce(InputIterator first, InputIterator last, T init, BinaryOperation binary_op); // C++17
0038
0039 template <class InputIterator1, class InputIterator2, class T>
0040 constexpr T // constexpr since C++20
0041 inner_product(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, T init);
0042
0043 template <class InputIterator1, class InputIterator2, class T, class BinaryOperation1, class BinaryOperation2>
0044 constexpr T // constexpr since C++20
0045 inner_product(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,
0046 T init, BinaryOperation1 binary_op1, BinaryOperation2 binary_op2);
0047
0048
0049 template<class InputIterator1, class InputIterator2, class T>
0050 constexpr T // constexpr since C++20
0051 transform_reduce(InputIterator1 first1, InputIterator1 last1,
0052 InputIterator2 first2, T init); // C++17
0053
0054 template<class InputIterator1, class InputIterator2, class T, class BinaryOperation1, class BinaryOperation2>
0055 constexpr T // constexpr since C++20
0056 transform_reduce(InputIterator1 first1, InputIterator1 last1,
0057 InputIterator2 first2, T init,
0058 BinaryOperation1 binary_op1, BinaryOperation2 binary_op2); // C++17
0059
0060 template<class InputIterator, class T, class BinaryOperation, class UnaryOperation>
0061 constexpr T // constexpr since C++20
0062 transform_reduce(InputIterator first, InputIterator last, T init,
0063 BinaryOperation binary_op, UnaryOperation unary_op); // C++17
0064
0065 template <class InputIterator, class OutputIterator>
0066 constexpr OutputIterator // constexpr since C++20
0067 partial_sum(InputIterator first, InputIterator last, OutputIterator result);
0068
0069 template <class InputIterator, class OutputIterator, class BinaryOperation>
0070 constexpr OutputIterator // constexpr since C++20
0071 partial_sum(InputIterator first, InputIterator last, OutputIterator result, BinaryOperation binary_op);
0072
0073 template<class InputIterator, class OutputIterator, class T>
0074 constexpr OutputIterator // constexpr since C++20
0075 exclusive_scan(InputIterator first, InputIterator last,
0076 OutputIterator result, T init); // C++17
0077
0078 template<class InputIterator, class OutputIterator, class T, class BinaryOperation>
0079 constexpr OutputIterator // constexpr since C++20
0080 exclusive_scan(InputIterator first, InputIterator last,
0081 OutputIterator result, T init, BinaryOperation binary_op); // C++17
0082
0083 template<class InputIterator, class OutputIterator>
0084 constexpr OutputIterator // constexpr since C++20
0085 inclusive_scan(InputIterator first, InputIterator last, OutputIterator result); // C++17
0086
0087 template<class InputIterator, class OutputIterator, class BinaryOperation>
0088 constexpr OutputIterator // constexpr since C++20
0089 inclusive_scan(InputIterator first, InputIterator last,
0090 OutputIterator result, BinaryOperation binary_op); // C++17
0091
0092 template<class InputIterator, class OutputIterator, class BinaryOperation, class T>
0093 constexpr OutputIterator // constexpr since C++20
0094 inclusive_scan(InputIterator first, InputIterator last,
0095 OutputIterator result, BinaryOperation binary_op, T init); // C++17
0096
0097 template<class InputIterator, class OutputIterator, class T,
0098 class BinaryOperation, class UnaryOperation>
0099 constexpr OutputIterator // constexpr since C++20
0100 transform_exclusive_scan(InputIterator first, InputIterator last,
0101 OutputIterator result, T init,
0102 BinaryOperation binary_op, UnaryOperation unary_op); // C++17
0103
0104 template<class InputIterator, class OutputIterator,
0105 class BinaryOperation, class UnaryOperation>
0106 constexpr OutputIterator // constexpr since C++20
0107 transform_inclusive_scan(InputIterator first, InputIterator last,
0108 OutputIterator result,
0109 BinaryOperation binary_op, UnaryOperation unary_op); // C++17
0110
0111 template<class InputIterator, class OutputIterator,
0112 class BinaryOperation, class UnaryOperation, class T>
0113 constexpr OutputIterator // constexpr since C++20
0114 transform_inclusive_scan(InputIterator first, InputIterator last,
0115 OutputIterator result,
0116 BinaryOperation binary_op, UnaryOperation unary_op,
0117 T init); // C++17
0118
0119 template <class InputIterator, class OutputIterator>
0120 constexpr OutputIterator // constexpr since C++20
0121 adjacent_difference(InputIterator first, InputIterator last, OutputIterator result);
0122
0123 template <class InputIterator, class OutputIterator, class BinaryOperation>
0124 constexpr OutputIterator // constexpr since C++20
0125 adjacent_difference(InputIterator first, InputIterator last, OutputIterator result, BinaryOperation binary_op);
0126
0127 template <class ForwardIterator, class T>
0128 constexpr void // constexpr since C++20
0129 iota(ForwardIterator first, ForwardIterator last, T value);
0130
0131 template <class M, class N>
0132 constexpr common_type_t<M,N> gcd(M m, N n); // C++17
0133
0134 template <class M, class N>
0135 constexpr common_type_t<M,N> lcm(M m, N n); // C++17
0136
0137 template<class T>
0138 constexpr T midpoint(T a, T b) noexcept; // C++20
0139
0140 template<class T>
0141 constexpr T* midpoint(T* a, T* b); // C++20
0142
0143 // [numeric.sat], saturation arithmetic
0144 template<class T>
0145 constexpr T add_sat(T x, T y) noexcept; // freestanding, Since C++26
0146 template<class T>
0147 constexpr T sub_sat(T x, T y) noexcept; // freestanding, Since C++26
0148 template<class T>
0149 constexpr T mul_sat(T x, T y) noexcept; // freestanding, Since C++26
0150 template<class T>
0151 constexpr T div_sat(T x, T y) noexcept; // freestanding, Since C++26
0152 template<class T, class U>
0153 constexpr T saturate_cast(U x) noexcept; // freestanding, Since C++26
0154
0155 } // std
0156
0157 */
0158
0159 #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
0160 # include <__cxx03/numeric>
0161 #else
0162 # include <__config>
0163
0164 # include <__numeric/accumulate.h>
0165 # include <__numeric/adjacent_difference.h>
0166 # include <__numeric/inner_product.h>
0167 # include <__numeric/iota.h>
0168 # include <__numeric/partial_sum.h>
0169
0170 # if _LIBCPP_STD_VER >= 17
0171 # include <__numeric/exclusive_scan.h>
0172 # include <__numeric/gcd_lcm.h>
0173 # include <__numeric/inclusive_scan.h>
0174 # include <__numeric/pstl.h>
0175 # include <__numeric/reduce.h>
0176 # include <__numeric/transform_exclusive_scan.h>
0177 # include <__numeric/transform_inclusive_scan.h>
0178 # include <__numeric/transform_reduce.h>
0179 # endif
0180
0181 # if _LIBCPP_STD_VER >= 20
0182 # include <__numeric/midpoint.h>
0183 # include <__numeric/saturation_arithmetic.h>
0184 # endif
0185
0186 # include <version>
0187
0188 # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0189 # pragma GCC system_header
0190 # endif
0191
0192 # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 14
0193 # include <initializer_list>
0194 # include <limits>
0195 # endif
0196
0197 # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
0198 # include <climits>
0199 # include <cmath>
0200 # include <concepts>
0201 # include <cstdint>
0202 # include <execution>
0203 # include <functional>
0204 # include <iterator>
0205 # include <new>
0206 # include <optional>
0207 # include <type_traits>
0208 # endif
0209 #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
0210
0211 #endif // _LIBCPP_NUMERIC