/* SPDX-License-Identifier: BSL-1.0 OR BSD-3-Clause */ #ifndef MPT_BASE_NUMBRES_HPP #define MPT_BASE_NUMBRES_HPP #include "mpt/base/detect_compiler.hpp" #include "mpt/base/namespace.hpp" #if MPT_CXX_AT_LEAST(20) #include #else #include #include #include #endif namespace mpt { inline namespace MPT_INLINE_NS { namespace numbers { #if MPT_CXX_AT_LEAST(20) template inline constexpr T e_v = std::numbers::e_v; template inline constexpr T log2e_v = std::numbers::log2e_v; template inline constexpr T log10e_v = std::numbers::log10e_v; template inline constexpr T pi_v = std::numbers::pi_v; template inline constexpr T inv_pi_v = std::numbers::inv_pi_v; template inline constexpr T inv_sqrtpi_v = std::numbers::inv_sqrtpi_v; template inline constexpr T ln2_v = std::numbers::ln2_v; template inline constexpr T ln10_v = std::numbers::ln10_v; template inline constexpr T sqrt2_v = std::numbers::sqrt2_v; template inline constexpr T sqrt3_v = std::numbers::sqrt3_v; template inline constexpr T inv_sqrt3_v = std::numbers::inv_sqrt3_v; template inline constexpr T egamma_v = std::numbers::egamma_v; template inline constexpr T phi_v = std::numbers::phi_v; inline constexpr double e = e_v; inline constexpr double log2e = log2e_v; inline constexpr double log10e = log10e_v; inline constexpr double pi = pi_v; inline constexpr double inv_pi = inv_pi_v; inline constexpr double inv_sqrtpi = inv_sqrtpi_v; inline constexpr double ln2 = ln2_v; inline constexpr double ln10 = ln10_v; inline constexpr double sqrt2 = sqrt2_v; inline constexpr double sqrt3 = sqrt3_v; inline constexpr double inv_sqrt3 = inv_sqrt3_v; inline constexpr double egamma = egamma_v; inline constexpr double phi = phi_v; #else #ifdef M_E template ::value, bool>::type = true> inline constexpr T e_v = static_cast(M_E); #else template ::value, bool>::type = true> inline constexpr T e_v = static_cast(2.71828182845904523536); #endif #ifdef M_LOG2E template ::value, bool>::type = true> inline constexpr T log2e_v = static_cast(M_LOG2E); #else template ::value, bool>::type = true> inline constexpr T log2e_v = static_cast(1.44269504088896340736); #endif #ifdef M_LOG10E template ::value, bool>::type = true> inline constexpr T log10e_v = static_cast(M_LOG10E); #else template ::value, bool>::type = true> inline constexpr T log10e_v = static_cast(0.434294481903251827651); #endif #ifdef M_PI template ::value, bool>::type = true> inline constexpr T pi_v = static_cast(M_PI); #else template ::value, bool>::type = true> inline constexpr T pi_v = static_cast(3.14159265358979323846); #endif #ifdef M_1_PI template ::value, bool>::type = true> inline constexpr T inv_pi_v = static_cast(M_1_PI); #else template ::value, bool>::type = true> inline constexpr T inv_pi_v = static_cast(0.318309886183790671538); #endif template ::value, bool>::type = true> inline constexpr T inv_sqrtpi_v = static_cast(0.564189583547756286948079451560772586); #ifdef M_LN2 template ::value, bool>::type = true> inline constexpr T ln2_v = static_cast(M_LN2); #else template ::value, bool>::type = true> inline constexpr T ln2_v = static_cast(0.693147180559945309417); #endif #ifdef M_LN10 template ::value, bool>::type = true> inline constexpr T ln10_v = static_cast(M_LN10); #else template ::value, bool>::type = true> inline constexpr T ln10_v = static_cast(2.30258509299404568402); #endif #ifdef M_SQRT2 template ::value, bool>::type = true> inline constexpr T sqrt2_v = static_cast(M_SQRT2); #else template ::value, bool>::type = true> inline constexpr T sqrt2_v = static_cast(1.41421356237309504880); #endif template ::value, bool>::type = true> inline constexpr T sqrt3_v = static_cast(1.732050807568877293527446341505872367); template ::value, bool>::type = true> inline constexpr T inv_sqrt3_v = static_cast(0.577350269189625764509148780501957456); template ::value, bool>::type = true> inline constexpr T egamma_v = static_cast(0.577215664901532860606512090082402431); template ::value, bool>::type = true> inline constexpr T phi_v = static_cast(1.618033988749894848204586834365638118); inline constexpr double e = e_v; inline constexpr double log2e = log2e_v; inline constexpr double log10e = log10e_v; inline constexpr double pi = pi_v; inline constexpr double inv_pi = inv_pi_v; inline constexpr double inv_sqrtpi = inv_sqrtpi_v; inline constexpr double ln2 = ln2_v; inline constexpr double ln10 = ln10_v; inline constexpr double sqrt2 = sqrt2_v; inline constexpr double sqrt3 = sqrt3_v; inline constexpr double inv_sqrt3 = inv_sqrt3_v; inline constexpr double egamma = egamma_v; inline constexpr double phi = phi_v; #endif } // namespace numbers } // namespace MPT_INLINE_NS } // namespace mpt #endif // MPT_BASE_NUMBRES_HPP