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

Detailed Description

These functions allows performing trigonometric computations

All trigonometric functions admits three flavors for parameters being radian, degrees or \(\pi\) multiples.

Moreover each function can be decorated with eve::quarter_circle, eve::half_circle, eve::full_circle.

  • eve::quarter_circle provides accurate result for the corresponding radian angle in \(]-\pi/4,\pi/4[\), Nan outside
  • eve::half_circle provides accurate result for the corresponding radian angle in \(]-\pi/2,\pi/2[\), Nan outside
  • eve::full_circle provides accurate result for the corresponding radian angle in \(]-\pi,\pi[\), Nan outside
  • regular call (not decorated) choose the best call and is valid on the full range.

Variables

constexpr auto eve::arg = functor<arg_t>
 elementwise_callable object computing the phase angle (in radians).
constexpr auto eve::cos = functor<cos_t>
 elementwise_callable object computing the cosine.
constexpr auto eve::cot = functor<cot_t>
 elementwise_callable object computing the cotangent of the input.
constexpr auto eve::csc = functor<csc_t>
 elementwise_callable object computing the cosecant of the input.
constexpr auto eve::deginrad = functor<deginrad_t>
 elementwise_callable object computing the product of the input by \(\pi/180\).
constexpr auto eve::div_180 = functor<div_180_t>
 elementwise_callable object computing the product of the input by \(1/180\).
constexpr auto eve::quadrant = functor<quadrant_t>
 Callable object computing the quadrant value.
constexpr auto eve::radindeg = functor<radindeg_t>
 elementwise_callable object multiplying the input by \(180/\pi\).
constexpr auto eve::radinpi = functor<radinpi_t>
 elementwise_callable object multiplying the input by \(1/\pi\).
constexpr auto eve::rempio2 = functor<rempio2_t>
 elementwise_callable object computing the remainder of the division by \(\pi/2\).
constexpr auto eve::sec = functor<sec_t>
 elementwise_callable object computing the secant of the input.
constexpr auto eve::sin = functor<sin_t>
 elementwise_callable object computing the sine.
constexpr auto eve::sinc = functor<sinc_t>
 elementwise_callable object computing the sine cardinal.
constexpr auto eve::sincos = functor<sincos_t>
 elementwise_callable object computing the simultaneous computation of sine an cosine.
constexpr auto eve::tan = functor<tan_t>
 elementwise_callable object computing the tangent.

Variable Documentation

◆ arg

auto eve::arg = functor<arg_t>
inlineconstexpr

elementwise_callable object computing the phase angle (in radians).

Callable Signatures

#include <eve/module/math.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto arg(floating_value auto x) noexcept; // 1
// Lanes masking
constexpr auto arg[conditional_expr auto c](value auto x) noexcept; // 2
constexpr auto arg[logical_value auto m](value auto x) noexcept; // 2
// Semantic option
constexpr auto arg[pedantic](floating_value auto x) noexcept; // 3
constexpr auto arg[rad](floating_value auto x) noexcept; // 1
constexpr auto arg[deg](floating_value auto x) noexcept; // 4
constexpr auto arg[pirad](floating_value auto x) noexcept; // 5
}
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
The concept value<T> is satisfied if and only if T satisfies either eve::scalar_value or eve::simd_va...
Definition value.hpp:34
constexpr auto pedantic
Follows the corner cases of the corresponding standard function.
Definition core.hpp:91
constexpr auto arg
elementwise_callable object computing the phase angle (in radians).
Definition arg.hpp:83
EVE Main Namespace.
Definition abi.hpp:19

Parameters

Return value

  1. Returns elementwise the phase angle (in radians) of the input (0 or \(\pi\)) depending of the bit of sign of the input
  2. The operation is performed conditionally.
  3. If the entry is NaN the result is NaN.
  4. Result in degrees
  5. Result in \(\pi\) multiples
Note
phase can be used as an alias

External references

Example

