◆ twopower()

IntegerValue boost::simd::twopower ( IntegerValue const &  x)

This function object returns \(2^n\) (or 0 if n is less than zero)

Header <boost/simd/function/twopower.hpp>
Note:

This function is not defined for floating entries

See also
ilog2
Example:
#include <boost/simd/bitwise.hpp>
#include <boost/simd/pack.hpp>
#include <iostream>
namespace bs = boost::simd;
using pack_it = bs::pack<std::int32_t, 4>;
int main() {
pack_it pi = {1, 2, -1, 5};
std::cout << "---- simd" << '\n'
<< "<- pi = " << pi << '\n'
<< "-> bs::twopower(pi) = " << bs::twopower(pi) << '\n';
std::int32_t xi = 4;
std::cout << "---- scalar" << '\n'
<< "<- xi = " << xi << '\n'
<< "-> bs::twopower(xi) = " << bs::twopower(xi) << '\n';
return 0;
}
Possible output:
---- simd
<- pi = (1, 2, -1, 5)
-> bs::twopower(pi) = (2, 4, 0, 32)
---- scalar
<- xi = 4
-> bs::twopower(xi) = 16