Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:12:59

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
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()