// revision 1
#include <eve/module/math.hpp>
#include <iostream>
int main()
{
eve::wide wf = { 0.0f, -0.0f, 1.0f, -1.0f,
std::cout << "<- wf = " << wf << "\n";
std::cout << "-> arg(wf) = " << eve::arg(wf) << "\n";
std::cout << "-> arg[deg](wf) = " << eve::arg[eve::deg](wf) << "\n";
std::cout << "-> arg[radpi](wf) = " << eve::arg[eve::radpi](wf) << "\n";
std::cout << "-> arg[rad](wf) = " << eve::arg[eve::rad](wf) << "\n";
std::cout << "-> arg[pedantic](wf) = " << eve::arg[eve::pedantic](wf) << "\n";
std::cout << "-> arg[ignore_last(2)](wf) = " << eve::arg[eve::ignore_last(2)](wf) << "\n";
std::cout << "-> arg[wf != 0.5f](wf) = " << eve::arg[wf != 0.5f](wf) << "\n";
}
constexpr auto nan
Computes the IEEE quiet NaN constant.
Definition nan.hpp:67
constexpr auto inf
Computes the infinity ieee value.
Definition inf.hpp:67
Lightweight type-wrapper.
Definition as.hpp:29
Conditional expression ignoring the k last lanes from a eve::simd_value.
Definition conditional.hpp:361
Wrapper for SIMD registers.
Definition wide.hpp:94

◆ cos

auto eve::cos = functor<cos_t>
inlineconstexpr

elementwise_callable object computing the cosine.

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
}
constexpr auto raw
Performs the operation minimally, trading accuracy for speed.
Definition core.hpp:95
constexpr auto fast
Performs the operation faster than the regular call while keeping more accuracy than raw.
Definition core.hpp:79
constexpr auto cos
elementwise_callable object computing the cosine.
Definition cos.hpp:94

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 conditionally.
  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 lower
Guarantees a result no greater than the exact mathematical one.
Definition core.hpp:103
constexpr auto inv_pi
Callable object computing the constant .
Definition inv_pi.hpp:76
constexpr auto pi
Callable object computing the constant .
Definition pi.hpp:79
constexpr auto radindeg
elementwise_callable object multiplying the input by .
Definition radindeg.hpp:68

◆ cot

auto eve::cot = functor<cot_t>
inlineconstexpr

elementwise_callable object computing the cotangent of the input.

Header file

#include <eve/module/math.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto cot(floating_value auto x) noexcept; // 1
// Lanes masking
constexpr auto cot[conditional_expr auto c](floating_value auto x) noexcept; // 2
constexpr auto cot[logical_value auto m](floating_value auto x) noexcept; // 2
// Semantic options
constexpr auto cot[rad](floating_value auto x) noexcept; // 1.a
constexpr auto cot[deg](floating_value auto x) noexcept; // 1.b
constexpr auto cot[pirad](floating_value auto x) noexcept; // 1.c
constexpr auto cot[quarter_circle](floating_value auto x) noexcept; // 3.a
constexpr auto cot[half_circle](floating_value auto x) noexcept; // 3.b
constexpr auto cot[full_circle](floating_value auto x) noexcept; // 3.c
}
constexpr auto cot
elementwise_callable object computing the cotangent of the input.
Definition cot.hpp:91

Parameters

Return value

  1. Returns the elementwise cotangent of the input. In particular:
    1. assume a parameter in radian.
    2. assume a parameter in degree.
    3. assume a parameter in \(\pi\) multiples.
  2. The operation is performed conditionally.
  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.

    In particular:

    • If the element is \(\pm0\), \(\pm\infty\) is returned.
    • If the element is \(\pm\infty\), Nan is returned.
    • If the element is a Nan, Nan is returned.

External references

Example

