mixmod  3.2.0
Mixture models for clustering and classification
 All Classes Namespaces Files Functions Variables Enumerations Friends
DiagMatrix.h
1 /***************************************************************************
2  SRC/mixmod/Matrix/DiagMatrix.h description
3  copyright : (C) MIXMOD Team - 2001-2016
4  email : contact@mixmod.org
5  ***************************************************************************/
6 
7 /***************************************************************************
8  This file is part of MIXMOD
9 
10  MIXMOD is free software: you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  MIXMOD is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with MIXMOD. If not, see <http://www.gnu.org/licenses/>.
22 
23  All informations available on : http://www.mixmod.org
24 ***************************************************************************/
25 #ifndef XEMDIAGMATRIX_H
26 #define XEMDIAGMATRIX_H
27 
28 #include "mixmod/Matrix/Matrix.h"
29 
30 namespace XEM {
31 
32 // pre-declaration
33 class GeneralMatrix;
34 
40 class DiagMatrix : public Matrix {
41 
42 public:
43 
45  DiagMatrix();
46 
49  DiagMatrix(int64_t pbDimension, double d = 1.0);
50 
52 
54  virtual ~DiagMatrix();
55 
57  double determinant(Exception& errorType);
59  double * getStore();
61  void inverse(Matrix * & A);
62 
63  void compute_product_Lk_Wk(Matrix* Wk, double L);
64 
66  double norme(double * xMoinsMean);
67 
69  void equalToMatrixDividedByDouble(Matrix * A, double d);
70 
72  void equalToMatrixMultiplyByDouble(Matrix*D, double d);
73 
75  void computeSVD(DiagMatrix* & S, GeneralMatrix* & O);
76 
78  double computeTrace();
79 
81  void add(double * xMoinsMean, double cik);
82 
83  // add : diag( cik * xMoinsMean * xMoinsMean' ) to this
84  //void addDiag(double * xMoinsMean, double cik);
85 
87  void operator=(const double& d);
89  void operator/=(const double& d);
91  void operator*=(const double& d);
93  void operator+=(Matrix* M);
95  void operator=(Matrix* M);
96 
98  double putSphericalValueInStore(double & store);
100  double addSphericalValueInStore(double & store);
101 
102  double getSphericalStore();
103 
105  double* putDiagonalValueInStore(double * store);
107  double* addDiagonalValueInStore(double * store);
108 
109  double* getDiagonalStore();
110 
112  double* putSymmetricValueInStore(double * store);
114  double* addSymmetricValueInStore(double * store);
115 
116  double* getSymmetricStore();
117 
119  double* putGeneralValueInStore(double * store);
121  double* addGeneralValueInStore(double * store);
122 
123  double* getGeneralStore();
124 
126  void input(std::ifstream & fi);
127  virtual void input(double ** variances);
128 
130  void setSymmetricStore(double * store);
131  void setGeneralStore(double * store);
132  void setDiagonalStore(double * store);
133  void setSphericalStore(double store);
134  double** storeToArray() const;
135 
137  double detDiag(Exception& errorType);
138 
139  void compute_as__multi_O_S_O(double multi, GeneralMatrix* & O, DiagMatrix *& S);
140  double trace_this_O_Sm1_O(GeneralMatrix* & O, DiagMatrix* & S);
141  double compute_trace_W_C(Matrix * C);
142  void computeShape_as__diag_Ot_this_O(DiagMatrix* & Shape, GeneralMatrix* & Ori, double diviseur = 1.0);
143 
145  void sortDiagMatrix();
146 
147 protected:
148 
149  double * _store;
150 
151 };
152 
153 inline double * DiagMatrix::getStore() {
154  return _store;
155 }
156 
157 inline void DiagMatrix::setSymmetricStore(double * store) {
158  THROW(OtherException, wrongMatrixType);
159 }
160 
161 inline void DiagMatrix::setGeneralStore(double * store) {
162  THROW(OtherException, wrongMatrixType);
163 }
164 
165 inline void DiagMatrix::setDiagonalStore(double * store) {
166  //_store = store;
167  recopyTab(store, _store, _s_pbDimension);
168 }
169 
170 inline void DiagMatrix::setSphericalStore(double store) {
171  THROW(OtherException, wrongMatrixType);
172 }
173 
174 }
175 
176 #endif
double * addDiagonalValueInStore(double *store)
Add store of a diagonal matrix in a diagonal one.
Definition: DiagMatrix.cpp:165
class XEMDiagMatrix
Definition: DiagMatrix.h:40
class GeneralMatrix
Definition: GeneralMatrix.h:40
double putSphericalValueInStore(double &store)
Return store of a spherical matrix in a diagonal one.
Definition: DiagMatrix.cpp:139
void operator*=(const double &d)
this = this * (d * Identity)
Definition: DiagMatrix.cpp:284
void setSymmetricStore(double *store)
set store
Definition: DiagMatrix.h:157
double * addGeneralValueInStore(double *store)
Add store of a diagonal matrix in a diagonal one.
Definition: DiagMatrix.cpp:206
void input(std::ifstream &fi)
read general matrix in an input file
Definition: DiagMatrix.cpp:300
double norme(double *xMoinsMean)
compute (x - mean)' this (x - mean)
Definition: DiagMatrix.cpp:109
Definition: OtherException.h:37
Definition: Exception.h:42
double * putDiagonalValueInStore(double *store)
Return store of a diagonal matrix.
Definition: DiagMatrix.cpp:158
void operator/=(const double &d)
this = this / (d * Identity)
Definition: DiagMatrix.cpp:276
double * putGeneralValueInStore(double *store)
Return store of a diagonal matrix.
Definition: DiagMatrix.cpp:202
double computeTrace()
compute trace of general matrix
Definition: DiagMatrix.cpp:214
void add(double *xMoinsMean, double cik)
add : cik * xMoinsMean * xMoinsMean' to this
Definition: DiagMatrix.cpp:242
void equalToMatrixDividedByDouble(Matrix *A, double d)
(this) will be A / d
Definition: DiagMatrix.cpp:224
void inverse(Matrix *&A)
compute inverse of diagonal matrix
Definition: DiagMatrix.cpp:77
void equalToMatrixMultiplyByDouble(Matrix *D, double d)
this = matrix * d
Definition: DiagMatrix.cpp:233
void operator=(const double &d)
set the value of (d x Identity) to this
Definition: DiagMatrix.cpp:267
double * putSymmetricValueInStore(double *store)
Return store of a diagonal matrix.
Definition: DiagMatrix.cpp:187
double * addSymmetricValueInStore(double *store)
Add store of a diagonal matrix in a diagonal one.
Definition: DiagMatrix.cpp:172
void sortDiagMatrix()
sort diagonal matrix in decreasing order
Definition: DiagMatrix.cpp:340
void operator+=(Matrix *M)
this = this + matrix
Definition: DiagMatrix.cpp:292
double addSphericalValueInStore(double &store)
Add store of a spherical matrix in a diagonal one.
Definition: DiagMatrix.cpp:149
double * getStore()
return store of diagonal matrix
Definition: DiagMatrix.h:153
void computeSVD(DiagMatrix *&S, GeneralMatrix *&O)
compute singular vector decomposition
Definition: DiagMatrix.cpp:210
virtual ~DiagMatrix()
Desctructor.
Definition: DiagMatrix.cpp:53
double determinant(Exception &errorType)
compute determinant of diagonal matrix
Definition: DiagMatrix.cpp:60
Base class for Matrix.
Definition: Matrix.h:41
double detDiag(Exception &errorType)
gives : det(diag(this))
Definition: DiagMatrix.cpp:336
DiagMatrix()
Default constructor.
Definition: DiagMatrix.cpp:34