gsl_cblas__hypot.c 430 B

1234567891011121314151617181920212223242526272829
  1. #include <math.h>
  2. static double xhypot (const double x, const double y);
  3. static double xhypot (const double x, const double y)
  4. {
  5. double xabs = fabs(x) ;
  6. double yabs = fabs(y) ;
  7. double min, max;
  8. if (xabs < yabs) {
  9. min = xabs ;
  10. max = yabs ;
  11. } else {
  12. min = yabs ;
  13. max = xabs ;
  14. }
  15. if (min == 0)
  16. {
  17. return max ;
  18. }
  19. {
  20. double u = min / max ;
  21. return max * sqrt (1 + u * u) ;
  22. }
  23. }