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

◆ hypot() [1/3]

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

Definition at line 2466 of file mpreal.h.

2467{
2468 if(isnan(a) || isnan(b) || isnan(c)) return mpreal().setNan();
2469 else
2470 {
2471 mpreal absa = abs(a), absb = abs(b), absc = abs(c);
2472 mpreal w = (std::max)(absa, (std::max)(absb, absc));
2473 mpreal r;
2474
2475 if (!iszero(w))
2476 {
2477 mpreal iw = 1/w;
2478 r = w * sqrt(sqr(absa*iw) + sqr(absb*iw) + sqr(absc*iw));
2479 }
2480
2481 return r;
2482 }
2483}
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().