Skip to content

Commit

Permalink
remove min_max
Browse files Browse the repository at this point in the history
  • Loading branch information
AJPfleger committed Sep 6, 2024
1 parent 26b059f commit d6d7067
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 34 deletions.
20 changes: 3 additions & 17 deletions Core/include/Acts/Utilities/Helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,20 +164,6 @@ T clampValue(U value) {
static_cast<U>(std::numeric_limits<T>::max()));
}

/// Return min/max from a (optionally) sorted series, obsolete with C++20
/// (ranges)
///
/// @tparam T a numeric series
///
/// @param tseries is the number series
///
/// @return [ min, max ] in an array of length 2
template <typename T>
std::array<typename T::value_type, 2u> min_max(const T& tseries) {
return {*std::min_element(tseries.begin(), tseries.end()),
*std::max_element(tseries.begin(), tseries.end())};
}

/// Return range and medium of a sorted numeric series
///
/// @tparam T a numeric series
Expand All @@ -187,9 +173,9 @@ std::array<typename T::value_type, 2u> min_max(const T& tseries) {
/// @return [ range, medium ] in an tuple
template <typename T>
std::tuple<typename T::value_type, ActsScalar> range_medium(const T& tseries) {
auto [min, max] = min_max(tseries);
typename T::value_type range = (max - min);
ActsScalar medium = static_cast<ActsScalar>((max + min) * 0.5);
auto [minIt, maxIt] = std::ranges::minmax_element(tseries);
typename T::value_type range = (*maxIt - *minIt);
ActsScalar medium = static_cast<ActsScalar>((*maxIt + *minIt) * 0.5);
return std::tie(range, medium);
}

Expand Down
6 changes: 3 additions & 3 deletions Core/src/Detector/detail/CylindricalDetectorHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ Acts::Experimental::PortalReplacement createDiscReplacement(
? Acts::BinningValue::binR
: Acts::BinningValue::binPhi;
// Estimate ranges
auto [minR, maxR] = Acts::min_max(rBoundaries);
auto [minRit, maxRit] = std::ranges::minmax_element(rBoundaries);
auto [sectorPhi, avgPhi] = Acts::range_medium(phiBoundaries);

// Transform and bounds
auto bounds =
std::make_unique<Acts::RadialBounds>(minR, maxR, 0.5 * sectorPhi, avgPhi);
auto bounds = std::make_unique<Acts::RadialBounds>(*minRit, *maxRit,
0.5 * sectorPhi, avgPhi);
// A new surface on the negative side over the full range
auto surface = Acts::Surface::makeShared<Acts::DiscSurface>(
transform, std::move(bounds));
Expand Down
14 changes: 0 additions & 14 deletions Tests/UnitTests/Core/Utilities/HelpersTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,20 +193,6 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(BlockedMatrixMultiplication, Matrices,
}
}

BOOST_AUTO_TEST_CASE(min_max) {
std::vector<ActsScalar> ordered = {-3., -2., -1., 0., 1., 2., 3.};
auto [min0, max0] = Acts::min_max(ordered);

CHECK_CLOSE_ABS(min0, -3., std::numeric_limits<ActsScalar>::epsilon());
CHECK_CLOSE_ABS(max0, 3., std::numeric_limits<ActsScalar>::epsilon());

std::vector<ActsScalar> unordered = {3., -3., -2., -1., 0., 1., 2.};
auto [min1, max1] = Acts::min_max(unordered);

CHECK_CLOSE_ABS(min1, -3., std::numeric_limits<ActsScalar>::epsilon());
CHECK_CLOSE_ABS(max1, 3., std::numeric_limits<ActsScalar>::epsilon());
}

BOOST_AUTO_TEST_CASE(range_medium) {
std::vector<ActsScalar> ordered = {-3., -2., -1., 0., 1., 2., 3.};
auto [range0, medium0] = Acts::range_medium(ordered);
Expand Down

0 comments on commit d6d7067

Please sign in to comment.