#ifndef _theplu_yat_utility_pca_
#define _theplu_yat_utility_pca_
// $Id: PCA.h 1487 2008-09-10 08:41:36Z jari $
/*
Copyright (C) 2003 Daniel Dalevi
Copyright (C) 2004 Jari Häkkinen
Copyright (C) 2005 Jari Häkkinen, Peter Johansson
Copyright (C) 2006 Jari Häkkinen
Copyright (C) 2007 Jari Häkkinen, Peter Johansson
Copyright (C) 2008 Peter Johansson
This file is part of the yat library, http://dev.thep.lu.se/yat
The yat library is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 3 of the
License, or (at your option) any later version.
The yat library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with yat. If not, see .
*/
#include "Matrix.h"
#include "Vector.h"
namespace theplu {
namespace yat {
namespace utility {
/**
@brief Principal Component Analysis
Class performing PCA using SVD. This class assumes that
the columns corresponds to the dimenension of the problem.
That means if data has dimension NxM (M=columns) the number
of principal-axes will equal M-1. When projecting data into
this space, all Nx1 vectors will have dimension Mx1. Hence
the projection will have dimension MxM where each column is
a point in the new space. Also, it assumes that M>N. The opposite
problem is added in the functions: process_transposed_problem and
projection_transposed()...
*/
class PCA
{
public:
/**
Constructor taking the data-matrix as input. No row-centering
should have been performed and no products.
*/
explicit PCA(const utility::Matrix&);
/**
If M USV' \n
3: Calculate eigenvalues according to \n
\f$ \lambda_{ii} = s_{ii}/N_{rows} \f$ \n
4: Sort eigenvectors (from matrix V) according to descending eigenvalues\n
*/
void process(void);
/**
Private function that will row-center the matrix A,
that is, A = A - M, where M is a matrix
with the meanvalues of each row
*/
void row_center( utility::Matrix& A_center );
utility::Matrix A_;
utility::Vector eigenvalues_;
utility::Matrix eigenvectors_;
utility::Vector meanvalues_;
};
}}} // of namespace utility, yat, and theplu
#endif