## ◆ cospi()

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

This function object returns the cosine of angle in $$\pi$$ multiples: $$\cos(\pi x)$$.

Note
• The semantics of the function are similar to cos ones. See cos for further details
• As it conveys a peculiar meaning, unlike the other cosine, cospi is defined for integral types and the result of cospi(n) coincides with $$(-1)^n$$.

Take care that large floating entries are always integral and even !

sincospi, cos, cosd
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::cospi(pf) = " << bs::cospi(pf) << '\n';
float xf = 2.0f;
std::cout
<< "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> bs::cospi(xf) = " << bs::cospi(xf) << '\n';
return 0;
}
Possible output:
---- simd
<- pf = (1, 2, -1, 0.5)
-> bs::cospi(pf) = (-1, 1, -1, -0)
---- scalar
<- xf = 2
-> bs::cospi(xf) = 1