#include <numeric>
#include <Eigen/Eigenvalues>
#include "sopt/power_method.h"
Go to the source code of this file.
|
int | main (int, char const **) |
|
◆ main()
int main |
( |
int |
, |
|
|
char const ** |
|
|
) |
| |
Definition at line 5 of file power_method.cc.
21 Eigen::EigenSolver<sopt::Matrix<Scalar>> es;
22 es.compute(A.adjoint() * A,
true);
23 Eigen::DenseIndex index;
24 (es.eigenvalues().transpose() * es.eigenvalues()).real().maxCoeff(&index);
25 auto const eigenvalue = es.eigenvalues()(index);
28 if (std::abs(result.magnitude - std::abs(eigenvalue)) > 1e-8 * std::abs(eigenvalue))
29 throw std::runtime_error(
"Power method did not converge to the expected value");
Eigenvalue and eigenvector for eigenvalue with largest magnitude.
DiagnosticAndResult AtA(t_LinearTransform const &A, t_Vector const &input) const
Maximum number of iterations.
LinearTransform< VECTOR > linear_transform(OperatorFunction< VECTOR > const &direct, OperatorFunction< VECTOR > const &indirect, std::array< t_int, 3 > const &sizes={{1, 1, 0}})
double t_real
Root of the type hierarchy for real numbers.
Eigen::Matrix< T, Eigen::Dynamic, 1 > Vector
A vector of a given type.
std::complex< t_real > t_complex
Root of the type hierarchy for (real) complex numbers.
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > Matrix
A matrix of a given type.
References sopt::algorithm::PowerMethod< SCALAR >::AtA(), sopt::linear_transform(), and N.