// revision 1
#include <eve/module/math.hpp>
#include <iostream>
int main()
{
eve::wide wf = {0.0, 0.25, 0.4, 2.2, -0.0, -0.25, -0.4, -2.2};
wf *= eve::pi[eve::lower](eve::as(wf));
std::cout << "<- wf = " << wf << "\n";
std::cout << "-> cot(wf) = " << eve::cot(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 << "-> cot[ignore_last(2)](wf)= " << eve::cot[eve::ignore_last(2)](wf) << "\n";
std::cout << "-> cot[wf > 0.0](wf) = " << eve::cot[wf > 0.0](wf) << "\n";
std::cout << "-> cot[quarter_circle](wf)= " << eve::cot[eve::quarter_circle](wf) << "\n";
std::cout << "-> cot[half_circle](wf) = " << eve::cot[eve::half_circle](wf) << "\n";
std::cout << "-> cot[full_circle](wf) = " << eve::cot[eve::full_circle](wf) << "\n";
}

◆ csc

auto eve::csc = functor<csc_t>
inlineconstexpr

elementwise_callable object computing the cosecant of the input.

Header file

#include <eve/module/math.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto csc(floating_value auto x) noexcept; // 1
// Lanes masking
constexpr auto csc[conditional_expr auto c](floating_value auto x) noexcept; // 2
constexpr auto csc[logical_value auto m](floating_value auto x) noexcept; // 2
// Semantic options
constexpr auto csc[quarter_circle](floating_value auto x) noexcept; // 3.a
constexpr auto csc[half_circle](floating_value auto x) noexcept; // 3.b
constexpr auto csc[full_circle](floating_value auto x) noexcept; // 3.c
constexpr auto csc[raw](floating_value auto x) noexcept; // 4.a
constexpr auto csc[fast] (floating_value auto x) noexcept; // 4.b
constexpr auto csc[rad](floating_value auto x) noexcept; // 1
constexpr auto csc[deg](floating_value auto x) noexcept; // 5
constexpr auto csc[pirad](floating_value auto x) noexcept; // 6
}
constexpr auto csc
elementwise_callable object computing the cosecant of the input.
Definition csc.hpp:98

Parameters

Return value

  1. Returns the elementwise cosecant of the input. In particular:
    • If the element is \(\pm0\), \(\pm\infty\) is returned.
    • If the element is \(\pm\infty\), Nan is returned.
    • If the element is a NaN, NaN is returned. (the inverse of the sine). In particular:
  2. The operation is performed conditionally.
  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::upper](eve::as(wf));
std::cout << "<- wf = " << wf << "\n";
std::cout << "-> csc(wf) = " << eve::csc(wf) << "\n";
std::cout << "-> csc[deg](wf) = " << eve::csc[eve::deg](wf) << "\n";
std::cout << "-> csc[radpi](wf) = " << eve::csc[eve::radpi](wf) << "\n";
std::cout << "-> csc[rad](wf) = " << eve::csc[eve::rad](wf) << "\n";
std::cout << "-> csc[ignore_last(2)](wf)= " << eve::csc[eve::ignore_last(2)](wf) << "\n";
std::cout << "-> csc[wf != -2.0f](wf) = " << eve::csc[wf != -2.0f](wf) << "\n";
std::cout << "-> csc[quarter_circle](wf)= " << eve::csc[eve::quarter_circle](wf) << "\n";
std::cout << "-> csc[half_circle](wf) = " << eve::csc[eve::half_circle](wf) << "\n";
std::cout << "-> csc[full_circle](wf) = " << eve::csc[eve::full_circle](wf) << "\n";
}
constexpr auto upper
Guarantees a result no smaller than the exact mathematical one.
Definition core.hpp:102

◆ deginrad

auto eve::deginrad = functor<deginrad_t>
inlineconstexpr

elementwise_callable object computing the product of the input by \(\pi/180\).

Header file

#include <eve/module/math.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto deginrad(floating_value auto x) noexcept; // 1
// Lanes masking
constexpr auto deginrad[conditional_expr auto c](floating_value auto x) noexcept; // 2
constexpr auto deginrad[logical_value auto m](floating_value auto x) noexcept; // 2
}
constexpr auto deginrad
elementwise_callable object computing the product of the input by .
Definition deginrad.hpp:67

Parameters

Return value

  1. Returns the elementwise the degree input converted in radian.
  2. The operation is performed conditionally.

Example

