TooN::SymEigen< Size, Precision > Class Template Reference
[Matrix decompositions]

Performs eigen decomposition of a matrix. More...

#include <SymEigen.h>

List of all members.

Public Member Functions

template<int R, int C, typename B>
 SymEigen (const Matrix< R, C, Precision, B > &m)
template<int R, int C, typename B>
void compute (const Matrix< R, C, Precision, B > &m)
template<int S, typename P, typename B>
Vector< Size, Precision > backsub (const Vector< S, P, B > &rhs) const
template<int R, int C, typename P, typename B>
Matrix< Size, C,
Precision > 
backsub (const Matrix< R, C, P, B > &rhs) const
Matrix< Size, Size,
Precision > 
get_pinv (const double condition=symeigen_condition_no) const
Vector< Size, Precision > get_inv_diag (const double condition) const
Matrix< Size, Size,
Precision > & 
get_evectors ()
const Matrix< Size,
Size, Precision > & 
get_evectors () const
Vector< Size,
Precision > & 
get_evalues ()
const Vector< Size,
Precision > & 
get_evalues () const
bool is_posdef () const
bool is_negdef () const
Precision get_determinant () const


Detailed Description

template<int Size = Dynamic, typename Precision = double>
class TooN::SymEigen< Size, Precision >

Performs eigen decomposition of a matrix.

Real symmetric (and hence square matrices) can be decomposed into

\[M = U \times \Lambda \times U^T\]

where $U$ is an orthogonal matrix (and hence $U^T = U^{-1}$) whose columns are the eigenvectors of $M$ and $\Lambda$ is a diagonal matrix whose entries are the eigenvalues of $M$. These quantities are often of use directly, and can be obtained as follows:

// construct M
double d1[][] = {{1,2,3},{2,5,6},{3,6,7}};
Matrix<3> M(d1);
// create the eigen decomposition of M
SymEigen<3> eigM(M);
// print the smallest eigenvalue
cout << eigM.get_evalues()[0] << endl;
// print the associated eigenvector
cout << eigM.get_evectors()[0] << endl;

This decomposition is very similar to the SVD (q.v.), and can be used to solve equations using backsub() or get_pinv(), with the same treatment of condition numbers.

SymEigen<> (= SymEigen<-1>) can be used to create an eigen decomposition whose size is determined at run-time.


Constructor & Destructor Documentation

template<int Size = Dynamic, typename Precision = double>
template<int R, int C, typename B>
TooN::SymEigen< Size, Precision >::SymEigen ( const Matrix< R, C, Precision, B > &  m  ) 

Construct the eigen decomposition of a matrix.

This initialises the class, and performs the decomposition immediately.


Member Function Documentation

template<int Size = Dynamic, typename Precision = double>
template<int R, int C, typename B>
void TooN::SymEigen< Size, Precision >::compute ( const Matrix< R, C, Precision, B > &  m  ) 

Perform the eigen decomposition of a matrix.

template<int Size = Dynamic, typename Precision = double>
template<int S, typename P, typename B>
Vector<Size, Precision> TooN::SymEigen< Size, Precision >::backsub ( const Vector< S, P, B > &  rhs  )  const

Calculate result of multiplying the (pseudo-)inverse of M by a vector.

For a vector $b$, this calculates $M^{\dagger}b$ by back substitution (i.e. without explictly calculating the (pseudo-)inverse). See the SVD detailed description for a description of condition variables.

template<int Size = Dynamic, typename Precision = double>
template<int R, int C, typename P, typename B>
Matrix<Size,C, Precision> TooN::SymEigen< Size, Precision >::backsub ( const Matrix< R, C, P, B > &  rhs  )  const

Calculate result of multiplying the (pseudo-)inverse of M by another matrix.

For a matrix $A$, this calculates $M^{\dagger}A$ by back substitution (i.e. without explictly calculating the (pseudo-)inverse). See the SVD detailed description for a description of condition variables.

template<int Size = Dynamic, typename Precision = double>
Matrix<Size, Size, Precision> TooN::SymEigen< Size, Precision >::get_pinv ( const double  condition = symeigen_condition_no  )  const

Calculate (pseudo-)inverse of the matrix.

This is not usually needed: if you need the inverse just to multiply it by a matrix or a vector, use one of the backsub() functions, which will be faster. See the SVD detailed description for a description of the pseudo-inverse and condition variables.

template<int Size = Dynamic, typename Precision = double>
Vector<Size, Precision> TooN::SymEigen< Size, Precision >::get_inv_diag ( const double  condition  )  const

Calculates the reciprocals of the eigenvalues of the matrix.

The vector invdiag lists the eigenvalues in order, from the largest (i.e. smallest reciprocal) to the smallest. These are also the diagonal values of the matrix $Lambda^{-1}$. Any eigenvalues which are too small are set to zero (see the SVD detailed description for a description of the and condition variables).

template<int Size = Dynamic, typename Precision = double>
Matrix<Size,Size,Precision>& TooN::SymEigen< Size, Precision >::get_evectors (  ) 

Returns the eigenvectors of the matrix.

This returns $U^T$, so that the rows of the matrix are the eigenvectors, which can be extracted using usual Matrix::operator[]() subscript operator. They are returned in order of the size of the corresponding eigenvalue, i.e. the vector with the largest eigenvalue is first.

template<int Size = Dynamic, typename Precision = double>
Vector<Size, Precision>& TooN::SymEigen< Size, Precision >::get_evalues (  ) 

Returns the eigenvalues of the matrix.

The eigenvalues are listed in order, from the largest to the smallest. These are also the diagonal values of the matrix $\Lambda$.

template<int Size = Dynamic, typename Precision = double>
bool TooN::SymEigen< Size, Precision >::is_posdef (  )  const

Is the matrix positive definite?

template<int Size = Dynamic, typename Precision = double>
bool TooN::SymEigen< Size, Precision >::is_negdef (  )  const

Is the matrix negative definite?

template<int Size = Dynamic, typename Precision = double>
Precision TooN::SymEigen< Size, Precision >::get_determinant (  )  const

Get the determinant of the matrix.


Generated on Thu May 7 20:28:42 2009 for TooN by  doxygen 1.5.3