116 lines
4.0 KiB
Markdown
116 lines
4.0 KiB
Markdown
[simd.alg]
|
||
|
||
# 29 Numerics library [[numerics]](./#numerics)
|
||
|
||
## 29.10 Data-parallel types [[simd]](simd#alg)
|
||
|
||
### 29.10.8 basic_vec non-member operations [[simd.nonmembers]](simd.nonmembers#simd.alg)
|
||
|
||
#### 29.10.8.12 Algorithms [simd.alg]
|
||
|
||
[ð](#lib:min,simd)
|
||
|
||
`template<class T, class Abi>
|
||
constexpr basic_vec<T, Abi> min(const basic_vec<T, Abi>& a,
|
||
const basic_vec<T, Abi>& b) noexcept;
|
||
`
|
||
|
||
[1](#1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L19237)
|
||
|
||
*Constraints*: T models [totally_ordered](concept.totallyordered#concept:totally_ordered "18.5.5 Concept totally_ordered [concept.totallyordered]")[.](#1.sentence-1)
|
||
|
||
[2](#2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L19241)
|
||
|
||
*Returns*: The result of the element-wise application of min(a[i], b[i]) for
|
||
all i in the range of [0, basic_vec<T, Abi>::size())[.](#2.sentence-1)
|
||
|
||
[ð](#lib:max,simd)
|
||
|
||
`template<class T, class Abi>
|
||
constexpr basic_vec<T, Abi> max(const basic_vec<T, Abi>& a,
|
||
const basic_vec<T, Abi>& b) noexcept;
|
||
`
|
||
|
||
[3](#3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L19255)
|
||
|
||
*Constraints*: T models [totally_ordered](concept.totallyordered#concept:totally_ordered "18.5.5 Concept totally_ordered [concept.totallyordered]")[.](#3.sentence-1)
|
||
|
||
[4](#4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L19259)
|
||
|
||
*Returns*: The result of the element-wise application of max(a[i], b[i]) for
|
||
all i in the range of [0, basic_vec<T, Abi>::size())[.](#4.sentence-1)
|
||
|
||
[ð](#lib:minmax,simd)
|
||
|
||
`template<class T, class Abi>
|
||
constexpr pair<basic_vec<T, Abi>, basic_vec<T, Abi>>
|
||
minmax(const basic_vec<T, Abi>& a, const basic_vec<T, Abi>& b) noexcept;
|
||
`
|
||
|
||
[5](#5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L19273)
|
||
|
||
*Effects*: Equivalent to: return pair{min(a, b), max(a, b)};
|
||
|
||
[ð](#lib:clamp,simd)
|
||
|
||
`template<class T, class Abi>
|
||
constexpr basic_vec<T, Abi> clamp(
|
||
const basic_vec<T, Abi>& v, const basic_vec<T, Abi>& lo, const basic_vec<T, Abi>& hi);
|
||
`
|
||
|
||
[6](#6)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L19286)
|
||
|
||
*Constraints*: T models [totally_ordered](concept.totallyordered#concept:totally_ordered "18.5.5 Concept totally_ordered [concept.totallyordered]")[.](#6.sentence-1)
|
||
|
||
[7](#7)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L19290)
|
||
|
||
*Preconditions*: No element in lo shall be greater than the corresponding element inhi[.](#7.sentence-1)
|
||
|
||
[8](#8)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L19295)
|
||
|
||
*Returns*: The result of element-wise application of clamp(v[i], lo[i],
|
||
hi[i]) for all i in the range of [0, basic_vec<T, Abi>::size())[.](#8.sentence-1)
|
||
|
||
[ð](#lib:select,simd)
|
||
|
||
`template<class T, class U>
|
||
constexpr auto select(bool c, const T& a, const U& b)
|
||
-> remove_cvref_t<decltype(c ? a : b)>;
|
||
`
|
||
|
||
[9](#9)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L19309)
|
||
|
||
*Effects*: Equivalent to: return c ? a : b;
|
||
|
||
[ð](#lib:select,simd_)
|
||
|
||
`template<size_t Bytes, class Abi, class T, class U>
|
||
constexpr auto select(const basic_mask<Bytes, Abi>& c, const T& a, const U& b)
|
||
noexcept -> decltype(simd-select-impl(c, a, b));
|
||
`
|
||
|
||
[10](#10)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L19322)
|
||
|
||
*Effects*: Equivalent to:return *simd-select-impl*(c, a, b); where *simd-select-impl* is found by argument-dependent
|
||
lookup ([[basic.lookup.argdep]](basic.lookup.argdep "6.5.4 Argument-dependent name lookup")) contrary to [[contents]](contents "16.4.2.2 Library contents")[.](#10.sentence-1)
|