// revision 1
#include <eve/module/math.hpp>
#include <iostream>
int main()
{
eve::wide wf{0.0, 200.0, 40.0, -17.0};
std::cout << "<- wf = " << wf << "\n";
std::cout << "-> deginrad(wf) = " << eve::deginrad(wf) << "\n";
std::cout << "-> deginrad[ignore_last(2)](wf)= " << eve::deginrad[eve::ignore_last(2)](wf) << "\n";
std::cout << "-> deginrad[wf > 0.0](wf) = " << eve::deginrad[wf > 0.0](wf) << "\n";
}

◆ div_180

auto eve::div_180 = functor<div_180_t>
inlineconstexpr

elementwise_callable object computing the product of the input by \(1/180\).

Callable Signatures

#include <eve/module/math.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto div_180(floating_value auto x) noexcept; // 1
// Lanes masking
constexpr auto div_180[conditional_expr auto c](floating_value auto x) noexcept; // 2
constexpr auto div_180[logical_floating_value auto m](floating_value auto x) noexcept; // 2
}
constexpr auto div_180
elementwise_callable object computing the product of the input by .
Definition div_180.hpp:67

Parameters

Return value

  1. Returns the elementwise the input divided by 180.
  2. The operation is performed conditionally.

Example

// revision 1
#include <eve/module/math.hpp>
#include <iostream>
int main()
{
eve::wide wf{0.0, 200.0, 40.0, -17.0};
std::cout << "<- wf = " << wf << "\n";
std::cout << "-> div_180(wf) = " << eve::div_180(wf) << "\n";
std::cout << "-> div_180[ignore_last(2)](wf)= " << eve::div_180[eve::ignore_last(2)](wf) << "\n";
std::cout << "-> div_180[wf > 0.0](wf) = " << eve::div_180[wf > 0.0](wf) << "\n";
}

◆ quadrant

auto eve::quadrant = functor<quadrant_t>
inlineconstexpr

Callable object computing the quadrant value.

Header file

#include <eve/module/math.hpp>

Callable Signatures

namespace eve
{
constexpr auto quadrant(value auto n) noexcept; // 1
}
constexpr auto quadrant
Callable object computing the quadrant value.
Definition quadrant.hpp:59

Parameters

n: value. Must be of integral type or a flint

Return value

return a value of the same type as n containing the quadrant number where n (supposed an integer) lies.

Example

// revision 1
#include <eve/module/math.hpp>
#include <iostream>
eve::wide<float> wf([](auto i, auto c)->float{ return 2*(i-c/2);});
eve::wide<std::int32_t> wi([](auto i, auto c)->std::int32_t{ return i-c/2;});
eve::wide<std::uint32_t> wu([](auto i, auto )->std::uint32_t{ return i;});
int main()
{
std::cout << "<- wf = " << wf << "\n";
std::cout << "<- wi = " << wi << "\n";
std::cout << "<- wu = " << wu << "\n";
std::cout << "-> quadrant(wf)= " << eve::quadrant(wf) << "\n";
std::cout << "-> quadrant(wi)= " << eve::quadrant(wi) << "\n";
std::cout << "-> quadrant(wu)= " << eve::quadrant(wu) << "\n";
}

◆ radindeg

auto eve::radindeg = functor<radindeg_t>
inlineconstexpr

elementwise_callable object multiplying the input by \(180/\pi\).

Header file

#include <eve/module/math.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto radindeg(floating_value auto x) noexcept; // 1
// Lanes masking
constexpr auto radindeg[conditional_expr auto c](floating_value auto x) noexcept; // 2
constexpr auto radindeg[logical_value auto m](floating_value auto x) noexcept; // 2
}

Parameters

Return value

  1. Returns the radian input converted in degree.
  2. The operation is performed conditionally.

Example

// revision 1
#include <eve/module/math.hpp>
#include <iostream>
int main()
{
eve::wide<float> wf([](auto i, auto c)->float{ return 2*(i-c/2);});
std::cout << "<- wf = " << wf << "\n";
std::cout << "-> radindeg(wf) = " << eve::radindeg(wf) << "\n";
std::cout << "-> radindeg[ignore_last(2)](wf)= " << eve::radindeg[eve::ignore_last(2)](wf) << "\n";
std::cout << "-> radindeg[wf != -2.0f](wf) = " << eve::radindeg[wf != -2.0f](wf) << "\n";
}

