|
||||
File indexing completed on 2025-01-18 09:10:48
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 #pragma once 0010 0011 #include "Acts/Definitions/TrackParametrization.hpp" 0012 #include "Acts/Utilities/Helpers.hpp" 0013 0014 #include <cstddef> 0015 0016 namespace Acts { 0017 0018 namespace detail { 0019 /// Helper functor for @c visit_measurement. This is the actual functor given 0020 /// to @c template_switch. 0021 /// @tparam I Compile time int value 0022 template <std::size_t I> 0023 struct visit_measurement_callable { 0024 /// The invoked function. It will perform the head/top-left corner 0025 /// extraction, and pass thee results to the given lambda. 0026 /// @tparam L The lambda type 0027 /// @tparam A The parameter vector type 0028 /// @tparam B The covariance matrix type 0029 /// @note No requirements on @c A and @c B are made, to enable a single 0030 /// overload for both const and non-const matrices/vectors. 0031 /// @param param The parameter vector 0032 /// @param cov The covariance matrix 0033 /// @param lambda The lambda to call with the statically sized subsets 0034 template <typename L, typename A, typename B> 0035 auto static constexpr invoke(A&& param, B&& cov, L&& lambda) { 0036 return lambda(param.template head<I>(), cov.template topLeftCorner<I, I>()); 0037 } 0038 }; 0039 } // namespace detail 0040 0041 /// Dispatch a lambda call on an overallocated parameter vector and covariance 0042 /// matrix, based on a runtime dimension value. Inside the lambda call, the 0043 /// vector and matrix will have fixed dimensions, but will still point back to 0044 /// the originally given overallocated values. 0045 /// @tparam L The lambda type 0046 /// @tparam A The parameter vector type 0047 /// @tparam B The covariance matrix type 0048 /// @note No requirements on @c A and @c B are made, to enable a single 0049 /// overload for both const and non-const matrices/vectors. 0050 /// @param param The parameter vector 0051 /// @param cov The covariance matrix 0052 /// @param dim The actual dimension as a runtime value 0053 /// @param lambda The lambda to call with the statically sized subsets 0054 template <typename L, typename A, typename B> 0055 auto visit_measurement(A&& param, B&& cov, std::size_t dim, L&& lambda) { 0056 return template_switch<detail::visit_measurement_callable, 1, eBoundSize>( 0057 dim, param, cov, lambda); 0058 } 0059 0060 /// Dispatch a generic lambda on a measurement dimension. This overload doesn't 0061 /// assume anything about what is needed inside the lambda, it communicates the 0062 /// dimension via an integral constant type 0063 /// @tparam L The generic lambda type to call 0064 /// @param dim The runtime dimension of the measurement 0065 /// @param lambda The generic lambda instance to call 0066 /// @param args Additional arguments passed to @p lambda 0067 /// @return Returns the lambda return value 0068 template <typename L, typename... Args> 0069 auto visit_measurement(std::size_t dim, L&& lambda, Args&&... args) { 0070 return template_switch_lambda<1, eBoundSize>(dim, lambda, 0071 std::forward<Args>(args)...); 0072 } 0073 0074 } // namespace Acts
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |