1 #include <eigen3/Eigen/Eigenvalues> // header file
2 #include <iostream>
3
4 int main(){
5 Eigen::Matrix<double, 2, 2> A; // declare a real (double) 2x2 matrix
6 A << 0, 2, 1, 0; // defined the matrix A
7
8 Eigen::EigenSolver<Eigen::Matrix<double, 2,2> > s(A); // the instance s(A) includes the eigensystem
9 std::cout << A << std::endl;
10 std::cout << "eigenvalues:" << std::endl;
11 std::cout << s.eigenvalues()(0) << std::endl;
12 std::cout << "eigenvectors=" << std::endl;
13 std::cout << s.eigenvectors() << std::endl;
14
15 return(0);
16}