openGPMP
Open Source Mathematics Package
eigen.cpp
Go to the documentation of this file.
1 #include <iostream>
3 #include <vector>
4 
5 const double TOLERANCE = 1e-3;
6 
7 int main () {
8  std::vector<std::vector<double>> squareMat = {{2.0, -1.0, 0.0},
9  {-1.0, 2.0, -1.0},
10  {0.0, -1.0, 2.0}};
11  gpmp::linalg::Eigen eigenSquare(squareMat);
12 
13  double eigenvalueSquare = eigenSquare.power_iter(1000, TOLERANCE);
14 
15  std::cout << "Eigenvalue square: " << eigenvalueSquare << std::endl;
16 
17 }
Class for computing eigenvalues of a matrix.
Definition: eigen.hpp:45
double power_iter(int max_iters=100, double tolerance=1e-10) const
Perform the power iteration method to find the dominant eigenvalue.
Definition: eigen.cpp:48
const double TOLERANCE
Definition: eigen.cpp:5
int main()
Definition: eigen.cpp:7