CLA3P v0.3.1
Compact Linear Algebra Parallel Portable Package
Loading...
Searching...
No Matches
cla3p::LapackGeev< T_Matrix > Class Template Reference

Eigenvalue decomposition solver using LAPACK GEEV routines. More...

Public Member Functions

 LapackGeev ()
 Default constructor.
 LapackGeev (bool calcLeft, bool calcRight)
 Constructor with explicit eigenvector options.
 ~LapackGeev ()
 Destructor.
void reserve (int_t n)
 Pre-allocates internal buffers for a matrix of dimension n.
void clear ()
 Clears all internal data and releases allocated memory.
void decompose (const T_Matrix &mat)
 Performs the eigenvalue decomposition of mat.
void setCalcLeft (bool calcLeft)
 Sets whether to compute left eigenvectors.
void setCalcRight (bool calcRight)
 Sets whether to compute right eigenvectors.
bool getCalcLeft () const
 Checks if left eigenvectors will be computed.
bool getCalcRight () const
 Checks if right eigenvectors will be computed.
const T_CVector & eigenvalues () const
 Returns the computed eigenvalues.
const T_CMatrix & leftEigenvectors () const
 Returns the computed left eigenvectors.
const T_CMatrix & rightEigenvectors () const
 Returns the computed right eigenvectors.

Detailed Description

template<typename T_Matrix>
class cla3p::LapackGeev< T_Matrix >

Eigenvalue decomposition solver using LAPACK GEEV routines.

This class provides a high-level interface for computing eigenvalues and eigenvectors of general (non-symmetric) square matrices using the LAPACK GEEV implementation (real: dgeev/sgeev, complex: zgeev/cgeev).

The GEEV routine computes the eigenvalue decomposition of a general matrix \( A \):

  • Right eigenvectors: \( A v_i = \lambda_i v_i \)
  • Left eigenvectors: \( w_i^H A = \lambda_i w_i^H \)

Results are always returned as complex matrices/vectors, even for real input matrices, since real matrices may have complex conjugate eigenvalue pairs. Internal buffers are managed automatically and can be pre-allocated via reserve() to avoid repeated heap allocations when the solver is reused for multiple decompositions.

Template Parameters
T_MatrixThe dense matrix type to decompose (can be real or complex).

Usage Example

cla3p::dns::RdMatrix A = ...; // Input matrix
LapackGeev<cla3p::dns::RdMatrix> geev;
geev.reserve(A.nrows()); // Optional: pre-allocate buffers
geev.decompose(A);
const T_CVector & eigenvalues() const
Returns the computed eigenvalues.
const T_CMatrix & rightEigenvectors() const
Returns the computed right eigenvectors.
void reserve(int_t n)
Pre-allocates internal buffers for a matrix of dimension n.
void decompose(const T_Matrix &mat)
Performs the eigenvalue decomposition of mat.
virtual T_Int nrows() const
Number of rows.
Definition meta2d.hpp:54
XxMatrix< real_t > RdMatrix
Double precision real matrix.
Definition dense.hpp:55
CxMatrix< complex_t > CdMatrix
Double precision complex matrix.
Definition dense.hpp:67
CxVector< complex_t > CdVector
Double precision complex vector.
Definition dense.hpp:43
Examples
ex10a_geev_decomposition.cpp.

Constructor & Destructor Documentation

◆ LapackGeev() [1/2]

template<typename T_Matrix>
cla3p::LapackGeev< T_Matrix >::LapackGeev ( )

Default constructor.

Initializes the eigenvalue solver with default settings. calcLeft is set to false and calcRight is set to true, so only right eigenvectors are computed by default.

◆ LapackGeev() [2/2]

template<typename T_Matrix>
cla3p::LapackGeev< T_Matrix >::LapackGeev ( bool calcLeft,
bool calcRight )

Constructor with explicit eigenvector options.

Initializes the eigenvalue solver with the specified eigenvector computation options. Use this form when left eigenvectors are needed or when neither set of eigenvectors is required (eigenvalues only).

Parameters
[in]calcLeftIf true, left eigenvectors will be computed in decompose().
[in]calcRightIf true, right eigenvectors will be computed in decompose().

◆ ~LapackGeev()

template<typename T_Matrix>
cla3p::LapackGeev< T_Matrix >::~LapackGeev ( )

Destructor.

Releases all allocated resources and clears internal state.

Member Function Documentation

◆ reserve()

