dlapy3 function

double dlapy3(
  1. double X,
  2. double Y,
  3. double Z
)

Implementation

double dlapy3(final double X, final double Y, final double Z) {
  const ZERO = 0.0;
  double W, XABS, YABS, ZABS, HUGEVAL;

  HUGEVAL = dlamch('Overflow');
  XABS = X.abs();
  YABS = Y.abs();
  ZABS = Z.abs();
  W = max(XABS, max(YABS, ZABS));
  if (W == ZERO || W > HUGEVAL) {
    // W can be zero for max(0,nan,0)
    // adding all three entries together will make sure
    // NaN will not disappear.
    return XABS + YABS + ZABS;
  }

  return W * sqrt(pow(XABS / W, 2) + pow(YABS / W, 2) + pow(ZABS / W, 2));
}