1996-08-29 15:10:41 -03:00
|
|
|
/* hypot() replacement */
|
|
|
|
|
2007-11-12 01:14:05 -04:00
|
|
|
#include "Python.h"
|
1996-08-29 15:10:41 -03:00
|
|
|
|
2008-01-20 10:28:28 -04:00
|
|
|
#ifndef HAVE_HYPOT
|
2000-07-22 15:47:25 -03:00
|
|
|
double hypot(double x, double y)
|
1996-08-29 15:10:41 -03:00
|
|
|
{
|
|
|
|
double yx;
|
|
|
|
|
|
|
|
x = fabs(x);
|
|
|
|
y = fabs(y);
|
|
|
|
if (x < y) {
|
|
|
|
double temp = x;
|
|
|
|
x = y;
|
|
|
|
y = temp;
|
|
|
|
}
|
|
|
|
if (x == 0.)
|
|
|
|
return 0.;
|
|
|
|
else {
|
|
|
|
yx = y/x;
|
|
|
|
return x*sqrt(1.+yx*yx);
|
|
|
|
}
|
|
|
|
}
|
2008-01-20 10:28:28 -04:00
|
|
|
#endif /* HAVE_HYPOT */
|
|
|
|
|