◆ shr()

Value boost::simd::shr ( Value const &  x,
IntegerValue const &  n 
)

This function object returns the first parameter logically shifted right by value of the second one.

Header <boost/simd/function/shr.hpp>
Notes:
  • On many architectures a scalar second parameter results in a much faster call.
  • If the second entry is negative the result is not defined.
Precondition
the second parameter must be of integer type, scalar or associated to the first parameter
Note:
  • on many architectures a scalar second parameter results in a much faster call
See also
shift_right, shift_left, rshl, rshr, rol, ror
Example:
#include <boost/simd/bitwise.hpp>
#include <boost/simd/pack.hpp>
#include <iostream>
namespace bs = boost::simd;
using iT = std::int32_t;
using pack_it = bs::pack<iT, 4>;
int main() {
pack_it pi = {1, 2, -1, 3};
pack_it qi = {1, 2, 4, 3};
std::cout << "---- simd" << '\n'
<< "<- pi = " << pi << '\n'
<< "<- qi = " << qi << '\n'
<< "-> bs::shr(pi, qi) = " << bs::shr(pi, qi) << '\n';
iT xi = 2, yi = 3;
std::cout << "---- scalar" << '\n'
<< "<- xi = " << xi << '\n'
<< "<- yi = " << yi << '\n'
<< "-> bs::shr(xi, yi) = " << bs::shr(xi, yi) << '\n';
return 0;
}
Possible output:
---- simd
<- pi = (1, 2, -1, 3)
<- qi = (1, 2, 4, 3)
-> bs::shr(pi, qi) = (0, 0, 268435455, 0)
---- scalar
<- xi = 2
<- yi = 3
-> bs::shr(xi, yi) = 0