E.V.E
v2022.09.01

◆ bit_mask

eve::bit_mask = {}
inlineconstexpr

Computes a bit mask full of zeroes or ones.

Defined in Header

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
template< eve::value T >
T bit_mask(T x) noexcept;
}
constexpr callable_bit_mask_ bit_mask
Computes a bit mask full of zeroes or ones.
Definition: bit_mask.hpp:65
Definition: all_of.hpp:22

Parameters

Return value

For each elementwise of x:

  • if the element is zero, an element with all bits unset is returned.
  • else an element of the type with all bits set is returned.

Example

#include <eve/module/core.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
wide_it pi = {14, 1, 3, 0, 16, 23000, 0, 27};
wide_ft pf = {14.0, 1.0, -0.0, 0.0, 16.0, 23000.0, eve::inf(eve::as<float>()), 27.0};
std::cout << "---- simd" << '\n'
<< "<- pi = " << pi << '\n'
<< "<- pf = " << pf << '\n'
<< "-> bit_mask(pi) = " << eve::bit_mask(pi) << '\n'
<< "-> bit_mask(pf) = " << eve::bit_mask(pf) << '\n';
std::uint32_t xf = 48;
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> bit_mask(xf) = " << eve::bit_mask(xf) << '\n';
return 0;
}
constexpr callable_inf_ inf
Computes the infinity ieee value.
Definition: inf.hpp:58
constexpr callable_pi_ pi
Callable object computing the constant .
Definition: pi.hpp:49
Lightweight type-wrapper.
Definition: as.hpp:29
Wrapper for SIMD registers.
Definition: wide.hpp:65

Semantic Modifiers

  • Masked Call

    The call eve::bit_mask[mask](x) provides a masked version of bit_mask which is equivalent to if_else(mask, bit_mask(x), x)

    Example

    #include <eve/module/core.hpp>
    #include <eve/wide.hpp>
    #include <iostream>
    int main()
    {
    wide_it pi = {14, 1, 3, 0, 16, 23000, 0, 27};
    wide_ft pf = {14.0, 1.0, -0.0, 0.0, 16.0, 23000.0, eve::inf(eve::as<float>()), 27.0};
    std::cout << "---- simd" << '\n'
    << "<- pi = " << pi << '\n'
    << "<- pf = " << pf << '\n'
    << "-> bit_mask[pi > 4](pi) = " << eve::bit_mask[pi > 4](pi) << '\n'
    << "-> bit_mask[pf > 4](pf) = " << eve::bit_mask[pf > 4](pf) << '\n';
    return 0;
    }