diff --git a/Core/include/Acts/EventData/TrackStateProxy.hpp b/Core/include/Acts/EventData/TrackStateProxy.hpp index 4338c434f77..3d91547c725 100644 --- a/Core/include/Acts/EventData/TrackStateProxy.hpp +++ b/Core/include/Acts/EventData/TrackStateProxy.hpp @@ -16,6 +16,7 @@ #include "Acts/EventData/TrackStateType.hpp" #include "Acts/EventData/Types.hpp" #include "Acts/Surfaces/Surface.hpp" +#include "Acts/Utilities/EigenConcepts.hpp" #include "Acts/Utilities/HashedString.hpp" #include "Acts/Utilities/Helpers.hpp" @@ -782,12 +783,11 @@ class TrackStateProxy { template void allocateCalibrated(const Eigen::DenseBase& val, const Eigen::DenseBase& cov) - requires(Eigen::PlainObjectBase::RowsAtCompileTime > 0 && - Eigen::PlainObjectBase::RowsAtCompileTime <= eBoundSize && - Eigen::PlainObjectBase::RowsAtCompileTime == - Eigen::PlainObjectBase::RowsAtCompileTime && - Eigen::PlainObjectBase::RowsAtCompileTime == - Eigen::PlainObjectBase::ColsAtCompileTime) + requires(Concepts::eigen_base_is_fixed_size && + Concepts::eigen_bases_have_same_num_rows && + Concepts::eigen_base_is_square && + Eigen::PlainObjectBase::RowsAtCompileTime <= + static_cast>(eBoundSize)) { m_traj->template allocateCalibrated< Eigen::PlainObjectBase::RowsAtCompileTime>(m_istate, val, cov); diff --git a/Core/include/Acts/EventData/VectorMultiTrajectory.hpp b/Core/include/Acts/EventData/VectorMultiTrajectory.hpp index e13498cea2c..8f416dd6969 100644 --- a/Core/include/Acts/EventData/VectorMultiTrajectory.hpp +++ b/Core/include/Acts/EventData/VectorMultiTrajectory.hpp @@ -16,6 +16,7 @@ #include "Acts/EventData/Types.hpp" #include "Acts/EventData/detail/DynamicColumn.hpp" #include "Acts/EventData/detail/DynamicKeyIterator.hpp" +#include "Acts/Utilities/EigenConcepts.hpp" #include "Acts/Utilities/HashedString.hpp" #include "Acts/Utilities/Helpers.hpp" #include "Acts/Utilities/ThrowAssert.hpp" @@ -495,13 +496,11 @@ class VectorMultiTrajectory final void allocateCalibrated_impl(IndexType istate, const Eigen::DenseBase& val, const Eigen::DenseBase& cov) - - requires(Eigen::PlainObjectBase::RowsAtCompileTime > 0 && - Eigen::PlainObjectBase::RowsAtCompileTime <= eBoundSize && - Eigen::PlainObjectBase::RowsAtCompileTime == - Eigen::PlainObjectBase::RowsAtCompileTime && - Eigen::PlainObjectBase::RowsAtCompileTime == - Eigen::PlainObjectBase::ColsAtCompileTime) + requires(Concepts::eigen_base_is_fixed_size && + Concepts::eigen_bases_have_same_num_rows && + Concepts::eigen_base_is_square && + Eigen::PlainObjectBase::RowsAtCompileTime <= + static_cast>(eBoundSize)) { constexpr std::size_t measdim = val_t::RowsAtCompileTime; diff --git a/Core/include/Acts/Utilities/EigenConcepts.hpp b/Core/include/Acts/Utilities/EigenConcepts.hpp new file mode 100644 index 00000000000..4151dd6e237 --- /dev/null +++ b/Core/include/Acts/Utilities/EigenConcepts.hpp @@ -0,0 +1,56 @@ +// This file is part of the ACTS project. +// +// Copyright (C) 2016 CERN for the benefit of the ACTS project +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +#pragma once + +#include + +namespace Acts::Concepts { +/// @brief Concept that is true iff T is a valid Eigen dense base. +template +concept is_eigen_base = requires { + { T::RowsAtCompileTime }; + { T::ColsAtCompileTime }; +}; + +/// @brief Concept that is true iff T is a valid Eigen dense base with fixed +/// size. +template +concept eigen_base_is_fixed_size = + is_eigen_base && Eigen::PlainObjectBase::RowsAtCompileTime > 0 && + Eigen::PlainObjectBase::ColsAtCompileTime > 0; + +/// @brief Concept that is true iff T is a valid Eigen dense base with fixed, +/// square size. +template +concept eigen_base_is_square = eigen_base_is_fixed_size && + Eigen::PlainObjectBase::RowsAtCompileTime == + Eigen::PlainObjectBase::ColsAtCompileTime; + +/// @brief Concept that is true iff T1 and T2 have the same, known at compile +/// time, number of rows. +template +concept eigen_bases_have_same_num_rows = + eigen_base_is_fixed_size && eigen_base_is_fixed_size && + static_cast(Eigen::PlainObjectBase::RowsAtCompileTime) == + static_cast(Eigen::PlainObjectBase::RowsAtCompileTime); + +/// @brief Concept that is true iff T1 and T2 have the same, known at compile +/// time, number of columns. +template +concept eigen_bases_have_same_num_cols = + eigen_base_is_fixed_size && eigen_base_is_fixed_size && + static_cast(Eigen::PlainObjectBase::ColsAtCompileTime) == + static_cast(Eigen::PlainObjectBase::ColsAtCompileTime); + +/// @brief Concept that is true iff T1 and T2 have the same, known at compile +/// time, size. +template +concept eigen_bases_have_same_size = eigen_bases_have_same_num_rows && + eigen_bases_have_same_num_cols; +} // namespace Acts::Concepts