C++ main module for mmsd Package  1.0
MMSD_FluryGautschiGaussianLaw.h
Go to the documentation of this file.
1 #ifndef MMSD_FluryGautschiGaussianLaw_H
2 #define MMSD_FluryGautschiGaussianLaw_H
3 
4 
5 #include "MMSD_GaussianLaw.h"
6 
7 
18  // ATTRIBUTES
19 public:
20 
22 
23 private:
24 
25  MMSD_IntegerFullMatrix mCombinations;
26  MMSD_DoubleFullMatrix mBestMatrix,mMatrix,mYM;
28 
29 
30 
31 protected:
32  // METHODS
33 
34  // CONSTRUCTORS
35 
38 
39 
40 
41  // DESTRUCTORS
42 
43 
46  virtual ~MMSD_FluryGautschiGaussianLaw(void);
47 
48 
49 
50 public:
51  //----------------
52  // NEW constructors
53  // ---------------
54 
57  inline static SP::MMSD_FluryGautschiGaussianLaw New() {
58  return New(6,1.e-16);
59  }
62  inline static SP::MMSD_FluryGautschiGaussianLaw New(const int& nFGIterations,const double& minEigenValue) {
63  SP::MMSD_FluryGautschiGaussianLaw p(new MMSD_FluryGautschiGaussianLaw(),
65  p->setThis(p);
66  p->setMaxIterationsNumber(nFGIterations);
67  p->setMinEigenValue(minEigenValue);
68  return p;
69  }
70 
71  // -----------------
72  // SET & GET Methods
73  // -----------------
74 
78  inline void setMaxIterationsNumber(const int& n) {
79  mMaxIterationsNumber=n;
80  };
83  inline int getMaxIterationsNumber() const {
84  return mMaxIterationsNumber;
85  };
86 
87 
88 protected:
89 
90 
91 public:
96  virtual void restore(const MMSD_DoubleFullMatrix& Y) {
98 
99  int nProperties=Y.getColumnsNumber();
100  if (nProperties>1) mCombinations.computeCombinations(2,nProperties);
101 
102 
103  }
104 
114  virtual void initialize(const int& clusterIndex,
115  const int& samplesNumber,
116  const MMSD_IntegerVector& clustersIndex,
117  const MMSD_DoubleFullMatrix& Y) {
118  MMSD_GaussianLaw::initialize(clusterIndex,samplesNumber,clustersIndex,Y);
119 
120 
121  //compute the combinations
122  int nProperties=Y.getColumnsNumber();
123  if (nProperties>1) mCombinations.computeCombinations(2,nProperties);
124 
125 
126 
127  }
128 
129  // -----------------------------
130  // Parameters estimation methods
131  // ------------------------------
132 
133 private:
163  void updateCovarianceDecompositionMatrix(const MMSD_DoubleFullMatrix& Y,
164  const MMSD_DoubleVector& Diag,
165  const MMSD_DoubleVector& mean,
166  const MMSD_DoubleFullMatrix& W,
167  const MMSD_DoubleVector& probs,
168  MMSD_IntegerFullMatrix& combinations,
169  MMSD_DoubleFullMatrix& workOptimalMatrix,
170  MMSD_DoubleFullMatrix& workMatrix,
171  MMSD_DoubleFullMatrix& workYMatrix,
173  MMSD_DoubleVector& work,
176  const int& maxIterationsNumber);
177 
198  static void updateCovarianceDecompositionMatrix(const MMSD_DoubleFullMatrix& Y,
199  MMSD_IntegerFullMatrix& combinations,
202  const MMSD_DoubleVector& Diag,
203  const MMSD_DoubleFullMatrix& W,
204  const MMSD_DoubleVector& mean,
206  MMSD_DoubleVector& work,
207  const MMSD_DoubleVector& probs);
208 
209 
238  static void computeGStepForFluryGautschiAlgorithm(const int& C0,const int& C1,
239  const MMSD_DoubleFullMatrix& YP,
240  const MMSD_DoubleFullMatrix& P,
241  const MMSD_DoubleFullMatrix& W,
242  const MMSD_DoubleVector& D,
243  const MMSD_DoubleVector& probs,
244  const MMSD_DoubleVector& mean,
245  MMSD_DoubleVector& work,
247 
265  static double computeQuality(const MMSD_DoubleFullMatrix& YP,
266  const MMSD_DoubleFullMatrix& P,
267  const MMSD_DoubleVector& D,
268  const MMSD_DoubleVector& mean,
269  const MMSD_DoubleFullMatrix& W,
270  const MMSD_DoubleVector& probs);
271 
272 
273 
274 protected:
275 
297  const MMSD_DoubleVector& Diag,
298  const MMSD_DoubleVector& mean,
299  const MMSD_DoubleFullMatrix& W,
300  const MMSD_DoubleVector& probs,
302  MMSD_DoubleFullMatrix& YP) {
303 
304  updateCovarianceDecompositionMatrix(Y,Diag,mean,
305  W,probs,
306  mCombinations,mBestMatrix,mMatrix,mYM,mQ,getWork(),
307  P,YP,getMaxIterationsNumber());
308 
309  }
310 
311 
312  // ----------------------
313  // String representation
314  // ----------------------
315 public:
318  virtual tString toString() const {
320  return ret;
321  }
322 
323 };
324 
325 #endif
virtual void initialize(const int &clusterIndex, const int &samplesNumber, const MMSD_IntegerVector &clustersIndex, const MMSD_DoubleFullMatrix &Y)
initialization of the parameters opf the law
Definition: MMSD_FluryGautschiGaussianLaw.h:114
static SP::MMSD_FluryGautschiGaussianLaw New()
create an instance of gaussian law
Definition: MMSD_FluryGautschiGaussianLaw.h:57
MMSD_DoubleVector & getWork()
get work vector
Definition: MMSD_GaussianLaw.h:72
int getMaxIterationsNumber() const
get the max iterations number for the Fleury Gautschi algorithm
Definition: MMSD_FluryGautschiGaussianLaw.h:83
This class describes the FullMatrix class.
Definition: MMSD_DoubleFullMatrix.h:17
virtual tString toString() const
turn the class into string
Definition: MMSD_GaussianLaw.h:172
virtual ~MMSD_FluryGautschiGaussianLaw(void)
destroy an object.
Definition: MMSD_FluryGautschiGaussianLaw.cpp:15
This class is a Gaussian Law inherits from MMSD_Law.
Definition: MMSD_GaussianLaw.h:21
virtual void initialize(const int &clusterIndex, const int &samplesNumber, const MMSD_IntegerVector &clustersIndex, const MMSD_DoubleFullMatrix &properties)
initialization of the parameters opf the law
Definition: MMSD_Law.cpp:59
MMSD_FluryGautschiGaussianLaw(void)
create an object
Definition: MMSD_FluryGautschiGaussianLaw.cpp:9
int computeCombinations(const int &p, const int &n)
compute the combinaison of P elements among N It creates a matrix of size (C_N^P x P) the column i is...
Definition: MMSD_IntegerFullMatrix.cpp:20
virtual void updateCovarianceDecompositionMatrix(const MMSD_DoubleFullMatrix &Y, const MMSD_DoubleVector &Diag, const MMSD_DoubleVector &mean, const MMSD_DoubleFullMatrix &W, const MMSD_DoubleVector &probs, MMSD_DoubleFullMatrix &P, MMSD_DoubleFullMatrix &YP)
pdate the decomposition matrix of the covariance parameters
Definition: MMSD_FluryGautschiGaussianLaw.h:296
int mMaxIterationsNumber
Definition: MMSD_FluryGautschiGaussianLaw.h:21
Definition: MMSD_DoubleVector.h:16
virtual void restore(const MMSD_DoubleFullMatrix &properties)
restore the unstored values after a backup
Definition: MMSD_Law.cpp:50
Definition: MMSD_IntegerVector.h:15
This class describes the FullMatrix class.
Definition: MMSD_IntegerFullMatrix.h:17
void setMaxIterationsNumber(const int &n)
set the max iterations number for the Fleury Gautschi algorithm By default set to 6 ...
Definition: MMSD_FluryGautschiGaussianLaw.h:78
DEFINE_SPTR(MMSD_FluryGautschiGaussianLaw)
#define tString
Definition: types.h:49
virtual void restore(const MMSD_DoubleFullMatrix &Y)
restore the unstored values after a backup
Definition: MMSD_FluryGautschiGaussianLaw.h:96
virtual tLVectorIndex getColumnsNumber() const
get the columns number of the matrix from view
Definition: LAP_DoubleFullGeneralMatrix.h:371
virtual tString toString() const
turn the class into string
Definition: MMSD_FluryGautschiGaussianLaw.h:318
This class is aFlury Gautschi Gaussian Law.
Definition: MMSD_FluryGautschiGaussianLaw.h:16
static SP::MMSD_FluryGautschiGaussianLaw New(const int &nFGIterations, const double &minEigenValue)
create an instance of gaussian law
Definition: MMSD_FluryGautschiGaussianLaw.h:62
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:106