simdpp::to_mask

From libsimdpp-docs
template<unsigned N, class E>
Ret<N, _DETAIL_> to_mask( Vec<N,E> a );

Converts a vector to a mask.

The values of the elements in the source vector must be either all ones or all zeros. Otherwise the behavior is undefined.

In instruction sets that support optimized mask types (e.g. AVX512), the operation results in a conversion instruction being executed. In instruction sets where masks are implemented as regular vectors this function is equivalent to a simple type conversion and does not result in any instructions being executed.

The implementation behaves as if the following set of overloads is provided:

Ret Vec
mask_int8 int8
mask_int8 uint8
mask_int16 int16
mask_int16 uint16
mask_int32 int32
mask_int32 uint32
mask_int64 int64
mask_int64 uint64
mask_float32 float32
mask_float64 float64

The return type is a vector expression.

Parameters[edit]

a - vector to convert

Return value[edit]

A vector expression evaluating to vector converted to its mask equivalent.

Equivalent operation[edit]

r0 = a0 != 0 ? 1 : 0
...
rN = aN != 0 ? 1 : 0

See also[edit]

compares vector elements for equality
(function template)