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::eigen_decomposition< T > Class Template Reference

The eigenvalues, and optionally the right eigenvectors, of a general square matrix, as numpy.linalg.eig. More...

#include <eigen.hpp>

Collaboration diagram for numerical::eigen_decomposition< T >:
[legend]

Public Member Functions

 eigen_decomposition (const matrix< T > &input, bool vectors=true)
 Decomposes input.
 
const vector< std::complex< double > > & values () const noexcept
 The eigenvalues, in the order of the Schur form.
 
const matrix< std::complex< double > > & vectors () const &noexcept
 The eigenvectors as columns, ordered to match values (empty where they were not computed).
 
matrix< std::complex< double > > vectors () &&
 The eigenvectors, moved out of an expiring decomposition.
 
bool real () const noexcept
 Whether every eigenvalue is real (a real matrix's whose Schur form has no 2 × 2 block): its vectors are then real too.
 

Private Member Functions

void finish (std::complex< double > *row, const std::complex< double > &value, double) const
 Normalises the eigenvector row (a row of Vᵀ) of a real matrix's eigenvalue value, as dgeev: a real one to unit norm; a pair's first to unit norm, its largest component real, its second the first's conjugate (the row above).
 
void finish (std::complex< double > *row, const std::complex< double > &, const std::complex< double > &) const
 Normalises the eigenvector row of a complex matrix, as zgeev: to unit norm, its largest component real and positive.
 

Private Attributes

std::size_t n_
 The matrix order.
 
vector< std::complex< double > > values_
 The eigenvalues.
 
matrix< std::complex< double > > vectors_
 The eigenvectors as columns.
 
bool real_ {true}
 Whether all eigenvalues are real.
 

Detailed Description

template<typename T>
class numerical::eigen_decomposition< T >

The eigenvalues, and optionally the right eigenvectors, of a general square matrix, as numpy.linalg.eig.

T is double or std::complex<double>; the eigenvalues and vectors are complex either way (real says whether a real matrix's are all real). Column j of vectors is the eigenvector of values [j], A V = V Λ, each of unit norm with its component of largest modulus real.

Definition at line 2979 of file eigen.hpp.

Constructor & Destructor Documentation

◆ eigen_decomposition()

template<typename T >
numerical::eigen_decomposition< T >::eigen_decomposition ( const matrix< T > &  input,
bool  vectors = true 
)
inlineexplicit

Decomposes input.

Parameters
[in]inputA square matrix.
[in]vectorsWhether to compute the eigenvectors (the eigenvalues alone cost a third as much).
Exceptions
dimension_errorIf input is not square.
non_finite_errorIf an entry is infinite or NaN.
convergence_errorIf the QR iterations did not converge.

Definition at line 2991 of file eigen.hpp.

Member Function Documentation

◆ finish() [1/2]

template<typename T >
void numerical::eigen_decomposition< T >::finish ( std::complex< double > *  row,
const std::complex< double > &  ,
const std::complex< double > &   
) const
inlineprivate

Normalises the eigenvector row of a complex matrix, as zgeev: to unit norm, its largest component real and positive.

Definition at line 3139 of file eigen.hpp.

◆ finish() [2/2]

template<typename T >
void numerical::eigen_decomposition< T >::finish ( std::complex< double > *  row,
const std::complex< double > &  value,
double   
) const
inlineprivate

Normalises the eigenvector row (a row of Vᵀ) of a real matrix's eigenvalue value, as dgeev: a real one to unit norm; a pair's first to unit norm, its largest component real, its second the first's conjugate (the row above).

Definition at line 3116 of file eigen.hpp.

◆ real()

template<typename T >
bool numerical::eigen_decomposition< T >::real ( ) const
inlinenoexcept

Whether every eigenvalue is real (a real matrix's whose Schur form has no 2 × 2 block): its vectors are then real too.

Definition at line 3106 of file eigen.hpp.

◆ values()

template<typename T >
const vector< std::complex< double > > & numerical::eigen_decomposition< T >::values ( ) const
inlinenoexcept

The eigenvalues, in the order of the Schur form.

Definition at line 3087 of file eigen.hpp.

◆ vectors() [1/2]

template<typename T >
matrix< std::complex< double > > numerical::eigen_decomposition< T >::vectors ( ) &&
inline

The eigenvectors, moved out of an expiring decomposition.

Definition at line 3099 of file eigen.hpp.

◆ vectors() [2/2]

template<typename T >
const matrix< std::complex< double > > & numerical::eigen_decomposition< T >::vectors ( ) const &
inlinenoexcept

The eigenvectors as columns, ordered to match values (empty where they were not computed).

Definition at line 3093 of file eigen.hpp.

Member Data Documentation

◆ n_

template<typename T >
std::size_t numerical::eigen_decomposition< T >::n_
private

The matrix order.

Definition at line 3146 of file eigen.hpp.

◆ real_

template<typename T >
bool numerical::eigen_decomposition< T >::real_ {true}
private

Whether all eigenvalues are real.

Definition at line 3149 of file eigen.hpp.

◆ values_

template<typename T >
vector<std::complex<double> > numerical::eigen_decomposition< T >::values_
private

The eigenvalues.

Definition at line 3147 of file eigen.hpp.

◆ vectors_

template<typename T >
matrix<std::complex<double> > numerical::eigen_decomposition< T >::vectors_
private

The eigenvectors as columns.

Definition at line 3148 of file eigen.hpp.


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