◆ radinpi

auto eve::radinpi = functor<radinpi_t>
inlineconstexpr

elementwise_callable object multiplying the input by \(1/\pi\).

Header file

#include <eve/module/math.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto radinpi(floating_value auto x) noexcept; // 1
// Lanes masking
constexpr auto radinpi[conditional_expr auto c](floating_value auto x) noexcept; // 2
constexpr auto radinpi[logical_value auto m](floating_value auto x) noexcept; // 2
}
constexpr auto radinpi
elementwise_callable object multiplying the input by .
Definition radinpi.hpp:68

Parameters

Return value

  1. Returns the radian input converted in \(\pi\) multiples.
  2. The operation is performed conditionally.

Example

// revision 1
#include <eve/module/math.hpp>
#include <iostream>
int main()
{
eve::wide<float> wf([](auto i, auto c)->float{ return 2*(i-c/2);});
std::cout << "<- wf = " << wf << "\n";
std::cout << "-> radinpi(wf) = " << eve::radinpi(wf) << "\n";
std::cout << "-> radinpi[ignore_last(2)](wf)= " << eve::radinpi[eve::ignore_last(2)](wf) << "\n";
std::cout << "-> radinpi[wf != -2.0f](wf) = " << eve::radinpi[wf != -2.0f](wf) << "\n";
}

◆ rempio2

auto eve::rempio2 = functor<rempio2_t>
inlineconstexpr

elementwise_callable object computing the remainder of the division by \(\pi/2\).

Header file

#include <eve/module/math.hpp>

Callable Signatures

namespace eve
{
{
// Regular overload
constexpr auto rempio2(floating_value auto x) noexcept; // 1
// Semantic options
constexpr auto rempio2[quarter_circle](floating_value auto x) noexcept; // 2.a
constexpr auto rempio2[half_circle](floating_value auto x) noexcept; // 2.b
constexpr auto rempio2[full_circle](floating_value auto x) noexcept; // 2.c
constexpr auto rempio2[medium](floating_value auto x) noexcept; // 2.d
constexpr auto rempio2[big](floating_value auto x) noexcept; // 2.e
}
constexpr auto rempio2
elementwise_callable object computing the remainder of the division by .
Definition rempio2.hpp:86

Parameters

Return value

  1. A tuple-like consisting of an flint value designing the quadrant and two floating values of type T giving the remainder of x modulo \(\pi/2\) and a corrective to the rounding error on the first result.
  2. These options enable faster computations by assuming that the input satisfies the following respective condition:

    1. \(|x| \le \pi/4\)
    2. \(|x| \le \pi/2\)
    3. \(|x| \le \pi\)
    4. \(|x| \le 10^4\)
    5. no conditions, will directly use the most expansive reduction algorithm

    For each option, if the respective above condition is not met the result is undefined.

Example

// revision 1
#include <eve/module/math.hpp>
#include <iostream>
int main()
{
eve::wide<float> wf([](auto i, auto c)->float{ return eve::pi(eve::as < float>())*2*(i-c/2);});
std::cout << "<- wf = " << wf << "\n";
std::cout << "-> rempio2(wf) = " << eve::rempio2(wf) << "\n";
std::cout << "-> rempio2[quarter_circle](wf)= " << eve::rempio2[eve::quarter_circle](wf) << "\n";
std::cout << "-> rempio2[half_circle](wf) = " << eve::rempio2[eve::half_circle](wf) << "\n";
std::cout << "-> rempio2[full_circle](wf) = " << eve::rempio2[eve::full_circle](wf) << "\n";
}

◆ sec

auto eve::sec = functor<sec_t>
inlineconstexpr

elementwise_callable object computing the secant of the input.

Header file

#include <eve/module/math.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto sec(floating_value auto x) noexcept; // 1
// Lanes masking
constexpr auto sec[conditional_expr auto c](floating_value auto x) noexcept; // 2
constexpr auto sec[logical_value auto m](floating_value auto x) noexcept; // 2
// Semantic options
constexpr auto sec[quarter_circle](floating_value auto x) noexcept; // 3.a
constexpr auto sec[half_circle](floating_value auto x) noexcept; // 3.b
constexpr auto sec[full_circle](floating_value auto x) noexcept; // 3.c
constexpr auto sec[raw](floating_value auto x) noexcept; // 4.a
constexpr auto sec[fast] (floating_value auto x) noexcept; // 4.b
constexpr auto sec[rad](floating_value auto x) noexcept; // 1
constexpr auto sec[deg](floating_value auto x) noexcept; // 5
constexpr auto sec[pirad](floating_value auto x) noexcept; // 6
}
constexpr auto sec
elementwise_callable object computing the secant of the input.
Definition sec.hpp:98

