Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /acts/Tests/UnitTests/Core/Utilities/MathHelpersTests.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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/Utilities/MathHelpers.hpp"
0013 #include "ActsTests/CommonHelpers/FloatComparisons.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 namespace ActsTetsts {
0024 
0025 BOOST_AUTO_TEST_SUITE(UtilitiesSuite)
0026 
0027 BOOST_DATA_TEST_CASE(fastHypot, expDist ^ expDist ^ bdata::xrange(100), xExp,
0028                      yExp, i) {
0029   (void)i;
0030 
0031   const double x = std::pow(10, xExp);
0032   const double y = std::pow(10, yExp);
0033 
0034   const float fastFloat =
0035       Acts::fastHypot(static_cast<float>(x), static_cast<float>(y));
0036   const double fastDouble = Acts::fastHypot(x, y);
0037 
0038   const float stdFloat =
0039       std::hypot(static_cast<float>(x), static_cast<float>(y));
0040   const double stdDouble = std::hypot(x, y);
0041 
0042   CHECK_CLOSE_REL(stdFloat, fastFloat, 1e-6);
0043   CHECK_CLOSE_REL(stdDouble, fastDouble, 1e-6);
0044 }
0045 
0046 BOOST_AUTO_TEST_SUITE_END()
0047 
0048 }  // namespace ActsTetsts