E.V.E
v2023.02.15
 
Loading...
Searching...
No Matches

◆ hypot

eve::hypot = functor<hypot_t>
inlineconstexpr

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:33
constexpr auto hypot
Callable object computing the norm of its inputs.
Definition: hypot.hpp:89
EVE Main Namespace.
Definition: abi.hpp:18

Parameters

x, ... args: floating real 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'
<< "-> hypot[pedantic](pf, qf) = " << eve::hypot[eve::pedantic](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'
<< "-> hypot[pedantic](xf, yf) = " << eve::hypot[eve::pedantic](xf, yf) << '\n';
return 0;
}
constexpr auto valmax
Computes the the greatest representable value.
Definition: valmax.hpp:68
constexpr pedantic_type const pedantic
Higher-order Callable Object imbuing more standard semantic onto other Callable Objects.
Definition: pedantic.hpp:52
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::smallestposval(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'
    << "-> hypot[pedantic](pf, qf) = " << eve::hypot[eve::pedantic](pf, qf) << '\n';
    std::cout << eve::hypot[eve::pedantic](5.0, 1.0e-305) << std::endl;
    return 0;
    }
    constexpr auto smallestposval
    Computes the smallest normal positive value.
    Definition: smallestposval.hpp:74
    constexpr auto nan
    Computes the IEEE quiet NaN constant.
    Definition: nan.hpp:69
    constexpr auto inf
    Computes the infinity ieee value.
    Definition: inf.hpp:70