E.V.E  0.1-beta

◆ rshr

eve::rshr = {}
inlineconstexpr

Callable object computing the arithmetic left/right shift operation according to shift sign.

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

Members Functions

Member Effect
operator() the arithmetic left/right shift operation according to shift sign
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 arithmetic left/right shift of the first parameter by the second one.

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.


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

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

Parameters

cond : conditional expression

Return value

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


Supported decorators

no decorators are supported

Example

See it live on Compiler Explorer

#include <eve/function/rshr.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 value.
Definition: pi.hpp:54
constexpr callable_rshr_ rshr
Callable object computing the arithmetic left/right shift operation according to shift sign.
Definition: rshr.hpp:102
Wrapper for SIMD registers.
Definition: wide.hpp:65