13e519524SHoward Hinnant// -*- C++ -*- 2eb8650a7SLouis Dionne//===----------------------------------------------------------------------===// 33e519524SHoward Hinnant// 457b08b09SChandler Carruth// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 557b08b09SChandler Carruth// See https://llvm.org/LICENSE.txt for license information. 657b08b09SChandler Carruth// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 73e519524SHoward Hinnant// 83e519524SHoward Hinnant//===----------------------------------------------------------------------===// 93e519524SHoward Hinnant 103e519524SHoward Hinnant#ifndef _LIBCPP_NUMERIC 113e519524SHoward Hinnant#define _LIBCPP_NUMERIC 123e519524SHoward Hinnant 133e519524SHoward Hinnant/* 143e519524SHoward Hinnant numeric synopsis 153e519524SHoward Hinnant 163e519524SHoward Hinnantnamespace std 173e519524SHoward Hinnant{ 183e519524SHoward Hinnant 193e519524SHoward Hinnanttemplate <class InputIterator, class T> 2067c88e47SMark de Wever constexpr T // constexpr since C++20 213e519524SHoward Hinnant accumulate(InputIterator first, InputIterator last, T init); 223e519524SHoward Hinnant 233e519524SHoward Hinnanttemplate <class InputIterator, class T, class BinaryOperation> 2467c88e47SMark de Wever constexpr T // constexpr since C++20 253e519524SHoward Hinnant accumulate(InputIterator first, InputIterator last, T init, BinaryOperation binary_op); 263e519524SHoward Hinnant 27f4ea23d3SMarshall Clowtemplate<class InputIterator> 2867c88e47SMark de Wever constexpr typename iterator_traits<InputIterator>::value_type // constexpr since C++20 29f4ea23d3SMarshall Clow reduce(InputIterator first, InputIterator last); // C++17 30f4ea23d3SMarshall Clow 31f4ea23d3SMarshall Clowtemplate<class InputIterator, class T> 3267c88e47SMark de Wever constexpr T // constexpr since C++20 33f4ea23d3SMarshall Clow reduce(InputIterator first, InputIterator last, T init); // C++17 34f4ea23d3SMarshall Clow 35f4ea23d3SMarshall Clowtemplate<class InputIterator, class T, class BinaryOperation> 3667c88e47SMark de Wever constexpr T // constexpr since C++20 37f4ea23d3SMarshall Clow reduce(InputIterator first, InputIterator last, T init, BinaryOperation binary_op); // C++17 38f4ea23d3SMarshall Clow 393e519524SHoward Hinnanttemplate <class InputIterator1, class InputIterator2, class T> 4067c88e47SMark de Wever constexpr T // constexpr since C++20 413e519524SHoward Hinnant inner_product(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, T init); 423e519524SHoward Hinnant 433e519524SHoward Hinnanttemplate <class InputIterator1, class InputIterator2, class T, class BinaryOperation1, class BinaryOperation2> 4467c88e47SMark de Wever constexpr T // constexpr since C++20 453e519524SHoward Hinnant inner_product(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, 463e519524SHoward Hinnant T init, BinaryOperation1 binary_op1, BinaryOperation2 binary_op2); 473e519524SHoward Hinnant 48f4ea23d3SMarshall Clow 49f4ea23d3SMarshall Clowtemplate<class InputIterator1, class InputIterator2, class T> 5067c88e47SMark de Wever constexpr T // constexpr since C++20 51f4ea23d3SMarshall Clow transform_reduce(InputIterator1 first1, InputIterator1 last1, 52f4ea23d3SMarshall Clow InputIterator2 first2, T init); // C++17 53f4ea23d3SMarshall Clow 54f4ea23d3SMarshall Clowtemplate<class InputIterator1, class InputIterator2, class T, class BinaryOperation1, class BinaryOperation2> 5567c88e47SMark de Wever constexpr T // constexpr since C++20 56f4ea23d3SMarshall Clow transform_reduce(InputIterator1 first1, InputIterator1 last1, 57f4ea23d3SMarshall Clow InputIterator2 first2, T init, 58f4ea23d3SMarshall Clow BinaryOperation1 binary_op1, BinaryOperation2 binary_op2); // C++17 59f4ea23d3SMarshall Clow 60f4ea23d3SMarshall Clowtemplate<class InputIterator, class T, class BinaryOperation, class UnaryOperation> 6167c88e47SMark de Wever constexpr T // constexpr since C++20 62f4ea23d3SMarshall Clow transform_reduce(InputIterator first, InputIterator last, T init, 63f4ea23d3SMarshall Clow BinaryOperation binary_op, UnaryOperation unary_op); // C++17 64f4ea23d3SMarshall Clow 653e519524SHoward Hinnanttemplate <class InputIterator, class OutputIterator> 6667c88e47SMark de Wever constexpr OutputIterator // constexpr since C++20 673e519524SHoward Hinnant partial_sum(InputIterator first, InputIterator last, OutputIterator result); 683e519524SHoward Hinnant 693e519524SHoward Hinnanttemplate <class InputIterator, class OutputIterator, class BinaryOperation> 7067c88e47SMark de Wever constexpr OutputIterator // constexpr since C++20 713e519524SHoward Hinnant partial_sum(InputIterator first, InputIterator last, OutputIterator result, BinaryOperation binary_op); 723e519524SHoward Hinnant 73e948ba1cSMarshall Clowtemplate<class InputIterator, class OutputIterator, class T> 7467c88e47SMark de Wever constexpr OutputIterator // constexpr since C++20 75e948ba1cSMarshall Clow exclusive_scan(InputIterator first, InputIterator last, 76e948ba1cSMarshall Clow OutputIterator result, T init); // C++17 77e948ba1cSMarshall Clow 78e948ba1cSMarshall Clowtemplate<class InputIterator, class OutputIterator, class T, class BinaryOperation> 7967c88e47SMark de Wever constexpr OutputIterator // constexpr since C++20 80e948ba1cSMarshall Clow exclusive_scan(InputIterator first, InputIterator last, 81e948ba1cSMarshall Clow OutputIterator result, T init, BinaryOperation binary_op); // C++17 82e948ba1cSMarshall Clow 83ac8ea7c6SMarshall Clowtemplate<class InputIterator, class OutputIterator> 8467c88e47SMark de Wever constexpr OutputIterator // constexpr since C++20 85ac8ea7c6SMarshall Clow inclusive_scan(InputIterator first, InputIterator last, OutputIterator result); // C++17 86ac8ea7c6SMarshall Clow 87ac8ea7c6SMarshall Clowtemplate<class InputIterator, class OutputIterator, class BinaryOperation> 8867c88e47SMark de Wever constexpr OutputIterator // constexpr since C++20 89ac8ea7c6SMarshall Clow inclusive_scan(InputIterator first, InputIterator last, 90ac8ea7c6SMarshall Clow OutputIterator result, BinaryOperation binary_op); // C++17 91ac8ea7c6SMarshall Clow 92ac8ea7c6SMarshall Clowtemplate<class InputIterator, class OutputIterator, class BinaryOperation, class T> 9367c88e47SMark de Wever constexpr OutputIterator // constexpr since C++20 94ac8ea7c6SMarshall Clow inclusive_scan(InputIterator first, InputIterator last, 95ac8ea7c6SMarshall Clow OutputIterator result, BinaryOperation binary_op, T init); // C++17 96ac8ea7c6SMarshall Clow 97e948ba1cSMarshall Clowtemplate<class InputIterator, class OutputIterator, class T, 98e948ba1cSMarshall Clow class BinaryOperation, class UnaryOperation> 9967c88e47SMark de Wever constexpr OutputIterator // constexpr since C++20 100e948ba1cSMarshall Clow transform_exclusive_scan(InputIterator first, InputIterator last, 101e948ba1cSMarshall Clow OutputIterator result, T init, 102e948ba1cSMarshall Clow BinaryOperation binary_op, UnaryOperation unary_op); // C++17 103e948ba1cSMarshall Clow 104ac8ea7c6SMarshall Clowtemplate<class InputIterator, class OutputIterator, 105ac8ea7c6SMarshall Clow class BinaryOperation, class UnaryOperation> 10667c88e47SMark de Wever constexpr OutputIterator // constexpr since C++20 107ac8ea7c6SMarshall Clow transform_inclusive_scan(InputIterator first, InputIterator last, 108ac8ea7c6SMarshall Clow OutputIterator result, 109ac8ea7c6SMarshall Clow BinaryOperation binary_op, UnaryOperation unary_op); // C++17 110ac8ea7c6SMarshall Clow 111ac8ea7c6SMarshall Clowtemplate<class InputIterator, class OutputIterator, 112ac8ea7c6SMarshall Clow class BinaryOperation, class UnaryOperation, class T> 11367c88e47SMark de Wever constexpr OutputIterator // constexpr since C++20 114ac8ea7c6SMarshall Clow transform_inclusive_scan(InputIterator first, InputIterator last, 115ac8ea7c6SMarshall Clow OutputIterator result, 116ac8ea7c6SMarshall Clow BinaryOperation binary_op, UnaryOperation unary_op, 117ac8ea7c6SMarshall Clow T init); // C++17 118ac8ea7c6SMarshall Clow 1193e519524SHoward Hinnanttemplate <class InputIterator, class OutputIterator> 12067c88e47SMark de Wever constexpr OutputIterator // constexpr since C++20 1213e519524SHoward Hinnant adjacent_difference(InputIterator first, InputIterator last, OutputIterator result); 1223e519524SHoward Hinnant 1233e519524SHoward Hinnanttemplate <class InputIterator, class OutputIterator, class BinaryOperation> 12467c88e47SMark de Wever constexpr OutputIterator // constexpr since C++20 1253e519524SHoward Hinnant adjacent_difference(InputIterator first, InputIterator last, OutputIterator result, BinaryOperation binary_op); 1263e519524SHoward Hinnant 12740c7ef90SHoward Hinnanttemplate <class ForwardIterator, class T> 12867c88e47SMark de Wever constexpr void // constexpr since C++20 12967c88e47SMark de Wever iota(ForwardIterator first, ForwardIterator last, T value); 13040c7ef90SHoward Hinnant 13119b4035fSMarshall Clowtemplate <class M, class N> 13219b4035fSMarshall Clow constexpr common_type_t<M,N> gcd(M m, N n); // C++17 13319b4035fSMarshall Clow 13419b4035fSMarshall Clowtemplate <class M, class N> 13519b4035fSMarshall Clow constexpr common_type_t<M,N> lcm(M m, N n); // C++17 13619b4035fSMarshall Clow 13767c88e47SMark de Wevertemplate<class T> 13867c88e47SMark de Wever constexpr T midpoint(T a, T b) noexcept; // C++20 13967c88e47SMark de Wever 14067c88e47SMark de Wevertemplate<class T> 14167c88e47SMark de Wever constexpr T* midpoint(T* a, T* b); // C++20 142330ab33fSMarshall Clow 1433e519524SHoward Hinnant} // std 1443e519524SHoward Hinnant 1453e519524SHoward Hinnant*/ 1463e519524SHoward Hinnant 147385cc25aSLouis Dionne#include <__assert> // all public C++ headers provide the assertion handler 1483e519524SHoward Hinnant#include <__config> 14906b40e80SArthur O'Dwyer#include <cmath> // for isnormal 150f56972e2SMarshall Clow#include <version> 1513e519524SHoward Hinnant 152a0efb175SChristopher Di Bella#include <__numeric/accumulate.h> 153a0efb175SChristopher Di Bella#include <__numeric/adjacent_difference.h> 154a0efb175SChristopher Di Bella#include <__numeric/exclusive_scan.h> 155a0efb175SChristopher Di Bella#include <__numeric/gcd_lcm.h> 156a0efb175SChristopher Di Bella#include <__numeric/inclusive_scan.h> 157a0efb175SChristopher Di Bella#include <__numeric/inner_product.h> 158a0efb175SChristopher Di Bella#include <__numeric/iota.h> 159a0efb175SChristopher Di Bella#include <__numeric/midpoint.h> 160a0efb175SChristopher Di Bella#include <__numeric/partial_sum.h> 161a0efb175SChristopher Di Bella#include <__numeric/reduce.h> 162a0efb175SChristopher Di Bella#include <__numeric/transform_exclusive_scan.h> 163a0efb175SChristopher Di Bella#include <__numeric/transform_inclusive_scan.h> 164a0efb175SChristopher Di Bella#include <__numeric/transform_reduce.h> 165a0efb175SChristopher Di Bella 166*de4a57cbSLouis Dionne#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES 167*de4a57cbSLouis Dionne# include <functional> 168*de4a57cbSLouis Dionne# include <iterator> 169*de4a57cbSLouis Dionne#endif 170*de4a57cbSLouis Dionne 171073458b1SHoward Hinnant#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 1723e519524SHoward Hinnant# pragma GCC system_header 173073458b1SHoward Hinnant#endif 1743e519524SHoward Hinnant 1750a06eb91SLouis Dionne#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17 17695689243SLouis Dionne# include <__pstl_numeric> 1770a06eb91SLouis Dionne#endif 1780a06eb91SLouis Dionne 1793e519524SHoward Hinnant#endif // _LIBCPP_NUMERIC 180