1MatrixXd A = MatrixXd::Random(6,6);
2cout << "Here is a random 6x6 matrix, A:" << endl << A << endl << endl;
3
4EigenSolver<MatrixXd> es(A);
5cout << "The eigenvalues of A are:" << endl << es.eigenvalues() << endl;
6cout << "The matrix of eigenvectors, V, is:" << endl << es.eigenvectors() << endl << endl;
7
8complex<double> lambda = es.eigenvalues()[0];
9cout << "Consider the first eigenvalue, lambda = " << lambda << endl;
10VectorXcd v = es.eigenvectors().col(0);
11cout << "If v is the corresponding eigenvector, then lambda * v = " << endl << lambda * v << endl;
12cout << "... and A * v = " << endl << A.cast<complex<double> >() * v << endl << endl;
13
14MatrixXcd D = es.eigenvalues().asDiagonal();
15MatrixXcd V = es.eigenvectors();
16cout << "Finally, V * D * V^(-1) = " << endl << V * D * V.inverse() << endl;
17