E.V.E
v2022.09.01

◆ bit_select

eve::bit_select = {}
inlineconstexpr

selects bits from a mask and two entries.

Defined in Header

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
template< value T, value U > bit_select)( T m, U x, U y )
requires compatible< T,U> noexcept;
}
constexpr callable_bit_select_ bit_select
selects bits from a mask and two entries.
Definition: bit_select.hpp:72
Definition: all_of.hpp:22

Parameters

  • m: mask value
  • y, z: selection values

    Return value

    • In a short way (omitting casting details to bring all bit sizes of the parameters equal), it means that the result is composed of the bits of x for which the corresponding bit of m is set and the bits of y for which the corresponding bit of m is unset.
    • If T or U is an simd value, the type of the result has the element type of T and the maximum of the cardinals of M and T, otherwise it is T. The value of the selected bits is returned.

Example

#include <eve/wide.hpp>
#include <iostream>
#include <iomanip>
int main()
{
wide_t pi = {2, -3, 0, 1 << 10};
wide_t qi = {3, -2, 4, 2 };
wide_t mi = {0, -1, 1, ~0u << 8};
std::cout << "---- simd" << '\n'
<< " <- mi = " << mi << '\n'
<< " <- pi = " << pi << '\n'
<< " <- qi = " << qi << '\n'
<< " -> bit_select(mi, pi, qi) = " << eve::bit_select(mi, pi, qi) << '\n';
std::cout << "---- scalar" << std::setprecision(10) << '\n'
<< " -> bit_select(32767, 1, 32768 ) = " << eve::bit_select(32767, 1, 32768) << '\n';
return 0;
}
constexpr callable_pi_ pi
Callable object computing the constant .
Definition: pi.hpp:49
Wrapper for SIMD registers.
Definition: wide.hpp:65