Computes the arithmetic left shift operation.
Defined in Header
#include <eve/module/core.hpp>
{
template< eve::real_value T , integral_value N >
T
shl(T x, N n)
noexcept;
}
constexpr callable_shl_ shl
Computes the arithmetic left shift operation.
Definition: shl.hpp:104
Definition: all_of.hpp:22
Parameters
x
: argument to be shifted.
n
: shift.
Return value
The elementwise arithmetic left shift of the first parameter by the second one is returned.
The call shl(x, n)
is equivalent to x << n
if x
is an [simd value](eve::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.
- Note
- Although the infix notation with
<<
is supported, the <<
operator on standard scalar types is the original one and so can not be overloaded on standard floating parameters due to C++ limitations.
#include <eve/module/core.hpp>
#include <eve/wide.hpp>
#include <iostream>
using iT = std::int32_t;
int main()
{
wide_it
pi = {100, 200, -2, 3};
wide_it qi = {1, 2, 3, 2};
std::cout << "---- simd" << '\n'
<<
"<- pi = " <<
pi <<
'\n'
<< "<- qi = " << qi << '\n'
<<
"-> eve::shl(pi, qi) = " <<
eve::shl(
pi, qi) <<
'\n';
iT xi = 2, mxi = -2, yi = 3;
std::cout << "---- scalar" << '\n'
<< "<- xi = " << xi << '\n'
<< "<- mxi = " << mxi << '\n'
<< "<- yi = " << yi << '\n'
<<
"-> eve::shl(xi, yi) = " <<
eve::shl(xi, yi) <<
'\n'
<<
"-> eve::shl(mxi, yi) = " <<
eve::shl(mxi, 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
Masked Call
The call eve::shl[mask](x, ...)
provides a masked version of shl
which is equivalent to if_else(mask, shl(x, ...), x)
Example
#include <eve/module/core.hpp>
#include <eve/wide.hpp>
#include <iostream>
using iT = std::int32_t;
using uiT = std::uint32_t;
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!= 200](pi, qi) = " <<
eve::shl[
pi!= 200](
pi, qi) <<
'\n';
return 0;
}