File: normalsShortTimeStaticLongTime.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 (89 lines) | stat: -rw-r--r-- 3,693 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/***********************************************/
/**
* @file normalsShortTimeStaticLongTime.h
*
* @brief Normal equations with short and long time gravity variations.
*
* @author Torsten Mayer-Guerr
* @date 2020-11-29
*
*/
/***********************************************/

#ifndef __GROOPS_NORMALSSHORTTIMESTATICLONGTIME__
#define __GROOPS_NORMALSSHORTTIMESTATICLONGTIME__

#include "base/import.h"
#include "parallel/matrixDistributed.h"
#include "classes/observation/observation.h"

/***** TYPES ***********************************/

class ParameterSelector;
class ParametrizationTemporal;
typedef std::shared_ptr<ParameterSelector>       ParameterSelectorPtr;
typedef std::shared_ptr<ParametrizationTemporal> ParametrizationTemporalPtr;

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

/** @brief Normal equations with short and long time gravity variations.
* @ingroup miscGroup */
class NormalsShortTimeStaticLongTime : public MatrixDistributed
{
public:
  Matrix n;         // right hand sides
  Vector lPl;       // =l'Pl, weighted norm of the observations
  UInt   obsCount;  // number of observations

  std::vector<ParameterName>       parameterNames;
  std::vector<std::vector<UInt>>   indexA; // for each interval
  std::vector<std::vector<UInt>>   indexN; // for each interval
  UInt                             blockIndexStatic;
  std::vector<UInt>                blockIndexShortTime;
  UInt                             blockCountTemporal;
  std::vector<UInt>                blockIndexTemporal; // static + for each temporal
  std::vector<MatrixDistributed>   normalsTemporal;
  std::vector<Matrix>              nTemporal;
  std::vector<std::vector<Double>> factorTemporal;

  void init(ObservationPtr observation, const std::vector<Time> &timesInterval,
            UInt defaultBlockSize, Parallel::CommunicatorPtr comm, Bool sortStateBeforeGravityParameter,
            UInt countShortTimeParameters, ParameterSelectorPtr parameterShortTime,
            ParametrizationTemporalPtr temporal=nullptr, ParameterSelectorPtr parameterTemporal=nullptr);

  /// Allocate memory of matrix blocks.
  void setBlocks(const std::vector<UInt> &arcsInterval);

  /// Fill all matrix blocks with zero.
  void setNull();

  /** @brief Add observation equations to the normal system.
  * The design matrix @p A must contain only parameters valid in interval @p idInterval
  * (Computed with @a setInterval()).
  * The input matrices @p l, @p A, and @p B might be destroyed. */
  void accumulate(UInt idInterval, Matrix &l, Matrix &A, Matrix &B);

  /// Reduce the system of normal equations.
  void reduceSum(Bool timing=TRUE);

  void addShortTimeNormals(Double sigma2, const std::vector<std::vector<std::vector<Matrix>>> &normalsShortTime);

  void regularizeUnusedParameters(UInt countBlock);

  Double solve(Matrix &x, Matrix &Wz);

  /** @brief Compute the standard devitiations of the parameter vector.
  * (The sqrt of the diagonals of inverse normal matrix). The normals must be given as cholesky decomposition (with @a solve).
  * On oputput the normal matrix contains the inverse of cholesky matrix. */
  Vector parameterStandardDeviation();

  Double estimateShortTimeNormalsVariance(Double sigma2, const std::vector<std::vector<std::vector<Matrix>>> &normalsShortTime,
                                          const_MatrixSliceRef x, const_MatrixSliceRef Wz) const;
  /** @brief Computes Ax = factor*A*x.
  * The design matrix @p A contains only parameters valid in interval @p idInterval. */
  void designMatMult(UInt idInterval, Double factor, const_MatrixSliceRef A, const_MatrixSliceRef x, MatrixSliceRef Ax);
};

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

#endif