brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · 2321f14 Raw
61 lines · plain
1//  (C) Copyright Matt Borland 2021.2//  Use, modification and distribution are subject to the3//  Boost Software License, Version 1.0. (See accompanying file4//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)5 6#ifndef BOOST_MATH_CCMATH_SCALBLN_HPP7#define BOOST_MATH_CCMATH_SCALBLN_HPP8 9#include <boost/math/ccmath/detail/config.hpp>10 11#ifdef BOOST_MATH_NO_CCMATH12#error "The header <boost/math/scalbln.hpp> can only be used in C++17 and later."13#endif14 15#include <cfloat>16#include <boost/math/ccmath/scalbn.hpp>17#include <boost/math/ccmath/abs.hpp>18#include <boost/math/ccmath/isinf.hpp>19#include <boost/math/ccmath/isnan.hpp>20 21namespace boost::math::ccmath {22 23template <typename Real, std::enable_if_t<!std::is_integral_v<Real>, bool> = true>24inline constexpr Real scalbln(Real arg, long exp) noexcept25{26    if(BOOST_MATH_IS_CONSTANT_EVALUATED(arg))27    {28        return boost::math::ccmath::abs(arg) == Real(0) ? arg :29               boost::math::ccmath::isinf(arg) ? arg :30               boost::math::ccmath::isnan(arg) ? arg :31               boost::math::ccmath::detail::scalbn_impl(arg, exp);32    }33    else34    {35        using std::scalbln;36        return scalbln(arg, exp);37    }38}39 40template <typename Z, std::enable_if_t<std::is_integral_v<Z>, bool> = true>41inline constexpr double scalbln(Z arg, long exp) noexcept42{43    return boost::math::ccmath::scalbln(static_cast<double>(arg), exp);44}45 46inline constexpr float scalblnf(float arg, long exp) noexcept47{48    return boost::math::ccmath::scalbln(arg, exp);49}50 51#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS52inline constexpr long double scalblnl(long double arg, long exp) noexcept53{54    return boost::math::ccmath::scalbln(arg, exp);55}56#endif57 58} // Namespaces59 60#endif // BOOST_MATH_CCMATH_SCALBLN_HPP61