Parameters

 * `x`: [floating value](@ref eve::floating_value).
 * `c`: [Conditional expression](@ref eve::conditional_expr) masking the operation.
 * `m`: [Logical value](@ref eve::logical_value) masking the operation.

Return value

  1. Returns the elementwise secant of (the inverse of the cosine). In particular: In particular:
    1. assume a parameter in radian.
    2. assume a parameter in degree.
    3. assume a parameter in \(\pi\) multiples.
  2. The operation is performed conditionally.
  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 << "-> sec(wf) = " << eve::sec(wf) << "\n";
std::cout << "-> sec[deg](wf) = " << eve::sec[eve::deg](wf) << "\n";
std::cout << "-> sec[radpi](wf) = " << eve::sec[eve::radpi](wf) << "\n";
std::cout << "-> sec[rad](wf) = " << eve::sec[eve::rad](wf) << "\n";
std::cout << "-> sec[ignore_last(2)](wf)= " << eve::sec[eve::ignore_last(2)](wf) << "\n";
std::cout << "-> sec[wf > 0.0](wf) = " << eve::sec[wf > 0.0](wf) << "\n";
std::cout << "-> sec[quarter_circle](wf)= " << eve::sec[eve::quarter_circle](wf) << "\n";
std::cout << "-> sec[half_circle](wf) = " << eve::sec[eve::half_circle](wf) << "\n";
std::cout << "-> sec[full_circle](wf) = " << eve::sec[eve::full_circle](wf) << "\n";
}

◆ sin

auto eve::sin = functor<sin_t>
inlineconstexpr

elementwise_callable object computing the sine.

Header file

#include <eve/module/math.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto sin(floating_value auto x) noexcept; // 1
// Lanes masking
constexpr auto sin[conditional_expr auto c](floating_value auto x) noexcept; // 2
constexpr auto sin[logical_value auto m](floating_value auto x) noexcept; // 2
// Semantic options
constexpr auto sin[quarter_circle](floating_value auto x) noexcept; // 3.a
constexpr auto sin[half_circle](floating_value auto x) noexcept; // 3.b
constexpr auto sin[full_circle](floating_value auto x) noexcept; // 3.c
constexpr auto sin[raw](floating_value auto x) noexcept; // 4
constexpr auto sin[fast] (floating_value auto x) noexcept; // 4
constexpr auto sin[rad](floating_value auto x) noexcept; // 1
constexpr auto sin[deg](floating_value auto x) noexcept; // 5
constexpr auto sin[radpi](floating_value auto x) noexcept; // 6
}
constexpr auto sin
elementwise_callable object computing the sine.
Definition sin.hpp:98

Parameters

 * `x`: [floating value](@ref eve::floating_value).
 * `c`: [Conditional expression](@ref eve::conditional_expr) masking the operation.
 * `m`: [Logical value](@ref eve::logical_value) masking the operation.

Return value

  1. Returns the elementwise sine of the input in radian. In particular:
    • If the element is \(\pm0\), \(\pm0\) 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 conditionally.
  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.

    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 << "-> sin(wf) = " << eve::sin(wf) << "\n";
