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_SCALBLN_HPP
0007 #define BOOST_MATH_CCMATH_SCALBLN_HPP
0008 
0009 #include <boost/math/ccmath/detail/config.hpp>
0010 
0011 #ifdef BOOST_MATH_NO_CCMATH
0012 #error "The header <boost/math/scalbln.hpp> can only be used in C++17 and later."
0013 #endif
0014 
0015 #include <cfloat>
0016 #include <boost/math/ccmath/scalbn.hpp>
0017 #include <boost/math/ccmath/abs.hpp>
0018 #include <boost/math/ccmath/isinf.hpp>
0019 #include <boost/math/ccmath/isnan.hpp>
0020 
0021 namespace boost::math::ccmath {
0022 
0023 template <typename Real, std::enable_if_t<!std::is_integral_v<Real>, bool> = true>
0024 inline constexpr Real scalbln(Real arg, long exp) noexcept
0025 {
0026     if(BOOST_MATH_IS_CONSTANT_EVALUATED(arg))
0027     {
0028         return boost::math::ccmath::abs(arg) == Real(0) ? arg :
0029                boost::math::ccmath::isinf(arg) ? arg :
0030                boost::math::ccmath::isnan(arg) ? arg :
0031                boost::math::ccmath::detail::scalbn_impl(arg, exp);
0032     }
0033     else
0034     {
0035         using std::scalbln;
0036         return scalbln(arg, exp);
0037     }
0038 }
0039 
0040 template <typename Z, std::enable_if_t<std::is_integral_v<Z>, bool> = true>
0041 inline constexpr double scalbln(Z arg, long exp) noexcept
0042 {
0043     return boost::math::ccmath::scalbln(static_cast<double>(arg), exp);
0044 }
0045 
0046 inline constexpr float scalblnf(float arg, long exp) noexcept
0047 {
0048     return boost::math::ccmath::scalbln(arg, exp);
0049 }
0050 
0051 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
0052 inline constexpr long double scalblnl(long double arg, long exp) noexcept
0053 {
0054     return boost::math::ccmath::scalbln(arg, exp);
0055 }
0056 #endif
0057 
0058 } // Namespaces
0059 
0060 #endif // BOOST_MATH_CCMATH_SCALBLN_HPP