E.V.E
v2023.02.15

◆ rshr

eve::rshr = {}
inlineconstexpr

Computes the arithmetic right/left shift operation according to shift sign.

Defined in Header

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
template< eve::ordered_value T , integral_value N >
T rshr(T x, N n) noexcept;
}
constexpr callable_rshr_ rshr
Computes the arithmetic right/left shift operation according to shift sign.
Definition: rshr.hpp:108
Definition: abi.hpp:18

Parameters

Return value

The value of the arithmetic right/left shift operation according to shift sign is returned

Note
  • the call rshr(x, n) is equivalent to if_else(n>0, shl(x, n), shr(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: ]-N, N[ or the result is undefined.
  • The call rshr(x, n) is equivalent to x << n if x is an simd value.

Example

#include <eve/module/core.hpp>
#include <eve/wide.hpp>
#include <iostream>
using iT = std::int32_t;
using uiT = std::uint32_t;
using wide_it = eve::wide<iT, eve::fixed<4>>;
using wide_uit = eve::wide<uiT, eve::fixed<4>>;
int main()
{
wide_uit pi = {100, 200, 2, 3};
wide_it qi = {1, -2, 3, -1};
std::cout << "---- simd" << '\n'
<< "<- pi = " << pi << '\n'
<< "<- qi = " << qi << '\n'
<< "-> shl(pi, qi) = " << eve::rshr(pi, qi) << '\n';
uiT xi = 2, yi = 3;
std::cout << "---- scalar" << '\n'
<< "<- xi = " << xi << '\n'
<< "<- yi = " << yi << '\n'
<< "-> rshr(xi, yi) = " << eve::rshr(xi, yi) << '\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::rshr[mask](x, ...) provides a masked version of rshr which is equivalent to if_else(mask, rshr(x, ...), x)

    Example

    #include <eve/module/core.hpp>
    #include <eve/wide.hpp>
    #include <iostream>
    using iT = std::int32_t;
    using uiT = std::uint32_t;
    using wide_it = eve::wide<iT, eve::fixed<4>>;
    using wide_uit = eve::wide<uiT, eve::fixed<4>>;
    int main()
    {
    wide_uit pi = {100, 200, 2, 3};
    wide_it qi = {1, -2, 3, -1};
    std::cout << "---- simd" << '\n'
    << "<- pi = " << pi << '\n'
    << "<- qi = " << qi << '\n'
    << "-> rshr[pi!= 200](pi, qi) = " << eve::rshr[pi!= 200](pi, qi) << '\n';
    return 0;
    }