E.V.E
v2022.03.00

◆ erf

eve::erf = {}
inlineconstexpr

Computes the error function: \( \displaystyle \mbox{erf}(x)=\frac{2}{\sqrt\pi}\int_0^{x} e^{-t^2}\mbox{d}t\) or its analytic continuation in the complex plane.

Defined in header

#include <eve/module/special.hpp>

Callable Signatures

namespace eve
{
template< eve::floating_real_value T >
T erf(T x) noexcept; //1
template< eve::floating_value T >
}
constexpr callable_erf_ erf
Computes the error function: or its analytic continuation in the complex plane.
Definition: erf.hpp:65
Definition: all_of.hpp:22
SIMD-compatible representation of complex numbers.
Definition: complex.hpp:40

Parameters

Return value

The value of the error function is returned. In particular:

  • If the argument is \(\pm0\), \(\pm0\) is returned.
  • If the argument is \(\pm\infty\), \(\pm1\) is returned.
  • If the argument is Nan, nan returned.

Example

Real version

#include <eve/module/special.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
wide_ft pf = {0.0f, -0.0f, -1.0f, 1.0f, 2.0f,
std::cout << "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "-> erf(pf) = " << eve::erf(pf) << '\n'
;
float xf = 1.0f;
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> erf(xf) = " << eve::erf(xf) << '\n';
return 0;
}
constexpr callable_nan_ nan
Computes the IEEE NaN constant.
Definition: nan.hpp:53
constexpr callable_minf_ minf
Computes the -infinity ieee value.
Definition: minf.hpp:95
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 = { 1.0f, 10.0f, -1.0f, 0.5f};
wide_ft imf = { 0.2f , 0.2, -5.0, 0.0};
auto z = eve::as_complex_t<wide_ft>(ref, imf);
auto r = eve::erf(z);
std::cout
<< "---- simd" << std::endl
<< "<- z = " << z << std::endl
<< "-> erf(z) = " << r << std::endl;
auto zs = eve::as_complex_t<float>(-1, -5);
std::cout
<< "---- scalar" << std::endl
<< "<- zs = " << zs << std::endl
<< "-> erf(z) = " << r << std::endl;
return 0;
}