w_cabs.c 613 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. * cabs() wrapper for hypot().
  3. *
  4. * Written by J.T. Conklin, <jtc@wimsey.com>
  5. * Placed into the Public Domain, 1994.
  6. */
  7. #include <complex.h>
  8. #include <math.h>
  9. double cabs(double _Complex z)
  10. {
  11. return hypot(__real__ z, __imag__ z);
  12. }
  13. libm_hidden_def(cabs)
  14. libm_hidden_proto(cabsf)
  15. float cabsf(float _Complex z)
  16. {
  17. return (float) hypot(__real__ z, __imag__ z);
  18. }
  19. libm_hidden_def(cabsf)
  20. #if defined __UCLIBC_HAS_LONG_DOUBLE_MATH__ && !defined __NO_LONG_DOUBLE_MATH
  21. libm_hidden_proto(cabsl)
  22. long double cabsl(long double _Complex z)
  23. {
  24. return hypotl(__real__ z, __imag__ z);
  25. }
  26. libm_hidden_def(cabsl)
  27. #endif