E.V.E
v2022.03.00

◆ firstbitset

eve::firstbitset = {}
inlineconstexpr

Computes elementwise the bit pattern in which the only bit set (if it exists) is the first bit set in the input.

Defined in Header

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
template< eve::unsigned_value T >
T firstbitset(T x) noexcept;
}
constexpr callable_firstbitset_ firstbitset
Computes elementwise the bit pattern in which the only bit set (if it exists) is the first bit set in...
Definition: firstbitset.hpp:65
Definition: all_of.hpp:22

Parameters

Return value

Computes elementwise the bit pattern in which the only bit set (if it exists) is the first bit set (beginning with the least significant bit) in the input.

Example

#include <eve/module/core.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
wide_it pi = {14, 1, 3, 7, 20, 23000, 0, 27};
std::cout << "---- simd" << '\n'
<< "<- pi = " << pi << '\n'
<< "-> firstbitset(pi) = " << eve::firstbitset(pi) << '\n';
std::uint32_t xf = 48;
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> firstbitset(xf) = " << eve::firstbitset(xf) << '\n';
return 0;
}
constexpr callable_pi_ pi
Callable object computing the constant .
Definition: pi.hpp:49
Wrapper for SIMD registers.
Definition: wide.hpp:65

Semantic Modifiers

  • Masked Call

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

    Example

    #include <eve/module/core.hpp>
    #include <eve/wide.hpp>
    #include <iostream>
    int main()
    {
    wide_it pi = {14, 1, 3, 7, 20, 23000, 0, 27};
    std::cout << "---- simd" << '\n'
    << "<- pi = " << pi << '\n'
    << "-> firstbitset[pi > 4](pi) = " << eve::firstbitset[pi > 4](pi) << '\n';
    return 0;
    }