NumericAL
A header-only C++20 lexer built on REAL
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
numerical::symmetric_eigen Class Reference

The eigenvalues and eigenvectors of a real symmetric matrix. More...

#include <factorizations.hpp>

Collaboration diagram for numerical::symmetric_eigen:
[legend]

Public Member Functions

 symmetric_eigen (const matrix< double > &input, eigen_method method=eigen_method::divide_and_conquer)
 Diagonalises input.
 
 symmetric_eigen (matrix< double > &&input, eigen_method method=eigen_method::divide_and_conquer)
 Diagonalises input in its own storage, an expiring matrix's elements taken over: its scaled copy is made in place, one matrix less at the peak.
 
 symmetric_eigen (const matrix< double > &a, const matrix< double > &b, eigen_method method=eigen_method::divide_and_conquer)
 Diagonalises the pencil A − λ B, A x = λ B x, as scipy.linalg.eigh(a, b): B = L Lᴴ and the symmetric L⁻¹ A L⁻ᴴ diagonalised, its eigenvectors y the pencil's L⁻ᴴ y, B-orthonormal (Xᵀ B X = I). Each matrix's lower triangle alone is read.
 
const vector< double > & values () const noexcept
 The eigenvalues, ascending.
 
const matrix< double > & vectors () const &noexcept
 The eigenvectors as columns, ordered to match values.
 
matrix< double > vectors () &&
 The eigenvectors, moved out of an expiring decomposition.
 

Private Member Functions

 symmetric_eigen (detail::definite_pencil< double > pencil, eigen_method method)
 The pencil's eigenpairs: its standard form's, the vectors carried back.
 
void extract_sorted (const buffer< double > &diagonal, const buffer< double > &v)
 Sorts the eigenvalues diagonal ascending and reorders v's columns to match.
 

Private Attributes

std::size_t n_
 The matrix order.
 
vector< double > values_
 Eigenvalues, ascending.
 
matrix< double > vectors_
 Eigenvectors as columns.
 

Detailed Description

The eigenvalues and eigenvectors of a real symmetric matrix.

By default the matrix is reduced to tridiagonal form by Householder reflections and the tridiagonal is diagonalised by divide and conquer (eigen_method::divide_and_conquer), the method of LAPACK's dsyevd, most of its work in matrix products; implicit QL (eigen_method::tridiagonal_ql, dsyev's) and cyclic Jacobi rotations (eigen_method::jacobi) are the alternatives. Whichever, the eigenvalues are real and the eigenvectors orthonormal. The eigenvalues are returned in ascending order, with vectors j-th column the eigenvector of values [j] (A = V Λ Vᵀ). Real symmetric only (the complex Hermitian case is hermitian_eigen). Only the lower triangle is read, as numpy.linalg.eigh reads it by default: the upper one is taken to mirror it.

Definition at line 6674 of file factorizations.hpp.

Constructor & Destructor Documentation

◆ symmetric_eigen() [1/4]

numerical::symmetric_eigen::symmetric_eigen ( const matrix< double > &  input,
eigen_method  method = eigen_method::divide_and_conquer 
)
inlineexplicit

Diagonalises input.

Parameters
[in]inputA real symmetric matrix (its lower triangle is read).
[in]methodThe algorithm.
Exceptions
dimension_errorIf input is not square.
convergence_errorIf the method did not converge within its bound.

Definition at line 6685 of file factorizations.hpp.

◆ symmetric_eigen() [2/4]

numerical::symmetric_eigen::symmetric_eigen ( matrix< double > &&  input,
eigen_method  method = eigen_method::divide_and_conquer 
)
inlineexplicit

Diagonalises input in its own storage, an expiring matrix's elements taken over: its scaled copy is made in place, one matrix less at the peak.

Parameters
[in]inputA real symmetric matrix (its lower triangle is read).
[in]methodThe algorithm.
Exceptions
dimension_errorIf input is not square.
convergence_errorIf the method did not converge within its bound.

Definition at line 6699 of file factorizations.hpp.

◆ symmetric_eigen() [3/4]

numerical::symmetric_eigen::symmetric_eigen ( const matrix< double > &  a,
const matrix< double > &  b,
eigen_method  method = eigen_method::divide_and_conquer 
)
inline

Diagonalises the pencil A − λ B, A x = λ B x, as scipy.linalg.eigh(a, b): B = L Lᴴ and the symmetric L⁻¹ A L⁻ᴴ diagonalised, its eigenvectors y the pencil's L⁻ᴴ y, B-orthonormal (Xᵀ B X = I). Each matrix's lower triangle alone is read.

Parameters
[in]aA real symmetric matrix.
[in]bA real symmetric positive-definite matrix of its order.
[in]methodThe algorithm for the standard form.
Exceptions
dimension_errorIf a or b is not square, or their orders differ.
non_finite_errorIf an entry read is infinite or NaN.
not_positive_definite_errorIf b is not positive definite.
convergence_errorIf the method did not converge within its bound.

Definition at line 6775 of file factorizations.hpp.

◆ symmetric_eigen() [4/4]

numerical::symmetric_eigen::symmetric_eigen ( detail::definite_pencil< double >  pencil,
eigen_method  method 
)
inlineprivate

The pencil's eigenpairs: its standard form's, the vectors carried back.

Definition at line 6803 of file factorizations.hpp.

Member Function Documentation

◆ extract_sorted()

void numerical::symmetric_eigen::extract_sorted ( const buffer< double > &  diagonal,
const buffer< double > &  v 
)
inlineprivate

Sorts the eigenvalues diagonal ascending and reorders v's columns to match.

Definition at line 6812 of file factorizations.hpp.

◆ values()

const vector< double > & numerical::symmetric_eigen::values ( ) const
inlinenoexcept

The eigenvalues, ascending.

Definition at line 6783 of file factorizations.hpp.

◆ vectors() [1/2]

matrix< double > numerical::symmetric_eigen::vectors ( ) &&
inline

The eigenvectors, moved out of an expiring decomposition.

Definition at line 6795 of file factorizations.hpp.

◆ vectors() [2/2]

const matrix< double > & numerical::symmetric_eigen::vectors ( ) const &
inlinenoexcept

The eigenvectors as columns, ordered to match values.

Definition at line 6789 of file factorizations.hpp.

Member Data Documentation

◆ n_

std::size_t numerical::symmetric_eigen::n_
private

The matrix order.

Definition at line 6835 of file factorizations.hpp.

◆ values_

vector<double> numerical::symmetric_eigen::values_
private

Eigenvalues, ascending.

Definition at line 6836 of file factorizations.hpp.

◆ vectors_

matrix<double> numerical::symmetric_eigen::vectors_
private

Eigenvectors as columns.

Definition at line 6837 of file factorizations.hpp.


The documentation for this class was generated from the following file: