2 #include <Eigen/Eigenvalues>
5 int main(
int,
char const **) {
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.
int main(int, char const **)
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.