source: pacpussensors/trunk/Vislab/lib3dv/eigen/Eigen-install/doc/snippets/compile_ComplexEigenSolver_compute.cpp@ 136

Last change on this file since 136 was 136, checked in by ldecherf, 7 years ago

Doc

File size: 971 bytes
Line 
1#include <Eigen/Dense>
2#include <iostream>
3
4using namespace Eigen;
5using namespace std;
6
7int main(int, char**)
8{
9 cout.precision(3);
10 MatrixXcf A = MatrixXcf::Random(4,4);
11cout << "Here is a random 4x4 matrix, A:" << endl << A << endl << endl;
12
13ComplexEigenSolver<MatrixXcf> ces;
14ces.compute(A);
15cout << "The eigenvalues of A are:" << endl << ces.eigenvalues() << endl;
16cout << "The matrix of eigenvectors, V, is:" << endl << ces.eigenvectors() << endl << endl;
17
18complex<float> lambda = ces.eigenvalues()[0];
19cout << "Consider the first eigenvalue, lambda = " << lambda << endl;
20VectorXcf v = ces.eigenvectors().col(0);
21cout << "If v is the corresponding eigenvector, then lambda * v = " << endl << lambda * v << endl;
22cout << "... and A * v = " << endl << A * v << endl << endl;
23
24cout << "Finally, V * D * V^(-1) = " << endl
25 << ces.eigenvectors() * ces.eigenvalues().asDiagonal() * ces.eigenvectors().inverse() << endl;
26
27 return 0;
28}
Note: See TracBrowser for help on using the repository browser.