E.V.E  0.1-beta

◆ hypot

eve::hypot = {}
inlineconstexpr

Callable object computing the hypot operation.

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

Members Functions

Member Effect
operator() the hypot operation
operator[] Construct a conditional version of current function object

auto operator()( floating_real_value auto x, floating_real_value auto... args ) const noexcept;
Definition: value.hpp:103

Parameters

x, args: floating real values

Return value

The square root of the sum of the squared absolute values of the parameters.

The result type is the common compatible type of the three parameters.


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

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

Parameters

cond : conditional expression

Return value

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


Supported decorators

  • eve::pedantic

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

    The call pedantic(hypot)(x,args...) computes the square root of the sum of the squares of the parameters without undue overflow or underflow at intermediate stages of the computation and can be more accurate than the non-decorated call.

    Morever it returns \(\infty\) as soon as one of its parameter is infinite, regardless of possible Nan values.

  • eve::diff, eve::diff_1st, eve::diff_2nd, eve::diff_3rd, eve::diff_nth

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

    The expression diff_< N >(hypot)(x,args...) computes the partial derivativ of the function relative to its Nth parameter. The returned value is 0 if N is greater that the actual number of parameters, otherwise it is the Nth parameter value divided by the hypot value.

!!! Warning This is only available for floating point entries.

Example

See it live on Compiler Explorer

#include <eve/function/hypot.hpp>
#include <eve/function/pedantic/hypot.hpp>
#include <eve/constant/valmax.hpp>
#include <eve/wide.hpp>
#include <iomanip>
#include <iostream>
#include <cmath>
int main()
{
wide_ft pf = {-1.0f, 2.0f, -3.0f, eve::valmax(eve::as<float>())/2};
wide_ft qf = {-4, 3, -2, -12};
std::cout << "---- simd" << std::setprecision(10) << '\n'
<< "<- pf = " << pf << '\n'
<< "<- qf = " << qf << '\n'
<< "-> hypot(pf, qf) = " << eve::hypot(pf, qf) << '\n'
<< "-> pedantic(hypot)(pf, qf) = " << eve::pedantic(eve::hypot)(pf, qf) << '\n';
double xf = -327680000;
double yf = 10;
std::cout << "---- scalar" << std::setprecision(15) << '\n'
<< "<- xf = " << xf << '\n'
<< "<- yf = " << yf << '\n'
<< "-> hypot(xf, yf) = " << eve::hypot(xf, yf) << '\n'
<< "-> pedantic(hypot)(xf, yf) = " << eve::pedantic(eve::hypot)(xf, yf) << '\n';
return 0;
}
constexpr callable_hypot_ hypot
Callable object computing the hypot operation.
Definition: hypot.hpp:94
constexpr callable_valmax_ valmax
Callable object computing the greatest representable value.
Definition: valmax.hpp:53
constexpr pedantic_type const pedantic
Higher-order Callable Object imbuing more standard semantic onto other Callable Objects.
Definition: pedantic.hpp:56
Lightweight type-wrapper.
Definition: as.hpp:29
Wrapper for SIMD registers.
Definition: wide.hpp:65