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_ISNORMAL_HPP
0007 #define BOOST_MATH_ISNORMAL_HPP
0008 
0009 #include <boost/math/ccmath/detail/config.hpp>
0010 
0011 #ifdef BOOST_MATH_NO_CCMATH
0012 #error "The header <boost/math/isnormal.hpp> can only be used in C++17 and later."
0013 #endif
0014 
0015 #include <boost/math/ccmath/abs.hpp>
0016 #include <boost/math/ccmath/isinf.hpp>
0017 #include <boost/math/ccmath/isnan.hpp>
0018 
0019 namespace boost::math::ccmath {
0020 
0021 template <typename T>
0022 inline constexpr bool isnormal(T x)
0023 {
0024     if(BOOST_MATH_IS_CONSTANT_EVALUATED(x))
0025     {   
0026         return x == T(0) ? false :
0027                boost::math::ccmath::isinf(x) ? false :
0028                boost::math::ccmath::isnan(x) ? false :
0029                boost::math::ccmath::abs(x) < (std::numeric_limits<T>::min)() ? false : true;
0030     }
0031     else
0032     {
0033         using std::isnormal;
0034 
0035         if constexpr (!std::is_integral_v<T>)
0036         {
0037             return isnormal(x);
0038         }
0039         else
0040         {
0041             return isnormal(static_cast<double>(x));
0042         }
0043     }
0044 }
0045 }
0046 
0047 #endif // BOOST_MATH_ISNORMAL_HPP