fabs.hpp 850 B

1234567891011121314151617181920212223242526272829303132333435
  1. // (C) Copyright Matt Borland 2021.
  2. // Use, modification and distribution are subject to the
  3. // Boost Software License, Version 1.0. (See accompanying file
  4. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. //
  6. // Constepxr implementation of fabs (see c.math.abs secion 26.8.2 of the ISO standard)
  7. #ifndef BOOST_MATH_CCMATH_FABS
  8. #define BOOST_MATH_CCMATH_FABS
  9. #include <boost/math/ccmath/abs.hpp>
  10. namespace boost::math::ccmath {
  11. template <typename T>
  12. inline constexpr auto fabs(T x) noexcept
  13. {
  14. return boost::math::ccmath::abs(x);
  15. }
  16. inline constexpr float fabsf(float x) noexcept
  17. {
  18. return boost::math::ccmath::abs(x);
  19. }
  20. #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
  21. inline constexpr long double fabsl(long double x) noexcept
  22. {
  23. return boost::math::ccmath::abs(x);
  24. }
  25. #endif
  26. }
  27. #endif // BOOST_MATH_CCMATH_FABS