diff options
Diffstat (limited to 'gsl-1.9/cblas/hypot.c')
-rw-r--r-- | gsl-1.9/cblas/hypot.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/gsl-1.9/cblas/hypot.c b/gsl-1.9/cblas/hypot.c new file mode 100644 index 0000000..8f6bb47 --- /dev/null +++ b/gsl-1.9/cblas/hypot.c @@ -0,0 +1,28 @@ +#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) ; + } +} |