LTI-Lib latest version v1.9 - last update 10 Apr 2010

lti::serialPCA< T > Class Template Reference
[Linear Algebra]

Functor for sequentially computing a principal component analysis. More...

#include <ltiSerialPCA.h>

Inheritance diagram for lti::serialPCA< T >:
Collaboration diagram for lti::serialPCA< T >:

List of all members.

Classes

class  parameters
 the parameters for the class serialPCA More...

Public Member Functions

 serialPCA ()
 serialPCA (const serialPCA &other)
virtual ~serialPCA ()
virtual const char * getTypeName () const
bool consider (const matrix< T > &data)
bool consider (const vector< T > &data)
bool reset ()
bool apply (const matrix< T > &src, matrix< T > &dest)
bool apply (matrix< T > &srcdest)
bool apply (const vector< T > &src, vector< T > &result)
bool transform (const vector< T > &src, vector< T > &result)
bool transform (const matrix< T > &src, matrix< T > &result)
bool getTransformMatrix (matrix< T > &result) const
const matrix< T > & getTransformMatrix () const
bool getEigenValues (vector< T > &result) const
const vector< T > & getEigenValues () const
bool getEigenVectors (matrix< T > &result) const
bool getEigenVectorsInRows (matrix< T > &result) const
const matrix< T > & getEigenVectors () const
void setDimension (int k)
serialPCAcopy (const serialPCA &other)
virtual functorclone () const
const parametersgetParameters () const
virtual bool updateParameters ()
virtual bool read (ioHandler &handler, const bool complete=true)
virtual bool write (ioHandler &handler, const bool complete=true) const

Protected Member Functions

int checkDim ()

Detailed Description

template<class T>
class lti::serialPCA< T >

Functor for sequentially computing a principal component analysis.

It receives a set of input vectors in form of a matrix (each row of the matrix corresponds to an input vector), which will be transformed with PCA.

The first time you use the apply()-method, the transformation matrix will be computed. You can use this transformation matrix with other data sets using the transform() methods.

Please note that the eigenvector matrices will contain the eigenvector in the COLUMNS and not in the rows, as could be expected. This avoids the requirement of transposing matrices in the vector transformations (see also lti::eigenSystem<T>).

See also:
lti::principalComponents

Constructor & Destructor Documentation

template<class T >
lti::serialPCA< T >::serialPCA (  ) 

default constructor

template<class T >
lti::serialPCA< T >::serialPCA ( const serialPCA< T > &  other  ) 

copy constructor

Parameters:
other the object to be copied
template<class T >
virtual lti::serialPCA< T >::~serialPCA (  )  [virtual]

destructor


Member Function Documentation

template<class T >
bool lti::serialPCA< T >::apply ( const vector< T > &  src,
vector< T > &  result 
) [inline]

Transforms a single vector according to a previously computed transformation matrix.

References lti::serialPCA< T >::transform().

template<class T >
bool lti::serialPCA< T >::apply ( matrix< T > &  srcdest  ) 

On-Place version of the transformation.

Computes the principal components of the previously considered data points and applies it to the given data matrix. The result is the transformed matrix. This method uses the eigenvector functor given in the parameters. By default, it uses ltilib's own jacobi functor. However, you can speed it up considerably by using the eigensystem functor in the lamath directory.

Warning:
This method does not consider the given srcdest data to compute the transformation, unless it is the very first time you call this functor. The normal way of using apply() is previously having called the consider() method.
Parameters:
srcdest matrix<T> with the source data, which will also contain the result.
Returns:
a reference to srcdest.
template<class T >
bool lti::serialPCA< T >::apply ( const matrix< T > &  src,
matrix< T > &  dest 
)

Computes the principal components of the previously considered data points and applies it to the given data matrix.

The result is the transformed matrix. data and result must not be references to the same matrix. This method uses the eigenvector functor given in the parameters. By default, it uses ltilib's own jacobi functor. However, you can speed it up considerably by using the eigensystem functor in the lamath directory.

Warning:
This method does not consider the given src data to compute the transformation, unless it is the very first time you call this functor. The normal way of using apply() is previously having called the consider() method.
Parameters:
src matrix<T> with the source data.
dest matrix<T> with the result data.
Returns:
true if the PCA could be computed, false otherwise
template<class T >
int lti::serialPCA< T >::checkDim (  )  [protected]

Determines the intrinsic dimensionality of the data set if the user specify autoDim, otherwise return parameters::resultDim.

The member usedDimensionality will be set with the returned value

template<class T >
virtual functor* lti::serialPCA< T >::clone (  )  const [virtual]

returns a pointer to a clone of this functor.

Implements lti::functor.

template<class T >
bool lti::serialPCA< T >::consider ( const vector< T > &  data  ) 

Consider a vector in the estimation of the covariance/correlation matrix.

You can later call the transform() method or the apply method to transform the data.