std::cout << "-> sin[deg](wf) = " << eve::sin[eve::deg](wf) << "\n";
std::cout << "-> sin[radpi](wf) = " << eve::sin[eve::radpi](wf) << "\n";
std::cout << "-> sin[rad](wf) = " << eve::sin[eve::rad](wf) << "\n";
std::cout << "-> sin[ignore_last(2)](wf)= " << eve::sin[eve::ignore_last(2)](wf) << "\n";
std::cout << "-> sin[wf != -2.0f](wf) = " << eve::sin[wf != -2.0f](wf) << "\n";
std::cout << "-> sin[quarter_circle](wf)= " << eve::sin[eve::quarter_circle](wf) << "\n";
std::cout << "-> sin[half_circle](wf) = " << eve::sin[eve::half_circle](wf) << "\n";
std::cout << "-> sin[full_circle](wf) = " << eve::sin[eve::full_circle](wf) << "\n";
}

◆ sinc

auto eve::sinc = functor<sinc_t>
inlineconstexpr

elementwise_callable object computing the sine cardinal.

Header file

#include <eve/module/math.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto sinc(floating_value auto x) noexcept; // 1
// Lanes masking
constexpr auto sinc[conditional_expr auto c](floating_value auto x) noexcept; // 2
constexpr auto sinc[logical_value auto m](floating_value auto x) noexcept; // 2
// Semantic options
constexpr auto sinc[radpi](floating_value auto x) noexcept; // 1.c
constexpr auto sinc[quarter_circle](floating_value auto x) noexcept; // 3.a
constexpr auto sinc[half_circle](floating_value auto x) noexcept; // 3.b
constexpr auto sinc[full_circle](floating_value auto x) noexcept; // 3.c
constexpr auto sinc[raw](floating_value auto x) noexcept; // 4.a
constexpr auto sinc[fast] (floating_value auto x) noexcept; // 4.b
constexpr auto sinc[radpi](floating_value auto x) noexcept; // 5
}
constexpr auto sinc
elementwise_callable object computing the sine cardinal.
Definition sinc.hpp:94

Parameters

Return value

  1. Returns the elementwise sine of the input divided by the input. In particular:
    • If the element is \(\pm0\), \(1\) is returned.
    • If the element is \(\pm\infty\), 0 is returned.
    • If the element is a Nan, NaN is returned.
  2. The operation is performed conditionally.
  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. returns \(\frac{\sin \pi x}{\pi x}\)

    External references

Example

// revision 1
#include <eve/module/math.hpp>
#include <iostream>
int main()
{
eve::wide wf = {0.0, 1.0, 2.0, 20.0, 100.0, 1000.0,
std::cout << "<- wf = " << wf << "\n";
std::cout << "-> sinc(wf) = " << eve::sinc(wf) << "\n";
std::cout << "-> sinc[ignore_last(2)](wf)= " << eve::sinc[eve::ignore_last(2)](wf) << "\n";
std::cout << "-> sinc[wf != 2.0f](wf) = " << eve::sinc[wf != 2.0f](wf) << "\n";
}

◆ sincos

auto eve::sincos = functor<sincos_t>
inlineconstexpr

elementwise_callable object computing the simultaneous computation of sine an cosine.

Header file

#include <eve/module/math.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto sincos(floating_value auto x) noexcept; // 1
// Lanes masking
constexpr auto sincos[conditional_expr auto c](floating_value auto x) noexcept; // 2
constexpr auto sincos[logical_value auto m](floating_value auto x) noexcept; // 2
// Semantic options
constexpr auto sincos[rad](floating_value auto x) noexcept; // 1.a
constexpr auto sincos[deg](floating_value auto x) noexcept; // 1.b
constexpr auto sincos[pirad](floating_value auto x) noexcept; // 1.c
constexpr auto sincos[quarter_circle](floating_value auto x) noexcept; // 3.a
constexpr auto sincos[half_circle](floating_value auto x) noexcept; // 3.b
constexpr auto sincos[full_circle](floating_value auto x) noexcept; // 3.c
}
constexpr auto sincos
elementwise_callable object computing the simultaneous computation of sine an cosine.
Definition sincos.hpp:90

