COSC-4P80-Assignment-2/lib/eigen-3.4.0/doc/snippets/EigenSolver_compute.cpp

7 lines
361 B
C++
Raw Normal View History

2024-10-21 16:42:03 -04:00
EigenSolver<MatrixXf> es;
MatrixXf A = MatrixXf::Random(4,4);
es.compute(A, /* computeEigenvectors = */ false);
cout << "The eigenvalues of A are: " << es.eigenvalues().transpose() << endl;
es.compute(A + MatrixXf::Identity(4,4), false); // re-use es to compute eigenvalues of A+I
cout << "The eigenvalues of A+I are: " << es.eigenvalues().transpose() << endl;