Files
2025-10-25 03:02:53 +03:00

57 lines
2.6 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[simd.permute.static]
# 29 Numerics library [[numerics]](./#numerics)
## 29.10 Data-parallel types [[simd]](simd#permute.static)
### 29.10.8 basic_vec non-member operations [[simd.nonmembers]](simd.nonmembers#simd.permute.static)
#### 29.10.8.7 vec static permute [simd.permute.static]
[🔗](#lib:permute,simd)
`template<simd-size-type N = see below, [simd-vec-type](simd.expos#concept:simd-vec-type "29.10.2Exposition-only types, variables, and concepts[simd.expos]") V, class IdxMap>
constexpr resize_t<N, V> permute(const V& v, IdxMap&& idxmap);
template<simd-size-type N = see below, [simd-mask-type](simd.expos#concept:simd-mask-type "29.10.2Exposition-only types, variables, and concepts[simd.expos]") M, class IdxMap>
constexpr resize_t<N, M> permute(const M& v, IdxMap&& idxmap);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L18768)
Let:
- [(1.1)](#1.1)
*gen-fn*(i) be idxmap(i, V::size()) if that expression is well-formed, and idxmap(i) otherwise.
- [(1.2)](#1.2)
*perm-fn* be the following exposition-only function template:template<*simd-size-type* I>typename V::value_type *perm-fn*() {constexpr auto src_index = *gen-fn*(I); if constexpr (src_index == zero_element) {return typename V::value_type(); } else if constexpr (src_index == uninit_element) {return *unspecified-value*; } else {return v[src_index]; }}
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L18791)
*Constraints*: [integral](concepts.arithmetic#concept:integral "18.4.7Arithmetic concepts[concepts.arithmetic]")<invoke_result_t<IdxMap&, *simd-size-type*>> ||[integral](concepts.arithmetic#concept:integral "18.4.7Arithmetic concepts[concepts.arithmetic]")<invoke_result_t<IdxMap&, *simd-size-type*,*simd-size-type*>> is true[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L18797)
*Mandates*: *gen-fn*(i) is a constant expression whose value iszero_element, uninit_element, or in the range
[0, V::size()), for all i in the range [0, N)[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L18803)
*Returns*: A data-parallel object where theith element is initialized to the result of*perm-fn*<i>() for all i in the range [0, N)[.](#4.sentence-1)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L18809)
*Remarks*: The default argument for template parameter N is V::size()[.](#5.sentence-1)