File: normalEquationRegularizationGeneralized.h

package info (click to toggle)
groops 0%2Bgit20250907%2Bds-1
  • links: PTS, VCS
  • area: non-free
  • in suites: forky, sid
  • size: 11,140 kB
  • sloc: cpp: 135,607; fortran: 1,603; makefile: 20
file content (75 lines) | stat: -rw-r--r-- 3,039 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/***********************************************/
/**
* @file normalEquationRegularizationGeneralized.h
*
* @brief Regularization with sum of symmetric matrices.
* @see NormalEquation
*
* @author Andreas Kvas
* @date 2010-02-10
*
*/
/***********************************************/

#ifndef __GROOPS_NORMALEQUATIONREGULARIZATIONGENERALIZED__
#define __GROOPS_NORMALEQUATIONREGULARIZATIONGENERALIZED__

// Latex documentation
#ifdef DOCSTRING_NormalEquation
static const char *docstringNormalEquationRegularizationGeneralized = R"(
\subsection{RegularizationGeneralized}

Generalized regularization which is represented by the observation equation
\begin{equation}
\mathbf{x}_0 = \mathbf{I} \mathbf{x} + \mathbf{v}, \mathbf{v} \sim \mathcal{N}(0, \sum_k \sigma^2_k \mathbf{V}_k).
\end{equation}

There are no requirements for partial covariance matrices $\mathbf{V}_k$ except for them being symmetric.
The accumulated covariance matrix $\sum_k \sigma^2_k \mathbf{V}_k$ must be positive definite however.
The variance components $\sigma^2_k$ are estimated during the adjustment process and are assumed to be positive.
All \configFile{inputfilePartialCovarianceMatrix}{matrix} must be of same size
and must match the dimension of \configFile{inputfileBiasMatrix}{matrix}
(if provided, otherwise a zero vector of appropriate dimensions is created).

The parameter \config{aprioriSigma} determines the initial variance factor for the partial covariance matrices. Either one $\sigma_0$ can be
supplied or one for each $\mathbf{V}_k$.

The regularization matrix can be applied to a subset of parameters by adjusting \config{startIndex}.
)";
#endif

/***********************************************/

#include "classes/normalEquation/normalEquation.h"

/***** CLASS ***********************************/

/** @brief Regularization with sum of symmetric matrices.
* @ingroup normalEquationGroup
* @see NormalEquation */
class NormalEquationRegularizationGeneralized : public NormalEquationBase
{
  std::vector<FileName> fileNamesCovariance;
  Matrix                bias;
  UInt                  startIndex, startBlock;
  UInt                  paraCount, rhsCount;
  std::vector<Double>   sigma2;
  MatrixDistributed     Sigma; // = sum_i sigma2_i * V_i
  std::vector<MatrixDistributed> V;

public:
  NormalEquationRegularizationGeneralized(Config &config);

  UInt   rightHandSideCount() const override {return rhsCount;}
  UInt   parameterCount()     const override {return paraCount + startIndex;}
  void   parameterNames(std::vector<ParameterName> &/*names*/) const override {}
  void   init(MatrixDistributed &normals, UInt rhsCount) override;
  Bool   addNormalEquation(UInt rhsNo, const const_MatrixSlice &x, const const_MatrixSlice &Wz,
                           MatrixDistributed &normals, Matrix &n, Vector &lPl, UInt &obsCount) override;
  Vector contribution(MatrixDistributed &Cov) override;
  std::vector<Double> varianceComponentFactors() const override {return sigma2;}
};

/***********************************************/

#endif