E.V.E
v2023.02.15

◆ cospi

eve::cospi = {}
inlineconstexpr

Callable object computing the cosine from an input in \(\pi\) multiples.

Defined in Header

#include <eve/module/math.hpp>

Callable Signatures

namespace eve
{
template< eve::floating_value T >
T cospi(T x) noexcept; //1
template< eve::floating_value T >
as_complex_t<T> cospi(as_complex_t<T> z) noexcept; //2
}
constexpr callable_cospi_ cospi
Callable object computing the cosine from an input in multiples.
Definition: cospi.hpp:79
Definition: abi.hpp:18

Parameters

Return value

  1. Returns the elementwise cosine of the input. The call cospi(x) is semantically equivalent to \(\cos(\pi x)\).

    In particular:

    • If the element is \(\pm0\), \(1\) is returned.
    • If the element is \(\pm1/2\), \(0\) is returned.
    • If the element is \(\pm\infty\), Nan is returned.
    • If the element is a Nan, Nan is returned.
  2. Returns elementwise the cosine of the input in \(\pi\) multiples.

Example

Real version

#include <eve/module/math.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
wide_ft pf = {1.0f, 0.0f, eve::inf(eve::as<float>()), 0.5f};
std::cout << "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "-> cospi(pf) = " << eve::cospi(pf) << '\n'
;
float xf = 3.0f;
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> cospi(xf) = " << eve::cospi(xf) << '\n';
return 0;
}
constexpr callable_inf_ inf
Computes the infinity ieee value.
Definition: inf.hpp:58
Lightweight type-wrapper.
Definition: as.hpp:29
Wrapper for SIMD registers.
Definition: wide.hpp:65

Complex version

#include <eve/module/complex.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
wide_ft ref = { 0.0f, 1.0f, -1.0f, 0.5f};
wide_ft imf = { 2.0f , -1.0, -5.0, 0.0};
auto z = eve::as_complex_t<wide_ft>(ref, imf);
std::cout
<< "---- simd" << std::endl
<< "<- z = " << z << std::endl
<< "-> cospi(z) = " << eve::cospi(z) << std::endl;
return 0;
}

Semantic Modifiers