## ◆ acos()

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

This function object returns the inverse cosine in radian.

Call

For every parameter of floating type

auto r = acos(x);

Returns the arc r in the interval $$[0, \pi[$$ such that cos(r) == x. If x is outside $$[-1, 1[$$ the result is Nan.

Decorators
• pedantic_ is accurate on the full $$[-1, 1[$$ range
• the regular version (no decorator) is less accurate around for x < 0.9 (up to circa 256 ulp), but is faster by a factor 2 than the pedantic version.
acosd, acospi, cos
Example:
#include <boost/simd/trigonometric.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, -1.0f, 0.5f};
std::cout
<< "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "-> bs::acos(pf) = " << bs::acos(pf) << '\n';
float xf = 2.0f;
std::cout
<< "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> bs::acos(xf) = " << bs::acos(xf) << '\n';
return 0;
}
Possible output:
---- simd
<- pf = (1, 2, -1, 0.5)
-> bs::acos(pf) = (0, -nan, 3.14159, 1.0472)
---- scalar
<- xf = 2
-> bs::acos(xf) = -nan