Logo Search packages:      
Sourcecode: gsl version File versions

hypot.c

#include <math.h>

static double xhypot (const double x, const double y);

static double xhypot (const double x, const double y)
{
  double xabs = fabs(x) ;
  double yabs = fabs(y) ;
  double min, max;

  if (xabs < yabs) {
    min = xabs ;
    max = yabs ;
  } else {
    min = yabs ;
    max = xabs ;
  }

  if (min == 0) 
    {
      return max ;
    }

  {
    double u = min / max ;
    return max * sqrt (1 + u * u) ;
  }
}

Generated by  Doxygen 1.6.0   Back to index