17 namespace Acts::detail {
21 template <
typename component_t,
typename component_projector_t>
23 const component_projector_t &
proj) {
31 assert(std::isfinite(covA));
33 assert(std::isfinite(covB));
35 const auto kl = covA * (1 / covB) + covB * (1 / covA) +
36 (parsA - parsB) * (1 / covA + 1 / covB) * (parsA - parsB);
38 assert(kl >= 0.0 &&
"kl-divergence must be non-negative");
43 template <
typename component_t,
typename component_projector_t,
44 typename angle_desc_t>
46 const component_projector_t &
proj,
47 const angle_desc_t &angle_desc) {
49 "non-positive weight");
52 const auto refProj = [](
auto &
c) {
53 return std::tie(
c.get().weight,
c.get().boundPars,
c.get().boundCov);
56 auto [mergedPars, mergedCov] =
60 proj(ret).boundPars = mergedPars;
61 proj(ret).boundCov = mergedCov;
69 using Array = Eigen::Array<Acts::ActsScalar, Eigen::Dynamic, 1>;
70 using Mask = Eigen::Array<bool, Eigen::Dynamic, 1>;
77 template <
typename array_t,
typename setter_t>
79 const auto indexConst = (n - 1) * n / 2;
82 for (
auto i = 0ul;
i <
n; ++
i) {
83 array[indexConst +
i] = setter(n,
i);
88 array[(
i - 1) *
i / 2 + n] = setter(n,
i);
93 template <
typename component_t,
typename projector_t>
95 const projector_t &
proj)
101 const auto indexConst = (
i - 1) *
i / 2;
102 for (
auto j = 0ul;
j <
i; ++
j) {
110 auto at(std::size_t
i, std::size_t
j)
const {
114 template <
typename component_t,
typename projector_t>
116 const std::vector<component_t> &cmps,
117 const projector_t &
proj) {
130 auto min = std::numeric_limits<Acts::ActsScalar>::max();
146 const auto prev_precision = os.precision();
153 os << std::setw(width) <<
j <<
" ";
161 const auto indexConst = (
i - 1) *
i / 2;
162 os << std::setw(width) <<
i <<
" | ";
163 for (
auto j = 0ul;
j <
i; ++
j) {
164 os << std::setw(width) << std::setprecision(prec)
169 os << std::setprecision(prev_precision);