[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 constexpr resize_t permute(const V& v, IdxMap&& idxmap); template constexpr resize_t 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.7 Arithmetic concepts [concepts.arithmetic]")> ||[integral](concepts.arithmetic#concept:integral "18.4.7 Arithmetic concepts [concepts.arithmetic]")> 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*() 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)