Computes the square root of the parameter.
Defined in Header
#include <eve/module/core.hpp>
{
template< eve::floating_value T >
}
constexpr callable_sqrt_ sqrt
Computes the square root of the parameter.
Definition: sqrt.hpp:103
Parameters
Return value
- value containing the elementwise square root of
x
or Nan if x
is less than zero.
- Returns the elementwise the square root of z, in the range of the right half-plane, including the imaginary axis ( \([0, +\infty]\) along the real axis and \([-\infty, +\infty]\) along the imaginary axis.)
- The function is continuous onto the branch cut taking into account the sign of imaginary part
- eve::sqrt(eve::conj(z)) == eve::conj(eve::sqrt(z))
- If z is \(\pm0\), the result is \(+0\)
- If z is \(x+i \infty\), the result is \(\infty+i \infty\) even if x is \(NaN\)
- If z is \(x,NaN\), the result is \(NaN,NaN\) (unless x is \(\pm\infty\))
- If z is \(-\infty+i y\), the result is \(+0+i \infty\) for finite positive y
- If z is \(+\infty+i y\), the result is \(+\infty+i 0\) for finite positive y
- If z is \(-\infty+i NaN\), the result is \(NaN \pm i \infty\) (sign of imaginary part unspecified)
- If z is \(+\infty+i NaN\), the result is \(+\infty+i NaN\)
- If z is \(NaN+i y\), the result is \(NaN+i NaN\)
- If z is \(NaN+i NaN\), the result is \(NaN+i NaN\)
Real version
#include <eve/module/core.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
std::cout << "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
float xf = 32.768f;
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<<
"-> sqrt(xf) = " <<
eve::sqrt(xf) <<
'\n';
return 0;
}
constexpr callable_inf_ inf
Computes the infinity ieee value.
Definition: inf.hpp:58
constexpr raw_type const raw
Higher-order Callable Object imbuing quick and dirty behaviour onto other Callable Objects.
Definition: raw.hpp:43
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
<<
"-> sqrt(z) = " <<
eve::sqrt(z) << std::endl;
return 0;
}
Masked Call
The call eve;sqrt[mask](x)
provides a masked version of eve::sqrt
which is equivalent to if_else (mask, sqrt(x), x)
.
Example
#include <eve/module/core.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
std::cout << "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<<
"-> sqrt[pf > 0](pf)= " <<
eve::sqrt(pf) <<
'\n';
return 0;
}
eve::raw
The call raw(sqrt)(x)
, call a proper system intrinsic if one exists, but with possibly very poor accuracy in return. Otherwise it uses the non-decorated call.