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, bool left=false)
 Decomposes input.
 
 eigen_decomposition (matrix< T > &&input, bool vectors=true, bool left=false)
 Decomposes 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.
 
const vector< std::complex< double > > & values () const noexcept
 The eigenvalues, in the order of the Schur form.
 
const matrix< std::complex< double > > & left_vectors () const noexcept
 The left eigenvectors as columns, ordered to match values (empty where they were not computed): column j is u with uᴴ A = λ_j uᴴ, of unit norm with its component of largest modulus real, as dgeev's VL; from the same Schur form as the right ones, so that each matches its eigenvalue.
 
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 conjugate_second's).
 
void conjugate_second (std::complex< double > *row, const std::complex< double > &value, double) const
 A real matrix's pair's second eigenvector row (value's imaginary part negative): the first's, the row above, conjugated, once finish has normalised it; nothing for any other.
 
void conjugate_second (std::complex< double > *, const std::complex< double > &, const std::complex< double > &) const noexcept
 No pairs in a complex matrix's eigenvectors.
 
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.
 
matrix< std::complex< double > > finished (buffer< std::complex< double > > rows, const detail::balancing &balanced, bool left) const
 The vectors of the rows rows (each a vector of the balanced matrix) in the input's basis, normalised, as columns: D undone (a right vector times it, a left one, left, over it: B = D⁻¹ Pᵀ A P D), then the exchanges P, each row normalised; then a pair's second row, the first's conjugate. Each row its own, on the threads.
 

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.
 
matrix< std::complex< double > > left_vectors_
 The left eigenvectors as columns.
 
bool real_ {true}
 Whether all eigenvalues are real.
 

Detailed Description

template<double_field 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 3112 of file eigen.hpp.

Constructor & Destructor Documentation

◆ eigen_decomposition() [1/2]

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

Decomposes input.

Parameters
[in]inputA square matrix.
[in]vectorsWhether to compute the eigenvectors (the eigenvalues alone cost a third as much).
[in]leftWhether to compute the left eigenvectors too (left_vectors), from the same Schur form.
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 3125 of file eigen.hpp.

◆ eigen_decomposition() [2/2]

template<double_field T>
numerical::eigen_decomposition< T >::eigen_decomposition ( matrix< T > &&  input,
bool  vectors = true,
bool  left = false 
)
inlineexplicit

Decomposes 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 square matrix.
[in]vectorsWhether to compute the eigenvectors (the eigenvalues alone cost a third as much).
[in]leftWhether to compute the left eigenvectors too (left_vectors), from the same Schur form.
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 3143 of file eigen.hpp.

Member Function Documentation

◆ conjugate_second() [1/2]

template<double_field T>
void numerical::eigen_decomposition< T >::conjugate_second ( std::complex< double > *  ,
const std::complex< double > &  ,
const std::complex< double > &   
) const
inlineprivatenoexcept

No pairs in a complex matrix's eigenvectors.

Definition at line 3306 of file eigen.hpp.

◆ conjugate_second() [2/2]

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

A real matrix's pair's second eigenvector row (value's imaginary part negative): the first's, the row above, conjugated, once finish has normalised it; nothing for any other.

Definition at line 3293 of file eigen.hpp.

◆ finish() [1/2]

template<double_field 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 3314 of file eigen.hpp.

◆ finish() [2/2]

template<double_field 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 conjugate_second's).

Definition at line 3276 of file eigen.hpp.

◆ finished()

template<double_field T>
matrix< std::complex< double > > numerical::eigen_decomposition< T >::finished ( buffer< std::complex< double > >  rows,
const detail::balancing &  balanced,
bool  left 
) const
inlineprivate

The vectors of the rows rows (each a vector of the balanced matrix) in the input's basis, normalised, as columns: D undone (a right vector times it, a left one, left, over it: B = D⁻¹ Pᵀ A P D), then the exchanges P, each row normalised; then a pair's second row, the first's conjugate. Each row its own, on the threads.

Definition at line 3327 of file eigen.hpp.

◆ left_vectors()

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

The left eigenvectors as columns, ordered to match values (empty where they were not computed): column j is u with uᴴ A = λ_j uᴴ, of unit norm with its component of largest modulus real, as dgeev's VL; from the same Schur form as the right ones, so that each matches its eigenvalue.

Definition at line 3247 of file eigen.hpp.

◆ real()

template<double_field 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 3266 of file eigen.hpp.

◆ values()

template<double_field 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 3237 of file eigen.hpp.

◆ vectors() [1/2]

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

The eigenvectors, moved out of an expiring decomposition.

Definition at line 3259 of file eigen.hpp.

◆ vectors() [2/2]

template<double_field 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 3253 of file eigen.hpp.

Member Data Documentation

◆ left_vectors_

template<double_field T>
matrix<std::complex<double> > numerical::eigen_decomposition< T >::left_vectors_
private

The left eigenvectors as columns.

Definition at line 3348 of file eigen.hpp.

◆ n_

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

The matrix order.

Definition at line 3345 of file eigen.hpp.

◆ real_

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

Whether all eigenvalues are real.

Definition at line 3349 of file eigen.hpp.

◆ values_

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

The eigenvalues.

Definition at line 3346 of file eigen.hpp.

◆ vectors_

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

The eigenvectors as columns.

Definition at line 3347 of file eigen.hpp.


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