diff --git a/include/cnl/_impl/math_17.h b/include/cnl/_impl/numbers_17.h similarity index 98% rename from include/cnl/_impl/math_17.h rename to include/cnl/_impl/numbers_17.h index 3d5e122db..5d8af45c2 100644 --- a/include/cnl/_impl/math_17.h +++ b/include/cnl/_impl/numbers_17.h @@ -4,8 +4,8 @@ // (See accompanying file ../LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#if !defined(CNL_IMPL_MATH_17_H) -#define CNL_IMPL_MATH_17_H +#if !defined(CNL_IMPL_NUMBERS_17_H) +#define CNL_IMPL_NUMBERS_17_H #include "config.h" @@ -13,7 +13,7 @@ namespace cnl { //////////////////////////////////////////////////////////////////////////////// - // cnl::math_constants + // cnl::numbers #if defined(__cpp_inline_variables) namespace _impl { @@ -25,7 +25,7 @@ namespace cnl { CNL_NODISCARD constexpr T deleted_fn() = delete; } - namespace math { + namespace numbers { /// partial implementation of [P0631](http://wg21.link/p0631) // values taken from c++ (GCC) 7.2.0 implementation of math.h; disclaimer: may be a bit or two off diff --git a/include/cnl/_impl/math_20.h b/include/cnl/_impl/numbers_20.h similarity index 98% rename from include/cnl/_impl/math_20.h rename to include/cnl/_impl/numbers_20.h index 853c18daa..329e5f350 100644 --- a/include/cnl/_impl/math_20.h +++ b/include/cnl/_impl/numbers_20.h @@ -11,8 +11,8 @@ /// /// template concept floating_point = is_floating_point_v; -#if !defined(CNL_IMPL_MATH_20_H) -#define CNL_IMPL_MATH_20_H +#if !defined(CNL_IMPL_NUMBERS_20_H) +#define CNL_IMPL_NUMBERS_20_H #if __has_include() #include @@ -28,7 +28,7 @@ namespace cnl { #endif } - namespace math { + namespace numbers { template inline constexpr bool __always_false = false; diff --git a/include/cnl/_impl/scaled_integer/constants.h b/include/cnl/_impl/scaled_integer/numbers.h similarity index 99% rename from include/cnl/_impl/scaled_integer/constants.h rename to include/cnl/_impl/scaled_integer/numbers.h index 1bd5af002..3e4053e93 100644 --- a/include/cnl/_impl/scaled_integer/constants.h +++ b/include/cnl/_impl/scaled_integer/numbers.h @@ -13,7 +13,7 @@ #include "num_traits.h" #include "type.h" -#include "../../math.h" +#include "../../numbers.h" #include "../used_digits.h" /// compositional numeric library @@ -91,7 +91,7 @@ namespace cnl { } } - namespace math { + namespace numbers { /// specialization of \ref cnl::e for \ref cnl::scaled_integer template inline constexpr scaled_integer> e_v>> { _impl::constant_with_fallback(e_v, _impl::e) diff --git a/include/cnl/all.h b/include/cnl/all.h index 774a05b56..824bf607d 100644 --- a/include/cnl/all.h +++ b/include/cnl/all.h @@ -110,8 +110,8 @@ #include "fixed_point.h" #include "fraction.h" #include "limits.h" // NOLINT(modernize-deprecated-headers, hicpp-deprecated-headers) -#include "math.h" // NOLINT(modernize-deprecated-headers, hicpp-deprecated-headers) #include "num_traits.h" +#include "numbers.h" #include "numeric.h" #include "overflow.h" #include "overflow_integer.h" diff --git a/include/cnl/math.h b/include/cnl/math.h deleted file mode 100644 index 17b186d78..000000000 --- a/include/cnl/math.h +++ /dev/null @@ -1,19 +0,0 @@ - -// Copyright John McFarlane 2019. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file ../LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -/// \file cnl/math.h -/// \brief functions that might belong in the \verbatim\endverbatim header - -#if !defined(CNL_MATH_H) -#define CNL_MATH_H - -#if defined(__cpp_concepts) -#include "_impl/math_20.h" -#else -#include "_impl/math_17.h" -#endif - -#endif // CNL_MATH_H diff --git a/include/cnl/numbers.h b/include/cnl/numbers.h new file mode 100644 index 000000000..4e3248b91 --- /dev/null +++ b/include/cnl/numbers.h @@ -0,0 +1,19 @@ + +// Copyright John McFarlane 2019. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file ../LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +/// \file cnl/numbers.h +/// \brief functions that might belong in the \verbatim\endverbatim header + +#if !defined(CNL_NUMBERS_H) +#define CNL_NUMBERS_H + +#if defined(__cpp_concepts) +#include "_impl/numbers_20.h" +#else +#include "_impl/numbers_17.h" +#endif + +#endif // CNL_NUMBERS_H diff --git a/include/cnl/scaled_integer.h b/include/cnl/scaled_integer.h index ac51dc458..4a594f976 100644 --- a/include/cnl/scaled_integer.h +++ b/include/cnl/scaled_integer.h @@ -10,7 +10,6 @@ #if !defined(CNL_SCALED_INTEGER_H) #define CNL_SCALED_INTEGER_H -#include "_impl/scaled_integer/constants.h" #include "_impl/scaled_integer/convert_operator.h" #include "_impl/scaled_integer/declaration.h" #include "_impl/scaled_integer/extras.h" @@ -21,6 +20,7 @@ #include "_impl/scaled_integer/math.h" #include "_impl/scaled_integer/named.h" #include "_impl/scaled_integer/num_traits.h" +#include "_impl/scaled_integer/numbers.h" #include "_impl/scaled_integer/operators.h" #include "_impl/scaled_integer/rep.h" #include "_impl/scaled_integer/set_rep.h" diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index c3a2df56f..e48f6236f 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -12,10 +12,10 @@ set(test_sources cstdint.cpp common.cpp limits.cpp - math.cpp num_traits.cpp numeric.cpp number_test.cpp + numbers.cpp overflow/overflow.cpp overflow/rounding/integer.cpp rounding/rounding.cpp @@ -39,7 +39,7 @@ set(test_sources integer/type.cpp scaled_integer/scaled_integer_built_in.cpp scaled_integer/decimal.cpp - scaled_integer/constants.cpp + scaled_integer/numbers.cpp fraction/ctors.cpp fraction/fraction.cpp elastic_integer/elastic_integer.cpp diff --git a/test/unit/math.cpp b/test/unit/numbers.cpp similarity index 55% rename from test/unit/math.cpp rename to test/unit/numbers.cpp index 558aea457..127499525 100644 --- a/test/unit/math.cpp +++ b/test/unit/numbers.cpp @@ -4,9 +4,10 @@ // (See accompanying file ../LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#include + #include #include -#include #include @@ -15,7 +16,7 @@ namespace { #if defined(__cpp_inline_variables) - namespace test_math_constants { + namespace test_numbers { template void test_type() { @@ -25,19 +26,19 @@ namespace { // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define CNL_EXPECT_NEAR(expected, actual, epsilon) EXPECT_NEAR(double(expected), double(actual), double(epsilon)) - CNL_EXPECT_NEAR(std::exp(T{1}), cnl::math::e_v, epsilon); - EXPECT_EQ(std::log2(cnl::math::e_v), cnl::math::log2e_v); - CNL_EXPECT_NEAR(std::log10(cnl::math::e_v), cnl::math::log10e_v, epsilon); - CNL_EXPECT_NEAR(std::atan(T{1})*T{4}, cnl::math::pi_v, epsilon); - CNL_EXPECT_NEAR(T{1}/cnl::math::pi_v, cnl::math::inv_pi_v, epsilon); - CNL_EXPECT_NEAR(T{1}/std::sqrt(cnl::math::pi_v), cnl::math::inv_sqrtpi_v, epsilon); - CNL_EXPECT_NEAR(std::log(T{2}), cnl::math::ln2_v, epsilon); - CNL_EXPECT_NEAR(std::log(T{10}), cnl::math::ln10_v, epsilon); - CNL_EXPECT_NEAR(std::sqrt(T{2}), cnl::math::sqrt2_v, epsilon); - CNL_EXPECT_NEAR(std::sqrt(T{3}), cnl::math::sqrt3_v, epsilon); - CNL_EXPECT_NEAR(T{1}/cnl::math::sqrt3_v, cnl::math::inv_sqrt3_v, epsilon); - CNL_EXPECT_NEAR(0.5772156649015328606065120900824024L, cnl::math::egamma_v, epsilon); - CNL_EXPECT_NEAR(1.6180339887498948482045868343656381L, cnl::math::phi_v, epsilon); + CNL_EXPECT_NEAR(std::exp(T{1}), cnl::numbers::e_v, epsilon); + EXPECT_EQ(std::log2(cnl::numbers::e_v), cnl::numbers::log2e_v); + CNL_EXPECT_NEAR(std::log10(cnl::numbers::e_v), cnl::numbers::log10e_v, epsilon); + CNL_EXPECT_NEAR(std::atan(T{1})*T{4}, cnl::numbers::pi_v, epsilon); + CNL_EXPECT_NEAR(T{1}/cnl::numbers::pi_v, cnl::numbers::inv_pi_v, epsilon); + CNL_EXPECT_NEAR(T{1}/std::sqrt(cnl::numbers::pi_v), cnl::numbers::inv_sqrtpi_v, epsilon); + CNL_EXPECT_NEAR(std::log(T{2}), cnl::numbers::ln2_v, epsilon); + CNL_EXPECT_NEAR(std::log(T{10}), cnl::numbers::ln10_v, epsilon); + CNL_EXPECT_NEAR(std::sqrt(T{2}), cnl::numbers::sqrt2_v, epsilon); + CNL_EXPECT_NEAR(std::sqrt(T{3}), cnl::numbers::sqrt3_v, epsilon); + CNL_EXPECT_NEAR(T{1}/cnl::numbers::sqrt3_v, cnl::numbers::inv_sqrt3_v, epsilon); + CNL_EXPECT_NEAR(0.5772156649015328606065120900824024L, cnl::numbers::egamma_v, epsilon); + CNL_EXPECT_NEAR(1.6180339887498948482045868343656381L, cnl::numbers::phi_v, epsilon); } TEST(numeric, float_constants) // NOLINT diff --git a/test/unit/scaled_integer/constants.cpp b/test/unit/scaled_integer/constants.cpp deleted file mode 100644 index 6b485c947..000000000 --- a/test/unit/scaled_integer/constants.cpp +++ /dev/null @@ -1,184 +0,0 @@ - -// Copyright John McFarlane 2017. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file ../../LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include -#include -#include - -#include - -namespace { - -#if defined(__cpp_inline_variables) - - using cnl::_impl::identical; - - //////////////////////////////////////////////////////////////////////////////// - // simple one-off tests - - // 8-bit pi - static_assert( - identical( - cnl::scaled_integer>{3.140625}, - cnl::math::pi_v>>), - "cnl::math::pi_v test failed"); - - //////////////////////////////////////////////////////////////////////////////// - // precision tests - - // where greater of inputs is max and lesser is min, returns 1-max/min - template - long double get_error(cnl::scaled_integer> fp_constant, long double ld_constant) - { - CNL_ASSERT(fp_constant > 0.); - CNL_ASSERT(ld_constant > 0.); - - auto ratio = static_cast(fp_constant) / ld_constant; - auto error = ((ratio>1)?ratio:(1.L/ratio))-1.L; - return error; - } - - TEST(scaled_integer_constants, e) { // NOLINT - EXPECT_LT(get_error(cnl::math::e_v>>, cnl::math::e_v), .006L); - EXPECT_LT(get_error(cnl::math::e_v>>, cnl::math::e_v), .015L); - EXPECT_LT(get_error(cnl::math::e_v>>, cnl::math::e_v), .000002L); -#if !defined(__arm__) - EXPECT_LT(get_error(cnl::math::e_v>>, cnl::math::e_v), - .000000001L); -#endif - } - - TEST(scaled_integer_constants, log2e) { // NOLINT - EXPECT_LT(get_error(cnl::math::log2e_v>>, cnl::math::log2e_v), - .006L); - EXPECT_LT(get_error(cnl::math::log2e_v>>, cnl::math::log2e_v), - .015L); - EXPECT_LT(get_error(cnl::math::log2e_v>>, cnl::math::log2e_v), - .000005L); - EXPECT_LT(get_error(cnl::math::log2e_v>>, cnl::math::log2e_v), - .0000000000000000002L); - } - - TEST(scaled_integer_constants, log10e) { // NOLINT - EXPECT_LT(get_error(cnl::math::log10e_v>>, cnl::math::log10e_v), - .03L); - EXPECT_LT(get_error(cnl::math::log10e_v>>, cnl::math::log10e_v), - .16L); - EXPECT_LT(get_error(cnl::math::log10e_v>>, cnl::math::log10e_v), - .0000325L); - EXPECT_LT(get_error(cnl::math::log10e_v>>, cnl::math::log10e_v), - .0000000000000000004L); - } - - TEST(scaled_integer_constants, pi) { // NOLINT - EXPECT_LT(get_error(cnl::math::pi_v>>, cnl::math::pi_v), .006L); - EXPECT_LT(get_error(cnl::math::pi_v>>, cnl::math::pi_v), .015L); - EXPECT_LT(get_error(cnl::math::pi_v>>, cnl::math::pi_v), - .0000021L); -#if !defined(__arm__) - EXPECT_LT(get_error(cnl::math::pi_v>>, cnl::math::pi_v), - .000000001L); -#endif - } - - TEST(scaled_integer_constants, invpi) { // NOLINT - EXPECT_LT(get_error(cnl::math::inv_pi_v>>, cnl::math::inv_pi_v), - .02L); - EXPECT_LT(get_error(cnl::math::inv_pi_v>>, cnl::math::inv_pi_v), - .02L); - EXPECT_LT(get_error(cnl::math::inv_pi_v>>, cnl::math::inv_pi_v), - .00005L); - EXPECT_LT(get_error(cnl::math::inv_pi_v>>, cnl::math::inv_pi_v), - .0000000000000000003L); - } - - TEST(scaled_integer_constants, inv_sqrtpi) // NOLINT - { - EXPECT_LT(get_error(cnl::math::inv_sqrtpi_v>>, - cnl::math::inv_sqrtpi_v), .02L); - EXPECT_LT(get_error(cnl::math::inv_sqrtpi_v>>, - cnl::math::inv_sqrtpi_v), .02L); - EXPECT_LT(get_error(cnl::math::inv_sqrtpi_v>>, - cnl::math::inv_sqrtpi_v), .00005L); - EXPECT_LT(get_error(cnl::math::inv_sqrtpi_v>>, - cnl::math::inv_sqrtpi_v), .0000000000000000003L); - } - - TEST(scaled_integer_constants, ln2) { // NOLINT - EXPECT_LT(get_error(cnl::math::ln2_v>>, cnl::math::ln2_v), .01L); - EXPECT_LT(get_error(cnl::math::ln2_v>>, cnl::math::ln2_v), .015L); - EXPECT_LT(get_error(cnl::math::ln2_v>>, cnl::math::ln2_v), - .0000021L); - EXPECT_LT(get_error(cnl::math::ln2_v>>, cnl::math::ln2_v), - .0000000000000000002L); - } - - TEST(scaled_integer_constants, ln10) { // NOLINT - EXPECT_LT(get_error(cnl::math::ln10_v>>, cnl::math::ln10_v), - .006L); - EXPECT_LT(get_error(cnl::math::ln10_v>>, cnl::math::ln10_v), - .025L); - EXPECT_LT(get_error(cnl::math::ln10_v>>, cnl::math::ln10_v), - .0000021L); - EXPECT_LT(get_error(cnl::math::ln10_v>>, cnl::math::ln10_v), - .0000000000000000002L); - } - - TEST(scaled_integer_constants, sqrt2) { // NOLINT - EXPECT_LT(get_error(cnl::math::sqrt2_v>>, cnl::math::sqrt2_v), - .006L); - EXPECT_LT(get_error(cnl::math::sqrt2_v>>, cnl::math::sqrt2_v), - .03L); - EXPECT_LT(get_error(cnl::math::sqrt2_v>>, cnl::math::sqrt2_v), - .00001L); - EXPECT_LT(get_error(cnl::math::sqrt2_v>>, cnl::math::sqrt2_v), - .0000000000000000002L); - } - - TEST(scaled_integer_constants, sqrt3) { // NOLINT - EXPECT_LT(get_error(cnl::math::sqrt3_v>>, cnl::math::sqrt3_v), - .02L); - EXPECT_LT(get_error(cnl::math::sqrt3_v>>, cnl::math::sqrt3_v), - .03L); - EXPECT_LT(get_error(cnl::math::sqrt3_v>>, cnl::math::sqrt3_v), - .00005L); - EXPECT_LT(get_error(cnl::math::sqrt3_v>>, cnl::math::sqrt3_v), - .0000000000000000003L); - } - - TEST(scaled_integer_constants, invsqrt3) { // NOLINT - EXPECT_LT(get_error(cnl::math::inv_sqrt3_v>>, - cnl::math::inv_sqrt3_v), .03L); - EXPECT_LT(get_error(cnl::math::inv_sqrt3_v>>, - cnl::math::inv_sqrt3_v), .03L); - EXPECT_LT(get_error(cnl::math::inv_sqrt3_v>>, - cnl::math::inv_sqrt3_v), .00005L); - EXPECT_LT(get_error(cnl::math::inv_sqrt3_v>>, - cnl::math::inv_sqrt3_v), .0000000000000000003L); - } - - TEST(scaled_integer_constants, egamma) { // NOLINT - EXPECT_LT(get_error(cnl::math::egamma_v>>, cnl::math::egamma_v), - .03L); - EXPECT_LT(get_error(cnl::math::egamma_v>>, cnl::math::egamma_v), - .03L); - EXPECT_LT(get_error(cnl::math::egamma_v>>, cnl::math::egamma_v), - .00005L); - EXPECT_LT(get_error(cnl::math::egamma_v>>, cnl::math::egamma_v), - .0000000000000000003L); - } - - TEST(scaled_integer_constants, phi) { // NOLINT - EXPECT_LT(get_error(cnl::math::phi_v>>, cnl::math::phi_v), .02L); - EXPECT_LT(get_error(cnl::math::phi_v>>, cnl::math::phi_v), .04L); - EXPECT_LT(get_error(cnl::math::phi_v>>, cnl::math::phi_v), - .00005L); - EXPECT_LT(get_error(cnl::math::phi_v>>, cnl::math::phi_v), - .0000000000000000003L); - } - -#endif // defined(__cpp_inline_variables) -} diff --git a/test/unit/scaled_integer/fraction_ctor.h b/test/unit/scaled_integer/fraction_ctor.h index d0d5c887f..310d5eb79 100644 --- a/test/unit/scaled_integer/fraction_ctor.h +++ b/test/unit/scaled_integer/fraction_ctor.h @@ -40,7 +40,7 @@ namespace { // NOLINT(cert-dcl59-cpp) // pi stored as s5.10 (truncated rounding) constexpr auto n = cnl::_impl::from_rep>>(int16{3216}); #if defined(__cpp_inline_variables) - static_assert(identical(cnl::math::pi_v>>, n)); + static_assert(identical(cnl::numbers::pi_v>>, n)); #endif static_assert(identical(int16{3216}, cnl::_impl::to_rep(n)), "cnl::_impl::to_rep(cnl::scaled_integer)"); static_assert(identical(3.140625, static_cast(n)), "cnl::scaled_integer::operator double()"); diff --git a/test/unit/scaled_integer/numbers.cpp b/test/unit/scaled_integer/numbers.cpp new file mode 100644 index 000000000..9aef28972 --- /dev/null +++ b/test/unit/scaled_integer/numbers.cpp @@ -0,0 +1,184 @@ + +// Copyright John McFarlane 2017. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file ../../LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include + +#include + +namespace { + +#if defined(__cpp_inline_variables) + + using cnl::_impl::identical; + + //////////////////////////////////////////////////////////////////////////////// + // simple one-off tests + + // 8-bit pi + static_assert( + identical( + cnl::scaled_integer>{3.140625}, + cnl::numbers::pi_v>>), + "cnl::numbers::pi_v test failed"); + + //////////////////////////////////////////////////////////////////////////////// + // precision tests + + // where greater of inputs is max and lesser is min, returns 1-max/min + template + long double get_error(cnl::scaled_integer> fp_constant, long double ld_constant) + { + CNL_ASSERT(fp_constant > 0.); + CNL_ASSERT(ld_constant > 0.); + + auto ratio = static_cast(fp_constant) / ld_constant; + auto error = ((ratio>1)?ratio:(1.L/ratio))-1.L; + return error; + } + + TEST(scaled_integer_constants, e) { // NOLINT + EXPECT_LT(get_error(cnl::numbers::e_v>>, cnl::numbers::e_v), .006L); + EXPECT_LT(get_error(cnl::numbers::e_v>>, cnl::numbers::e_v), .015L); + EXPECT_LT(get_error(cnl::numbers::e_v>>, cnl::numbers::e_v), .000002L); +#if !defined(__arm__) + EXPECT_LT(get_error(cnl::numbers::e_v>>, cnl::numbers::e_v), + .000000001L); +#endif + } + + TEST(scaled_integer_constants, log2e) { // NOLINT + EXPECT_LT(get_error(cnl::numbers::log2e_v>>, cnl::numbers::log2e_v), + .006L); + EXPECT_LT(get_error(cnl::numbers::log2e_v>>, cnl::numbers::log2e_v), + .015L); + EXPECT_LT(get_error(cnl::numbers::log2e_v>>, cnl::numbers::log2e_v), + .000005L); + EXPECT_LT(get_error(cnl::numbers::log2e_v>>, cnl::numbers::log2e_v), + .0000000000000000002L); + } + + TEST(scaled_integer_constants, log10e) { // NOLINT + EXPECT_LT(get_error(cnl::numbers::log10e_v>>, cnl::numbers::log10e_v), + .03L); + EXPECT_LT(get_error(cnl::numbers::log10e_v>>, cnl::numbers::log10e_v), + .16L); + EXPECT_LT(get_error(cnl::numbers::log10e_v>>, cnl::numbers::log10e_v), + .0000325L); + EXPECT_LT(get_error(cnl::numbers::log10e_v>>, cnl::numbers::log10e_v), + .0000000000000000004L); + } + + TEST(scaled_integer_constants, pi) { // NOLINT + EXPECT_LT(get_error(cnl::numbers::pi_v>>, cnl::numbers::pi_v), .006L); + EXPECT_LT(get_error(cnl::numbers::pi_v>>, cnl::numbers::pi_v), .015L); + EXPECT_LT(get_error(cnl::numbers::pi_v>>, cnl::numbers::pi_v), + .0000021L); +#if !defined(__arm__) + EXPECT_LT(get_error(cnl::numbers::pi_v>>, cnl::numbers::pi_v), + .000000001L); +#endif + } + + TEST(scaled_integer_constants, invpi) { // NOLINT + EXPECT_LT(get_error(cnl::numbers::inv_pi_v>>, cnl::numbers::inv_pi_v), + .02L); + EXPECT_LT(get_error(cnl::numbers::inv_pi_v>>, cnl::numbers::inv_pi_v), + .02L); + EXPECT_LT(get_error(cnl::numbers::inv_pi_v>>, cnl::numbers::inv_pi_v), + .00005L); + EXPECT_LT(get_error(cnl::numbers::inv_pi_v>>, cnl::numbers::inv_pi_v), + .0000000000000000003L); + } + + TEST(scaled_integer_constants, inv_sqrtpi) // NOLINT + { + EXPECT_LT(get_error(cnl::numbers::inv_sqrtpi_v>>, + cnl::numbers::inv_sqrtpi_v), .02L); + EXPECT_LT(get_error(cnl::numbers::inv_sqrtpi_v>>, + cnl::numbers::inv_sqrtpi_v), .02L); + EXPECT_LT(get_error(cnl::numbers::inv_sqrtpi_v>>, + cnl::numbers::inv_sqrtpi_v), .00005L); + EXPECT_LT(get_error(cnl::numbers::inv_sqrtpi_v>>, + cnl::numbers::inv_sqrtpi_v), .0000000000000000003L); + } + + TEST(scaled_integer_constants, ln2) { // NOLINT + EXPECT_LT(get_error(cnl::numbers::ln2_v>>, cnl::numbers::ln2_v), .01L); + EXPECT_LT(get_error(cnl::numbers::ln2_v>>, cnl::numbers::ln2_v), .015L); + EXPECT_LT(get_error(cnl::numbers::ln2_v>>, cnl::numbers::ln2_v), + .0000021L); + EXPECT_LT(get_error(cnl::numbers::ln2_v>>, cnl::numbers::ln2_v), + .0000000000000000002L); + } + + TEST(scaled_integer_constants, ln10) { // NOLINT + EXPECT_LT(get_error(cnl::numbers::ln10_v>>, cnl::numbers::ln10_v), + .006L); + EXPECT_LT(get_error(cnl::numbers::ln10_v>>, cnl::numbers::ln10_v), + .025L); + EXPECT_LT(get_error(cnl::numbers::ln10_v>>, cnl::numbers::ln10_v), + .0000021L); + EXPECT_LT(get_error(cnl::numbers::ln10_v>>, cnl::numbers::ln10_v), + .0000000000000000002L); + } + + TEST(scaled_integer_constants, sqrt2) { // NOLINT + EXPECT_LT(get_error(cnl::numbers::sqrt2_v>>, cnl::numbers::sqrt2_v), + .006L); + EXPECT_LT(get_error(cnl::numbers::sqrt2_v>>, cnl::numbers::sqrt2_v), + .03L); + EXPECT_LT(get_error(cnl::numbers::sqrt2_v>>, cnl::numbers::sqrt2_v), + .00001L); + EXPECT_LT(get_error(cnl::numbers::sqrt2_v>>, cnl::numbers::sqrt2_v), + .0000000000000000002L); + } + + TEST(scaled_integer_constants, sqrt3) { // NOLINT + EXPECT_LT(get_error(cnl::numbers::sqrt3_v>>, cnl::numbers::sqrt3_v), + .02L); + EXPECT_LT(get_error(cnl::numbers::sqrt3_v>>, cnl::numbers::sqrt3_v), + .03L); + EXPECT_LT(get_error(cnl::numbers::sqrt3_v>>, cnl::numbers::sqrt3_v), + .00005L); + EXPECT_LT(get_error(cnl::numbers::sqrt3_v>>, cnl::numbers::sqrt3_v), + .0000000000000000003L); + } + + TEST(scaled_integer_constants, invsqrt3) { // NOLINT + EXPECT_LT(get_error(cnl::numbers::inv_sqrt3_v>>, + cnl::numbers::inv_sqrt3_v), .03L); + EXPECT_LT(get_error(cnl::numbers::inv_sqrt3_v>>, + cnl::numbers::inv_sqrt3_v), .03L); + EXPECT_LT(get_error(cnl::numbers::inv_sqrt3_v>>, + cnl::numbers::inv_sqrt3_v), .00005L); + EXPECT_LT(get_error(cnl::numbers::inv_sqrt3_v>>, + cnl::numbers::inv_sqrt3_v), .0000000000000000003L); + } + + TEST(scaled_integer_constants, egamma) { // NOLINT + EXPECT_LT(get_error(cnl::numbers::egamma_v>>, cnl::numbers::egamma_v), + .03L); + EXPECT_LT(get_error(cnl::numbers::egamma_v>>, cnl::numbers::egamma_v), + .03L); + EXPECT_LT(get_error(cnl::numbers::egamma_v>>, cnl::numbers::egamma_v), + .00005L); + EXPECT_LT(get_error(cnl::numbers::egamma_v>>, cnl::numbers::egamma_v), + .0000000000000000003L); + } + + TEST(scaled_integer_constants, phi) { // NOLINT + EXPECT_LT(get_error(cnl::numbers::phi_v>>, cnl::numbers::phi_v), .02L); + EXPECT_LT(get_error(cnl::numbers::phi_v>>, cnl::numbers::phi_v), .04L); + EXPECT_LT(get_error(cnl::numbers::phi_v>>, cnl::numbers::phi_v), + .00005L); + EXPECT_LT(get_error(cnl::numbers::phi_v>>, cnl::numbers::phi_v), + .0000000000000000003L); + } + +#endif // defined(__cpp_inline_variables) +}