2
$\begingroup$

Spectral decomposition of symmetric matrix $A_{n\times n}$, specifically, $n=3$

find the orthogonal matrix $Q$ and diagonal matrix $\Lambda$ such that:

$A=Q\Lambda Q^T$

How to implement such decomposition in Eigen C++? or any other C++ implementations?

$\endgroup$

1 Answer 1

6
$\begingroup$

You're looking for the SelfAdjointEigenSolver class, and there is also an example in the user manual that I report here:

#include <iostream>
#include <Eigen/Dense>
using namespace std;
using namespace Eigen;
int main()
{
   Matrix2f A;
   A << 1, 2, 2, 3;
   cout << "Here is the matrix A:\n" << A << endl;
   SelfAdjointEigenSolver<Matrix2f> eigensolver(A);
   if (eigensolver.info() != Success) abort();
   cout << "The eigenvalues of A are:\n" << eigensolver.eigenvalues() << endl;
   cout << "Here's a matrix whose columns are eigenvectors of A \n"
        << "corresponding to these eigenvalues:\n"
        << eigensolver.eigenvectors() << endl;
}
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.