E.V.E
v2023.02.15
Loading...
Searching...
No Matches

◆ cos

auto eve::cos = functor<cos_t>
inlineconstexpr

Header file

#include <eve/module/math.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto cos(floating_value auto x) noexcept; // 1
// Lanes masking
constexpr auto cos[conditional_expr auto c](floating_value auto x) noexcept; // 2
constexpr auto cos[logical_value auto m](floating_value auto x) noexcept; // 2
// Semantic options
constexpr auto cos[quarter_circle](floating_value auto x) noexcept; // 3.a
constexpr auto cos[half_circle](floating_value auto x) noexcept; // 3.b
constexpr auto cos[full_circle](floating_value auto x) noexcept; // 3.c
constexpr auto cos[raw](floating_value auto x) noexcept; // 4.a
constexpr auto cos[fast] (floating_value auto x) noexcept; // 4.b
constexpr auto cos[rad](floating_value auto x) noexcept; // 1
constexpr auto cos[deg](floating_value auto x) noexcept; // 5
constexpr auto cos[radpi](floating_value auto x) noexcept; // 6
}
Specifies that a type is a Conditional Expression.
Definition conditional.hpp:28
The concept floating_value<T> is satisfied if and only if T satisfies eve::value and the element type...
Definition value.hpp:116
The concept logical_value<T> is satisfied if and only if T satisfies eve::value and the element type ...
Definition value.hpp:134
constexpr auto cos
elementwise_callable object computing the cosine.
Definition cos.hpp:94
EVE Main Namespace.
Definition abi.hpp:19

Parameters

Return value

  1. Returns the elementwise cosine of the input in radian. In particular:
    • If the element is \(\pm0\), \(1\) is returned.
    • If the element is \(\pm\infty\), Nan is returned.
    • If the element is a Nan, Nan is returned.
  2. The operation is performed conditionnaly.
  3. These are optimized calls providing a balance between speed and range limitation.
    1. assumes that the inputs elements belong to \([-\pi/4,\pi/4]\) and return NaN outside.
    2. assumes that the inputs elements belong to \([-\pi/2,\pi/2]\) and return NaN outside.
    3. assumes that the inputs elements belong to \([-\pi,\pi]\) and return NaN outside. these options can be combined with the previous ones with ranges adapted to the chosen unity.
  4. faster but less accurate versions that can be mixed with range limitations to quarter_circle or half_circle_option to have any effect.
  5. assume a parameter in degree.
  6. assume a parameter in \(\pi\) multiples.

External references

Example

// revision 1
#include <eve/module/math.hpp>
#include <iostream>
int main()
{
eve::wide wf = {0.0, 0.25, 0.5, 2.0, -0.0, -0.25, -0.5, -2.0};
wf *= eve::pi[eve::lower](eve::as(wf));
std::cout << "<- wf = " << wf << "\n";
std::cout << "-> cos(wf) = " << eve::cos(wf) << "\n";
std::cout << "-> cos[deg](radindeg(wf)) = " << eve::cos[eve::deg](eve::radindeg(wf)) << "\n";
std::cout << "-> cos[radpi](wf/pi) = " << eve::cos[eve::radpi](wf*eve::inv_pi(eve::as(wf))) << "\n";
std::cout << "-> cos[rad](wf) = " << eve::cos[eve::rad](wf) << "\n";
std::cout << "-> cos[ignore_last(2)](wf)= " << eve::cos[eve::ignore_last(2)](wf) << "\n";
std::cout << "-> cos[wf > 0.0](wf) = " << eve::cos[wf > 0.0](wf) << "\n";
std::cout << "-> cos[quarter_circle](wf)= " << eve::cos[eve::quarter_circle](wf) << "\n";
std::cout << "-> cos[half_circle](wf) = " << eve::cos[eve::half_circle](wf) << "\n";
std::cout << "-> cos[full_circle](wf) = " << eve::cos[eve::full_circle](wf) << "\n";
}
constexpr auto inv_pi
Callable object computing the constant .
Definition inv_pi.hpp:77
constexpr auto pi
Callable object computing the constant .
Definition pi.hpp:77
constexpr auto radindeg
elementwise_callable object multiplying the input by .
Definition radindeg.hpp:68
Lightweight type-wrapper.
Definition as.hpp:29
Conditional expression ignoring the k last lanes from a eve::simd_value.
Definition conditional.hpp:353
Wrapper for SIMD registers.
Definition wide.hpp:94