#include <SymEigen.h>
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 |
Real symmetric (and hence square matrices) can be decomposed into
where is an orthogonal matrix (and hence
) whose columns are the eigenvectors of
and
is a diagonal matrix whose entries are the eigenvalues of
. 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.
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.
void TooN::SymEigen< Size, Precision >::compute | ( | const Matrix< R, C, Precision, B > & | m | ) |
Perform the eigen decomposition of a matrix.
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 , this calculates
by back substitution (i.e. without explictly calculating the (pseudo-)inverse). See the SVD detailed description for a description of condition variables.
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 , this calculates
by back substitution (i.e. without explictly calculating the (pseudo-)inverse). See the SVD detailed description for a description of condition variables.
Matrix<Size, Size, Precision> TooN::SymEigen< Size, Precision >::get_pinv | ( | const double | condition = symeigen_condition_no |
) | const |
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 . Any eigenvalues which are too small are set to zero (see the SVD detailed description for a description of the and condition variables).
Matrix<Size,Size,Precision>& TooN::SymEigen< Size, Precision >::get_evectors | ( | ) |
Returns the eigenvectors of the matrix.
This returns , 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.
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 .
bool TooN::SymEigen< Size, Precision >::is_posdef | ( | ) | const |
Is the matrix positive definite?
bool TooN::SymEigen< Size, Precision >::is_negdef | ( | ) | const |
Is the matrix negative definite?
Precision TooN::SymEigen< Size, Precision >::get_determinant | ( | ) | const |
Get the determinant of the matrix.