GPLIB++
GradFunc.h
Go to the documentation of this file.
1 #ifndef GRADFUNC_H_
2 #define GRADFUNC_H_
3 
4 #include "VecMat.h"
5 #include "GeneralObjective.h"
6 
7 namespace ublas = boost::numeric::ublas;
8 
9 //! Calculate the model gradient vector df(m)/dm
10 gplib::rvec CalcGradient(GeneralObjective &Objective, const gplib::rvec &Model);
11 //! Calculate the model sensitivity matrix
12 gplib::rmat CalcPartialDerivs(GeneralObjective &Objective,
13  const gplib::rvec &Model, const gplib::rvec varfactor);
14 
15 //! The class ModelAnalysis is used to calculate resolution matrix, nullspace and other parameters for model analyis
16 
17 /*! We assume that the data characteristics as indicated by the CGeneralObjective object do not change, but we want
18  * the possibility to analyse several different models
19  */
21  {
22 private:
23  bool haveModel;
24  bool haveSVD;
25  bool changedThreshold;
26  double SVDThreshold;
27  GeneralObjective &Objective;
28  gplib::rvec Model;
29  gplib::rmat OldSensitivityMatrix;
30  gplib::rmat SensitivityMatrix;
31  gplib::rmat SensitivityInv;
32  gplib::rvec s;
33  gplib::rmat u, vt;
34  gplib::rmat vnull, unull;
35  gplib::rmat sinv;
36  gplib::rvec varfactor;
37  void CalcSensitivityMatrix();
38  void CalcSVD();
39  void ApplyThreshold();
40 public:
41  void SetVariationFactor(const gplib::rvec varfac)
42  {
43  varfactor = varfac;
44  }
45  void SetModel(const gplib::rvec &TheModel);
46  void SetRelativeSVDThreshold(const double t)
47  {
48  changedThreshold = true;
49  SVDThreshold = t;
50  }
51  const gplib::rmat &GetSensitivityMatrix()
52  {
53  CalcSensitivityMatrix();
54  return SensitivityMatrix;
55  }
56  const gplib::rmat &GetSensitivityInverse() const
57  {
58  return SensitivityInv;
59  }
60  gplib::rmat GetModelCorrelation(const gplib::rmat &DataCovar);
61  gplib::rmat GetModelResolution();
62  gplib::rmat GetDataResolution();
63  gplib::rmat GetModelCovariance(const gplib::rmat &DataCovar);
64  gplib::rmat GetModelNullspace();
65  gplib::rvec GetSingularValues();
66  ModelAnalysis(GeneralObjective &TheObjective) :
67  haveModel(false), haveSVD(false), changedThreshold(true), Objective(
68  TheObjective), SVDThreshold(0.0)
69  {
70  }
71  ;
73  {
74  }
75  ;
76  };
77 #endif /*GRADFUNC_H_*/
gplib::rmat GetModelCorrelation(const gplib::rmat &DataCovar)
Definition: GradFunc.cpp:181
gplib::rvec CalcGradient(GeneralObjective &Objective, const gplib::rvec &Model)
Calculate the model gradient vector df(m)/dm.
Definition: GradFunc.cpp:6
gplib::rmat CalcPartialDerivs(GeneralObjective &Objective, const gplib::rvec &Model, const gplib::rvec varfactor)
Calculate the model sensitivity matrix.
Definition: GradFunc.cpp:42
gplib::rmat GetDataResolution()
Definition: GradFunc.cpp:160
gplib::rmat GetModelNullspace()
Definition: GradFunc.cpp:165
void SetVariationFactor(const gplib::rvec varfac)
Definition: GradFunc.h:41
gplib::rvec GetSingularValues()
Definition: GradFunc.cpp:201
~ModelAnalysis()
Definition: GradFunc.h:72
void SetModel(const gplib::rvec &TheModel)
Definition: GradFunc.cpp:87
gplib::rmat GetModelCovariance(const gplib::rmat &DataCovar)
The calculation of the Model Covariance is based on Menke, p. 122 formula 7.37.
Definition: GradFunc.cpp:172
const gplib::rmat & GetSensitivityMatrix()
Definition: GradFunc.h:51
void SetRelativeSVDThreshold(const double t)
Definition: GradFunc.h:46
ModelAnalysis(GeneralObjective &TheObjective)
Definition: GradFunc.h:66
gplib::rmat GetModelResolution()
Definition: GradFunc.cpp:155
The class ModelAnalysis is used to calculate resolution matrix, nullspace and other parameters for mo...
Definition: GradFunc.h:20
const gplib::rmat & GetSensitivityInverse() const
Definition: GradFunc.h:56