compile_SelfAdjointEigenSolver_SelfAdjointEigenSolver_MatrixType.cpp
Go to the documentation of this file.
00001 #include <Eigen/Core>
00002 #include <Eigen/LU>
00003 #include <Eigen/QR>
00004 #include <Eigen/Cholesky>
00005 #include <Eigen/Geometry>
00006 #include <Eigen/Jacobi>
00007 #include <Eigen/Eigenvalues>
00008 #include <iostream>
00009 
00010 using namespace Eigen;
00011 using namespace std;
00012 
00013 int main(int, char**)
00014 {
00015   cout.precision(3);
00016   MatrixXd X = MatrixXd::Random(5,5);
00017 MatrixXd A = X + X.transpose();
00018 cout << "Here is a random symmetric 5x5 matrix, A:" << endl << A << endl << endl;
00019 
00020 SelfAdjointEigenSolver<MatrixXd> es(A);
00021 cout << "The eigenvalues of A are:" << endl << es.eigenvalues() << endl;
00022 cout << "The matrix of eigenvectors, V, is:" << endl << es.eigenvectors() << endl << endl;
00023 
00024 double lambda = es.eigenvalues()[0];
00025 cout << "Consider the first eigenvalue, lambda = " << lambda << endl;
00026 VectorXd v = es.eigenvectors().col(0);
00027 cout << "If v is the corresponding eigenvector, then lambda * v = " << endl << lambda * v << endl;
00028 cout << "... and A * v = " << endl << A * v << endl << endl;
00029 
00030 MatrixXd D = es.eigenvalues().asDiagonal();
00031 MatrixXd V = es.eigenvectors();
00032 cout << "Finally, V * D * V^(-1) = " << endl << V * D * V.inverse() << endl;
00033 
00034   return 0;
00035 }


re_vision
Author(s): Dorian Galvez-Lopez
autogenerated on Sun Jan 5 2014 11:30:58