openGPMP
Open Source Mathematics Package
eigen.hpp
Go to the documentation of this file.
1 /*************************************************************************
2  *
3  * Project
4  * _____ _____ __ __ _____
5  * / ____| __ \| \/ | __ \
6  * ___ _ __ ___ _ __ | | __| |__) | \ / | |__) |
7  * / _ \| '_ \ / _ \ '_ \| | |_ | ___/| |\/| | ___/
8  *| (_) | |_) | __/ | | | |__| | | | | | | |
9  * \___/| .__/ \___|_| |_|\_____|_| |_| |_|_|
10  * | |
11  * |_|
12  *
13  * Copyright (C) Akiel Aries, <akiel@akiel.org>, et al.
14  *
15  * This software is licensed as described in the file LICENSE, which
16  * you should have received as part of this distribution. The terms
17  * among other details are referenced in the official documentation
18  * seen here : https://akielaries.github.io/openGPMP/ along with
19  * important files seen in this project.
20  *
21  * You may opt to use, copy, modify, merge, publish, distribute
22  * and/or sell copies of the Software, and permit persons to whom
23  * the Software is furnished to do so, under the terms of the
24  * LICENSE file. As this is an Open Source effort, all implementations
25  * must be of the same methodology.
26  *
27  *
28  *
29  * This software is distributed on an AS IS basis, WITHOUT
30  * WARRANTY OF ANY KIND, either express or implied.
31  *
32  ************************************************************************/
33 
34 #ifndef EIGEN_HPP
35 #define EIGEN_HPP
36 #include <vector>
37 
38 namespace gpmp {
39 
40 namespace linalg {
41 
45 class Eigen {
46  private:
47  // matrix for eigenvalue computation
48  std::vector<std::vector<double>> matrix;
49  // size of square matrix
50  int size;
51 
52  public:
57  Eigen(const std::vector<std::vector<double>> &mat);
58 
65  double power_iter(int max_iters = 100, double tolerance = 1e-10) const;
66 
73  std::vector<double> qr_algorithm(int max_iters = 100,
74  double tolerance = 1e-10) const;
75 
91  std::vector<double> sensitivity(double perturbation) const;
92  double determinant() const;
93 
111  void schur_decomp(std::vector<std::vector<double>> &schurMatrix,
112  double tolerance = 1e-10) const;
113 
130  std::vector<std::vector<double>>
131  jordan_normal_form(double tolerance = 1e-10) const;
132 
148  double rayleigh_iter(int maxIterations, double tolerance) const;
149 };
150 
151 } // namespace linalg
152 } // namespace gpmp
153 
154 #endif
Class for computing eigenvalues of a matrix.
Definition: eigen.hpp:45
void schur_decomp(std::vector< std::vector< double >> &schurMatrix, double tolerance=1e-10) const
Computes the Schur decomposition of a matrix.
Definition: eigen.cpp:181
std::vector< double > qr_algorithm(int max_iters=100, double tolerance=1e-10) const
Calculate all eigenvalues of the matrix using the QR algorithm.
Definition: eigen.cpp:93
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
double rayleigh_iter(int maxIterations, double tolerance) const
Perform Rayleigh Quotient Iteration to approximate the dominant eigenvalue.
Definition: eigen.cpp:237
std::vector< double > sensitivity(double perturbation) const
Calculates the sensitivity of the eigenvalues of a matrix to small perturbations.
Definition: eigen.cpp:154
std::vector< std::vector< double > > jordan_normal_form(double tolerance=1e-10) const
Computes the Jordan normal form of a matrix.
Definition: eigen.cpp:212
std::vector< std::vector< double > > matrix
Definition: eigen.hpp:48
double determinant() const
Definition: eigen.cpp:143
Eigen(const std::vector< std::vector< double >> &mat)
Constructor for the Eigen class.
Definition: eigen.cpp:39
The source C++ openGPMP namespace.