◆ log2()

IEEEValue boost::simd::log2 ( IEEEValue const &  x)

This function object returns the base two logarithm of its argument.

Header <boost/simd/function/log2.hpp>
Decorators
  • std_ for floating entries calls std::log2
See also
log10, log, log1p
Example:
#include <boost/simd/exponential.hpp>
#include <boost/simd/pack.hpp>
#include <iostream>
namespace bs = boost::simd;
using pack_ft = bs::pack<float, 4>;
int main() {
pack_ft pf = {1.0f, 2.0f, 1024.0f, 0.5f};
std::cout << "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "-> bs::log2(pf) = " << bs::log2(pf) << '\n';
float xf = 2.0f;
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> bs::log2(xf) = " << bs::log2(xf) << '\n';
return 0;
}
Possible output:
---- simd
<- pf = (1, 2, 1024, 0.5)
-> bs::log2(pf) = (0, 1, 10, -1)
---- scalar
<- xf = 2
-> bs::log2(xf) = 1