Intel xvec
Experimental C++ simd class library
Loading...
Searching...
No Matches
Named permutation functions

Named permutations and related element-manipulation operations for vectors and masks. More...

Functions

template<int _Np>
constexpr auto xvec::simd::take (const vec_or_mask_type auto &in)
template<int _Np>
constexpr auto xvec::simd::drop (const vec_or_mask_type auto &in)
 Discard the first _Np elements of the input, returning the remainder.
template<int _Np>
constexpr auto xvec::simd::grow (const vec_or_mask_type auto &in)
 Grow the vec or mask input to be N elements.
template<int _Np, vec_or_mask_type _Sp>
constexpr auto xvec::simd::grow (const _Sp &in, const typename _Sp::value_type &fill)
 Grow the vec or mask input to be N elements, padding with the supplied value.
template<int _Np>
constexpr auto xvec::simd::repeat_all (const vec_or_mask_type auto &in)
 Repeat the entire input value N times. The input [a b c] repeated 3 times would be [a b c a b c a b c].
template<int _Np>
constexpr auto xvec::simd::repeat_each (const vec_or_mask_type auto &in)
 Repeat each value in the vec or mask N times. The input [a b c] repeated 2 times would be [a a b b c c].
constexpr auto xvec::simd::reverse (const vec_or_mask_type auto &in)
 Reverse the order of the elements in the input vec or mask.
template<int _Np, vec_or_mask_type _V>
constexpr auto xvec::simd::stride (const _V &in)
template<int _Middle>
constexpr auto xvec::simd::rotate (const vec_or_mask_type auto &in)
template<vec_or_mask_type... _Sps>
constexpr auto xvec::simd::zip (const _Sps &...simds)
template<int N>
constexpr auto xvec::simd::unzip (const vec_or_mask_type auto &in)
template<int _Rows, int _Cols>
constexpr auto xvec::simd::transpose (const vec_or_mask_type auto &in)
 Treat the vec or mask as a matrix of size [ROWS, COLS] and transpose the data into a matrix of size[COLS, ROWS].
template<vec_or_mask_type _V>
constexpr auto xvec::simd::set_element (const _V &v, int index, typename _V::value_type element)
 Insert a scalar element into the given index position of the supplied vec_or_mask_type object.
template<int _Begin, int _End, vec_or_mask_type _Vp>
constexpr resize_t< _End - _Begin, _Vp > xvec::simd::extract (const _Vp &v)
 Extract the subset denoted by the range [begin..end) from the supplied vec or mask.
template<simd_size_type _Begin, vec_or_mask_type _Parent, vec_or_mask_type _Child>
requires (vec_or_mask_same_element_type<_Parent, _Child>)
constexpr _Parent xvec::simd::insert (const _Parent &parent, const _Child &child) noexcept

Detailed Description

Named permutations and related element-manipulation operations for vectors and masks.

Groups xvec's named-permutation family with the proposal "Named permutation functions for std::simd".

See also
https://wg21.link/P3067

Function Documentation

◆ insert()

template<simd_size_type _Begin, vec_or_mask_type _Parent, vec_or_mask_type _Child>
requires (vec_or_mask_same_element_type<_Parent, _Child>)
_Parent xvec::simd::insert ( const _Parent & parent,
const _Child & child )
constexprnoexcept

Return a copy of the parent basic_vec such that the selected range of elements is overwritten by the respective elements from the child basic_vec.

Template Parameters
_BeginThe compile-time index at which to insert the child
_ParentThe type of the parent container.
_ChildThe type of the child container.
Parameters
parentThe parent container.
childThe child container.
Returns
A copy of the original container with its original element values in the position [_Begin, _Begin + child::size()] replaced by the values from the child.

◆ rotate()

template<int _Middle>
auto xvec::simd::rotate ( const vec_or_mask_type auto & in)
constexpr

Rotate the elements within the vec or mask such that the element at index MIDDLE is moved to the first index position. The MIDDLE index must be in the range [0..SIZE).

◆ stride()

template<int _Np, vec_or_mask_type _V>
auto xvec::simd::stride ( const _V & in)
constexpr

Extract every element which is a multiple of N, discarding the others. To have an offset stride use drop first.

◆ take()

template<int _Np>
auto xvec::simd::take ( const vec_or_mask_type auto & in)
constexpr

Keep the first _Np elements of the input, discarding the remainder. This is equivalent to shrinking the vec or mask to a new size.

◆ unzip()

template<int N>
auto xvec::simd::unzip ( const vec_or_mask_type auto & in)
constexpr

unzip breaks a vec or mask down into N smaller objects, where each object is the values at the stride of N and offset by the output simd index. For example, unzip<2>([a 0 b 1 c 2]) will become [a b c] [0 1 2].

◆ zip()

template<vec_or_mask_type... _Sps>
auto xvec::simd::zip ( const _Sps &... simds)
constexpr

zip takes one or more vec or mask values and produces a new object where all the i'th elements are moved into contiguous positions, for all values of i between [0..min_size_of_inputs). For example, zip([a b c d e], [0 1 2]) becomes [a 0 b 1 c 2]. Note the discard of [d e] to match the size of [0 1 2].