Eigenvalues

template<Number T, DataLocation L, template<typename, typename> typename S>
internal::Eigen<T, L, kInPlace> eigen(const Matrix<T, L, S> &A, InPlace, SortOrder order = kNoOrder)

Calculates the eigenvalues \( \lambda_i \) (and optionally, the corresponding eigenvectors \( \vec{v}_i \)) of a square matrix \( \mathbf{A} \). By default, the matrix will be balanced before computing the eigen decomposition of A to improve the accuracy of the results. The eigenvalues are not sorted.

Usage:

Matrix<double> A;
Vector<std::complex<double>> eigenvalues;   // Always complex
Matrix<double> V;                           // Matrix with the eigenvectors
Matrix<double> Vinv;
eigenvalues = eigen(A);                     // Calculates only the eigenvalues.
Tie(eigenvalues, V) = eigen(A);             // Calculates the eigenvalues and V.
tie(eigenvalues, V, Vinv) = eigen(A);       // Calculates the eigenvalues, V and Vinv.

Warning

This routine will overwrite the matrix A.

Parameters:
  • A[in] input matrix

  • order[in] define how the eigenvalues will be sorted

template<Number T, DataLocation L, template<typename, typename> typename S>
internal::Eigen<T, L> eigen(const Matrix<T, L, S> &A, SortOrder order = kNoOrder)

Calculates the eigenvalues \( \lambda_i \) (and optionally, the corresponding eigenvectors \( \vec{v}_i \)) of a square matrix \( \mathbf{A} \). By default, the matrix will be balanced before computing the eigen decomposition of A to improve the accuracy of the results. The eigenvalues are not sorted.

Usage:

Matrix<double> A;
Vector<std::complex<double>> eigenvalues;   // Always complex
Matrix<double> V;                           // Matrix with the eigenvectors
Matrix<double> Vinv;
eigenvalues = eigen(A);                     // Calculates only the eigenvalues.
Tie(eigenvalues, V) = eigen(A);             // Calculates the eigenvalues and V.
tie(eigenvalues, V, Vinv) = eigen(A);       // Calculates the eigenvalues, V and Vinv.

Parameters:
  • A[in] input matrix

  • order[in] define how the eigenvalues will be sorted.

template<Number T, DataLocation L, template<typename, typename> typename S>
internal::SymmetricEigen<T, L, kInPlace> symmetric_eigen(const Matrix<T, L, S> &A, InPlace)

Calculates the eigenvalues \( \lambda_i \) (and optionally, the corresponding eigenvectors \( \vec{v}_i \)) of a symmetric/hermitian square matrix \( \mathbf{A} \). The eigenvalues are sorted in ascending order. This method uses the Relatively Robust Representations to compute the eigen decomposition and only the entries on and above the diagonal of A are accessed.

Usage:

Matrix<double> A;                                     // A must be symmetric or hermitian.
Vector<double> eigenvalues;                           // Always real
Matrix<double> V;                                     // Matrix with the eigenvectors
eigenvalues = symmetric_eigen(A);                     // Calculates only the eigenvalues.
Tie(eigenvalues, V) = symmetric_eigen(A);             // Calculates the eigenvalues and V.

Warning

This routine will overwrite the matrix A.

Parameters:

A[in] input matrix

template<Number T, DataLocation L, template<typename, typename> typename S>
internal::SymmetricEigen<T, L> symmetric_eigen(const Matrix<T, L, S> &A)

Calculates the eigenvalues \( \lambda_i \) (and optionally, the corresponding eigenvectors \( \vec{v}_i \)) of a symmetric/hermitian square matrix \( \mathbf{A} \). The eigenvalues are sorted in ascending order. This method uses the Relatively Robust Representations to compute the eigen decomposition and only the entries on and above the diagonal of A are accessed.

Usage:

Matrix<double> A;                                     // A must be symmetric or hermitian.
Vector<double> eigenvalues;                           // Always real
Matrix<double> V;                                     // Matrix with the eigenvectors
eigenvalues = symmetric_eigen(A);                     // Calculates only the eigenvalues.
Tie(eigenvalues, V) = symmetric_eigen(A);             // Calculates the eigenvalues and V.

Parameters:

A[in] input matrix