E.V.E  0.1-beta

◆ rsqrt

eve::rsqrt = {}
inlineconstexpr

Callable object computing the inverse of the square root.

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

Members Functions

Member Effect
operator() the computation of the inverse 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 real value.

Return value

Returns the elementwise inverse of the square root of the input.


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

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

Parameters

cond : conditional expression

Return value

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


Supported decorators

  • eve::raw The call raw(rsqrt)(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/rsqrt.hpp>

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

Example

See it live on Compiler Explorer

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