E.V.E
v2022.09.01

◆ rsqrt

eve::rsqrt = {}
inlineconstexpr

Computes the inverse of the square root of the parameter.

Defined in Header

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
template< eve::value T >
T rsqrt(T x) noexcept;
}
constexpr callable_rsqrt_ rsqrt
Computes the inverse of the square root of the parameter.
Definition: rsqrt.hpp:68
Definition: all_of.hpp:22

Parameters

Return value

value containing the elementwise inverse of the square root of x.

Example

#include <eve/module/core.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_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

Semantic Modifiers

  • Masked Call

    The call eve;rsqrt[mask](x) provides a masked version of eve::rsqrt which is equivalent to if_else (mask, rsqrt(x), x).

    Example

    #include <eve/module/core.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 > 0](pf) = " << eve::rsqrt[pf > 0](pf) << '\n';
    return 0;
    }
  • 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.