E.V.E
v2023.02.15

◆ bit_shl

eve::bit_shl = {}
inline

Computes a logical left shift.

Defined in Header

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
template< eve::value T , integral_value N >
T bit_shl(T x, N n) noexcept;
}
detail::callable_object< tag::shl_ > const bit_shl
Computes a logical left shift.
Definition: bit_shl.hpp:74
Definition: abi.hpp:18

Parameters

Return value

The value of the logical left shift is returned.

Note
  • The call bit_shl(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.

Example

#include <eve/module/core.hpp>
#include <iostream>
int main()
{
w_t pi = {3, 2, 3, 4}, qi = {4, 1, 2, 0};
std::uint32_t z = 5;
std::cout << "---- simd" << '\n'
<< " <- pi = " << pi << '\n'
<< " <- qi = " << qi << '\n'
<< " <- z = " << z << '\n'
<< " -> bit_shl(pi, qi) = " << eve::bit_shl(pi, qi) << '\n'
<< " -> bit_shl(z, qi) = " << eve::bit_shl(z, qi) << '\n'
<< " -> bit_shl(pi, z ) = " << eve::bit_shl(pi, z) << '\n';
std::uint32_t a = 1;
std::uint32_t n = 4;
std::cout << "---- scalar" << '\n'
<< " <- a = " << a << '\n'
<< " <- n = " << n << '\n'
<< " -> bit_shl(a, n) = " << eve::bit_shl(a, n) << '\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::bit_shl[mask](x, ...) provides a masked version of bit_shl which is equivalent to if_else(mask, bit_shl(x, ...), x)

    Example

    #include <eve/module/core.hpp>
    #include <eve/wide.hpp>
    #include <iostream>
    int main()
    {
    w_t pi = {3, 2, 3, 4}, qi = {4, 1, 2, 0};
    std::cout << "---- simd" << '\n'
    << " <- pi = " << pi << '\n'
    << " <- qi = " << qi << '\n'
    << " -> bit_shl[pi < qi]((pi, qi) = " << eve::bit_shl[pi < qi](pi, qi) << '\n';
    return 0;
    }