◆ pow2()

IEEEValue boost::simd::pow2 ( IEEEValue const &  x,
Value const &  y 
)

This function object returns \( x 2^y\).

(the result is undefined on overflow and the function asserts for invalid second parameter )

Header <boost/simd/function/pow2.hpp>
Note

The first parameter default to One.

Example:
#include <boost/simd/exponential.hpp>
#include <boost/simd/pack.hpp>
#include <iostream>
namespace bs = boost::simd;
using iT = std::int32_t;
using pack_it = bs::pack<iT, 4>;
using pack_ft = bs::pack<float, 4>;
int main() {
pack_ft pf = {1.0f, 2.0f, -1.0f, 0.5f};
pack_it qi = {1, 2, -1, 0};
std::cout << "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "<- qi = " << qi << '\n'
<< "-> bs::pow2(qi) = " << bs::pow2(qi) << '\n'
<< "-> bs::pow2(pf, qi) = " << bs::pow2(pf, qi) << '\n';
float xf = 2.0f;
iT yi = 3;
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "<- yi = " << yi << '\n'
<< "-> bs::pow2(yi) = " << bs::pow2(yi) << '\n'
<< "-> bs::pow2(xf, yi) = " << bs::pow2(xf, yi) << '\n';
return 0;
}
Possible output:
---- simd
<- pf = (1, 2, -1, 0.5)
<- qi = (1, 2, -1, 0)
-> bs::pow2(qi) = (2, 4, 0, 1)
-> bs::pow2(pf, qi) = (2, 8, -0.5, 0.5)
---- scalar
<- xf = 2
<- yi = 3
-> bs::pow2(yi) = 8
-> bs::pow2(xf, yi) = 16