The basic object in the LAPACK.h++ nonsymmetric eigenvalue classes is the DoubleEigDecomp object, which represents the eigenvalues and eigenvectors of a matrix. Here is a short program that reads a matrix from standard input, computes its eigenvalue decomposition, and prints out its eigenvalues and eigenvectors:
#include <iostream.h> #include <deig.h> main() { RWGenMat<double> A; // 1 cin >> A; DoubleEigDecomp decomp(A); // 2 cout << decomp.eigenValues() << endl; // 3 cout << decomp.leftEigenVectors() << endl; // 4 cout << decomp.rightEigenVectors() << endl; }
//1 | A is defined to be a general dense matrix, and is read in from standard input. |
//2 | Here we construct an eigenvalue decomposition object decomp from the matrix. The decomposition object contains all the eigenvalues and eigenvectors, as well as information about whether these quantities are fully accurate and were successfully computed. See the Class Reference for a complete description of the available member functions. |
//3 | We can access a vector containing all the eigenvalues as shown in this line. It is also possible to access one eigenvalue at a time, using the member function eigenValue(int). Note that the eigenvalues are of type DComplex, since in general they are complex. |
//4 | The next two lines print out matrices whose columns are the eigenvectors. You can also access a vector containing just one eigenvector using the member functions leftEigenVector(int) and rightEigenVector(int). |
©Copyright 1999, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.