Belle II Software development
PrecisionMatrixUtil Struct Reference

Collection of functions related to precision matrices. More...

#include <PrecisionMatrixUtil.h>

Static Public Member Functions

template<int N>
static PrecisionMatrix< N > identity ()
 Constructs an identity matrix.
 
template<int N>
static void transport (const JacobianMatrix< N, N > &ambiguity, PrecisionMatrix< N > &precision)
 Transport the precision matrix inplace with the given jacobian matrix.
 
template<int M, int N>
static PrecisionMatrix< M > transported (const JacobianMatrix< N, M > &ambiguity, const PrecisionMatrix< N > &precision)
 Return a copy of the precision matrix transported with the given back projection jacobian matrix.
 
template<int N>
static void scale (const ParameterVector< N > &scales, PrecisionMatrix< N > &precision)
 Scale the precision inplace by the given factors in each parameter.
 
template<int N>
static PrecisionMatrix< N > scale (const ParameterVector< N > &scales, const PrecisionMatrix< N > &precision)
 Return a copy of the precision scaled by the given factors in each parameter.
 
template<int N1, int N2>
static PrecisionMatrix< N1+N2 > stackBlocks (const PrecisionMatrix< N1 > &block1, const PrecisionMatrix< N2 > &block2)
 Combines two precision matrices by putting them in two blocks on the diagonal of a larger matrix.
 
template<class APrecisionMatrix , int I = 0, int N = 0>
static APrecisionMatrix getSub (const PrecisionMatrix< N > &precision)
 Gets a subprecision from a precision matrix.
 
template<int N>
static double average (const ParameterVector< N > &parameter1, const PrecisionMatrix< N > &precision1, const ParameterVector< N > &parameter2, const PrecisionMatrix< N > &precision2, ParameterVector< N > &parameter, PrecisionMatrix< N > &precision)
 Averages two parameter vectors taking into account their respective precision.
 
template<int M, int N1, int N2>
static double average (const ParameterVector< N1 > &parameter1, const PrecisionMatrix< N1 > &precision1, const JacobianMatrix< N1, M > &ambiguity1, const ParameterVector< N2 > &parameter2, const PrecisionMatrix< N2 > &precision2, const JacobianMatrix< N2, M > &ambiguity2, ParameterVector< M > &parameter, PrecisionMatrix< M > &precision)
 Averages two parameter vectors from a projected space taking into account their respective precisions and ambiguity matrices.
 

Detailed Description

Collection of functions related to precision matrices.

Definition at line 30 of file PrecisionMatrixUtil.h.

Member Function Documentation

◆ average() [1/2]

static double average ( const ParameterVector< N > &  parameter1,
const PrecisionMatrix< N > &  precision1,
const ParameterVector< N > &  parameter2,
const PrecisionMatrix< N > &  precision2,
ParameterVector< N > &  parameter,
PrecisionMatrix< N > &  precision 
)
inlinestatic

Averages two parameter vectors taking into account their respective precision.

Parameters
parameter1First parameters
precision1Precision matrix to the first parameters
parameter2Second parameters
precision2Precision matrix to the second parameters
[out]parameterAveraged parameters
[out]precisionAveraged precision matrix
Returns
Chi square deviation of original parameters to the average

Definition at line 104 of file PrecisionMatrixUtil.h.

110 {
111 const auto& ePrecision1 = mapToEigen(precision1);
112 const auto& ePrecision2 = mapToEigen(precision2);
113 auto&& ePrecision = mapToEigen(precision);
114
115 const auto& eParameter1 = mapToEigen(parameter1);
116 const auto& eParameter2 = mapToEigen(parameter2);
117 auto&& eParameter = mapToEigen(parameter);
118
119 ePrecision = ePrecision1 + ePrecision2;
120 eParameter = ePrecision.colPivHouseholderQr().solve(ePrecision1 * eParameter1 +
121 ePrecision2 * eParameter2);
122
123 auto eResidual1 = eParameter1 - eParameter;
124 auto eResidual2 = eParameter2 - eParameter;
125
126 Eigen::Matrix<double, 1, 1> chi2 = (eResidual1.transpose() * ePrecision1 * eResidual1 +
127 eResidual2.transpose() * ePrecision2 * eResidual2);
128 return chi2[0];
129 }

◆ average() [2/2]

static double average ( const ParameterVector< N1 > &  parameter1,
const PrecisionMatrix< N1 > &  precision1,
const JacobianMatrix< N1, M > &  ambiguity1,
const ParameterVector< N2 > &  parameter2,
const PrecisionMatrix< N2 > &  precision2,
const JacobianMatrix< N2, M > &  ambiguity2,
ParameterVector< M > &  parameter,
PrecisionMatrix< M > &  precision 
)
inlinestatic

Averages two parameter vectors from a projected space taking into account their respective precisions and ambiguity matrices.

Parameters
parameter1First parameters
precision1Precision matrix to the first parameters
ambiguity1Projection ambiguity of the first parameters
parameter2Second parameters
precision2Precision matrix to the second parameters
ambiguity2Projection ambiguity of the second parameters
[out]parameterAveraged parameters
[out]precisionAveraged precision matrix
Returns
Chi square deviation of original parameters to the average

