00001 #ifndef PCA_H_ 00002 #define PCA_H_ 00003 00004 #include <Matrix.h> 00005 #include <vector> 00006 00007 using namespace std; 00008 00010 class PCA 00011 { 00012 00013 public: 00014 00020 PCA(double ** data=0, int rows=0, int cols=0); 00021 00023 virtual ~PCA(); 00024 00029 void LoadData(double ** data, int rows, int cols); 00030 00034 void PerformPCA(bool center = true, bool scale = false); 00035 00038 void GetPCScores(Matrix<double> *scores); 00039 00042 void GetPCLoadings(Matrix<double> *loadings); 00043 00046 void GetEigenvalues(vector<double> *eigenvalues); 00047 00050 void GetMean(vector<double> *mean); 00051 00054 void GetVariance(vector<double> *var); 00055 00058 void GetCumulativeVariance(vector<double> *cumvar); 00059 00062 void GetEigenvectors(vector<vector<double> > *eigenvectors); 00063 00066 bool IsCalculated(); 00067 00068 00069 private: 00070 00071 bool m_calculated; 00072 int m_rows; 00073 int m_cols; 00074 Matrix<double> m_data; 00075 Matrix<double> m_PCScores; 00076 Matrix<double> m_PCLoadings; 00077 vector<double> m_eigenvalues; 00078 vector<vector<double> > m_eigenvectors; 00079 vector<double> m_variance; 00080 vector<double> m_mean; 00081 }; 00082 00083 00084 #endif