mixmod  3.2.0
Mixture models for clustering and classification
 All Classes Namespaces Files Functions Variables Enumerations Friends
SphericalMatrix.h
1 /***************************************************************************
2  SRC/mixmod/Matrix/SphericalMatrix.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 XEMSPHERICALMATRIX_H
26 #define XEMSPHERICALMATRIX_H
27 
28 #include "mixmod/Matrix/Matrix.h"
29 
30 namespace XEM {
31 
32 // pre-declaration
33 class GeneralMatrix;
34 class DiagMatrix;
35 
41 class SphericalMatrix : public Matrix {
42 
43 public:
44 
47 
50  SphericalMatrix(int64_t pbDimension, double initValue = 1.0);
51 
53 
55  virtual ~SphericalMatrix();
56 
58  double determinant(Exception& errorType);
59 
61  double getStore();
62 
63 
65  void inverse(Matrix * & A);
66 
67  void compute_product_Lk_Wk(Matrix* Wk, double L);
68 
70  void addToValue(double a);
71 
73  double norme(double * xMoinsMean);
74 
76  void equalToMatrixDividedByDouble(Matrix * A, double d);
77 
79  void equalToMatrixMultiplyByDouble(Matrix*D, double d);
80 
82  double computeTrace();
83 
84 
86  void add(double * xMoinsMean, double cik);
87 
89  void addDiag(double * xMoinsMean, double cik);
90 
92  void operator=(const double& d);
93 
95  void operator/=(const double& d);
96 
98  void operator*=(const double& d);
100  void operator+=(Matrix* M);
102  void operator=(Matrix* M);
103 
104 
106  void input(std::ifstream & fi);
107  virtual void input(double ** variances);
108 
110  double putSphericalValueInStore(double & store);
112  double addSphericalValueInStore(double & store);
113 
114  double getSphericalStore();
115 
117  double* putDiagonalValueInStore(double * store);
119  double* addDiagonalValueInStore(double * store);
120 
121  double* getDiagonalStore();
122 
124  double* putSymmetricValueInStore(double * store);
126  double* addSymmetricValueInStore(double * store);
127 
128  double* getSymmetricStore();
129 
131  double* putGeneralValueInStore(double * store);
133  double* addGeneralValueInStore(double * store);
134 
135  double* getGeneralStore();
136 
137 
139  void computeSVD(DiagMatrix* & S, GeneralMatrix* & O);
140 
141  void compute_as__multi_O_S_O(double multi, GeneralMatrix* & O, DiagMatrix *& S);
142  double trace_this_O_Sm1_O(GeneralMatrix* & O, DiagMatrix* & S);
143  double compute_trace_W_C(Matrix * C);
144  void computeShape_as__diag_Ot_this_O(DiagMatrix* & Shape, GeneralMatrix* & Ori, double diviseur = 1.0);
146  double detDiag(Exception& errorType);
147 
148  void setSymmetricStore(double * store);
149  void setGeneralStore(double * store);
150  void setDiagonalStore(double * store);
151  void setSphericalStore(double store);
152  double** storeToArray() const;
153 
154 protected:
155 
156  double _store;
157 };
158 
159 inline double SphericalMatrix::getStore() {
160  return _store;
161 }
162 
163 inline void SphericalMatrix::setSymmetricStore(double * store) {
164  THROW(OtherException, wrongMatrixType);
165 }
166 
167 inline void SphericalMatrix::setSphericalStore(double store) {
168  _store = store;
169 }
170 
171 inline void SphericalMatrix::setGeneralStore(double * store) {
172  THROW(OtherException, wrongMatrixType);
173 }
174 
175 inline void SphericalMatrix::setDiagonalStore(double * store) {
176  THROW(OtherException, wrongMatrixType);
177 }
178 
179 }
180 
181 #endif
double norme(double *xMoinsMean)
compute (x - mean)' this (x - mean)
Definition: SphericalMatrix.cpp:128
class XEMDiagMatrix
Definition: DiagMatrix.h:40
double * putGeneralValueInStore(double *store)
Return store of a diagonal matrix.
Definition: SphericalMatrix.cpp:244
class GeneralMatrix
Definition: GeneralMatrix.h:40
double putSphericalValueInStore(double &store)
return store of a spherical matrix
Definition: SphericalMatrix.cpp:218
void equalToMatrixDividedByDouble(Matrix *A, double d)
(this) will be A / d
Definition: SphericalMatrix.cpp:142
double addSphericalValueInStore(double &store)
add store of a spherical matrix
Definition: SphericalMatrix.cpp:223
Definition: OtherException.h:37
Definition: Exception.h:42
void computeSVD(DiagMatrix *&S, GeneralMatrix *&O)
compute general matrix SVD decomposition
Definition: SphericalMatrix.cpp:82
virtual ~SphericalMatrix()
Desctructor.
Definition: SphericalMatrix.cpp:50
double * addSymmetricValueInStore(double *store)
Add store of a diagonal matrix in a diagonal one.
Definition: SphericalMatrix.cpp:240
double computeTrace()
compute trace of spherical matrix
Definition: SphericalMatrix.cpp:119
void input(std::ifstream &fi)
read spherical matrix store in file
Definition: SphericalMatrix.cpp:252
SphericalMatrix()
Default constructor.
Definition: SphericalMatrix.cpp:35
double getStore()
return store of spherical matrix
Definition: SphericalMatrix.h:159
double * addDiagonalValueInStore(double *store)
Add store of a diagonal matrix in a diagonal one.
Definition: SphericalMatrix.cpp:232
double * putDiagonalValueInStore(double *store)
Return store of a diagonal matrix.
Definition: SphericalMatrix.cpp:228
void inverse(Matrix *&A)
inverse spherical matrix
Definition: SphericalMatrix.cpp:92
class XEMSphericalMatrix
Definition: SphericalMatrix.h:41
double detDiag(Exception &errorType)
gives : det(diag(this))
Definition: SphericalMatrix.cpp:282
void addDiag(double *xMoinsMean, double cik)
add : diag( cik * xMoinsMean * xMoinsMean' ) to this
Definition: SphericalMatrix.cpp:180
void setSymmetricStore(double *store)
set store
Definition: SphericalMatrix.h:163
double * addGeneralValueInStore(double *store)
Add store of a diagonal matrix in a diagonal one.
Definition: SphericalMatrix.cpp:248
void operator=(const double &d)
this = d * Identity
Definition: SphericalMatrix.cpp:195
void addToValue(double a)
add a to the value of this
Definition: SphericalMatrix.cpp:124
void equalToMatrixMultiplyByDouble(Matrix *D, double d)
(this) will be A * d
Definition: SphericalMatrix.cpp:86
double * putSymmetricValueInStore(double *store)
Return store of a diagonal matrix.
Definition: SphericalMatrix.cpp:236
Base class for Matrix.
Definition: Matrix.h:41
void operator+=(Matrix *M)
this = this + matrix
Definition: SphericalMatrix.cpp:210
void operator*=(const double &d)
this = this * (d * Identity)
Definition: SphericalMatrix.cpp:205
void add(double *xMoinsMean, double cik)
add : cik * xMoinsMean * xMoinsMean' to this
Definition: SphericalMatrix.cpp:165
void operator/=(const double &d)
this = this / (d * Identity)
Definition: SphericalMatrix.cpp:200
double determinant(Exception &errorType)
compute determinant of spherical matrix
Definition: SphericalMatrix.cpp:53