Init
This commit is contained in:
102
cppdraft/transform/exclusive/scan.md
Normal file
102
cppdraft/transform/exclusive/scan.md
Normal file
@@ -0,0 +1,102 @@
|
||||
[transform.exclusive.scan]
|
||||
|
||||
# 26 Algorithms library [[algorithms]](./#algorithms)
|
||||
|
||||
## 26.10 Generalized numeric operations [[numeric.ops]](numeric.ops#transform.exclusive.scan)
|
||||
|
||||
### 26.10.10 Transform exclusive scan [transform.exclusive.scan]
|
||||
|
||||
[ð](#lib:transform_exclusive_scan)
|
||||
|
||||
`template<class InputIterator, class OutputIterator, class T,
|
||||
class BinaryOperation, class UnaryOperation>
|
||||
constexpr OutputIterator
|
||||
transform_exclusive_scan(InputIterator first, InputIterator last,
|
||||
OutputIterator result, T init,
|
||||
BinaryOperation binary_op, UnaryOperation unary_op);
|
||||
template<class ExecutionPolicy,
|
||||
class ForwardIterator1, class ForwardIterator2, class T,
|
||||
class BinaryOperation, class UnaryOperation>
|
||||
ForwardIterator2
|
||||
transform_exclusive_scan(ExecutionPolicy&& exec,
|
||||
ForwardIterator1 first, ForwardIterator1 last,
|
||||
ForwardIterator2 result, T init,
|
||||
BinaryOperation binary_op, UnaryOperation unary_op);
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L12953)
|
||||
|
||||
*Mandates*: All of
|
||||
|
||||
- [(1.1)](#1.1)
|
||||
|
||||
binary_op(init, init),
|
||||
|
||||
- [(1.2)](#1.2)
|
||||
|
||||
binary_op(init, unary_op(*first)), and
|
||||
|
||||
- [(1.3)](#1.3)
|
||||
|
||||
binary_op(unary_op(*first), unary_op(*first))
|
||||
|
||||
are convertible to T[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L12963)
|
||||
|
||||
*Preconditions*:
|
||||
|
||||
- [(2.1)](#2.1)
|
||||
|
||||
T meets the [*Cpp17MoveConstructible*](utility.arg.requirements#:Cpp17MoveConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") (Table [31](utility.arg.requirements#tab:cpp17.moveconstructible "Table 31: Cpp17MoveConstructible requirements")) requirements[.](#2.1.sentence-1)
|
||||
|
||||
- [(2.2)](#2.2)
|
||||
|
||||
Neither unary_op nor binary_op invalidates iterators or subranges, nor modifies elements in
|
||||
the ranges [first, last] or [result, result + (last - first)][.](#2.2.sentence-1)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L12974)
|
||||
|
||||
*Effects*: For each integer K in [0, last - first)
|
||||
assigns through result + K the value of:*GENERALIZED_NONCOMMUTATIVE_SUM*( binary_op, init,
|
||||
unary_op(*(first + 0)), unary_op(*(first + 1)), …, unary_op(*(first + K - 1)))
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L12984)
|
||||
|
||||
*Returns*: The end of the resulting range beginning at result[.](#4.sentence-1)
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L12988)
|
||||
|
||||
*Complexity*: O(last - first) applications each
|
||||
of unary_op and binary_op[.](#5.sentence-1)
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L12993)
|
||||
|
||||
*Remarks*: result may be equal to first[.](#6.sentence-1)
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L12997)
|
||||
|
||||
[*Note [1](#note-1)*:
|
||||
|
||||
The difference between transform_exclusive_scan andtransform_inclusive_scan is that transform_exclusive_scan excludes the ith input element from the ith sum[.](#7.sentence-1)
|
||||
|
||||
If binary_op is not mathematically associative,
|
||||
the behavior of transform_exclusive_scan can be nondeterministic[.](#7.sentence-2)
|
||||
|
||||
transform_exclusive_scan does not apply unary_op to init[.](#7.sentence-3)
|
||||
|
||||
â *end note*]
|
||||
141
cppdraft/transform/inclusive/scan.md
Normal file
141
cppdraft/transform/inclusive/scan.md
Normal file
@@ -0,0 +1,141 @@
|
||||
[transform.inclusive.scan]
|
||||
|
||||
# 26 Algorithms library [[algorithms]](./#algorithms)
|
||||
|
||||
## 26.10 Generalized numeric operations [[numeric.ops]](numeric.ops#transform.inclusive.scan)
|
||||
|
||||
### 26.10.11 Transform inclusive scan [transform.inclusive.scan]
|
||||
|
||||
[ð](#lib:transform_inclusive_scan)
|
||||
|
||||
`template<class InputIterator, class OutputIterator,
|
||||
class BinaryOperation, class UnaryOperation>
|
||||
constexpr OutputIterator
|
||||
transform_inclusive_scan(InputIterator first, InputIterator last,
|
||||
OutputIterator result,
|
||||
BinaryOperation binary_op, UnaryOperation unary_op);
|
||||
template<class ExecutionPolicy,
|
||||
class ForwardIterator1, class ForwardIterator2,
|
||||
class BinaryOperation, class UnaryOperation>
|
||||
ForwardIterator2
|
||||
transform_inclusive_scan(ExecutionPolicy&& exec,
|
||||
ForwardIterator1 first, ForwardIterator1 last,
|
||||
ForwardIterator2 result,
|
||||
BinaryOperation binary_op, UnaryOperation unary_op);
|
||||
template<class InputIterator, class OutputIterator,
|
||||
class BinaryOperation, class UnaryOperation, class T>
|
||||
constexpr OutputIterator
|
||||
transform_inclusive_scan(InputIterator first, InputIterator last,
|
||||
OutputIterator result,
|
||||
BinaryOperation binary_op, UnaryOperation unary_op,
|
||||
T init);
|
||||
template<class ExecutionPolicy,
|
||||
class ForwardIterator1, class ForwardIterator2,
|
||||
class BinaryOperation, class UnaryOperation, class T>
|
||||
ForwardIterator2
|
||||
transform_inclusive_scan(ExecutionPolicy&& exec,
|
||||
ForwardIterator1 first, ForwardIterator1 last,
|
||||
ForwardIterator2 result,
|
||||
BinaryOperation binary_op, UnaryOperation unary_op,
|
||||
T init);
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13046)
|
||||
|
||||
Let U be the value type of decltype(first)[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13049)
|
||||
|
||||
*Mandates*: If init is provided, all of
|
||||
|
||||
- [(2.1)](#2.1)
|
||||
|
||||
binary_op(init, init),
|
||||
|
||||
- [(2.2)](#2.2)
|
||||
|
||||
binary_op(init, unary_op(*first)), and
|
||||
|
||||
- [(2.3)](#2.3)
|
||||
|
||||
binary_op(unary_op(*first), unary_op(*first))
|
||||
|
||||
are convertible to T;
|
||||
otherwise, binary_op(unary_op(*first), unary_op(*first)) is convertible to U[.](#2.sentence-1)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13061)
|
||||
|
||||
*Preconditions*:
|
||||
|
||||
- [(3.1)](#3.1)
|
||||
|
||||
If init is provided, T meets the [*Cpp17MoveConstructible*](utility.arg.requirements#:Cpp17MoveConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") (Table [31](utility.arg.requirements#tab:cpp17.moveconstructible "Table 31: Cpp17MoveConstructible requirements")) requirements;
|
||||
otherwise, U meets the [*Cpp17MoveConstructible*](utility.arg.requirements#:Cpp17MoveConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements[.](#3.1.sentence-1)
|
||||
|
||||
- [(3.2)](#3.2)
|
||||
|
||||
Neither unary_op nor binary_op invalidates
|
||||
iterators or subranges, nor modifies elements in
|
||||
the ranges [first, last] or [result, result + (last - first)][.](#3.2.sentence-1)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13075)
|
||||
|
||||
*Effects*: For each integer K in [0, last - first)
|
||||
assigns through result + K the value of
|
||||
|
||||
- [(4.1)](#4.1)
|
||||
|
||||
*GENERALIZED_NONCOMMUTATIVE_SUM*(
|
||||
binary_op, init,
|
||||
unary_op(*(first + 0)), unary_op(*(first + 1)), …, unary_op(*(first + K)))
|
||||
if init is provided, or
|
||||
|
||||
- [(4.2)](#4.2)
|
||||
|
||||
*GENERALIZED_NONCOMMUTATIVE_SUM*(
|
||||
binary_op,
|
||||
unary_op(*(first + 0)), unary_op(*(first + 1)), …, unary_op(*(first + K)))
|
||||
otherwise[.](#4.2.sentence-2)
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13088)
|
||||
|
||||
*Returns*: The end of the resulting range beginning at result[.](#5.sentence-1)
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13092)
|
||||
|
||||
*Complexity*: O(last - first) applications each
|
||||
of unary_op and binary_op[.](#6.sentence-1)
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13097)
|
||||
|
||||
*Remarks*: result may be equal to first[.](#7.sentence-1)
|
||||
|
||||
[8](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13101)
|
||||
|
||||
[*Note [1](#note-1)*:
|
||||
|
||||
The difference between transform_exclusive_scan andtransform_inclusive_scan is that transform_inclusive_scan includes the ith input element in the ith sum[.](#8.sentence-1)
|
||||
|
||||
If binary_op is not mathematically associative,
|
||||
the behavior of transform_inclusive_scan can be nondeterministic[.](#8.sentence-2)
|
||||
|
||||
transform_inclusive_scan does not
|
||||
apply unary_op to init[.](#8.sentence-3)
|
||||
|
||||
â *end note*]
|
||||
185
cppdraft/transform/reduce.md
Normal file
185
cppdraft/transform/reduce.md
Normal file
@@ -0,0 +1,185 @@
|
||||
[transform.reduce]
|
||||
|
||||
# 26 Algorithms library [[algorithms]](./#algorithms)
|
||||
|
||||
## 26.10 Generalized numeric operations [[numeric.ops]](numeric.ops#transform.reduce)
|
||||
|
||||
### 26.10.6 Transform reduce [transform.reduce]
|
||||
|
||||
[ð](#lib:transform_reduce)
|
||||
|
||||
`template<class InputIterator1, class InputIterator2, class T>
|
||||
constexpr T transform_reduce(InputIterator1 first1, InputIterator1 last1,
|
||||
InputIterator2 first2,
|
||||
T init);
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L12504)
|
||||
|
||||
*Effects*: Equivalent to:return transform_reduce(first1, last1, first2, init, plus<>(), multiplies<>());
|
||||
|
||||
[ð](#lib:transform_reduce_)
|
||||
|
||||
`template<class ExecutionPolicy,
|
||||
class ForwardIterator1, class ForwardIterator2, class T>
|
||||
T transform_reduce(ExecutionPolicy&& exec,
|
||||
ForwardIterator1 first1, ForwardIterator1 last1,
|
||||
ForwardIterator2 first2,
|
||||
T init);
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L12523)
|
||||
|
||||
*Effects*: Equivalent to:return transform_reduce(std::forward<ExecutionPolicy>(exec),
|
||||
first1, last1, first2, init, plus<>(), multiplies<>());
|
||||
|
||||
[ð](#lib:transform_reduce__)
|
||||
|
||||
`template<class InputIterator1, class InputIterator2, class T,
|
||||
class BinaryOperation1, class BinaryOperation2>
|
||||
constexpr T transform_reduce(InputIterator1 first1, InputIterator1 last1,
|
||||
InputIterator2 first2,
|
||||
T init,
|
||||
BinaryOperation1 binary_op1,
|
||||
BinaryOperation2 binary_op2);
|
||||
template<class ExecutionPolicy,
|
||||
class ForwardIterator1, class ForwardIterator2, class T,
|
||||
class BinaryOperation1, class BinaryOperation2>
|
||||
T transform_reduce(ExecutionPolicy&& exec,
|
||||
ForwardIterator1 first1, ForwardIterator1 last1,
|
||||
ForwardIterator2 first2,
|
||||
T init,
|
||||
BinaryOperation1 binary_op1,
|
||||
BinaryOperation2 binary_op2);
|
||||
`
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L12553)
|
||||
|
||||
*Mandates*: All of
|
||||
|
||||
- [(3.1)](#3.1)
|
||||
|
||||
binary_op1(init, init),
|
||||
|
||||
- [(3.2)](#3.2)
|
||||
|
||||
binary_op1(init, binary_op2(*first1, *first2)),
|
||||
|
||||
- [(3.3)](#3.3)
|
||||
|
||||
binary_op1(binary_op2(*first1, *first2), init), and
|
||||
|
||||
- [(3.4)](#3.4)
|
||||
|
||||
binary_op1(binary_op2(*first1, *first2), binary_op2(*first1, *first2))
|
||||
|
||||
are convertible to T[.](#3.sentence-1)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L12564)
|
||||
|
||||
*Preconditions*:
|
||||
|
||||
- [(4.1)](#4.1)
|
||||
|
||||
T meets the [*Cpp17MoveConstructible*](utility.arg.requirements#:Cpp17MoveConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") (Table [31](utility.arg.requirements#tab:cpp17.moveconstructible "Table 31: Cpp17MoveConstructible requirements")) requirements[.](#4.1.sentence-1)
|
||||
|
||||
- [(4.2)](#4.2)
|
||||
|
||||
Neither binary_op1 nor binary_op2 invalidates subranges, nor modifies elements in the ranges
|
||||
[first1, last1] and [first2, first2 + (last1 - first1)][.](#4.2.sentence-1)
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L12575)
|
||||
|
||||
*Returns*: *GENERALIZED_SUM*(binary_op1, init, binary_op2(*i, *(first2 + (i - first1))), …) for every iterator i in [first1, last1)[.](#5.sentence-1)
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L12582)
|
||||
|
||||
*Complexity*: O(last1 - first1) applications each
|
||||
of binary_op1 and binary_op2[.](#6.sentence-1)
|
||||
|
||||
[ð](#lib:transform_reduce___)
|
||||
|
||||
`template<class InputIterator, class T,
|
||||
class BinaryOperation, class UnaryOperation>
|
||||
constexpr T transform_reduce(InputIterator first, InputIterator last, T init,
|
||||
BinaryOperation binary_op, UnaryOperation unary_op);
|
||||
template<class ExecutionPolicy,
|
||||
class ForwardIterator, class T,
|
||||
class BinaryOperation, class UnaryOperation>
|
||||
T transform_reduce(ExecutionPolicy&& exec,
|
||||
ForwardIterator first, ForwardIterator last,
|
||||
T init, BinaryOperation binary_op, UnaryOperation unary_op);
|
||||
`
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L12603)
|
||||
|
||||
*Mandates*: All of
|
||||
|
||||
- [(7.1)](#7.1)
|
||||
|
||||
binary_op(init, init),
|
||||
|
||||
- [(7.2)](#7.2)
|
||||
|
||||
binary_op(init, unary_op(*first)),
|
||||
|
||||
- [(7.3)](#7.3)
|
||||
|
||||
binary_op(unary_op(*first), init), and
|
||||
|
||||
- [(7.4)](#7.4)
|
||||
|
||||
binary_op(unary_op(*first), unary_op(*first))
|
||||
|
||||
are convertible to T[.](#7.sentence-1)
|
||||
|
||||
[8](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L12614)
|
||||
|
||||
*Preconditions*:
|
||||
|
||||
- [(8.1)](#8.1)
|
||||
|
||||
T meets the [*Cpp17MoveConstructible*](utility.arg.requirements#:Cpp17MoveConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") (Table [31](utility.arg.requirements#tab:cpp17.moveconstructible "Table 31: Cpp17MoveConstructible requirements")) requirements[.](#8.1.sentence-1)
|
||||
|
||||
- [(8.2)](#8.2)
|
||||
|
||||
Neither unary_op nor binary_op invalidates subranges,
|
||||
nor modifies elements in the range [first, last][.](#8.2.sentence-1)
|
||||
|
||||
[9](#9)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L12624)
|
||||
|
||||
*Returns*: *GENERALIZED_SUM*(binary_op, init, unary_op(*i), …) for every iterator i in [first, last)[.](#9.sentence-1)
|
||||
|
||||
[10](#10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L12631)
|
||||
|
||||
*Complexity*: O(last - first) applications each of unary_op andbinary_op[.](#10.sentence-1)
|
||||
|
||||
[11](#11)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L12636)
|
||||
|
||||
[*Note [1](#note-1)*:
|
||||
|
||||
transform_reduce does not apply unary_op to init[.](#11.sentence-1)
|
||||
|
||||
â *end note*]
|
||||
Reference in New Issue
Block a user