E.V.E
v2023.02.15

◆ hypot

eve::hypot = {}
inlineconstexpr

Callable object computing the \(l_2\) norm of its inputs.

Defined in Header

#include <eve/module/math.hpp>

Callable Signatures

namespace eve
{
template< value T, value ... Ts>
auto hypot( T x,Ts ... args ) const noexcept
}
Definition: value.hpp:31
constexpr callable_hypot_ hypot
Callable object computing the norm of its inputs.
Definition: hypot.hpp:71
Definition: abi.hpp:18

Parameters

x, ... args: floating real or complex values

Return value

\(\sqrt{\sum_1^n |x_i|^2}\) is returned. The result type is the common value type of the absolute values of the parameters.

Example

#include <eve/module/math.hpp>
#include <eve/module/math.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_valmax_ valmax
Computes the the greatest representable value.
Definition: valmax.hpp:55
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

Semantic Modifiers

  • eve::pedantic

    The call pedantic(hypot)(x,args...) computes the square root of the sum of the absolute 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.

    Example

    #include <eve/module/math.hpp>
    #include <eve/wide.hpp>
    #include <iomanip>
    #include <iostream>
    #include <cmath>
    int main()
    {
    wide_ft pf = {-1.0f, eve::inf(eve::as(1.0f)), -3.0f, eve::valmax(eve::as<float>())/2};
    wide_ft qf = {-4, eve::nan(eve::as(1.0f)), -2, -12};
    std::cout << "---- simd" << std::setprecision(10) << '\n'
    << "<- pf = " << pf << '\n'
    << "<- qf = " << qf << '\n'
    << "-> pedantic(hypot)(pf, qf) = " << eve::pedantic(eve::hypot)(pf, qf) << '\n';
    return 0;
    }
    constexpr callable_nan_ nan
    Computes the IEEE NaN constant.
    Definition: nan.hpp:53
    constexpr callable_inf_ inf
    Computes the infinity ieee value.
    Definition: inf.hpp:58