File indexing completed on 2025-01-18 09:12:59
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/data/test_case.hpp>
0010 #include <boost/test/unit_test.hpp>
0011
0012 #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp"
0013 #include "Acts/Utilities/MathHelpers.hpp"
0014
0015 #include <cmath>
0016
0017 namespace bdata = boost::unit_test::data;
0018
0019 const auto expDist = bdata::random(
0020 (bdata::engine = std::mt19937{}, bdata::seed = 0,
0021 bdata::distribution = std::uniform_real_distribution<double>(-4, 4)));
0022
0023 BOOST_AUTO_TEST_SUITE(Utilities)
0024
0025 BOOST_DATA_TEST_CASE(fastHypot, expDist ^ expDist ^ bdata::xrange(100), xExp,
0026 yExp, i) {
0027 (void)i;
0028
0029 const double x = std::pow(10, xExp);
0030 const double y = std::pow(10, yExp);
0031
0032 const float fastFloat =
0033 Acts::fastHypot(static_cast<float>(x), static_cast<float>(y));
0034 const double fastDouble = Acts::fastHypot(x, y);
0035
0036 const float stdFloat =
0037 std::hypot(static_cast<float>(x), static_cast<float>(y));
0038 const double stdDouble = std::hypot(x, y);
0039
0040 CHECK_CLOSE_REL(stdFloat, fastFloat, 1e-6);
0041 CHECK_CLOSE_REL(stdDouble, fastDouble, 1e-6);
0042 }
0043
0044 BOOST_AUTO_TEST_SUITE_END()