5 #include "../../Matrix/Matrix.h" 6 #include "../../Matrix/MatrixTools.h" 16 double tol,
bool verbose) :
24 for (
size_t i = 0; i < nRow; i++)
26 for (
unsigned int j = 0; j < nCol; j++)
29 throw Exception(
"CorrespondenceAnalysis (constructor). Negative value(s) in the input data. This is not allowed !");
36 throw Exception(
"CorrespondenceAnalysis (constructor). All frequencies in the input data are zero...");
41 vector<double> rowWeights(nRow);
42 vector<double> colWeights(nCol);
44 for (
size_t i = 0; i < nRow; i++)
46 for (
unsigned int j = 0; j < nCol; j++)
48 rowWeights[i] += dataTmp(i, j);
49 colWeights[j] += dataTmp(i, j);
53 vector<double> tmpRowWeigths(nRow);
54 vector<double> tmpColWeigths(nCol);
55 for (
size_t i = 0; i < rowWeights.size(); i++)
57 if (rowWeights[i] == 0.)
58 tmpRowWeigths[i] = 0.;
60 tmpRowWeigths[i] = 1. / rowWeights[i];
62 for (
size_t j = 0; j < colWeights.size(); j++)
64 if (colWeights[j] == 0.)
65 tmpColWeigths[j] = 0.;
67 tmpColWeigths[j] = 1. / colWeights[j];
76 setData(weightedData, rowWeights, colWeights, nbAxes, tol, verbose);
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.
virtual size_t getNumberOfColumns() const =0
Exception base class. Overload exception constructor (to control the exceptions mechanism). Destructor is already virtual (from std::exception)
CorrespondenceAnalysis(const Matrix< double > &data, unsigned int nbAxes, double tol=0.0000001, bool verbose=true)
Build a new CorrespondenceAnalysis object.
virtual size_t getNumberOfRows() const =0
The core class of a multivariate analysis.