Decomposition Object
The most important object for the symmetric eigenvalue problem is the symmetric eigenvalue decomposition object
RWSymEigDecomp<double>. Here is a short program which reads a symmetric matrix from standard input, computes its eigenvalue decomposition, and prints out its eigenvalues and eigenvectors:
#include <iostream>
#include <rw/lapack/symmat.h>
#include <rw/lapack/symeig.h>
int main()
{
RWSymMat<double> A; // 1
std::cin >> A;
RWSymEigDecomp<double> decomp(A); // 2
std::cout << decomp.eigenValues() << std::endl; // 3
std::cout << decomp.eigenVectors() << std::endl; // 4
return 0;
}
The most common variant on this basic problem is to compute only the eigenvectors, and no eigenvalues. This is so common that you can use an optional argument in the decomposition constructor to control computation of eigenvectors. Thus by replacing //2 in the above example with:
RWSymEigDecomp<double> decomp(A,true);
the decomposition is constructed without eigenvectors.