Each time you call this method, the current transformation matrix is invalidated and later recomputed when you call a transform method. Then, all data considered so far will be used in the covariance/correlation matrix estimation.

Parameters:
data matrix<T> with the source data.
Returns:
true if the PCA could be computed, false otherwise
template<class T >
bool lti::serialPCA< T >::consider ( const matrix< T > &  data  ) 

Consider the given data for the computation of a principal components transformation matrix.

You can later call the transform() method or the apply method to transform the data.

Each time you call this method, the current transformation matrix is invalidated and later recomputed when you call a transform method. Then, all data considered so far will be used in the covariance/correlation matrix estimation.

Parameters:
data matrix<T> with the source data.
Returns:
true if the PCA could be computed, false otherwise
template<class T >
serialPCA& lti::serialPCA< T >::copy ( const serialPCA< T > &  other  ) 

copy data of "other" functor.

Parameters:
other the functor to be copied
Returns:
a reference to this functor object

Reimplemented from lti::functor.

template<class T >
const vector<T>& lti::serialPCA< T >::getEigenValues (  )  const

Returns the previously computed eigenvalues of the covariance matrix.

Returns:
a const reference to the last computed eigenvalues
template<class T >
bool lti::serialPCA< T >::getEigenValues ( vector< T > &  result  )  const

Returns the previously computed eigenvalues of the covariance matrix.

Parameters:
result the vector which will receive the eigenvalues.
Returns:
true if the values could be obtained, false otherwise.
template<class T >
const matrix<T>& lti::serialPCA< T >::getEigenVectors (  )  const

Returns the previously computed eigenvectors of the covariance matrix.

Returns:
a const reference to the last computed eigenvectors
template<class T >
bool lti::serialPCA< T >::getEigenVectors ( matrix< T > &  result  )  const

Returns the previously computed eigenvectors of the covariance matrix.

Parameters:
result the matrix which will receive the eigenvectors. Each column of the matrix contains one eigenvector.
Returns:
true if the vectors could be obtained, false otherwise
template<class T >
bool lti::serialPCA< T >::getEigenVectorsInRows ( matrix< T > &  result  )  const

Returns the previously computed eigenvectors of the covariance matrix.

This method will call the normal getEigenVectors() methods and after that will transpose the obtained matrix, i.e. it is faster to get the eigenvectors in the columns.

Parameters:
result the matrix which will receive the eigenvectors. Each row of the matrix contains one eigenvector.
Returns:
true if the vectors could be obtained, false otherwise
template<class T >
const parameters& lti::serialPCA< T >::getParameters (  )  const

returns used parameters

Reimplemented from lti::functor.

template<class T >
const matrix<T>& lti::serialPCA< T >::getTransformMatrix (  )  const

Returns the previously computed transform matrix.

Returns:
a const reference to the last computed or used transformation matrix.
template<class T >
bool lti::serialPCA< T >::getTransformMatrix ( matrix< T > &  result  )  const

Returns the previously computed transform matrix.

Parameters:
result the matrix which will receive the transformation matrix.
Returns:
true if the matrix could be computed, false otherwise.
template<class T >
virtual const char* lti::serialPCA< T >::getTypeName (  )  const [virtual]

returns the name of this type ("serialPCA")

Reimplemented from lti::linearAlgebraFunctor.

template<class T >
virtual bool lti::serialPCA< T >::read ( ioHandler handler,
const bool  complete = true 
) [virtual]

Reads this functor from the given handler.

Reimplemented from lti::functor.

template<class T >
bool lti::serialPCA< T >::reset (  ) 

Reset the data.

Removes all data considered until now and set the functor as in the initial empty state.

template<class T >
void lti::serialPCA< T >::setDimension ( int  k  ) 

Set the dimension to which the vectors should be reduced.

template<class T >
bool lti::serialPCA< T >::transform ( const matrix< T > &  src,
matrix< T > &  result 
)

Transform an entire matrix according to a previously computed transformation matrix.

Unfortunately, we must choose a name different from apply.

Parameters:
src the data matrix
result the matrix which will receive the transformed data
Returns:
a reference to result
template<class T >
bool lti::serialPCA< T >::transform ( const vector< T > &  src,
vector< T > &  result 
)

Transforms a single vector according to a previously computed transformation matrix.

Parameters:
src the data vector
result the vector which will receive the transformed data
Returns:
a reference to result

Referenced by lti::serialPCA< T >::apply().

template<class T >
virtual bool lti::serialPCA< T >::updateParameters (  )  [virtual]

Update functor's parameters.

Initialize some internal data according to the parameters.

Returns:
true if successful, false otherwise

Reimplemented from lti::functor.

template<class T >
virtual bool lti::serialPCA< T >::write ( ioHandler handler,
const bool  complete = true 
) const [virtual]

Writes this functor to the given handler.

Reimplemented from lti::functor.


The documentation for this class was generated from the following file:

Generated on Sat Apr 10 15:28:41 2010 for LTI-Lib by Doxygen 1.6.1