Definition at line 146 of file PrecisionMatrixUtil.h.

154 {
155 const auto& eParameter1 = mapToEigen(parameter1);
156 const auto& ePrecision1 = mapToEigen(precision1);
157 const auto& eAmbiguity1 = mapToEigen(ambiguity1);
158
159 const auto& eParameter2 = mapToEigen(parameter2);
160 const auto& ePrecision2 = mapToEigen(precision2);
161 const auto& eAmbiguity2 = mapToEigen(ambiguity2);
162
163 auto&& ePrecision = mapToEigen(precision);
164 auto&& eParameter = mapToEigen(parameter);
165
166 ePrecision = (eAmbiguity1.transpose() * ePrecision1 * eAmbiguity1 +
167 eAmbiguity2.transpose() * ePrecision2 * eAmbiguity2);
168
169 eParameter = ePrecision.colPivHouseholderQr().solve(
170 eAmbiguity1.transpose() * ePrecision1 * eParameter1 +
171 eAmbiguity2.transpose() * ePrecision2 * eParameter2);
172
173 auto eResidual1 = eParameter1 - eAmbiguity1 * eParameter;
174 auto eResidual2 = eParameter2 - eAmbiguity2 * eParameter;
175
176 Eigen::Matrix<double, 1, 1> chi2 = (eResidual1.transpose() * ePrecision1 * eResidual1 +
177 eResidual2.transpose() * ePrecision2 * eResidual2);
178 return chi2[0];
179 }

◆ getSub()

static APrecisionMatrix getSub ( const PrecisionMatrix< N > &  precision)
inlinestatic

Gets a subprecision from a precision matrix.

Definition at line 85 of file PrecisionMatrixUtil.h.

86 {
87 constexpr const int M =
88 std::remove_reference_t<decltype(mapToEigen(APrecisionMatrix()))>::RowsAtCompileTime;
89 return precision.template block<M, M>(I, I);
90 }

◆ identity()

static PrecisionMatrix< N > identity ( )
inlinestatic

Constructs an identity matrix.

Definition at line 34 of file PrecisionMatrixUtil.h.

35 {
37 }
static PlainMatrix< T, M, N > Identity()
Construct an identity matrix.
Definition: PlainMatrix.h:74

◆ scale() [1/2]

static PrecisionMatrix< N > scale ( const ParameterVector< N > &  scales,
const PrecisionMatrix< N > &  precision 
)
inlinestatic

Return a copy of the precision scaled by the given factors in each parameter.

Definition at line 65 of file PrecisionMatrixUtil.h.

67 {
68 return transported(JacobianMatrixUtil::scale(1 / scales), precision);
69 }
static JacobianMatrix< N > scale(const ParameterVector< N > &scales)
Calculates the jacobian matrix for a scaling in each parameter.
static PrecisionMatrix< M > transported(const JacobianMatrix< N, M > &ambiguity, const PrecisionMatrix< N > &precision)
Return a copy of the precision matrix transported with the given back projection jacobian matrix.

◆ scale() [2/2]

static void scale ( const ParameterVector< N > &  scales,
PrecisionMatrix< N > &  precision 
)
inlinestatic

Scale the precision inplace by the given factors in each parameter.

Definition at line 58 of file PrecisionMatrixUtil.h.

59 {
60 return transport(JacobianMatrixUtil::scale(1 / scales), precision);
61 }
static void transport(const JacobianMatrix< N, N > &ambiguity, PrecisionMatrix< N > &precision)
Transport the precision matrix inplace with the given jacobian matrix.

◆ stackBlocks()

static PrecisionMatrix< N1+N2 > stackBlocks ( const PrecisionMatrix< N1 > &  block1,
const PrecisionMatrix< N2 > &  block2 
)
inlinestatic

Combines two precision matrices by putting them in two blocks on the diagonal of a larger matrix.

Definition at line 74 of file PrecisionMatrixUtil.h.

76 {
77 PrecisionMatrix < N1 + N2 > result;
78 mapToEigen(result) << mapToEigen(block1), Eigen::Matrix<double, N1, N2>::Zero(),
79 Eigen::Matrix<double, N2, N1>::Zero(), mapToEigen(block2);
80 return result;
81 }

◆ transport()

static void transport ( const JacobianMatrix< N, N > &  ambiguity,
PrecisionMatrix< N > &  precision 
)
inlinestatic

Transport the precision matrix inplace with the given jacobian matrix.

Definition at line 41 of file PrecisionMatrixUtil.h.

42 {
43 mapToEigen(precision) =
44 mapToEigen(ambiguity).transpose() * mapToEigen(precision) * mapToEigen(ambiguity);
45 }

◆ transported()

static PrecisionMatrix< M > transported ( const JacobianMatrix< N, M > &  ambiguity,
const PrecisionMatrix< N > &  precision 
)
inlinestatic

Return a copy of the precision matrix transported with the given back projection jacobian matrix.

Definition at line 50 of file PrecisionMatrixUtil.h.

52 {
53 return mapToEigen(ambiguity).transpose() * mapToEigen(precision) * mapToEigen(ambiguity);
54 }

The documentation for this struct was generated from the following file: