◆ sqrt()

Value boost::simd::sqrt ( Value const &  x)

This function object computes the square root of its parameter.

For integers it is the truncation of the real square root.

Header <boost/simd/function/sqrt.hpp>
Decorators
  • std_ calls std::sqrt
  • raw_ for floating entries can gain some speed with less accuracy on some architectures.
See also
rsqrt, sqr_abs, sqr
Example:
#include <boost/simd/arithmetic.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, 4.0f};
std::cout
<< "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "-> bs::sqrt(pf) =" << bs::sqrt(pf) << '\n';
float xf = 32768.0f;
std::cout
<< "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> bs::sqrt(xf) = " << bs::sqrt(xf) << '\n';
return 0;
}
Possible output:
---- simd
<- pf = (1, 2, 3, 4)
-> bs::sqrt(pf) =(1, 1.41421, 1.73205, 2)
---- scalar
<- xf = 32768
-> bs::sqrt(xf) = 181.019