◆ ilog2()

as_integer_t<Value> boost::simd::ilog2 ( Value const &  x)

This function object returns the integer part of the base 2 logarithm of the input.

Header <boost/simd/function/ilog2.hpp>
Note
This function asserts for negative or null values.
See also
twopower, exponent
Example:
#include <boost/simd/bitwise.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, 3.0f, 0.5f};
std::cout << "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "-> bs::ilog2(pf) = " << bs::ilog2(pf) << '\n';
float xf = 2.0f;
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> bs::ilog2(xf) = " << bs::ilog2(xf) << '\n';
return 0;
}
Possible output:
---- simd
<- pf = (1, 2, -1, 0.5)
-> bs::ilog2(pf) = (0, 1, 0, -1)
---- scalar
<- xf = 2
-> bs::ilog2(xf) = 1