SelfAdjointEigenSolver_SelfAdjointEigenSolver_MatrixType.cpp
Go to the documentation of this file.
00001 MatrixXd X = MatrixXd::Random(5,5);
00002 MatrixXd A = X + X.transpose();
00003 cout << "Here is a random symmetric 5x5 matrix, A:" << endl << A << endl << endl;
00004 
00005 SelfAdjointEigenSolver<MatrixXd> es(A);
00006 cout << "The eigenvalues of A are:" << endl << es.eigenvalues() << endl;
00007 cout << "The matrix of eigenvectors, V, is:" << endl << es.eigenvectors() << endl << endl;
00008 
00009 double lambda = es.eigenvalues()[0];
00010 cout << "Consider the first eigenvalue, lambda = " << lambda << endl;
00011 VectorXd v = es.eigenvectors().col(0);
00012 cout << "If v is the corresponding eigenvector, then lambda * v = " << endl << lambda * v << endl;
00013 cout << "... and A * v = " << endl << A * v << endl << endl;
00014 
00015 MatrixXd D = es.eigenvalues().asDiagonal();
00016 MatrixXd V = es.eigenvectors();
00017 cout << "Finally, V * D * V^(-1) = " << endl << V * D * V.inverse() << endl;


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