diff --git a/sprout/math/acosh.hpp b/sprout/math/acosh.hpp index 4eb02eae..9d9325a1 100644 --- a/sprout/math/acosh.hpp +++ b/sprout/math/acosh.hpp @@ -5,26 +5,37 @@ #include #include #include +#include #include #include #include +#include namespace sprout { namespace math { namespace detail { + template + inline SPROUT_CONSTEXPR T + acosh_impl(T x) { + return sprout::math::log(x + sprout::math::sqrt(x * x - 1)); + } + template< typename FloatType, typename sprout::enabler_if::value>::type = sprout::enabler > inline SPROUT_CONSTEXPR FloatType acosh(FloatType x) { - return x == 1 ? FloatType(0) - : x < 1 ? std::numeric_limits::quiet_NaN() + return x < 1 ? std::numeric_limits::quiet_NaN() : x == std::numeric_limits::infinity() ? std::numeric_limits::infinity() - : sprout::log(x + sprout::sqrt(x * x - 1)) +#if SPROUT_USE_BUILTIN_CMATH_FUNCTION + : std::acosh(x) +#else + : x == 1 ? FloatType(0) + : static_cast(sprout::math::detail::acosh_impl(static_cast::type>(x))) +#endif ; } - template< typename IntType, typename sprout::enabler_if::value>::type = sprout::enabler @@ -34,8 +45,17 @@ namespace sprout { return sprout::math::detail::acosh(static_cast(x)); } } // namespace detail - - using NS_SPROUT_MATH_DETAIL::acosh; + // + // acosh + // + template< + typename ArithmeticType, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR typename sprout::float_promote::type + acosh(ArithmeticType x) { + return sprout::math::detail::acosh(x); + } } // namespace math using sprout::math::acosh; diff --git a/sprout/math/asin.hpp b/sprout/math/asin.hpp index 69242657..f55e5d25 100644 --- a/sprout/math/asin.hpp +++ b/sprout/math/asin.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -48,7 +49,7 @@ namespace sprout { #if SPROUT_USE_BUILTIN_CMATH_FUNCTION : std::asin(x) #else - : x == 0 ? FloatType(0) + : x == 0 ? sprout::math::copysign(FloatType(0), x) : static_cast( x < 0 ? -sprout::math::detail::asin_impl(static_cast::type>(-x)) : sprout::math::detail::asin_impl(static_cast::type>(x)) diff --git a/sprout/math/asinh.hpp b/sprout/math/asinh.hpp index 1931faef..1d3216d3 100644 --- a/sprout/math/asinh.hpp +++ b/sprout/math/asinh.hpp @@ -5,26 +5,38 @@ #include #include #include +#include +#include #include #include #include +#include namespace sprout { namespace math { namespace detail { + template + inline SPROUT_CONSTEXPR T + asinh_impl(T x) { + return sprout::math::log(x + sprout::math::sqrt(x * x + 1)); + } + template< typename FloatType, typename sprout::enabler_if::value>::type = sprout::enabler > inline SPROUT_CONSTEXPR FloatType asinh(FloatType x) { - return x == 0 ? FloatType(0) - : x == std::numeric_limits::infinity() ? std::numeric_limits::infinity() + return x == std::numeric_limits::infinity() ? std::numeric_limits::infinity() : x == -std::numeric_limits::infinity() ? -std::numeric_limits::infinity() - : sprout::log(x + sprout::sqrt(x * x + 1)) +#if SPROUT_USE_BUILTIN_CMATH_FUNCTION + : std::asinh(x) +#else + : x == 0 ? sprout::math::copysign(FloatType(0), x) + : static_cast(sprout::math::detail::asinh_impl(static_cast::type>(x))) +#endif ; } - template< typename IntType, typename sprout::enabler_if::value>::type = sprout::enabler @@ -34,8 +46,17 @@ namespace sprout { return sprout::math::detail::asinh(static_cast(x)); } } // namespace detail - - using NS_SPROUT_MATH_DETAIL::asinh; + // + // asinh + // + template< + typename ArithmeticType, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR typename sprout::float_promote::type + asinh(ArithmeticType x) { + return sprout::math::detail::asinh(x); + } } // namespace math using sprout::math::asinh; diff --git a/sprout/math/atan.hpp b/sprout/math/atan.hpp index 57230652..5dec7ffd 100644 --- a/sprout/math/atan.hpp +++ b/sprout/math/atan.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -42,12 +43,12 @@ namespace sprout { > inline SPROUT_CONSTEXPR FloatType atan(FloatType x) { - return x == 0 ? FloatType(0) - : x == std::numeric_limits::infinity() ? sprout::math::half_pi() + return x == std::numeric_limits::infinity() ? sprout::math::half_pi() : x == -std::numeric_limits::infinity() ? -sprout::math::half_pi() #if SPROUT_USE_BUILTIN_CMATH_FUNCTION : std::atan(x) #else + : x == 0 ? sprout::math::copysign(FloatType(0), x) : static_cast( x < 0 ? -sprout::math::detail::atan_impl(static_cast::type>(-x)) : sprout::math::detail::atan_impl(static_cast::type>(x)) diff --git a/sprout/math/atan2.hpp b/sprout/math/atan2.hpp index e64ae0aa..a8228f5e 100644 --- a/sprout/math/atan2.hpp +++ b/sprout/math/atan2.hpp @@ -7,8 +7,9 @@ #include #include #include +#include +#include #include -#include #include #include @@ -35,20 +36,21 @@ namespace sprout { return x == -std::numeric_limits::infinity() ? y == std::numeric_limits::infinity() ? sprout::math::three_quarters_pi() : y == -std::numeric_limits::infinity() ? -sprout::math::three_quarters_pi() - : y < 0 ? -sprout::math::half_pi() - : sprout::math::half_pi() + : sprout::math::copysign(sprout::math::pi(), y) : x == std::numeric_limits::infinity() ? y == std::numeric_limits::infinity() ? sprout::math::quarter_pi() : y == -std::numeric_limits::infinity() ? -sprout::math::quarter_pi() - : FloatType(0) + : sprout::math::copysign(FloatType(0), y) : y == std::numeric_limits::infinity() ? sprout::math::half_pi() : y == -std::numeric_limits::infinity() ? -sprout::math::half_pi() #if SPROUT_USE_BUILTIN_CMATH_FUNCTION : std::atan2(y, x) #else : y == 0 - ? x < 0 ? sprout::math::pi() - : FloatType(0) + ? x < 0 ? sprout::math::copysign(sprout::math::pi(), y) + : x > 0 ? sprout::math::copysign(FloatType(0), y) + : sprout::math::signbit(x) ? sprout::math::copysign(sprout::math::pi(), y) + : sprout::math::copysign(FloatType(0), y) : x == 0 ? y < 0 ? -sprout::math::half_pi() : sprout::math::half_pi() diff --git a/sprout/math/atanh.hpp b/sprout/math/atanh.hpp index 254fcbaf..6d73019d 100644 --- a/sprout/math/atanh.hpp +++ b/sprout/math/atanh.hpp @@ -5,26 +5,39 @@ #include #include #include +#include +#include #include +#include #include +#include namespace sprout { namespace math { namespace detail { + template + inline SPROUT_CONSTEXPR T + atanh_impl(T x) { + return sprout::math::log((1 + x) / (1 - x)) / 2; + } + template< typename FloatType, typename sprout::enabler_if::value>::type = sprout::enabler > inline SPROUT_CONSTEXPR FloatType atanh(FloatType x) { - return x == 0 ? FloatType(0) - : x == 1 ? std::numeric_limits::infinity() + return x == 1 ? std::numeric_limits::infinity() : x == -1 ? -std::numeric_limits::infinity() - : x > 1 || x < -1 ? std::numeric_limits::quiet_NaN() - : sprout::log((1 + x) / (1 - x)) / 2 + : sprout::math::fabs(x) > 1 ? std::numeric_limits::quiet_NaN() +#if SPROUT_USE_BUILTIN_CMATH_FUNCTION + : std::atanh(x) +#else + : x == 0 ? sprout::math::copysign(FloatType(0), x) + : static_cast(sprout::math::detail::atanh_impl(static_cast::type>(x))) +#endif ; } - template< typename IntType, typename sprout::enabler_if::value>::type = sprout::enabler @@ -34,8 +47,17 @@ namespace sprout { return sprout::math::detail::atanh(static_cast(x)); } } // namespace detail - - using NS_SPROUT_MATH_DETAIL::atanh; + // + // atanh + // + template< + typename ArithmeticType, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR typename sprout::float_promote::type + atanh(ArithmeticType x) { + return sprout::math::detail::atanh(x); + } } // namespace math using sprout::math::atanh; diff --git a/sprout/math/cmath.hpp b/sprout/math/cmath.hpp index b0abaa4e..d755bf80 100644 --- a/sprout/math/cmath.hpp +++ b/sprout/math/cmath.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include diff --git a/sprout/math/copysign.hpp b/sprout/math/copysign.hpp new file mode 100644 index 00000000..ff9c9aa4 --- /dev/null +++ b/sprout/math/copysign.hpp @@ -0,0 +1,44 @@ +#ifndef SPROUT_MATH_COPYSIGN_HPP +#define SPROUT_MATH_COPYSIGN_HPP + +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace math { + namespace detail { + template< + typename FloatType, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR FloatType + copysign(FloatType x, FloatType y) { + return sprout::math::signbit(y) != sprout::math::signbit(x) ? -x + : x + ; + } + template< + typename ArithmeticType1, + typename ArithmeticType2, + typename sprout::enabler_if< + std::is_arithmetic::value && std::is_arithmetic::value + >::type = sprout::enabler + > + inline SPROUT_CONSTEXPR typename sprout::float_promote::type + copysign(ArithmeticType1 x, ArithmeticType2 y) { + typedef typename sprout::float_promote::type type; + return sprout::math::detail::copysign(static_cast(x), static_cast(y)); + } + } // namespace detail + + using NS_SPROUT_MATH_DETAIL::copysign; + } // namespace math + + using sprout::math::copysign; +} // namespace sprout + +#endif // #ifndef SPROUT_MATH_COPYSIGN_HPP diff --git a/sprout/math/cos.hpp b/sprout/math/cos.hpp index d1eb19d5..4cdcf4aa 100644 --- a/sprout/math/cos.hpp +++ b/sprout/math/cos.hpp @@ -21,7 +21,7 @@ namespace sprout { inline SPROUT_CONSTEXPR T cos_impl_1(T x2, std::size_t n, std::size_t last) { return last - n == 1 - ? (n % 2 ? -1 : 1) * sprout::detail::pow_n(x2, n) / sprout::math::factorial(2 * n) + ? (n % 2 ? -1 : 1) * sprout::detail::pow_n(x2, n) / sprout::math::unchecked_factorial(2 * n) : sprout::math::detail::cos_impl_1(x2, n, n + (last - n) / 2) + sprout::math::detail::cos_impl_1(x2, n + (last - n) / 2, last) ; diff --git a/sprout/math/cosh.hpp b/sprout/math/cosh.hpp index 17564cb2..6250c431 100644 --- a/sprout/math/cosh.hpp +++ b/sprout/math/cosh.hpp @@ -10,19 +10,28 @@ #include #include #include +#include namespace sprout { namespace math { namespace detail { template inline SPROUT_CONSTEXPR T - cosh_impl(T x2, std::size_t n, std::size_t last) { + cosh_impl_1(T x2, std::size_t n, std::size_t last) { return last - n == 1 - ? sprout::detail::pow_n(x2, n) / sprout::math::factorial(2 * n) - : sprout::math::detail::cosh_impl(x2, n, n + (last - n) / 2) - + sprout::math::detail::cosh_impl(x2, n + (last - n) / 2, last) + ? sprout::detail::pow_n(x2, n) / sprout::math::unchecked_factorial(2 * n) + : sprout::math::detail::cosh_impl_1(x2, n, n + (last - n) / 2) + + sprout::math::detail::cosh_impl_1(x2, n + (last - n) / 2, last) ; } + template + inline SPROUT_CONSTEXPR T + cosh_impl(T x) { + return T(1) + sprout::math::detail::cosh_impl_1( + x * x, + 1, sprout::math::factorial_limit() / 2 + 1 + ); + } template< typename FloatType, @@ -30,19 +39,17 @@ namespace sprout { > inline SPROUT_CONSTEXPR FloatType cosh(FloatType x) { - typedef typename sprout::math::detail::float_compute::type type; - return x == 0 ? FloatType(1) - : x == std::numeric_limits::infinity() || x == -std::numeric_limits::infinity() + return x == std::numeric_limits::infinity() + || x == -std::numeric_limits::infinity() ? std::numeric_limits::infinity() - : static_cast( - type(1) + sprout::math::detail::cosh_impl( - static_cast(x) * static_cast(x), - 1, sprout::math::factorial_limit() / 2 + 1 - ) - ) +#if SPROUT_USE_BUILTIN_CMATH_FUNCTION + : std::cosh(x) +#else + : x == 0 ? FloatType(1) + : static_cast(sprout::math::detail::cosh_impl(static_cast::type>(x))) +#endif ; } - template< typename IntType, typename sprout::enabler_if::value>::type = sprout::enabler @@ -52,8 +59,17 @@ namespace sprout { return sprout::math::detail::cosh(static_cast(x)); } } // namespace detail - - using NS_SPROUT_MATH_DETAIL::cosh; + // + // cosh + // + template< + typename ArithmeticType, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR typename sprout::float_promote::type + cosh(ArithmeticType x) { + return sprout::math::detail::cosh(x); + } } // namespace math using sprout::math::cosh; diff --git a/sprout/math/exp.hpp b/sprout/math/exp.hpp index 9d84c9b1..b13443cf 100644 --- a/sprout/math/exp.hpp +++ b/sprout/math/exp.hpp @@ -10,6 +10,7 @@ #include #include #include +#include namespace sprout { namespace math { @@ -18,7 +19,7 @@ namespace sprout { inline SPROUT_CONSTEXPR T exp_impl_1(T x, std::size_t n, std::size_t last) { return last - n == 1 - ? sprout::detail::pow_n(x, n) / sprout::math::factorial(n) + ? sprout::detail::pow_n(x, n) / sprout::math::unchecked_factorial(n) : sprout::math::detail::exp_impl_1(x, n, n + (last - n) / 2) + sprout::math::detail::exp_impl_1(x, n + (last - n) / 2, last) ; @@ -26,7 +27,9 @@ namespace sprout { template inline SPROUT_CONSTEXPR T exp_impl(T x) { - return T(1) + sprout::math::detail::exp_impl_1(x, 1, sprout::math::factorial_limit() / 2 + 1); + return !(x > -1) ? T(1) / (T(1) + sprout::math::detail::exp_impl_1(-x, 1, sprout::math::factorial_limit() / 2 + 1)) + : T(1) + sprout::math::detail::exp_impl_1(x, 1, sprout::math::factorial_limit() / 2 + 1) + ; } template< @@ -35,15 +38,16 @@ namespace sprout { > inline SPROUT_CONSTEXPR FloatType exp(FloatType x) { - typedef typename sprout::math::detail::float_compute::type type; - return x == 0 ? FloatType(1) - : x == -std::numeric_limits::infinity() ? FloatType(0) + return x == -std::numeric_limits::infinity() ? FloatType(0) : x == std::numeric_limits::infinity() ? std::numeric_limits::infinity() - : !(x > -1) ? static_cast(type(1) / sprout::math::detail::exp_impl(-static_cast(x))) - : static_cast(sprout::math::detail::exp_impl(static_cast(x))) +#if SPROUT_USE_BUILTIN_CMATH_FUNCTION + : std::exp(x) +#else + : x == 0 ? FloatType(1) + : static_cast(sprout::math::detail::exp_impl(static_cast::type>(x))) +#endif ; } - template< typename IntType, typename sprout::enabler_if::value>::type = sprout::enabler @@ -53,8 +57,17 @@ namespace sprout { return sprout::math::detail::exp(static_cast(x)); } } // namespace detail - - using NS_SPROUT_MATH_DETAIL::exp; + // + // exp + // + template< + typename ArithmeticType, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR typename sprout::float_promote::type + exp(ArithmeticType x) { + return sprout::math::detail::exp(x); + } } // namespace math using sprout::math::exp; diff --git a/sprout/math/exp10.hpp b/sprout/math/exp10.hpp index 83ff9bf8..c7d3244a 100644 --- a/sprout/math/exp10.hpp +++ b/sprout/math/exp10.hpp @@ -4,26 +4,34 @@ #include #include #include +#include +#include #include #include #include +#include namespace sprout { namespace math { namespace detail { + template + inline SPROUT_CONSTEXPR T + exp10_impl(T x) { + return sprout::math::exp(x * sprout::math::ln_ten()); + } + template< typename FloatType, typename sprout::enabler_if::value>::type = sprout::enabler > inline SPROUT_CONSTEXPR FloatType exp10(FloatType x) { - return x == 0 ? FloatType(1) - : x == -std::numeric_limits::infinity() ? FloatType(0) + return x == -std::numeric_limits::infinity() ? FloatType(0) : x == std::numeric_limits::infinity() ? std::numeric_limits::infinity() - : sprout::exp(x * sprout::math::ln_ten()) + : x == 0 ? FloatType(1) + : static_cast(sprout::math::detail::exp10_impl(static_cast::type>(x))) ; } - template< typename IntType, typename sprout::enabler_if::value>::type = sprout::enabler @@ -33,8 +41,17 @@ namespace sprout { return sprout::math::detail::exp10(static_cast(x)); } } // namespace detail - - using sprout::math::detail::exp10; + // + // exp10 + // + template< + typename ArithmeticType, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR typename sprout::float_promote::type + exp10(ArithmeticType x) { + return sprout::math::detail::exp10(x); + } } // namespace math using sprout::math::exp10; diff --git a/sprout/math/exp2.hpp b/sprout/math/exp2.hpp index 3e1a9cb4..2658d41b 100644 --- a/sprout/math/exp2.hpp +++ b/sprout/math/exp2.hpp @@ -5,26 +5,37 @@ #include #include #include +#include #include #include #include +#include namespace sprout { namespace math { namespace detail { + template + inline SPROUT_CONSTEXPR T + exp2_impl(T x) { + return sprout::math::exp(x * sprout::math::ln_two()); + } + template< typename FloatType, typename sprout::enabler_if::value>::type = sprout::enabler > inline SPROUT_CONSTEXPR FloatType exp2(FloatType x) { - return x == 0 ? FloatType(1) - : x == -std::numeric_limits::infinity() ? FloatType(0) + return x == -std::numeric_limits::infinity() ? FloatType(0) : x == std::numeric_limits::infinity() ? std::numeric_limits::infinity() - : sprout::exp(x * sprout::math::ln_two()) +#if SPROUT_USE_BUILTIN_CMATH_FUNCTION + : std::exp2(x) +#else + : x == 0 ? FloatType(1) + : static_cast(sprout::math::detail::exp2_impl(static_cast::type>(x))) +#endif ; } - template< typename IntType, typename sprout::enabler_if::value>::type = sprout::enabler @@ -34,8 +45,17 @@ namespace sprout { return sprout::math::detail::exp2(static_cast(x)); } } // namespace detail - - using NS_SPROUT_MATH_DETAIL::exp2; + // + // exp2 + // + template< + typename ArithmeticType, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR typename sprout::float_promote::type + exp2(ArithmeticType x) { + return sprout::math::detail::exp2(x); + } } // namespace math using sprout::math::exp2; diff --git a/sprout/math/expm1.hpp b/sprout/math/expm1.hpp index dbfe5074..78a636b8 100644 --- a/sprout/math/expm1.hpp +++ b/sprout/math/expm1.hpp @@ -5,26 +5,38 @@ #include #include #include +#include +#include #include #include #include +#include namespace sprout { namespace math { namespace detail { + template + inline SPROUT_CONSTEXPR T + expm1_impl(T x) { + return sprout::math::exp(x) - T(1); + } + template< typename FloatType, typename sprout::enabler_if::value>::type = sprout::enabler > inline SPROUT_CONSTEXPR FloatType expm1(FloatType x) { - return x == 0 ? FloatType(0) - : x == -std::numeric_limits::infinity() ? FloatType(-1) + return x == -std::numeric_limits::infinity() ? FloatType(-1) : x == std::numeric_limits::infinity() ? std::numeric_limits::infinity() - : sprout::exp(x) - FloatType(1) +#if SPROUT_USE_BUILTIN_CMATH_FUNCTION + : std::expm1(x) +#else + : x == 0 ? sprout::math::copysign(FloatType(0), x) + : static_cast(sprout::math::detail::expm1_impl(static_cast::type>(x))) +#endif ; } - template< typename IntType, typename sprout::enabler_if::value>::type = sprout::enabler @@ -34,8 +46,17 @@ namespace sprout { return sprout::math::detail::expm1(static_cast(x)); } } // namespace detail - - using NS_SPROUT_MATH_DETAIL::expm1; + // + // expm1 + // + template< + typename ArithmeticType, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR typename sprout::float_promote::type + expm1(ArithmeticType x) { + return sprout::math::detail::expm1(x); + } } // namespace math using sprout::math::expm1; diff --git a/sprout/math/fabs.hpp b/sprout/math/fabs.hpp index b6792cff..6c95b36a 100644 --- a/sprout/math/fabs.hpp +++ b/sprout/math/fabs.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include namespace sprout { @@ -15,9 +16,8 @@ namespace sprout { > inline SPROUT_CONSTEXPR FloatType fabs(FloatType x) { - return x < 0 ? -x : x; + return sprout::math::copysign(x, FloatType(0)); } - template< typename IntType, typename sprout::enabler_if::value>::type = sprout::enabler diff --git a/sprout/math/hypot.hpp b/sprout/math/hypot.hpp index 950a89ce..4334d580 100644 --- a/sprout/math/hypot.hpp +++ b/sprout/math/hypot.hpp @@ -25,7 +25,7 @@ namespace sprout { ? std::numeric_limits::infinity() : x == std::numeric_limits::infinity() || x == -std::numeric_limits::infinity() ? std::numeric_limits::infinity() - : sprout::sqrt(x * x + y * y) + : sprout::math::sqrt(x * x + y * y) ; } diff --git a/sprout/math/lgamma.hpp b/sprout/math/lgamma.hpp index 6ed5c5e6..811aaf20 100644 --- a/sprout/math/lgamma.hpp +++ b/sprout/math/lgamma.hpp @@ -20,7 +20,7 @@ namespace sprout { template inline SPROUT_CONSTEXPR T lgamma_impl_3(T x, T y) { - return x < 0 ? sprout::log(sprout::math::pi() / sprout::math::fabs(x * sprout::math::sin(x * sprout::math::pi()))) - y + return x < 0 ? sprout::math::log(sprout::math::pi() / sprout::math::fabs(x * sprout::math::sin(x * sprout::math::pi()))) - y : y ; } @@ -31,7 +31,7 @@ namespace sprout { x, (((((-0.00163312359200500807 * t + 8.3644533703385956e-4) * t + -5.9518947575728181e-4) * t + 7.9365057505415415e-4) * t + -0.00277777777735463043) * t + 0.08333333333333309869) * v + 0.91893853320467274178 - + ((w - T(0.5)) * sprout::log(w) - w) + + ((w - T(0.5)) * sprout::math::log(w) - w) ); } template @@ -145,7 +145,7 @@ namespace sprout { lgamma_impl_2_a(T x, T w, int k) { return sprout::math::detail::lgamma_impl_3( x, - -sprout::log( + -sprout::math::log( k == 0 ? (((((((((( 9.967270908702825e-5 * w + -1.9831672170162227e-4) * w + -0.00117085315349625822) * w + 0.00722012810948319552) * w + -0.0096221300936780297) * w diff --git a/sprout/math/log.hpp b/sprout/math/log.hpp index b9303520..2ff222da 100644 --- a/sprout/math/log.hpp +++ b/sprout/math/log.hpp @@ -12,25 +12,33 @@ #include #include #include +#include namespace sprout { namespace math { namespace detail { template inline SPROUT_CONSTEXPR T - log_impl_1(T x, std::size_t n, std::size_t last) { + log_impl_2(T x, std::size_t n, std::size_t last) { return last - n == 1 ? (n % 2 ? 1 : -1) * sprout::detail::pow_n(x, n) / n - : sprout::math::detail::log_impl_1(x, n, n + (last - n) / 2) - + sprout::math::detail::log_impl_1(x, n + (last - n) / 2, last) + : sprout::math::detail::log_impl_2(x, n, n + (last - n) / 2) + + sprout::math::detail::log_impl_2(x, n + (last - n) / 2, last) + ; + } + template + inline SPROUT_CONSTEXPR T + log_impl_1(T x) { + return !(x > sprout::math::root_two()) + ? sprout::math::detail::log_impl_2(x - T(1), 1, sprout::math::factorial_limit() + 1) + : T(2) * sprout::math::detail::log_impl_1(sprout::math::sqrt(x)) ; } template inline SPROUT_CONSTEXPR T log_impl(T x) { - return !(x > sprout::math::root_two()) - ? sprout::math::detail::log_impl_1(x - 1, 1, sprout::math::factorial_limit() + 1) - : 2 * sprout::math::detail::log_impl(sprout::sqrt(x)) + return x < 1 ? -sprout::math::detail::log_impl_1(T(1) / x) + : sprout::math::detail::log_impl_1(x) ; } @@ -40,16 +48,17 @@ namespace sprout { > inline SPROUT_CONSTEXPR FloatType log(FloatType x) { - typedef typename sprout::math::detail::float_compute::type type; return x == 0 ? -std::numeric_limits::infinity() - : x == 1 ? FloatType(0) : x == std::numeric_limits::infinity() ? std::numeric_limits::infinity() : x < 0 ? std::numeric_limits::quiet_NaN() - : x < 1 ? static_cast(-sprout::math::detail::log_impl(1 / static_cast(x))) - : static_cast(sprout::math::detail::log_impl(static_cast(x))) +#if SPROUT_USE_BUILTIN_CMATH_FUNCTION + : std::log(x) +#else + : x == 1 ? FloatType(0) + : static_cast(sprout::math::detail::log_impl(static_cast::type>(x))) +#endif ; } - template< typename IntType, typename sprout::enabler_if::value>::type = sprout::enabler @@ -59,8 +68,17 @@ namespace sprout { return sprout::math::detail::log(static_cast(x)); } } // namespace detail - - using NS_SPROUT_MATH_DETAIL::log; + // + // log + // + template< + typename ArithmeticType, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR typename sprout::float_promote::type + log(ArithmeticType x) { + return sprout::math::detail::log(x); + } } // namespace math using sprout::math::log; diff --git a/sprout/math/log10.hpp b/sprout/math/log10.hpp index 4b5c4b3a..3c349c09 100644 --- a/sprout/math/log10.hpp +++ b/sprout/math/log10.hpp @@ -5,13 +5,21 @@ #include #include #include +#include #include #include #include +#include namespace sprout { namespace math { namespace detail { + template + inline SPROUT_CONSTEXPR T + log10_impl(T x) { + return sprout::math::log(x) / sprout::math::ln_ten(); + } + template< typename FloatType, typename sprout::enabler_if::value>::type = sprout::enabler @@ -19,13 +27,16 @@ namespace sprout { inline SPROUT_CONSTEXPR FloatType log10(FloatType x) { return x == 0 ? -std::numeric_limits::infinity() - : x == 1 ? FloatType(0) : x == std::numeric_limits::infinity() ? std::numeric_limits::infinity() : x < 0 ? std::numeric_limits::quiet_NaN() - : sprout::log(x) / sprout::math::ln_ten() +#if SPROUT_USE_BUILTIN_CMATH_FUNCTION + : std::log10(x) +#else + : x == 1 ? FloatType(0) + : static_cast(sprout::math::detail::log10_impl(static_cast::type>(x))) +#endif ; } - template< typename IntType, typename sprout::enabler_if::value>::type = sprout::enabler @@ -35,8 +46,17 @@ namespace sprout { return sprout::math::detail::log10(static_cast(x)); } } // namespace detail - - using NS_SPROUT_MATH_DETAIL::log10; + // + // log10 + // + template< + typename ArithmeticType, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR typename sprout::float_promote::type + log10(ArithmeticType x) { + return sprout::math::detail::log10(x); + } } // namespace math using sprout::math::log10; diff --git a/sprout/math/log1p.hpp b/sprout/math/log1p.hpp index 0aaa29af..d9a633fb 100644 --- a/sprout/math/log1p.hpp +++ b/sprout/math/log1p.hpp @@ -5,26 +5,38 @@ #include #include #include +#include +#include #include #include +#include namespace sprout { namespace math { namespace detail { + template + inline SPROUT_CONSTEXPR T + log1p_impl(T x) { + return sprout::math::log(T(1) + x); + } + template< typename FloatType, typename sprout::enabler_if::value>::type = sprout::enabler > inline SPROUT_CONSTEXPR FloatType log1p(FloatType x) { - return x == 0 ? FloatType(0) - : x == -1 ? -std::numeric_limits::infinity() + return x == -1 ? -std::numeric_limits::infinity() : x == std::numeric_limits::infinity() ? std::numeric_limits::infinity() : x < -1 ? std::numeric_limits::quiet_NaN() - : sprout::log(1 + x) +#if SPROUT_USE_BUILTIN_CMATH_FUNCTION + : std::log1p(x) +#else + : x == 0 ? sprout::math::copysign(FloatType(0), x) + : static_cast(sprout::math::detail::log1p_impl(static_cast::type>(x))) +#endif ; } - template< typename IntType, typename sprout::enabler_if::value>::type = sprout::enabler @@ -34,8 +46,17 @@ namespace sprout { return sprout::math::detail::log1p(static_cast(x)); } } // namespace detail - - using NS_SPROUT_MATH_DETAIL::log1p; + // + // log1p + // + template< + typename ArithmeticType, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR typename sprout::float_promote::type + log1p(ArithmeticType x) { + return sprout::math::detail::log1p(x); + } } // namespace math using sprout::math::log1p; diff --git a/sprout/math/log2.hpp b/sprout/math/log2.hpp index 415f7080..698f360c 100644 --- a/sprout/math/log2.hpp +++ b/sprout/math/log2.hpp @@ -5,13 +5,21 @@ #include #include #include +#include #include #include #include +#include namespace sprout { namespace math { namespace detail { + template + inline SPROUT_CONSTEXPR T + log2_impl(T x) { + return sprout::math::log(x) / sprout::math::ln_two(); + } + template< typename FloatType, typename sprout::enabler_if::value>::type = sprout::enabler @@ -19,13 +27,16 @@ namespace sprout { inline SPROUT_CONSTEXPR FloatType log2(FloatType x) { return x == 0 ? -std::numeric_limits::infinity() - : x == 1 ? FloatType(0) : x == std::numeric_limits::infinity() ? std::numeric_limits::infinity() : x < 0 ? std::numeric_limits::quiet_NaN() - : sprout::log(x) / sprout::math::ln_two() +#if SPROUT_USE_BUILTIN_CMATH_FUNCTION + : std::log2(x) +#else + : x == 1 ? FloatType(0) + : static_cast(sprout::math::detail::log2_impl(static_cast::type>(x))) +#endif ; } - template< typename IntType, typename sprout::enabler_if::value>::type = sprout::enabler @@ -35,8 +46,17 @@ namespace sprout { return sprout::math::detail::log2(static_cast(x)); } } // namespace detail - - using NS_SPROUT_MATH_DETAIL::log2; + // + // log2 + // + template< + typename ArithmeticType, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR typename sprout::float_promote::type + log2(ArithmeticType x) { + return sprout::math::detail::log2(x); + } } // namespace math using sprout::math::log2; diff --git a/sprout/math/log_a.hpp b/sprout/math/log_a.hpp index eb96165b..8de92409 100644 --- a/sprout/math/log_a.hpp +++ b/sprout/math/log_a.hpp @@ -18,9 +18,9 @@ namespace sprout { > inline SPROUT_CONSTEXPR FloatType log_a(FloatType x, FloatType y) { - return x == 2 ? sprout::log(y) / sprout::math::ln_two() - : x == 10 ? sprout::log(y) / sprout::math::ln_ten() - : sprout::log(y) / sprout::log(x) + return x == 2 ? sprout::math::log(y) / sprout::math::ln_two() + : x == 10 ? sprout::math::log(y) / sprout::math::ln_ten() + : sprout::math::log(y) / sprout::math::log(x) ; } diff --git a/sprout/math/manipulations.hpp b/sprout/math/manipulations.hpp new file mode 100644 index 00000000..1a1eed99 --- /dev/null +++ b/sprout/math/manipulations.hpp @@ -0,0 +1,7 @@ +#ifndef SPROUT_MATH_MANIPULATIONS_HPP +#define SPROUT_MATH_MANIPULATIONS_HPP + +#include +#include + +#endif // #ifndef SPROUT_MATH_MANIPULATIONS_HPP diff --git a/sprout/math/pow.hpp b/sprout/math/pow.hpp index 5ca85317..415595ce 100644 --- a/sprout/math/pow.hpp +++ b/sprout/math/pow.hpp @@ -23,27 +23,27 @@ namespace sprout { return x == 0 ? y < 0 ? std::numeric_limits::infinity() : y > 0 ? FloatType(0) - : sprout::exp(y * sprout::log(x)) + : sprout::math::exp(y * sprout::math::log(x)) : x == -1 && (y == std::numeric_limits::infinity() || y == -std::numeric_limits::infinity()) ? FloatType(1) : x == 1 ? FloatType(1) : y == 0 ? FloatType(1) : y == -std::numeric_limits::infinity() ? x < 1 && x > -1 ? std::numeric_limits::infinity() : x > 1 || x < -1 ? FloatType(0) - : sprout::exp(y * sprout::log(x)) + : sprout::math::exp(y * sprout::math::log(x)) : y == std::numeric_limits::infinity() ? x < 1 && x > -1 ? FloatType(0) : x > 1 || x < -1 ? std::numeric_limits::infinity() - : sprout::exp(y * sprout::log(x)) + : sprout::math::exp(y * sprout::math::log(x)) : x == -std::numeric_limits::infinity() ? y < 0 ? FloatType(0) : y > 0 ? std::numeric_limits::infinity() - : sprout::exp(y * sprout::log(x)) + : sprout::math::exp(y * sprout::math::log(x)) : x == std::numeric_limits::infinity() ? y < 0 ? FloatType(0) : y > 0 ? std::numeric_limits::infinity() - : sprout::exp(y * sprout::log(x)) - : sprout::exp(y * sprout::log(x)) + : sprout::math::exp(y * sprout::math::log(x)) + : sprout::math::exp(y * sprout::math::log(x)) ; } diff --git a/sprout/math/signbit.hpp b/sprout/math/signbit.hpp index 2aa980fa..91d2e09b 100644 --- a/sprout/math/signbit.hpp +++ b/sprout/math/signbit.hpp @@ -13,7 +13,7 @@ namespace sprout { typename FloatType, typename sprout::enabler_if::value>::type = sprout::enabler > - inline SPROUT_CONSTEXPR int + inline SPROUT_CONSTEXPR bool signbit(FloatType x) { return x < 0; } diff --git a/sprout/math/sin.hpp b/sprout/math/sin.hpp index 7ca86499..4e44a1a8 100644 --- a/sprout/math/sin.hpp +++ b/sprout/math/sin.hpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -32,7 +33,7 @@ namespace sprout { #if SPROUT_USE_BUILTIN_CMATH_FUNCTION : std::sin(x) #else - : x == 0 ? FloatType(0) + : x == 0 ? sprout::math::copysign(FloatType(0), x) : static_cast(sprout::math::detail::sin_impl(static_cast::type>(x))) #endif ; diff --git a/sprout/math/sinh.hpp b/sprout/math/sinh.hpp index 3248a87f..a9a51555 100644 --- a/sprout/math/sinh.hpp +++ b/sprout/math/sinh.hpp @@ -8,21 +8,31 @@ #include #include #include +#include #include #include +#include namespace sprout { namespace math { namespace detail { template inline SPROUT_CONSTEXPR T - sinh_impl(T x, std::size_t n, std::size_t last) { + sinh_impl_1(T x, std::size_t n, std::size_t last) { return last - n == 1 - ? sprout::detail::pow_n(x, 2 * n + 1) / sprout::math::factorial(2 * n + 1) - : sprout::math::detail::sinh_impl(x, n, n + (last - n) / 2) - + sprout::math::detail::sinh_impl(x, n + (last - n) / 2, last) + ? sprout::detail::pow_n(x, 2 * n + 1) / sprout::math::unchecked_factorial(2 * n + 1) + : sprout::math::detail::sinh_impl_1(x, n, n + (last - n) / 2) + + sprout::math::detail::sinh_impl_1(x, n + (last - n) / 2, last) ; } + template + inline SPROUT_CONSTEXPR T + sinh_impl(T x) { + return x + sprout::math::detail::sinh_impl_1( + x, + 1, (sprout::math::factorial_limit() - 1) / 2 + 1 + ); + } template< typename FloatType, @@ -30,19 +40,16 @@ namespace sprout { > inline SPROUT_CONSTEXPR FloatType sinh(FloatType x) { - typedef typename sprout::math::detail::float_compute::type type; - return x == 0 ? FloatType(1) - : x == std::numeric_limits::infinity() ? std::numeric_limits::infinity() + return x == std::numeric_limits::infinity() ? std::numeric_limits::infinity() : x == -std::numeric_limits::infinity() ? -std::numeric_limits::infinity() - : static_cast( - static_cast(x) + sprout::math::detail::sinh_impl( - static_cast(x), - 1, (sprout::math::factorial_limit() - 1) / 2 + 1 - ) - ) +#if SPROUT_USE_BUILTIN_CMATH_FUNCTION + : std::sinh(x) +#else + : x == 0 ? sprout::math::copysign(FloatType(0), x) + : static_cast(sprout::math::detail::sinh_impl(static_cast::type>(x))) +#endif ; } - template< typename IntType, typename sprout::enabler_if::value>::type = sprout::enabler @@ -52,8 +59,17 @@ namespace sprout { return sprout::math::detail::sinh(static_cast(x)); } } // namespace detail - - using NS_SPROUT_MATH_DETAIL::sinh; + // + // sinh + // + template< + typename ArithmeticType, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR typename sprout::float_promote::type + sinh(ArithmeticType x) { + return sprout::math::detail::sinh(x); + } } // namespace math using sprout::math::sinh; diff --git a/sprout/math/tan.hpp b/sprout/math/tan.hpp index 2e393059..51a1dbf6 100644 --- a/sprout/math/tan.hpp +++ b/sprout/math/tan.hpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -31,7 +32,7 @@ namespace sprout { #if SPROUT_USE_BUILTIN_CMATH_FUNCTION : std::sin(x) #else - : x == 0 ? FloatType(0) + : x == 0 ? sprout::math::copysign(FloatType(0), x) : static_cast(sprout::math::detail::tan_impl(static_cast::type>(x))) #endif ; diff --git a/sprout/math/tanh.hpp b/sprout/math/tanh.hpp index 007b2225..c0f7bc0c 100644 --- a/sprout/math/tanh.hpp +++ b/sprout/math/tanh.hpp @@ -5,26 +5,38 @@ #include #include #include +#include +#include #include #include #include +#include namespace sprout { namespace math { namespace detail { + template + inline SPROUT_CONSTEXPR T + tanh_impl(T x) { + return sprout::math::sinh(x) / sprout::math::cosh(x); + } + template< typename FloatType, typename sprout::enabler_if::value>::type = sprout::enabler > inline SPROUT_CONSTEXPR FloatType tanh(FloatType x) { - return x == 0 ? FloatType(0) - : x == std::numeric_limits::infinity() ? FloatType(1) + return x == std::numeric_limits::infinity() ? FloatType(1) : x == -std::numeric_limits::infinity() ? FloatType(-1) - : sprout::math::sinh(x) / sprout::math::cosh(x) +#if SPROUT_USE_BUILTIN_CMATH_FUNCTION + : std::tanh(x) +#else + : x == 0 ? sprout::math::copysign(FloatType(0), x) + : static_cast(sprout::math::detail::tanh_impl(static_cast::type>(x))) +#endif ; } - template< typename IntType, typename sprout::enabler_if::value>::type = sprout::enabler @@ -34,8 +46,17 @@ namespace sprout { return sprout::math::detail::tanh(static_cast(x)); } } // namespace detail - - using NS_SPROUT_MATH_DETAIL::tanh; + // + // tanh + // + template< + typename ArithmeticType, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR typename sprout::float_promote::type + tanh(ArithmeticType x) { + return sprout::math::detail::tanh(x); + } } // namespace math using sprout::math::tanh; diff --git a/sprout/random/binomial_distribution.hpp b/sprout/random/binomial_distribution.hpp index 04818b9c..78850526 100644 --- a/sprout/random/binomial_distribution.hpp +++ b/sprout/random/binomial_distribution.hpp @@ -249,8 +249,8 @@ namespace sprout { template SPROUT_CONSTEXPR sprout::random::random_result generate_10(Engine const& eng, RealType v, IntType k, IntType nm, RealType h, IntType nk) const { - return v <= h + (t_ + 1) * sprout::log(static_cast(nm) / nk) - + (k + RealType(0.5)) * sprout::log(nk * btrd_.r / (k + 1)) - fc(k) - fc(t_ - k) + return v <= h + (t_ + 1) * sprout::math::log(static_cast(nm) / nk) + + (k + RealType(0.5)) * sprout::math::log(nk * btrd_.r / (k + 1)) - fc(k) - fc(t_ - k) ? sprout::random::random_result(k, eng, *this) : generate(eng) ; @@ -264,7 +264,7 @@ namespace sprout { SPROUT_CONSTEXPR sprout::random::random_result generate_9(Engine const& eng, RealType v, IntType k, IntType nm) const { return generate_10( - eng, v, k, nm, (m_ + RealType(0.5)) * sprout::log((m_ + 1) / (btrd_.r * nm)) + fc(m_) + fc(t_ - m_), t_ - k + 1 + eng, v, k, nm, (m_ + RealType(0.5)) * sprout::math::log((m_ + 1) / (btrd_.r * nm)) + fc(m_) + fc(t_ - m_), t_ - k + 1 ); } template @@ -343,7 +343,7 @@ namespace sprout { return km <= 15 ? generate_7(eng, v, k) : generate_8( - eng, sprout::log(v), k, + eng, sprout::math::log(v), k, (km / btrd_.npq) * (((km / RealType(3.0) + RealType(0.625)) * km + RealType(1.0) / 6) / btrd_.npq + RealType(0.5)), -km * km / (2 * btrd_.npq)) ; @@ -455,8 +455,8 @@ namespace sprout { template SPROUT_CONSTEXPR sprout::random::random_result generate_10(Engine const& eng, RealType v, IntType k, IntType nm, RealType h, IntType nk) const { - return v <= h + (t_ + 1) * sprout::log(static_cast(nm) / nk) - + (k + RealType(0.5)) * sprout::log(nk * btrd_.r / (k + 1)) - fc(k) - fc(t_ - k) + return v <= h + (t_ + 1) * sprout::math::log(static_cast(nm) / nk) + + (k + RealType(0.5)) * sprout::math::log(nk * btrd_.r / (k + 1)) - fc(k) - fc(t_ - k) ? sprout::random::random_result(k, eng, *this) : generate(eng) ; @@ -465,7 +465,7 @@ namespace sprout { SPROUT_CONSTEXPR sprout::random::random_result generate_9(Engine const& eng, RealType v, IntType k, IntType nm) const { return generate_10( - eng, v, k, nm, (m_ + RealType(0.5)) * sprout::log((m_ + 1) / (btrd_.r * nm)) + fc(m_) + fc(t_ - m_), t_ - k + 1 + eng, v, k, nm, (m_ + RealType(0.5)) * sprout::math::log((m_ + 1) / (btrd_.r * nm)) + fc(m_) + fc(t_ - m_), t_ - k + 1 ); } template @@ -514,7 +514,7 @@ namespace sprout { return km <= 15 ? generate_7(eng, v, k) : generate_8( - eng, sprout::log(v), k, + eng, sprout::math::log(v), k, (km / btrd_.npq) * (((km / RealType(3.0) + RealType(0.625)) * km + RealType(1.0) / 6) / btrd_.npq + RealType(0.5)), -km * km / (2 * btrd_.npq)) ; diff --git a/sprout/random/geometric_distribution.hpp b/sprout/random/geometric_distribution.hpp index 9bcedbe6..e1a81d1e 100644 --- a/sprout/random/geometric_distribution.hpp +++ b/sprout/random/geometric_distribution.hpp @@ -73,7 +73,7 @@ namespace sprout { private: public: static SPROUT_CONSTEXPR RealType init_log_1mp(RealType p) { - return sprout::log(1 - p); + return sprout::math::log(1 - p); } private: public: @@ -83,7 +83,7 @@ namespace sprout { template SPROUT_CONSTEXPR sprout::random::random_result generate_1(Random const& rnd) const { return sprout::random::random_result( - static_cast(sprout::floor(sprout::log(RealType(1) - rnd.result()) / log_1mp_)), + static_cast(sprout::floor(sprout::math::log(RealType(1) - rnd.result()) / log_1mp_)), rnd.engine(), *this ); diff --git a/sprout/random/normal_distribution.hpp b/sprout/random/normal_distribution.hpp index 5728693b..996d2622 100644 --- a/sprout/random/normal_distribution.hpp +++ b/sprout/random/normal_distribution.hpp @@ -134,7 +134,7 @@ namespace sprout { generate_1_1(RealType r1, Random const& rnd) const { return generate_2( rnd.engine(), r1, rnd.result(), - sprout::sqrt(-result_type(2) * sprout::log(result_type(1) - rnd.result())), true + sprout::sqrt(-result_type(2) * sprout::math::log(result_type(1) - rnd.result())), true ); } template diff --git a/sprout/type_traits/aliases.hpp b/sprout/type_traits/aliases.hpp index 879ad889..75ee6a48 100644 --- a/sprout/type_traits/aliases.hpp +++ b/sprout/type_traits/aliases.hpp @@ -15,51 +15,51 @@ namespace sprout { // Const-volatility specifiers // template - using remove_const_ = typename std::remove_const::type; + using remove_const_t = typename std::remove_const::type; template - using remove_volatile_ = typename std::remove_volatile::type; + using remove_volatile_t = typename std::remove_volatile::type; template - using remove_cv_ = typename std::remove_cv::type; + using remove_cv_t = typename std::remove_cv::type; template - using add_const_ = typename std::add_const::type; + using add_const_t = typename std::add_const::type; template - using add_volatile_ = typename std::add_volatile::type; + using add_volatile_t = typename std::add_volatile::type; template - using add_cv_ = typename std::add_cv::type; + using add_cv_t = typename std::add_cv::type; // // References // template - using remove_reference_ = typename std::remove_reference::type; + using remove_reference_t = typename std::remove_reference::type; template - using add_lvalue_reference_ = typename std::add_lvalue_reference::type; + using add_lvalue_reference_t = typename std::add_lvalue_reference::type; template - using add_rvalue_reference_ = typename std::add_rvalue_reference::type; + using add_rvalue_reference_t = typename std::add_rvalue_reference::type; // // Pointers // template - using remove_pointer_ = typename std::remove_pointer::type; + using remove_pointer_t = typename std::remove_pointer::type; template - using add_pointer_ = typename std::add_pointer::type; + using add_pointer_t = typename std::add_pointer::type; // // Sign modifiers // template - using make_signed_ = typename std::make_signed::type; + using make_signed_t = typename std::make_signed::type; template - using make_unsigned_ = typename std::make_unsigned::type; + using make_unsigned_t = typename std::make_unsigned::type; // // Arrays // template - using remove_extent_ = typename std::remove_extent::type; + using remove_extent_t = typename std::remove_extent::type; template - using remove_all_extents_ = typename std::remove_all_extents::type; + using remove_all_extents_t = typename std::remove_all_extents::type; // // Miscellaneous transformations @@ -68,73 +68,73 @@ namespace sprout { std::size_t Len, std::size_t Align = std::alignment_of::type>::value > - using aligned_storage_ = typename std::aligned_storage::type; + using aligned_storage_t = typename std::aligned_storage::type; // ??? //template - //using aligned_union_ = typename std::aligned_union::type; + //using aligned_union_t = typename std::aligned_union::type; template - using decay_ = typename std::decay::type; + using decay_t = typename std::decay::type; template - using enable_if_ = typename std::enable_if::type; + using enable_if_t = typename std::enable_if::type; template - using conditional_ = typename std::conditional::type; + using conditional_t = typename std::conditional::type; template - using common_type_ = typename std::common_type::type; + using common_type_t = typename std::common_type::type; template - using underlying_type_ = typename std::underlying_type::type; + using underlying_type_t = typename std::underlying_type::type; template - using result_of_ = typename std::result_of::type; + using result_of_t = typename std::result_of::type; // // Const-volatility specifiers // template - using remove_const = sprout::remove_const_; + using remove_const = sprout::remove_const_t; template - using remove_volatile = sprout::remove_volatile_; + using remove_volatile = sprout::remove_volatile_t; template - using remove_cv = sprout::remove_cv_; + using remove_cv = sprout::remove_cv_t; template - using add_const = sprout::add_const_; + using add_const = sprout::add_const_t; template - using add_volatile = sprout::add_volatile_; + using add_volatile = sprout::add_volatile_t; template - using add_cv = sprout::add_cv_; + using add_cv = sprout::add_cv_t; // // References // template - using remove_reference = sprout::remove_reference_; + using remove_reference = sprout::remove_reference_t; template - using add_lvalue_reference = sprout::add_lvalue_reference_; + using add_lvalue_reference = sprout::add_lvalue_reference_t; template - using add_rvalue_reference = sprout::add_rvalue_reference_; + using add_rvalue_reference = sprout::add_rvalue_reference_t; // // Pointers // template - using remove_pointer = sprout::remove_pointer_; + using remove_pointer = sprout::remove_pointer_t; template - using add_pointer = sprout::add_pointer_; + using add_pointer = sprout::add_pointer_t; // // Sign modifiers // template - using make_signed = sprout::make_signed_; + using make_signed = sprout::make_signed_t; template - using make_unsigned = sprout::make_unsigned_; + using make_unsigned = sprout::make_unsigned_t; // // Arrays // template - using remove_extent = sprout::remove_extent_; + using remove_extent = sprout::remove_extent_t; template - using remove_all_extents = sprout::remove_all_extents_; + using remove_all_extents = sprout::remove_all_extents_t; // // Miscellaneous transformations @@ -143,23 +143,23 @@ namespace sprout { std::size_t Len, std::size_t Align = std::alignment_of::type>::value > - using aligned_storage = sprout::aligned_storage_; + using aligned_storage = sprout::aligned_storage_t; // ??? //template - //using aligned_union = sprout::aligned_union_; + //using aligned_union = sprout::aligned_union_t; template - using decay = sprout::decay_; + using decay = sprout::decay_t; template - using enable_if = sprout::enable_if_; + using enable_if = sprout::enable_if_t; template - using conditional = sprout::conditional_; + using conditional = sprout::conditional_t; template - using common_type = sprout::common_type_; + using common_type = sprout::common_type_t; template - using underlying_type = sprout::underlying_type_; + using underlying_type = sprout::underlying_type_t; // ??? //template - //using result_of = sprout::result_of_; + //using result_of = sprout::result_of_t; #endif // #if SPROUT_USE_TEMPLATE_ALIASES } // namespace sprout diff --git a/sprout/type_traits/arithmetic_promote.hpp b/sprout/type_traits/arithmetic_promote.hpp index 3cb79b07..233e70b9 100644 --- a/sprout/type_traits/arithmetic_promote.hpp +++ b/sprout/type_traits/arithmetic_promote.hpp @@ -55,7 +55,7 @@ namespace sprout { #if SPROUT_USE_TEMPLATE_ALIASES template - using arithmetic_promote_ = typename sprout::arithmetic_promote::type; + using arithmetic_promote_t = typename sprout::arithmetic_promote::type; #endif // #if SPROUT_USE_TEMPLATE_ALIASES } // namespace sprout diff --git a/sprout/type_traits/common_decay.hpp b/sprout/type_traits/common_decay.hpp index 7a61f8f5..4bdd556f 100644 --- a/sprout/type_traits/common_decay.hpp +++ b/sprout/type_traits/common_decay.hpp @@ -15,7 +15,7 @@ namespace sprout { #if SPROUT_USE_TEMPLATE_ALIASES template - using common_decay_ = typename sprout::common_decay::type; + using common_decay_t = typename sprout::common_decay::type; #endif // #if SPROUT_USE_TEMPLATE_ALIASES } // namespace sprout diff --git a/sprout/type_traits/const_reference.hpp b/sprout/type_traits/const_reference.hpp index 04f5db58..71ee658e 100644 --- a/sprout/type_traits/const_reference.hpp +++ b/sprout/type_traits/const_reference.hpp @@ -17,7 +17,7 @@ namespace sprout { #if SPROUT_USE_TEMPLATE_ALIASES template - using const_reference_ = typename sprout::const_reference::type; + using const_reference_t = typename sprout::const_reference::type; #endif // #if SPROUT_USE_TEMPLATE_ALIASES } // namespace sprout diff --git a/sprout/type_traits/enabler_if.hpp b/sprout/type_traits/enabler_if.hpp index a2b388c3..4386f168 100644 --- a/sprout/type_traits/enabler_if.hpp +++ b/sprout/type_traits/enabler_if.hpp @@ -21,7 +21,7 @@ namespace sprout { #if SPROUT_USE_TEMPLATE_ALIASES template - using enabler_if_ = typename sprout::enabler_if::type; + using enabler_if_t = typename sprout::enabler_if::type; #endif // #if SPROUT_USE_TEMPLATE_ALIASES } // namespace sprout diff --git a/sprout/type_traits/float_promote.hpp b/sprout/type_traits/float_promote.hpp index d82fee6a..66212b9c 100644 --- a/sprout/type_traits/float_promote.hpp +++ b/sprout/type_traits/float_promote.hpp @@ -66,7 +66,7 @@ namespace sprout { #if SPROUT_USE_TEMPLATE_ALIASES template - using float_promote_ = typename sprout::float_promote::type; + using float_promote_t = typename sprout::float_promote::type; #endif // #if SPROUT_USE_TEMPLATE_ALIASES } // namespace sprout diff --git a/sprout/type_traits/identity.hpp b/sprout/type_traits/identity.hpp index b5b68639..2c696265 100644 --- a/sprout/type_traits/identity.hpp +++ b/sprout/type_traits/identity.hpp @@ -15,7 +15,7 @@ namespace sprout { #if SPROUT_USE_TEMPLATE_ALIASES template - using identity_ = typename sprout::identity::type; + using identity_t = typename sprout::identity::type; #endif // #if SPROUT_USE_TEMPLATE_ALIASES } // namespace sprout diff --git a/sprout/type_traits/is_c_str.hpp b/sprout/type_traits/is_c_str.hpp index 5553bbd1..c403f1ee 100644 --- a/sprout/type_traits/is_c_str.hpp +++ b/sprout/type_traits/is_c_str.hpp @@ -43,7 +43,7 @@ namespace sprout { #if SPROUT_USE_TEMPLATE_ALIASES template - using is_c_str_ = typename sprout::is_c_str::type; + using is_c_str_t = typename sprout::is_c_str::type; #endif // #if SPROUT_USE_TEMPLATE_ALIASES } // namespace sprout diff --git a/sprout/type_traits/is_char_type.hpp b/sprout/type_traits/is_char_type.hpp index 950560b6..8fec8f0b 100644 --- a/sprout/type_traits/is_char_type.hpp +++ b/sprout/type_traits/is_char_type.hpp @@ -43,7 +43,7 @@ namespace sprout { #if SPROUT_USE_TEMPLATE_ALIASES template - using is_char_type_ = typename sprout::is_char_type::type; + using is_char_type_t = typename sprout::is_char_type::type; #endif // #if SPROUT_USE_TEMPLATE_ALIASES } // namespace sprout diff --git a/sprout/type_traits/is_convert_constructible.hpp b/sprout/type_traits/is_convert_constructible.hpp index 80fe50ca..de541c82 100644 --- a/sprout/type_traits/is_convert_constructible.hpp +++ b/sprout/type_traits/is_convert_constructible.hpp @@ -25,7 +25,7 @@ namespace sprout { #if SPROUT_USE_TEMPLATE_ALIASES template - using is_convert_constructible_ = typename sprout::is_convert_constructible::type; + using is_convert_constructible_t = typename sprout::is_convert_constructible::type; #endif // #if SPROUT_USE_TEMPLATE_ALIASES } // namespace sprout diff --git a/sprout/type_traits/is_int.hpp b/sprout/type_traits/is_int.hpp index 73566abd..bac4837a 100644 --- a/sprout/type_traits/is_int.hpp +++ b/sprout/type_traits/is_int.hpp @@ -18,7 +18,7 @@ namespace sprout { #if SPROUT_USE_TEMPLATE_ALIASES template - using is_int_ = typename sprout::is_int::type; + using is_int_t = typename sprout::is_int::type; #endif // #if SPROUT_USE_TEMPLATE_ALIASES } // namespace sprout diff --git a/sprout/type_traits/is_uint.hpp b/sprout/type_traits/is_uint.hpp index 4b0e12ba..b6d84c2f 100644 --- a/sprout/type_traits/is_uint.hpp +++ b/sprout/type_traits/is_uint.hpp @@ -18,7 +18,7 @@ namespace sprout { #if SPROUT_USE_TEMPLATE_ALIASES template - using is_uint_ = typename sprout::is_uint::type; + using is_uint_t = typename sprout::is_uint::type; #endif // #if SPROUT_USE_TEMPLATE_ALIASES } // namespace sprout diff --git a/sprout/type_traits/lvalue_reference.hpp b/sprout/type_traits/lvalue_reference.hpp index 2097bacd..8e00bca5 100644 --- a/sprout/type_traits/lvalue_reference.hpp +++ b/sprout/type_traits/lvalue_reference.hpp @@ -17,7 +17,7 @@ namespace sprout { #if SPROUT_USE_TEMPLATE_ALIASES template - using lvalue_reference_ = typename sprout::lvalue_reference::type; + using lvalue_reference_t = typename sprout::lvalue_reference::type; #endif // #if SPROUT_USE_TEMPLATE_ALIASES } // namespace sprout diff --git a/sprout/type_traits/remove_cvref.hpp b/sprout/type_traits/remove_cvref.hpp index 2e0b9b95..bad2bfaf 100644 --- a/sprout/type_traits/remove_cvref.hpp +++ b/sprout/type_traits/remove_cvref.hpp @@ -17,7 +17,7 @@ namespace sprout { #if SPROUT_USE_TEMPLATE_ALIASES template - using remove_cvref_ = typename sprout::remove_cvref::type; + using remove_cvref_t = typename sprout::remove_cvref::type; #endif // #if SPROUT_USE_TEMPLATE_ALIASES } // namespace sprout diff --git a/sprout/type_traits/remove_shallow_const.hpp b/sprout/type_traits/remove_shallow_const.hpp index 56c5ae45..9f4a2368 100644 --- a/sprout/type_traits/remove_shallow_const.hpp +++ b/sprout/type_traits/remove_shallow_const.hpp @@ -20,7 +20,7 @@ namespace sprout { #if SPROUT_USE_TEMPLATE_ALIASES template - using remove_shallow_const_ = typename sprout::remove_shallow_const::type; + using remove_shallow_const_t = typename sprout::remove_shallow_const::type; #endif // #if SPROUT_USE_TEMPLATE_ALIASES } // namespace sprout diff --git a/sprout/type_traits/remove_shallow_cv.hpp b/sprout/type_traits/remove_shallow_cv.hpp index 785690cc..c49a1793 100644 --- a/sprout/type_traits/remove_shallow_cv.hpp +++ b/sprout/type_traits/remove_shallow_cv.hpp @@ -28,7 +28,7 @@ namespace sprout { #if SPROUT_USE_TEMPLATE_ALIASES template - using remove_shallow_cv_ = typename sprout::remove_shallow_cv::type; + using remove_shallow_cv_t = typename sprout::remove_shallow_cv::type; #endif // #if SPROUT_USE_TEMPLATE_ALIASES } // namespace sprout diff --git a/sprout/type_traits/remove_shallow_cvref.hpp b/sprout/type_traits/remove_shallow_cvref.hpp index f4382853..7d1d2edb 100644 --- a/sprout/type_traits/remove_shallow_cvref.hpp +++ b/sprout/type_traits/remove_shallow_cvref.hpp @@ -18,7 +18,7 @@ namespace sprout { #if SPROUT_USE_TEMPLATE_ALIASES template - using remove_shallow_cvref_ = typename sprout::remove_shallow_cvref::type; + using remove_shallow_cvref_t = typename sprout::remove_shallow_cvref::type; #endif // #if SPROUT_USE_TEMPLATE_ALIASES } // namespace sprout diff --git a/sprout/type_traits/remove_shallow_volatile.hpp b/sprout/type_traits/remove_shallow_volatile.hpp index 6248011a..bdeee88d 100644 --- a/sprout/type_traits/remove_shallow_volatile.hpp +++ b/sprout/type_traits/remove_shallow_volatile.hpp @@ -20,7 +20,7 @@ namespace sprout { #if SPROUT_USE_TEMPLATE_ALIASES template - using remove_shallow_volatile_ = typename sprout::remove_shallow_volatile::type; + using remove_shallow_volatile_t = typename sprout::remove_shallow_volatile::type; #endif // #if SPROUT_USE_TEMPLATE_ALIASES } // namespace sprout