template<typename T_Matrix>
void cla3p::LapackGeev< T_Matrix >::reserve ( int_t n)

Pre-allocates internal buffers for a matrix of dimension n.

Allocates all scalar and complex workspace buffers required for eigenvalue decomposition of an n x n matrix. Calling this before decompose() avoids repeated heap allocations when the same solver instance is reused across multiple decompositions of equal or smaller size.

Parameters
[in]nMatrix dimension.
Examples
ex10a_geev_decomposition.cpp.

◆ clear()

template<typename T_Matrix>
void cla3p::LapackGeev< T_Matrix >::clear ( )

Clears all internal data and releases allocated memory.

Resets the solver to its initial state, releasing all computed results, internal workspace buffers, and resetting options to their defaults (calcLeft = false, calcRight = true).

◆ decompose()

template<typename T_Matrix>
void cla3p::LapackGeev< T_Matrix >::decompose ( const T_Matrix & mat)

Performs the eigenvalue decomposition of mat.

Computes the eigenvalues and, depending on the current settings, the left and/or right eigenvectors of mat using the LAPACK GEEV routine. The input matrix is copied internally before factorization; the original is left unmodified.

Results are accessible via eigenvalues(), leftEigenvectors(), and rightEigenvectors() after this call returns.

Parameters
[in]matSquare general dense matrix to decompose.
Note
For real input matrices, eigenvalues and eigenvectors are always returned as complex.
Examples
ex10a_geev_decomposition.cpp.

◆ setCalcLeft()

template<typename T_Matrix>
void cla3p::LapackGeev< T_Matrix >::setCalcLeft ( bool calcLeft)

Sets whether to compute left eigenvectors.

Takes effect on the next call to decompose(). Changing this setting after reserve() has been called will require new buffer allocations on the next decompose().

Parameters
[in]calcLeftIf true, left eigenvectors will be computed.

◆ setCalcRight()

template<typename T_Matrix>
void cla3p::LapackGeev< T_Matrix >::setCalcRight ( bool calcRight)

Sets whether to compute right eigenvectors.

Takes effect on the next call to decompose(). Changing this setting after reserve() has been called will require new buffer allocations on the next decompose().

Parameters
[in]calcRightIf true, right eigenvectors will be computed.

◆ getCalcLeft()

template<typename T_Matrix>
bool cla3p::LapackGeev< T_Matrix >::getCalcLeft ( ) const

Checks if left eigenvectors will be computed.

Returns
true if left eigenvectors will be computed, false otherwise.

◆ getCalcRight()

template<typename T_Matrix>
bool cla3p::LapackGeev< T_Matrix >::getCalcRight ( ) const

Checks if right eigenvectors will be computed.

Returns
true if right eigenvectors will be computed, false otherwise.

◆ eigenvalues()

template<typename T_Matrix>
const T_CVector & cla3p::LapackGeev< T_Matrix >::eigenvalues ( ) const

Returns the computed eigenvalues.

Each element i of the returned vector corresponds to the i-th eigenvalue \( \lambda_i \), matching the column ordering of leftEigenvectors() and rightEigenvectors().

Returns
Const reference to a complex vector of length n containing the eigenvalues.
Note
Only valid after a successful call to decompose().
Examples
ex10a_geev_decomposition.cpp.

◆ leftEigenvectors()

template<typename T_Matrix>
const T_CMatrix & cla3p::LapackGeev< T_Matrix >::leftEigenvectors ( ) const

Returns the computed left eigenvectors.

Column i of the returned matrix contains the left eigenvector \( w_i \) satisfying \( w_i^H A = \lambda_i w_i^H \), where \( \lambda_i \) is eigenvalues() [i].

Returns
Const reference to a complex n x n matrix of left eigenvectors.
Note
Only valid after calling decompose() with getCalcLeft() == true.
Examples
ex10a_geev_decomposition.cpp.

◆ rightEigenvectors()

template<typename T_Matrix>
const T_CMatrix & cla3p::LapackGeev< T_Matrix >::rightEigenvectors ( ) const

Returns the computed right eigenvectors.

Column i of the returned matrix contains the right eigenvector \( v_i \) satisfying \( A v_i = \lambda_i v_i \), where \( \lambda_i \) is eigenvalues() [i].

Returns
Const reference to a complex n x n matrix of right eigenvectors.
Note
Only valid after calling decompose() with getCalcRight() == true.
Examples
ex10a_geev_decomposition.cpp.