Line | |
---|
1 | #include <Eigen/Dense>
|
---|
2 | #include <iostream>
|
---|
3 |
|
---|
4 | using namespace Eigen;
|
---|
5 | using namespace std;
|
---|
6 |
|
---|
7 | int main(int, char**)
|
---|
8 | {
|
---|
9 | cout.precision(3);
|
---|
10 | MatrixXcf A = MatrixXcf::Random(4,4);
|
---|
11 | cout << "Here is a random 4x4 matrix, A:" << endl << A << endl << endl;
|
---|
12 |
|
---|
13 | ComplexEigenSolver<MatrixXcf> ces;
|
---|
14 | ces.compute(A);
|
---|
15 | cout << "The eigenvalues of A are:" << endl << ces.eigenvalues() << endl;
|
---|
16 | cout << "The matrix of eigenvectors, V, is:" << endl << ces.eigenvectors() << endl << endl;
|
---|
17 |
|
---|
18 | complex<float> lambda = ces.eigenvalues()[0];
|
---|
19 | cout << "Consider the first eigenvalue, lambda = " << lambda << endl;
|
---|
20 | VectorXcf v = ces.eigenvectors().col(0);
|
---|
21 | cout << "If v is the corresponding eigenvector, then lambda * v = " << endl << lambda * v << endl;
|
---|
22 | cout << "... and A * v = " << endl << A * v << endl << endl;
|
---|
23 |
|
---|
24 | cout << "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.