32 #ifndef MCKL_MATH_CONSTANTS_HPP 33 #define MCKL_MATH_CONSTANTS_HPP 37 #include <type_traits> 39 #define MCKL_DEFINE_MATH_CONSTANTS(name, val) \ 40 template <typename T> \ 41 inline constexpr T const_##name() noexcept( \ 42 std::is_floating_point<T>::value || std::is_integral<T>::value) \ 44 return static_cast<T>(val##l); \ 48 inline constexpr float const_##name<float>() noexcept \ 54 inline constexpr double const_##name<double>() noexcept \ 60 inline constexpr long double const_##name<long double>() noexcept \ 72 static_assert(std::is_floating_point<T>::value,
73 "**const_inf** used with T other than floating point types");
75 return std::numeric_limits<T>::infinity();
83 static_assert(std::is_floating_point<T>::value,
84 "**const_nan** used with T other than floating point types");
86 return std::numeric_limits<T>::quiet_NaN();
156 sqrt_pi_2, 2.506628274631000502415765284811045253007)
161 sqrt_pi_inv, 0.5641895835477562869480794515607725858441)
166 sqrt_pi_by2, 1.253314137315500251207882642405522626503)
171 sqrt_pi_by3, 1.023326707946488488479551624889264860707)
176 sqrt_pi_by4, 0.8862269254527580136490837416705725913988)
181 sqrt_pi_by6, 0.7236012545582676593630146272907957678721)
186 sqrt_pi_2by3, 1.447202509116535318726029254581591535744)
191 sqrt_pi_3by4, 1.534990061919732732719327437333897291061)
196 sqrt_pi_4by3, 2.046653415892976976959103249778529721415)
209 ln_pi_by2, 0.4515827052894548647261952298948821435718)
214 ln_pi_by3, 0.04611759718129048274818211443053300699980)
219 ln_pi_by4, -0.2415644752704904446910368915632944245037)
224 ln_pi_by6, -0.6470295833786548266690500070276435610757)
229 ln_pi_2by3, 0.7392647777412357921654142358887095750753)
234 ln_pi_3by4, 0.8570478133976192467042083453592312801438)
239 ln_pi_4by3, 1.432411958301181101582646357346886143151)
256 sqrt_e_inv, 0.6065306597126334236037995349911804534419)
277 sqrt_1by2, 0.7071067811865475244008443621048490392848)
282 sqrt_1by3, 0.5773502691896257645091487805019574556476)
287 sqrt_1by5, 0.4472135954999579392818347337462552470881)
292 sqrt_1by10, 0.3162277660168379331998893544432718533720)
317 ln_inv_3, 0.9102392266268373936142401657361070006126)
322 ln_inv_5, 0.6213349345596118107071993881805725841234)
327 ln_inv_10, 0.4342944819032518276511289189166050822944)
332 ln_ln_2, -0.3665129205816643270124391582326694694543)
336 #endif // MCKL_MATH_CONSTANTS_HPP constexpr T const_one()
One.
constexpr T const_inf()
Infinity.
#define MCKL_DEFINE_MATH_CONSTANTS(name, val)
constexpr T const_nan()
Non-signalling NaN.
constexpr T const_zero()
Zero.