E.V.E  0.1-beta

◆ bit_shr

eve::bit_shr = {}
inlineconstexpr

Callable object computing the logical right shift operation.

Required header: #include <eve/function/bit_shr.hpp>

Members Functions

Member Effect
operator() the logical right shift operation
operator[] Construct a conditional version of current function object

template< value T, integral_real_value U > auto operator()( T x, U n ) const noexcept requires bit_compatible< T, U >;

Parameters

x: value.

n: integral value.

Return value

Computes the elementwise logical right shift of the first parameter by the second one.

the call bit_shr(x, n) is equivalent to x >> n if x is an simd value.

The types must share the same cardinal or be scalar and if \(N\) is the size in bits of the element type of T, all elements of n must belong to the interval: \([0, N[\) or the result is undefined.


auto operator[]( conditional_expression auto cond ) const noexcept;

Higher-order function generating a masked version of eve::bit_shr

Parameters

cond : conditional expression

Return value

A Callable object so that the expression bit_shr[cond](x, ...) is equivalent to if_else(cond,bit_shr(x, ...),x)


Supported decorators

no decorators are supported

Example

See it live on Compiler Explorer

#include <eve/function/bit_shr.hpp>
#include <eve/literals.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
w_t pi = {3, 602, 3, 4001}, qi = {4, 1, 2, 0};
std::uint32_t z = 5;
std::cout << "---- simd" << '\n'
<< " <- pi = " << pi << '\n'
<< " <- qi = " << qi << '\n'
<< " <- z = " << z << '\n'
<< " -> bit_shr(pi, qi) = " << eve::bit_shr(pi, qi) << '\n'
<< " -> bit_shr(z, qi) = " << eve::bit_shr(z, qi) << '\n'
<< " -> bit_shr(pi, z ) = " << eve::bit_shr(pi, z) << '\n';
std::uint32_t a = 1;
std::uint32_t n = 4;
std::cout << "---- scalar" << '\n'
<< " <- a = " << a << '\n'
<< " <- n = " << n << '\n'
<< " -> bit_shr(a, n) = " << eve::bit_shr(a, n) << '\n';
return 0;
}
constexpr callable_bit_shr_ bit_shr
Callable object computing the logical right shift operation.
Definition: bit_shr.hpp:98
constexpr callable_pi_ pi
Callable object computing the value.
Definition: pi.hpp:54
Wrapper for SIMD registers.
Definition: wide.hpp:65