29 Numerics library [numerics]

29.10 Data-parallel types [simd]

29.10.8 basic_vec non-member operations [simd.nonmembers]

29.10.8.10 vec mask permute [simd.permute.mask]

template<simd-vec-type V> constexpr V compress(const V& v, const typename V::mask_type& selector); template<simd-mask-type M> constexpr M compress(const M& v, const type_identity_t<M>& selector);
Let:
  • bit-index(i) be a function which returns the index of the element of selector that is true.
  • select-value(i) be a function which returns v[bit-index(i)] for i in the range [0, reduce_count(selector)) and a valid but unspecified value otherwise.
    [Note 1: 
    Different calls to select-value can return different unspecified values.
    — end note]
Returns: A data-parallel object where the element is initialized to the result of select-value(i) for all i in the range [0, V​::​size()).
template<simd-vec-type V> constexpr V compress(const V& v, const typename V::mask_type& selector, const typename V::value_type& fill_value); template<simd-mask-type M> constexpr M compress(const M& v, const type_identity_t<M>& selector, const typename V::value_type& fill_value);
Let:
  • bit-index(i) be a function which returns the index of the element of selector that is true.
  • select-value(i) be a function which returns v[bit-index(i)] for i in the range [0, reduce_count(selector)) and fill_value otherwise.
Returns: A data-parallel object where the element is initialized to the result of select-value(i) for all i in the range [0, V​::​size()).
template<simd-vec-type V> constexpr V expand(const V& v, const typename V::mask_type& selector, const V& original = {}); template<simd-mask-type M> constexpr M expand(const M& v, const type_identity_t<M>& selector, const M& original = {});
Let:
  • set-indices be a list of the index positions of true elements in selector.
  • bit-lookup(b) be a function which returns the index where b appears in set-indices.
  • select-value(i) be a function which returns v[bit-lookup(i)] if selector[i] is true, otherwise returns original[i].
Returns: A data-parallel object where the element is initialized to the result of select-value(i) for all i in the range [0, V​::​size()).