7 #include "../../../App/ApplicationTools.h" 8 #include "../../Matrix/EigenValue.h" 9 #include "../../Matrix/Matrix.h" 10 #include "../../Matrix/MatrixTools.h" 18 const vector<double>& rowWeights,
19 const vector<double>& colWeights,
21 double tol,
bool verbose) :
22 rowWeights_(rowWeights),
23 colWeights_(colWeights),
32 check_(matrix, rowWeights, colWeights, verbose);
38 const vector<double>& rowWeights,
39 const vector<double>& colWeights,
45 if (rowWeights.size() != rowNb)
46 throw Exception(
"DualityDiagram::check_. The number of row weigths has to be equal to the number of rows!");
47 if (colWeights.size() != colNb)
48 throw Exception(
"DualityDiagram::check_. The number of column weigths has to be equal to the number of columns!");
51 for (vector<double>::const_iterator it = rowWeights.begin(); it != rowWeights.end(); it++)
54 throw Exception(
"DualityDiagram::check_. All row weights have to be positive");
58 for (vector<double>::const_iterator it = colWeights.begin(); it != colWeights.end(); it++)
61 throw Exception(
"DualityDiagram::check_. All column weights have to be positive");
68 const vector<double>& rowWeights,
69 const vector<double>& colWeights,
71 double tol,
bool verbose)
73 check_(matrix, rowWeights, colWeights, verbose);
81 double tol,
bool verbose)
87 bool transpose = (rowNb < colNb);
91 for (
unsigned int i = 0; i <
rowWeights_.size(); i++)
101 for (
unsigned int i = 0; i <
colWeights_.size(); i++)
120 throw Exception(
"DualityDiagram (constructor). The variance-covariance or correlation matrix should be symmetric...");
135 throw Exception(
"DualityDiagram (constructor). The number of axes to keep must be positive.");
146 vector<double> tmpEigenValues(
nbAxes_);
168 for (
size_t i = 0; i < dval.size(); i++)
173 vector<double> invDval(
nbAxes_);
174 for (
size_t i = 0; i < invDval.size(); i++)
182 vector<double> tmpColWeights(colNb);
183 for (
unsigned int i = 0; i <
colWeights_.size(); i++)
216 vector<double> tmpRowWeights(rowNb);
217 for (
unsigned int i = 0; i <
rowWeights_.size(); i++)
The matrix template interface.
void setData(const Matrix< double > &matrix, const std::vector< double > &rowWeights, const std::vector< double > &colWeights, unsigned int nbAxes, double tol=0.0000001, bool verbose=true)
Set the data and perform computations.
RowMatrix< double > eigenVectors_
RowMatrix< double > colCoord_
virtual ~DualityDiagram()
std::vector< double > colWeights_
RowMatrix< double > rowCoord_
RowMatrix< double > ppalAxes_
std::vector< double > eigenValues_
virtual size_t getNumberOfColumns() const =0
const RowMatrix< Real > & getV() const
Return the eigenvector matrix.
void resize(size_t nRows, size_t nCols)
Resize the matrix.
void check_(const Matrix< double > &matrix, const std::vector< double > &rowWeights, const std::vector< double > &colWeights, unsigned int nbAxes)
Computes eigenvalues and eigenvectors of a real (non-complex) matrix.
std::vector< double > rowWeights_
Exception base class. Overload exception constructor (to control the exceptions mechanism). Destructor is already virtual (from std::exception)
size_t getNumberOfRows() const
const std::vector< Real > & getRealEigenValues() const
Return the real parts of the eigenvalues.
RowMatrix< double > ppalComponents_
virtual size_t getNumberOfRows() const =0
DualityDiagram()
Build an empty DualityDiagram object.
size_t getNumberOfColumns() const
void compute_(const Matrix< double > &matrix, double tol, bool verbose)