Parameters

 * `x`: [floating value](@ref eve::floating_value).
 * `c`: [Conditional expression](@ref eve::conditional_expr) masking the operation.
 * `m`: [Logical value](@ref eve::logical_value) masking the operation.

Return value

  1. The computation returns a tuple-like whose elements are sin(x) and cos(x) In particular:
    1. assume a parameter in radian.
    2. assume a parameter in degree.
    3. assume a parameter in \(\pi\) multiples.
  2. The operation is performed conditionally.
  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.

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 << "-> sincos(wf) = " << eve::sincos(wf) << "\n";
std::cout << "-> sincos[deg](radindeg(wf)) = " << eve::sincos[eve::deg](eve::radindeg(wf)) << "\n";
std::cout << "-> sincos[radpi](wf/pi) = " << eve::sincos[eve::radpi](wf*eve::inv_pi(eve::as(wf))) << "\n";
std::cout << "-> sincos[rad](wf) = " << eve::sincos[eve::rad](wf) << "\n";
std::cout << "-> sincos[quarter_circle](wf)= " << eve::sincos[eve::quarter_circle](wf) << "\n";
std::cout << "-> sincos[half_circle](wf) = " << eve::sincos[eve::half_circle](wf) << "\n";
std::cout << "-> sincos[full_circle](wf) = " << eve::sincos[eve::full_circle](wf) << "\n";
}

◆ tan

auto eve::tan = functor<tan_t>
inlineconstexpr

elementwise_callable object computing the tangent.

Header file

#include <eve/module/math.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto tan(floating_value auto x) noexcept; // 1
// Lanes masking
constexpr auto tan[conditional_expr auto c](floating_value auto x) noexcept; // 2
constexpr auto tan[logical_value auto m](floating_value auto x) noexcept; // 2
// Semantic options
constexpr auto tan[quarter_circle](floating_value auto x) noexcept; // 3.a
constexpr auto tan[half_circle](floating_value auto x) noexcept; // 3.b
constexpr auto tan[full_circle](floating_value auto x) noexcept; // 3.c
constexpr auto sin[raw](floating_value auto x) noexcept; // 4
constexpr auto sin[fast] (floating_value auto x) noexcept; // 4
constexpr auto sin[rad](floating_value auto x) noexcept; // 1
constexpr auto sin[deg](floating_value auto x) noexcept; // 5
constexpr auto sin[radpi](floating_value auto x) noexcept; // 6
}
constexpr auto tan
elementwise_callable object computing the tangent.
Definition tan.hpp:93

Parameters

 * `x`: [floating value](@ref eve::floating_value).
 * `c`: [Conditional expression](@ref eve::conditional_expr) masking the operation.
 * `m`: [Logical value](@ref eve::logical_value) masking the operation.

Return value

  1. Returns the elementwise tangent of the input. In particular:
    • If the element is \(\pm0\), \(\pm0\) 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 conditionally.
  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.
  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 << "-> tan(wf) = " << eve::tan(wf) << "\n";
std::cout << "-> tan[deg](wf) = " << eve::tan[eve::deg](wf) << "\n";
std::cout << "-> tan[radpi](wf) = " << eve::tan[eve::radpi](wf) << "\n";
std::cout << "-> tan[rad](wf) = " << eve::tan[eve::rad](wf) << "\n";
std::cout << "-> tan[ignore_last(2)](wf)= " << eve::tan[eve::ignore_last(2)](wf) << "\n";
std::cout << "-> tan[wf != -2.0f](wf) = " << eve::tan[wf != -2.0f](wf) << "\n";
std::cout << "-> tan[quarter_circle](wf)= " << eve::tan[eve::quarter_circle](wf) << "\n";
std::cout << "-> tan[half_circle](wf) = " << eve::tan[eve::half_circle](wf) << "\n";
std::cout << "-> tan[full_circle](wf) = " << eve::tan[eve::full_circle](wf) << "\n";
}