mixmod  3.2.0
Mixture models for clustering and classification
 All Classes Namespaces Files Functions Variables Enumerations Friends
Matrix.h
1 /***************************************************************************
2  SRC/mixmod/Matrix/Matrix.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 XEMMATRIX_H
26 #define XEMMATRIX_H
27 
28 #include "mixmod/Utilities/Util.h"
29 
30 namespace XEM {
31 
32 // pre-declaration
33 class GeneralMatrix;
34 class DiagMatrix;
35 
41 class Matrix {
42 
43 public:
44 
46  Matrix();
47 
48  Matrix(int64_t pbDimension);
49 
50  Matrix(Matrix * A);
51 
53  virtual ~Matrix();
54 
55  int64_t getPbDimension();
56 
57  // TODO static
58  int64_t _s_pbDimension;
59 
60 
62  virtual void inverse(Matrix * & A) = 0;
63 
64  virtual void compute_product_Lk_Wk(Matrix* Wk, double L) = 0;
65 
67  virtual double norme(double * xMoinsMean) = 0;
68 
70  virtual double determinant(Exception& errorType) = 0;
71 
73  virtual double computeTrace() = 0;
74 
76  virtual void equalToMatrixDividedByDouble(Matrix * A, double d) = 0;
77 
79  virtual void equalToMatrixMultiplyByDouble(Matrix*D, double d) = 0;
80 
81 
83  virtual void add(double * xMoinsMean, double cik) = 0;
84 
85  // add : diag( cik * xMoinsMean * xMoinsMean' ) to this
86  //virtual void addDiag(double * xMoinsMean, double cik) = 0;
87 
89  virtual void operator=(const double& d) = 0;
91  virtual void operator/=(const double& d) = 0;
93  virtual void operator*=(const double& d) = 0;
95  virtual void operator+=(Matrix* M) = 0;
97  virtual void operator=(Matrix* M) = 0;
98 
99 
100  void edit(std::ostream& flux, std::string before);
102  virtual void input(std::ifstream & fi) = 0;
103  virtual void input(double ** variances) = 0;
104 
105  // pour ne plus faire de transtypages
106 
108  virtual double putSphericalValueInStore(double & store) = 0;
110  virtual double addSphericalValueInStore(double & store) = 0;
111 
112  virtual double getSphericalStore() = 0;
113 
115  virtual double* putDiagonalValueInStore(double * store) = 0;
117  virtual double* addDiagonalValueInStore(double * store) = 0;
118 
119  virtual double* getDiagonalStore() = 0;
120 
122  virtual double* putSymmetricValueInStore(double * store) = 0;
124  virtual double* addSymmetricValueInStore(double * store) = 0;
125 
126  virtual double* getSymmetricStore() = 0;
127 
129  virtual double* putGeneralValueInStore(double * store) = 0;
131  virtual double* addGeneralValueInStore(double * store) = 0;
132 
133  virtual double* getGeneralStore() = 0;
134 
135  virtual double** storeToArray() const = 0;
136 
138  virtual double detDiag(Exception& errorType) = 0;
139 
141  virtual void computeSVD(DiagMatrix* & S, GeneralMatrix* & O) = 0;
142 
143  virtual void compute_as__multi_O_S_O(double multi, GeneralMatrix* & O, DiagMatrix *& S) = 0;
144  virtual double trace_this_O_Sm1_O(GeneralMatrix* & O, DiagMatrix* & S) = 0;
145  virtual double compute_trace_W_C(Matrix * C) = 0;
146  virtual void computeShape_as__diag_Ot_this_O(DiagMatrix* & Shape, GeneralMatrix* & Ori, double diviseur = 1.0) = 0;
147  // temporary table of Size pbDimension, comes from XEMGaussianData
148  // used in norme in the General case
149  double * _tmpTab;
150 
152  virtual void setSymmetricStore(double * store) = 0;
153  virtual void setGeneralStore(double * store) = 0;
154  virtual void setDiagonalStore(double * store) = 0;
155  virtual void setSphericalStore(double store) = 0;
156 };
157 
158 inline int64_t Matrix::getPbDimension() {
159  return _s_pbDimension;
160 }
161 
162 }
163 
164 #endif
class XEMDiagMatrix
Definition: DiagMatrix.h:40
class GeneralMatrix
Definition: GeneralMatrix.h:40
virtual void equalToMatrixDividedByDouble(Matrix *A, double d)=0
this will be A / d
virtual void inverse(Matrix *&A)=0
fill this with the inverse matrix of A
virtual double * addDiagonalValueInStore(double *store)=0
Add store of a diagonal matrix.
virtual void add(double *xMoinsMean, double cik)=0
add : cik * xMoinsMean * xMoinsMean' to this
virtual double addSphericalValueInStore(double &store)=0
add store of a spherical matrix
virtual double norme(double *xMoinsMean)=0
compute (x - mean)' this (x - mean)
Definition: Exception.h:42
virtual double * addGeneralValueInStore(double *store)=0
Add store of a diagonal matrix in a diagonal one.
virtual double determinant(Exception &errorType)=0
compute determinant
virtual void computeSVD(DiagMatrix *&S, GeneralMatrix *&O)=0
compute singular vector decomposition
Matrix()
Default constructor.
Definition: Matrix.cpp:32
virtual double * putDiagonalValueInStore(double *store)=0
Return store of a diagonal matrix.
virtual void operator/=(const double &d)=0
this = this / (d * Identity)
virtual double putSphericalValueInStore(double &store)=0
return store of a spherical matrix
virtual double * addSymmetricValueInStore(double *store)=0
Add store of a diagonal matrix in a diagonal one.
virtual void operator=(const double &d)=0
this = d * Identity
virtual void operator*=(const double &d)=0
this = this * (d * Identity)
virtual double * putSymmetricValueInStore(double *store)=0
Return store of a diagonal matrix.
Constants definitions, various utilities to describe models, and others...
virtual void operator+=(Matrix *M)=0
this = this + matrix
virtual double * putGeneralValueInStore(double *store)=0
Return store of a diagonal matrix.
virtual ~Matrix()
Desctructor.
Definition: Matrix.cpp:47
virtual double computeTrace()=0
compute trace
virtual void input(std::ifstream &fi)=0
read matrix from an input file
virtual double detDiag(Exception &errorType)=0
gives : det(diag(this))
Base class for Matrix.
Definition: Matrix.h:41
virtual void setSymmetricStore(double *store)=0
set store
virtual void equalToMatrixMultiplyByDouble(Matrix *D, double d)=0
this will be A * d