Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:45:15

0001 //  (C) Copyright Matt Borland 2021.
0002 //  Use, modification and distribution are subject to the
0003 //  Boost Software License, Version 1.0. (See accompanying file
0004 //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0005 
0006 #ifndef BOOST_MATH_CCMATH_FPCLASSIFY
0007 #define BOOST_MATH_CCMATH_FPCLASSIFY
0008 
0009 #include <boost/math/ccmath/detail/config.hpp>
0010 
0011 #ifdef BOOST_MATH_NO_CCMATH
0012 #error "The header <boost/math/fpclassify.hpp> can only be used in C++17 and later."
0013 #endif
0014 
0015 #include <boost/math/special_functions/fpclassify.hpp>
0016 #include <boost/math/ccmath/abs.hpp>
0017 #include <boost/math/ccmath/isinf.hpp>
0018 #include <boost/math/ccmath/isnan.hpp>
0019 #include <boost/math/ccmath/isfinite.hpp>
0020 
0021 namespace boost::math::ccmath {
0022 
0023 template <typename T, std::enable_if_t<!std::is_integral_v<T>, bool> = true>
0024 inline constexpr int fpclassify BOOST_PREVENT_MACRO_SUBSTITUTION(T x)
0025 {
0026     if(BOOST_MATH_IS_CONSTANT_EVALUATED(x))
0027     {
0028         return (boost::math::ccmath::isnan)(x) ? FP_NAN :
0029                (boost::math::ccmath::isinf)(x) ? FP_INFINITE :
0030                boost::math::ccmath::abs(x) == T(0) ? FP_ZERO :
0031                boost::math::ccmath::abs(x) > 0 && boost::math::ccmath::abs(x) < (std::numeric_limits<T>::min)() ? FP_SUBNORMAL : FP_NORMAL;
0032     }
0033     else
0034     {
0035         using boost::math::fpclassify;
0036         return (fpclassify)(x);
0037     }
0038 }
0039 
0040 template <typename Z, std::enable_if_t<std::is_integral_v<Z>, bool> = true>
0041 inline constexpr int fpclassify(Z x)
0042 {
0043     return boost::math::ccmath::fpclassify(static_cast<double>(x));
0044 }
0045 
0046 }
0047 
0048 #endif // BOOST_MATH_CCMATH_FPCLASSIFY