00001 #ifndef GRADFUNC_H_ 00002 #define GRADFUNC_H_ 00003 00004 #include "VecMat.h" 00005 #include "GeneralObjective.h" 00006 00007 namespace ublas = boost::numeric::ublas; 00008 00009 //! Calculate the model gradient vector df(m)/dm 00010 gplib::rvec CalcGradient(GeneralObjective &Objective, const gplib::rvec &Model); 00011 //! Calculate the model sensitivity matrix 00012 gplib::rmat CalcPartialDerivs(GeneralObjective &Objective, const gplib::rvec &Model, const gplib::rvec varfactor); 00013 00014 //! The class ModelAnalysis is used to calculate resolution matrix, nullspace and other parameters for model analyis 00015 00016 /*! We assume that the data characteristics as indicated by the CGeneralObjective object do not change, but we want 00017 * the possibility to analyse several different models 00018 */ 00019 class ModelAnalysis{ 00020 private: 00021 bool haveModel; 00022 bool haveSVD; 00023 bool changedThreshold; 00024 double SVDThreshold; 00025 GeneralObjective &Objective; 00026 gplib::rvec Model; 00027 gplib::rmat OldSensitivityMatrix; 00028 gplib::rmat SensitivityMatrix; 00029 gplib::rmat SensitivityInv; 00030 gplib::rvec s; 00031 gplib::rmat u, vt; 00032 gplib::rmat vnull,unull; 00033 gplib::rmat sinv; 00034 gplib::rvec varfactor; 00035 void CalcSensitivityMatrix(); 00036 void CalcSVD(); 00037 void ApplyThreshold(); 00038 public: 00039 void SetVariationFactor(const gplib::rvec varfac){varfactor = varfac;} 00040 void SetModel(const gplib::rvec &TheModel); 00041 void SetRelativeSVDThreshold(const double t){changedThreshold = true; SVDThreshold = t; } 00042 const gplib::rmat &GetSensitivityMatrix(){CalcSensitivityMatrix(); return SensitivityMatrix;} 00043 const gplib::rmat &GetSensitivityInverse() const {return SensitivityInv;} 00044 gplib::rmat GetModelCorrelation(const gplib::rmat &DataCovar); 00045 gplib::rmat GetModelResolution(); 00046 gplib::rmat GetDataResolution(); 00047 gplib::rmat GetModelCovariance(const gplib::rmat &DataCovar); 00048 gplib::rmat GetModelNullspace(); 00049 gplib::rvec GetSingularValues(); 00050 ModelAnalysis(GeneralObjective &TheObjective):haveModel(false),haveSVD(false),changedThreshold(true),Objective(TheObjective),SVDThreshold(0.0){}; 00051 ~ModelAnalysis(){}; 00052 }; 00053 #endif /*GRADFUNC_H_*/
1.5.5