Files
cppdraft_translate/cppdraft/simd/permute/mask.md
2025-10-25 03:02:53 +03:00

4.1 KiB
Raw Blame History

[simd.permute.mask]

29 Numerics library [numerics]

29.10 Data-parallel types [simd]

29.10.8 basic_vec non-member operations [simd.nonmembers]

29.10.8.9 vec mask permute [simd.permute.mask]

🔗

template<[simd-vec-type](simd.expos#concept:simd-vec-type "29.10.2Exposition-only types, variables, and concepts[simd.expos]") V> constexpr V compress(const V& v, const typename V::mask_type& selector); template<[simd-mask-type](simd.expos#concept:simd-mask-type "29.10.2Exposition-only types, variables, and concepts[simd.expos]") M> constexpr M compress(const M& v, const type_identity_t<M>& selector);

1

#

Let:

  • (1.1)

    bit-index(i) be a function which returns the index of the ith element of selector that is true.

  • (1.2)

    select-value(i) be a function which returnsv[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]

2

#

Returns: A data-parallel object where the ith element is initialized to the result of select-value(i) for all i in the range [0, V::size()).

🔗

template<[simd-vec-type](simd.expos#concept:simd-vec-type "29.10.2Exposition-only types, variables, and concepts[simd.expos]") V> constexpr V compress(const V& v, const typename V::mask_type& selector, const typename V::value_type& fill_value); template<[simd-mask-type](simd.expos#concept:simd-mask-type "29.10.2Exposition-only types, variables, and concepts[simd.expos]") M> constexpr M compress(const M& v, const type_identity_t<M>& selector, const typename M::value_type& fill_value);

3

#

Let:

  • (3.1)

    bit-index(i) be a function which returns the index of the ith element of selector that is true.

  • (3.2)

    select-value(i) be a function which returnsv[bit-index(i)] for i in the range [0, reduce_count(selector)) and fill_value otherwise.

4

#

Returns: A data-parallel object where the ith element is initialized to the result of select-value(i) for all i in the range [0, V::size()).

🔗

template<[simd-vec-type](simd.expos#concept:simd-vec-type "29.10.2Exposition-only types, variables, and concepts[simd.expos]") V> constexpr V expand(const V& v, const typename V::mask_type& selector, const V& original = {}); template<[simd-mask-type](simd.expos#concept:simd-mask-type "29.10.2Exposition-only types, variables, and concepts[simd.expos]") M> constexpr M expand(const M& v, const type_identity_t<M>& selector, const M& original = {});

5

#

Let:

  • (5.1)

    set-indices be a list of the index positions of true elements in selector.

  • (5.2)

    bit-lookup(b) be a function which returns the index where b appears in set-indices.

  • (5.3)

    select-value(i) be a function which returnsv[bit-lookup(i)] if selector[i] istrue, otherwise returns original[i].

6

#

Returns: A data-parallel object where the ith element is initialized to the result of select-value(i) for all i in the range [0, V::size()).