Macaulay2 Engine
Loading...
Searching...
No Matches

◆ hypot() [2/3]

const mpreal mpfr::hypot ( const mpreal & a,
const mpreal & b,
const mpreal & c,
const mpreal & d )
inline

Definition at line 2485 of file mpreal.h.

2486{
2487 if(isnan(a) || isnan(b) || isnan(c) || isnan(d)) return mpreal().setNan();
2488 else
2489 {
2490 mpreal absa = abs(a), absb = abs(b), absc = abs(c), absd = abs(d);
2491 mpreal w = (std::max)(absa, (std::max)(absb, (std::max)(absc, absd)));
2492 mpreal r;
2493
2494 if (!iszero(w))
2495 {
2496 mpreal iw = 1/w;
2497 r = w * sqrt(sqr(absa*iw) + sqr(absb*iw) + sqr(absc*iw) + sqr(absd*iw));
2498 }
2499
2500 return r;
2501 }
2502}
mpreal & setNan()
Definition mpreal.h:2004
const mpreal sqrt(const unsigned int v, mp_rnd_t rnd_mode=mpreal::get_default_rnd())
Definition mpreal.h:2244
bool isnan(const mpreal &op)
Definition mpreal.h:1744
bool iszero(const mpreal &op)
Definition mpreal.h:1747
const mpreal sqr(const mpreal &x, mp_rnd_t r=mpreal::get_default_rnd())
Definition mpreal.h:2231
#define abs(x)
Definition polyroots.cpp:51

References abs, hypot(), isnan(), iszero(), mpfr::mpreal::setNan(), sqr(), and sqrt().