Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/boost/math/ccmath/copysign.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ constexpr auto copysign(T1 mag, T2 sgn) noexcept
{
if (BOOST_MATH_IS_CONSTANT_EVALUATED(mag))
{
using promoted_type = boost::math::tools::promote_args_2_t<T1, T2>;
using promoted_type = boost::math::tools::promote_args_t<T1, T2>;
return boost::math::ccmath::copysign(static_cast<promoted_type>(mag), static_cast<promoted_type>(sgn));
}
else
Expand Down
2 changes: 1 addition & 1 deletion include/boost/math/ccmath/fdim.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ constexpr auto fdim(T1 x, T2 y) noexcept
{
if (BOOST_MATH_IS_CONSTANT_EVALUATED(x))
{
using promoted_type = boost::math::tools::promote_args_2_t<T1, T2>;
using promoted_type = boost::math::tools::promote_args_t<T1, T2>;
return boost::math::ccmath::fdim(promoted_type(x), promoted_type(y));
}
else
Expand Down
2 changes: 1 addition & 1 deletion include/boost/math/ccmath/fmax.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ constexpr auto fmax(T1 x, T2 y) noexcept
{
if (BOOST_MATH_IS_CONSTANT_EVALUATED(x))
{
using promoted_type = boost::math::tools::promote_args_2_t<T1, T2>;
using promoted_type = boost::math::tools::promote_args_t<T1, T2>;
return boost::math::ccmath::fmax(static_cast<promoted_type>(x), static_cast<promoted_type>(y));
}
else
Expand Down
2 changes: 1 addition & 1 deletion include/boost/math/ccmath/fmin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ constexpr auto fmin(T1 x, T2 y) noexcept
{
if (BOOST_MATH_IS_CONSTANT_EVALUATED(x))
{
using promoted_type = boost::math::tools::promote_args_2_t<T1, T2>;
using promoted_type = boost::math::tools::promote_args_t<T1, T2>;
return boost::math::ccmath::fmin(static_cast<promoted_type>(x), static_cast<promoted_type>(y));
}
else
Expand Down
2 changes: 1 addition & 1 deletion include/boost/math/ccmath/hypot.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ constexpr auto hypot(T1 x, T2 y) noexcept
{
if(BOOST_MATH_IS_CONSTANT_EVALUATED(x))
{
using promoted_type = boost::math::tools::promote_args_2_t<T1, T2>;
using promoted_type = boost::math::tools::promote_args_t<T1, T2>;
return boost::math::ccmath::hypot(static_cast<promoted_type>(x), static_cast<promoted_type>(y));
}
else
Expand Down
14 changes: 7 additions & 7 deletions include/boost/math/differentiation/autodiff.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace detail {

template <typename RealType, typename... RealTypes>
struct promote_args_n {
using type = typename tools::promote_args_2<RealType, typename promote_args_n<RealTypes...>::type>::type;
using type = typename tools::promote_args<RealType, typename promote_args_n<RealTypes...>::type>::type;
};

template <typename RealType>
Expand Down Expand Up @@ -2002,9 +2002,9 @@ using autodiff_root_type = typename autodiff_fvar_type<RealType, Order>::root_ty

// See boost/math/tools/promotion.hpp
template <typename RealType0, size_t Order0, typename RealType1, size_t Order1>
struct promote_args_2<detail::autodiff_fvar_type<RealType0, Order0>,
struct promote_args<detail::autodiff_fvar_type<RealType0, Order0>,
detail::autodiff_fvar_type<RealType1, Order1>> {
using type = detail::autodiff_fvar_type<typename promote_args_2<RealType0, RealType1>::type,
using type = detail::autodiff_fvar_type<typename promote_args<RealType0, RealType1>::type,
#ifndef BOOST_NO_CXX14_CONSTEXPR
(std::max)(Order0, Order1)>;
#else
Expand All @@ -2018,13 +2018,13 @@ struct promote_args<detail::autodiff_fvar_type<RealType, Order>> {
};

template <typename RealType0, size_t Order0, typename RealType1>
struct promote_args_2<detail::autodiff_fvar_type<RealType0, Order0>, RealType1> {
using type = detail::autodiff_fvar_type<typename promote_args_2<RealType0, RealType1>::type, Order0>;
struct promote_args<detail::autodiff_fvar_type<RealType0, Order0>, RealType1> {
using type = detail::autodiff_fvar_type<typename promote_args<RealType0, RealType1>::type, Order0>;
};

template <typename RealType0, typename RealType1, size_t Order1>
struct promote_args_2<RealType0, detail::autodiff_fvar_type<RealType1, Order1>> {
using type = detail::autodiff_fvar_type<typename promote_args_2<RealType0, RealType1>::type, Order1>;
struct promote_args<RealType0, detail::autodiff_fvar_type<RealType1, Order1>> {
using type = detail::autodiff_fvar_type<typename promote_args<RealType0, RealType1>::type, Order1>;
};

template <typename destination_t, typename RealType, std::size_t Order>
Expand Down
40 changes: 27 additions & 13 deletions include/boost/math/policies/policy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include <boost/math/tools/config.hpp>
#include <boost/math/tools/mp.hpp>
#include <boost/math/tools/promotion.hpp>
#include <limits>
#include <type_traits>
#include <cmath>
Expand Down Expand Up @@ -723,22 +724,35 @@ inline constexpr typename normalise<policy<>, A1, A2, A3, A4, A5, A6, A7, A8, A9
//
// Traits class to handle internal promotion:
//

template <class Real, class Policy>
struct evaluation
{
typedef Real type;
};
struct evaluation {
// Operation specific minimum float type
struct min_policy_allowed_float_type {
using type = float;
};

template <class Policy>
struct evaluation<float, Policy>
{
using type = typename std::conditional<Policy::promote_float_type::value, double, float>::type;
};
// Minimum type returned after applying double promotion rules
struct min_promote_with_float_type {
using type = typename std::conditional<Policy::promote_float_type::value,
double, typename min_policy_allowed_float_type::type>::type;
};

template <class Policy>
struct evaluation<double, Policy>
{
using type = typename std::conditional<Policy::promote_double_type::value, long double, double>::type;
// Minimum type returned after applying long double promotion rules
struct min_promote_with_double_type {
using type = typename std::conditional<Policy::promote_double_type::value,
long double, typename min_policy_allowed_float_type::type>::type;
};

// Minimum type returned after applying double and long double promotion rules
struct min_evaluation_float_type {
using type = typename tools::promote_args<typename min_policy_allowed_float_type::type,
typename min_promote_with_float_type::type,
typename min_promote_with_double_type::type>::type;
};

using type = typename tools::promote_args<Real,
typename min_evaluation_float_type::type>::type;
};

template <class Real, class Policy>
Expand Down
Loading