E.V.E  0.1-beta

◆ sqrt

eve::sqrt = {}
inlineconstexpr

Callable object computing the square root.

Required header: #include <eve/function/sqrt.hpp>

Members Functions

Member Effect
operator() the computation of the square root
operator[] Construct a conditional version of current function object

auto operator()(floating_value auto x) const noexcept;
Definition: value.hpp:83

Parameters

x: floating value.

Return value

Returns the elementwise square root of the input.


auto operator[]( conditional_expression auto cond ) const noexcept;

Higher-order function generating a masked version of eve::sqrt

Parameters

cond : conditional expression

Return value

A Callable object so that the expression sqrt[cond](x, ...) is equivalent to if_else(cond,sqrt(x, ...),x)


Supported decorators

  • 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.
  • eve::diff, eve::diff_1st, eve::diff_nth

    Required header: #include <eve/function/diff/sqrt.hpp>

    The expression diff(sqrt)(x) computes the derivative of the function at x.

Example

See it live on Compiler Explorer

#include <eve/function/sqrt.hpp>
#include <eve/constant/inf.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
wide_ft pf = {1.0f, 2.0f, -3.0f, eve::inf(eve::as<float>())};
std::cout << "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "-> sqrt(pf) = " << eve::sqrt(pf) << '\n'
<< "-> raw(sqrt)(pf) = " << eve::raw(eve::sqrt)(pf) << '\n';
float xf = 32.768f;
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> sqrt(xf) = " << eve::sqrt(xf) << '\n';
return 0;
}
constexpr callable_sqrt_ sqrt
Callable object computing the square root.
Definition: sqrt.hpp:98
constexpr callable_inf_ inf
Callable object computing the infinity ieee value.
Definition: inf.hpp:54
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