TRIQS/nda 2.0.0
Multi-dimensional array library for C++
Loading...
Searching...
No Matches
Matrix eigenvalues

Detailed Description

Functions to compute eigenvalues and eigenvectors of matrices.

Functions

template<Matrix A>
requires (mem::have_host_compatible_addr_space<A> and is_blas_lapack_v<get_value_t<A>>)
auto nda::linalg::eig (A const &a)
 Compute the eigenvalues and right eigenvectors of a general matrix.
template<blas_lapack::BlasArray< 2 > A>
requires (mem::have_host_compatible_addr_space<A> and blas_lapack::has_F_layout<A>)
auto nda::linalg::eig_in_place (A &&a)
 Compute the eigenvalues and right eigenvectors of a general matrix in place.
template<Matrix A>
requires (mem::have_host_compatible_addr_space<A> and is_blas_lapack_v<get_value_t<A>>)
auto nda::linalg::eigh (A const &a)
 Compute the eigenvalues and eigenvectors of a real symmetric or complex hermitian matrix.
template<Matrix A, Matrix B>
requires (mem::have_host_compatible_addr_space<A, B> and is_blas_lapack_v<get_value_t<A>> and have_same_value_type_v<A, B>)
auto nda::linalg::eigh (A const &a, B const &b, int itype=1)
 Compute the eigenvalues and eigenvectors of a generalized real symmetric-definite or complex hermitian-definite eigenvalue problem.
template<blas_lapack::BlasArray< 2 > A>
requires (mem::have_host_compatible_addr_space<A> and blas_lapack::has_F_layout<A>)
auto nda::linalg::eigh_in_place (A &&a)
 Compute the eigenvalues and eigenvectors of a real symmetric or complex hermitian matrix in place.
template<blas_lapack::BlasArray< 2 > A, blas_lapack::BlasArrayFor< A, 2 > B>
requires (mem::have_host_compatible_addr_space<A, B> and blas_lapack::has_F_layout<A, B>)
auto nda::linalg::eigh_in_place (A &&a, B &&b, int itype=1)
 Compute the eigenvalues and eigenvectors of a generalized real symmetric-definite or complex hermitian-definite eigenvalue problem in place.
template<Matrix A>
requires (mem::have_host_compatible_addr_space<A> and is_blas_lapack_v<get_value_t<A>>)
auto nda::linalg::eigvals (A const &a)
 Compute the eigenvalues of a general matrix.
template<blas_lapack::BlasArray< 2 > A>
requires (mem::have_host_compatible_addr_space<A> and blas_lapack::has_F_layout<A>)
auto nda::linalg::eigvals_in_place (A &&a)
 Compute the eigenvalues of a general matrix in place.
template<Matrix A>
requires (mem::have_host_compatible_addr_space<A> and is_blas_lapack_v<get_value_t<A>>)
auto nda::linalg::eigvalsh (A const &a)
 Compute the eigenvalues of a real symmetric or complex hermitian matrix.
template<Matrix A, Matrix B>
requires (mem::have_host_compatible_addr_space<A, B> and is_blas_lapack_v<get_value_t<A>> and have_same_value_type_v<A, B>)
auto nda::linalg::eigvalsh (A const &a, B const &b, int itype=1)
 Compute the eigenvalues of a generalized real symmetric-definite or complex hermitian-definite eigenvalue problem.
template<blas_lapack::BlasArray< 2 > A>
requires (mem::have_host_compatible_addr_space<A> and blas_lapack::has_F_layout<A>)
auto nda::linalg::eigvalsh_in_place (A &&a)
 Compute the eigenvalues of a real symmetric or complex hermitian matrix in place.
template<blas_lapack::BlasArray< 2 > A, blas_lapack::BlasArrayFor< A, 2 > B>
requires (mem::have_host_compatible_addr_space<A, B> and blas_lapack::has_F_layout<A, B>)
auto nda::linalg::eigvalsh_in_place (A &&a, B &&b, int itype=1)
 Compute the eigenvalues of a generalized real symmetric-definite or complex hermitian-definite eigenvalue problem in place.
template<Vector WR, Vector WI>
requires (mem::have_host_compatible_addr_space<WR, WI> and AnyOf<get_value_t<WR>, float, double> and have_same_value_type_v<WR, WI>)
auto nda::linalg::get_geev_eigenvalues (const WR &wr, const WI &wi)
 Get the complex eigenvalues from nda::lapack::geev output for real matrices.
template<Vector A, Vector B>
requires (mem::have_host_compatible_addr_space<A, B> and AnyOf<get_value_t<A>, std::complex<float>, std::complex<double>> and
have_same_value_type_v<A, B>)
auto nda::linalg::get_ggev_eigenvalues (const A &alpha, const B &beta)
 Get the complex eigenvalues from nda::lapack::ggev output for complex matrices.
template<Vector AR, Vector AI, Vector B>
requires (mem::have_host_compatible_addr_space<AR, AI, B> and FloatOrDouble<get_value_t<AR>> and have_same_value_type_v<AR, AI, B>)
auto nda::linalg::get_ggev_eigenvalues (const AR &alphar, const AI &alphai, const B &beta)
 Get the complex eigenvalues from nda::lapack::ggev output for real matrices.
template<Vector WI, Matrix VA>
requires (mem::have_host_compatible_addr_space<WI, VA> and FloatOrDouble<get_value_t<WI>> and have_same_value_type_v<WI, VA>)
auto nda::linalg::unpack_eigenvectors (const WI &wi, const VA &va)
 Unpack eigenvectors of real matrices from nda::lapack::geev or nda::lapack::ggev output.

Function Documentation

◆ eig()

template<Matrix A>
requires (mem::have_host_compatible_addr_space<A> and is_blas_lapack_v<get_value_t<A>>)
auto nda::linalg::eig ( A const & a)

#include <nda/linalg/eig.hpp>

Compute the eigenvalues and right eigenvectors of a general matrix.

It makes a copy of the given input matrix \( \mathbf{A} \) and calls nda::linalg::eig_in_place with the copy.

The resulting matrix \( \mathbf{V} \) containing the eigenvectors is always returned in nda::F_layout.

Note
\( \mathbf{A} \) is required to satisfy nda::mem::have_host_compatible_addr_space and to have a value type that satisfies nda::is_blas_lapack_v.
Template Parameters
Anda::Matrix type.
Parameters
aInput matrix \( \mathbf{A} \).
Returns
std::pair containing an nda::array with the complex eigenvalues \( \lambda_j \) and an nda::matrix \(\mathbf{V} \) with the complex right eigenvectors \( \mathbf{v}_j \) in its columns.

Definition at line 342 of file eig.hpp.

◆ eig_in_place()

template<blas_lapack::BlasArray< 2 > A>
requires (mem::have_host_compatible_addr_space<A> and blas_lapack::has_F_layout<A>)
auto nda::linalg::eig_in_place ( A && a)

#include <nda/linalg/eig.hpp>

Compute the eigenvalues and right eigenvectors of a general matrix in place.

It computes the right eigenvectors \( \mathbf{v}_j \) and eigenvalues \( \lambda_j \) of the matrix \( \mathbf{A} \) such that

\[ \mathbf{A} \mathbf{v}_j = \lambda_j \mathbf{v}_j \; . \]

It calls nda::lapack::geev and, for real matrices, retrieves the complex eigenvalues and eigenvectors using nda::linalg::get_geev_eigenvalues and nda::linalg::unpack_eigenvectors.

The resulting matrix \( \mathbf{V} \) containing the eigenvectors is always returned in nda::F_layout.

An exception is thrown, if the LAPACK call fails.

Note
\( \mathbf{A} \) is required to satisfy nda::mem::have_host_compatible_addr_space and to have nda::F_layout. See nda::linalg::eig for a version that handles nda::C_layout.
Template Parameters
Anda::blas_lapack::BlasArray<2> type.
Parameters
aInput/output matrix. On entry, the matrix \( \mathbf{A} \). On exit, it is overwritten.
Returns
std::pair containing an nda::array with the complex eigenvalues \( \lambda_j \) and an nda::matrix \(\mathbf{V} \) with the complex right eigenvectors \( \mathbf{v}_j \) in its columns.

Definition at line 292 of file eig.hpp.

◆ eigh() [1/2]

template<Matrix A>
requires (mem::have_host_compatible_addr_space<A> and is_blas_lapack_v<get_value_t<A>>)
auto nda::linalg::eigh ( A const & a)

#include <nda/linalg/eigh.hpp>

Compute the eigenvalues and eigenvectors of a real symmetric or complex hermitian matrix.

It makes a copy of the input matrix \( \mathbf{A} \) and calls nda::linalg::eigh_in_place with the copy.

Note
\( \mathbf{A} \) is required to satisfy nda::mem::have_host_compatible_addr_space and to have a value type that satisfies nda::is_blas_lapack_v.
Template Parameters
Anda::Matrix type.
Parameters
aInput matrix \( \mathbf{A} \).
Returns
std::pair containing an nda::array with the real eigenvalues \( \lambda_i \) in ascending order and an nda::matrix \( \mathbf{V} \) in nda::F_layout containing the eigenvectors \( \mathbf{v}_i \) in its columns.

Definition at line 165 of file eigh.hpp.

◆ eigh() [2/2]

template<Matrix A, Matrix B>
requires (mem::have_host_compatible_addr_space<A, B> and is_blas_lapack_v<get_value_t<A>> and have_same_value_type_v<A, B>)
auto nda::linalg::eigh ( A const & a,
B const & b,
int itype = 1 )

#include <nda/linalg/eigh.hpp>

Compute the eigenvalues and eigenvectors of a generalized real symmetric-definite or complex hermitian-definite eigenvalue problem.

It makes copies of the input matrices \( \mathbf{A} \) and \( \mathbf{B} \) and calls nda::linalg::eigh_in_place(A &&, B&&, int) with the copies.

Note
\( \mathbf{A} \) and \( \mathbf{B} \) are required to satisfy nda::mem::have_host_compatible_addr_space and to have the same value type that satisfies nda::is_blas_lapack_v.
Template Parameters
Anda::Matrix type.
Bnda::Matrix type.
Parameters
aInput matrix \( \mathbf{A} \).
bInput matrix \( \mathbf{B} \).
itypeSpecifies the problem to be solved.
Returns
std::pair containing an nda::array with the real eigenvalues \( \lambda_i \) in ascending order and an nda::matrix \( \mathbf{V} \) in nda::F_layout containing the eigenvectors \( \mathbf{v}_i \) in its columns.

Definition at line 191 of file eigh.hpp.

◆ eigh_in_place() [1/2]

template<blas_lapack::BlasArray< 2 > A>
requires (mem::have_host_compatible_addr_space<A> and blas_lapack::has_F_layout<A>)
auto nda::linalg::eigh_in_place ( A && a)

#include <nda/linalg/eigh.hpp>

Compute the eigenvalues and eigenvectors of a real symmetric or complex hermitian matrix in place.

It computes the eigenvectors \( \mathbf{v}_i \) and eigenvalues \( \lambda_i \) of the matrix \(\mathbf{A} \) such that

\[ \mathbf{A} \mathbf{v}_i = \lambda_i \mathbf{v}_i \; . \]

If \( \mathbf{A} \) is real, it calls nda::lapack::syev. If \( \mathbf{A} \) is complex, it calls nda::lapack::heev.

An exception is thrown, if the LAPACK call fails.

Note
\( \mathbf{A} \) is required to satisfy nda::mem::have_host_compatible_addr_space and to have nda::F_layout. See nda::linalg::eigh for a version that handles nda::C_layout.
Template Parameters
Anda::blas_lapack::BlasArray<2> type.
Parameters
aInput/output matrix. On entry, the matrix \( \mathbf{A} \). On exit, it contains the orthonormal eigenvectors \( \mathbf{v}_i \) in its columns.
Returns
An nda::array containing the real eigenvalues \( \lambda_i \) in ascending order.

Definition at line 109 of file eigh.hpp.

◆ eigh_in_place() [2/2]

template<blas_lapack::BlasArray< 2 > A, blas_lapack::BlasArrayFor< A, 2 > B>
requires (mem::have_host_compatible_addr_space<A, B> and blas_lapack::has_F_layout<A, B>)
auto nda::linalg::eigh_in_place ( A && a,
B && b,
int itype = 1 )

#include <nda/linalg/eigh.hpp>

Compute the eigenvalues and eigenvectors of a generalized real symmetric-definite or complex hermitian-definite eigenvalue problem in place.

It computes the eigenvectors \( \mathbf{v}_i \) and eigenvalues \( \lambda_i \) of one of the following eigenvalue problems:

  • \( \mathbf{A} \mathbf{v}_i = \lambda_i \mathbf{B} \mathbf{v}_i \) (itype = 1),
  • \( \mathbf{A} \mathbf{B} \mathbf{v}_i = \lambda_i \mathbf{v}_i \) (itype = 2) or
  • \( \mathbf{B} \mathbf{A} \mathbf{v}_i = \lambda_i \mathbf{v}_i \) (itype = 3).

Here \( \mathbf{A} \) and \( \mathbf{B} \) are assumed to be real symmetric or complex hermitian. In addition, \( \mathbf{B} \) is assumed to be positive definite.

If \( \mathbf{A} \) and \( \mathbf{B} \) are real, it calls nda::lapack::sygv. If \( \mathbf{A} \) and \(\mathbf{B} \) are complex, it calls nda::lapack::hegv.

An exception is thrown, if the LAPACK call fails.

Note
\( \mathbf{A} \) and \( \mathbf{B} \) are required to satisfy nda::mem::have_host_compatible_addr_space and to have nda::F_layout. See nda::linalg::eigh for a version that handles nda::C_layout.
Template Parameters
Anda::blas_lapack::BlasArray<2> type.
Bnda::blas_lapack::BlasArrayFor<A, 2> type.
Parameters
aInput/output matrix. On entry, the matrix \( \mathbf{A} \). On exit, it contains the normalized eigenvectors \( \mathbf{v}_i \) in its columns (see nda::lapack::sygv or nda::lapack::hegv for details).
bInput/output matrix. On entry, the matrix \( \mathbf{B} \). On exit, it is overwritten (see nda::lapack::sygv or nda::lapack::hegv for details).
itypeSpecifies the problem to be solved.
Returns
An nda::array containing the real eigenvalues \( \lambda_i \) in ascending order.

Definition at line 146 of file eigh.hpp.

◆ eigvals()

template<Matrix A>
requires (mem::have_host_compatible_addr_space<A> and is_blas_lapack_v<get_value_t<A>>)
auto nda::linalg::eigvals ( A const & a)

#include <nda/linalg/eig.hpp>

Compute the eigenvalues of a general matrix.

It makes a copy of the given input matrix \( \mathbf{A} \) and calls nda::linalg::eigvals_in_place with the copy.

Note
\( \mathbf{A} \) is required to satisfy nda::mem::have_host_compatible_addr_space and to have a value type that satisfies nda::is_blas_lapack_v.
Template Parameters
Anda::Matrix type.
Parameters
aInput matrix \( \mathbf{A} \).
Returns
An nda::array with the complex eigenvalues \( \lambda_j \).

Definition at line 362 of file eig.hpp.

◆ eigvals_in_place()

template<blas_lapack::BlasArray< 2 > A>
requires (mem::have_host_compatible_addr_space<A> and blas_lapack::has_F_layout<A>)
auto nda::linalg::eigvals_in_place ( A && a)

#include <nda/linalg/eig.hpp>

Compute the eigenvalues of a general matrix in place.

It computes the eigenvalues \( \lambda_j \) of the matrix \( \mathbf{A} \) such that

\[ \mathbf{A} \mathbf{v}_j = \lambda_j \mathbf{v}_j \; . \]

It calls nda::lapack::geev and, for real matrices, retrieves the complex eigenvalues using nda::linalg::get_geev_eigenvalues.

An exception is thrown, if the LAPACK call fails.

Note
\( \mathbf{A} \) is required to satisfy nda::mem::have_host_compatible_addr_space and to have nda::F_layout. See nda::linalg::eigvals for a version that handles nda::C_layout.
Template Parameters
Anda::blas_lapack::BlasArray<2> type.
Parameters
aInput/output matrix. On entry, the matrix \( \mathbf{A} \). On exit, it is overwritten.
Returns
An nda::array with the complex eigenvalues \( \lambda_j \).

Definition at line 319 of file eig.hpp.

◆ eigvalsh() [1/2]

template<Matrix A>
requires (mem::have_host_compatible_addr_space<A> and is_blas_lapack_v<get_value_t<A>>)
auto nda::linalg::eigvalsh ( A const & a)

#include <nda/linalg/eigh.hpp>

Compute the eigenvalues of a real symmetric or complex hermitian matrix.

It makes a copy of the input matrix \( \mathbf{A} \) and calls nda::linalg::eigvalsh_in_place with the copy.

Note
\( \mathbf{A} \) is required to satisfy nda::mem::have_host_compatible_addr_space and to have a value type that satisfies nda::is_blas_lapack_v.
Template Parameters
Anda::Matrix type.
Parameters
aInput matrix \( \mathbf{A} \).
Returns
An nda::array containing the real eigenvalues \( \lambda_i \) in ascending order.

Definition at line 276 of file eigh.hpp.

◆ eigvalsh() [2/2]

template<Matrix A, Matrix B>
requires (mem::have_host_compatible_addr_space<A, B> and is_blas_lapack_v<get_value_t<A>> and have_same_value_type_v<A, B>)
auto nda::linalg::eigvalsh ( A const & a,
B const & b,
int itype = 1 )

#include <nda/linalg/eigh.hpp>

Compute the eigenvalues of a generalized real symmetric-definite or complex hermitian-definite eigenvalue problem.

It makes copies of the input matrices \( \mathbf{A} \) and \( \mathbf{B} \) and calls nda::linalg::eigvalsh_in_place(A &&, B&&, int) with the copies.

Note
\( \mathbf{A} \) and \( \mathbf{B} \) are required to satisfy nda::mem::have_host_compatible_addr_space and to have the same value type that satisfies nda::is_blas_lapack_v.
Template Parameters
Anda::Matrix type.
Bnda::Matrix type.
Parameters
aInput matrix \( \mathbf{A} \).
bInput matrix \( \mathbf{B} \).
itypeSpecifies the problem to be solved.
Returns
An nda::array containing the real eigenvalues \( \lambda_i \) in ascending order.

Definition at line 300 of file eigh.hpp.

◆ eigvalsh_in_place() [1/2]

template<blas_lapack::BlasArray< 2 > A>
requires (mem::have_host_compatible_addr_space<A> and blas_lapack::has_F_layout<A>)
auto nda::linalg::eigvalsh_in_place ( A && a)

#include <nda/linalg/eigh.hpp>

Compute the eigenvalues of a real symmetric or complex hermitian matrix in place.

It computes the eigenvalues \( \lambda_i \) of the matrix \( \mathbf{A} \) such that

\[ \mathbf{A} \mathbf{v}_i = \lambda_i \mathbf{v}_i \; . \]

If \( \mathbf{A} \) is real, it calls nda::lapack::syev. If \( \mathbf{A} \) is complex, it calls nda::lapack::heev.

An exception is thrown, if the LAPACK call fails.

Note
\( \mathbf{A} \) is required to satisfy nda::mem::have_host_compatible_addr_space and to have nda::F_layout. See nda::linalg::eigvalsh for a version that handles nda::C_layout.
Template Parameters
Anda::blas_lapack::BlasArray<2> type.
Parameters
aInput/output matrix. On entry, the matrix \( \mathbf{A} \). On exit, the contents of \( \mathbf{A} \) are destroyed.
Returns
An nda::array containing the real eigenvalues \( \lambda_i \) in ascending order.

Definition at line 221 of file eigh.hpp.

◆ eigvalsh_in_place() [2/2]

template<blas_lapack::BlasArray< 2 > A, blas_lapack::BlasArrayFor< A, 2 > B>
requires (mem::have_host_compatible_addr_space<A, B> and blas_lapack::has_F_layout<A, B>)
auto nda::linalg::eigvalsh_in_place ( A && a,
B && b,
int itype = 1 )

#include <nda/linalg/eigh.hpp>

Compute the eigenvalues of a generalized real symmetric-definite or complex hermitian-definite eigenvalue problem in place.

It computes the eigenvalues \( \lambda_i \) of one of the following eigenvalue problems:

  • \( \mathbf{A} \mathbf{v}_i = \lambda_i \mathbf{B} \mathbf{v}_i \) (itype = 1),
  • \( \mathbf{A} \mathbf{B} \mathbf{v}_i = \lambda_i \mathbf{v}_i \) (itype = 2) or
  • \( \mathbf{B} \mathbf{A} \mathbf{v}_i = \lambda_i \mathbf{v}_i \) (itype = 3).

Here \( \mathbf{A} \) and \( \mathbf{B} \) are assumed to be real symmetric or complex hermitian. In addition, \( \mathbf{B} \) is assumed to be positive definite.

If \( \mathbf{A} \) and \( \mathbf{B} \) are real, it calls nda::lapack::sygv. If \( \mathbf{A} \) and \(\mathbf{B} \) are complex, it calls nda::lapack::hegv.

An exception is thrown, if the LAPACK call fails.

Note
\( \mathbf{A} \) and \( \mathbf{B} \) are required to satisfy nda::mem::have_host_compatible_addr_space and to have nda::F_layout. See nda::linalg::eigvalsh for a version that handles nda::C_layout.
Template Parameters
Anda::blas_lapack::BlasArray<2> type.
Bnda::blas_lapack::BlasArrayFor<A, 2> type.
Parameters
aInput/output matrix. On entry, the matrix \( \mathbf{A} \). On exit, the contents of \( \mathbf{A} \) are destroyed.
bInput/output matrix. On entry, the matrix \( \mathbf{B} \). On exit, it is overwritten (see nda::lapack::sygv or nda::lapack::hegv for details).
itypeSpecifies the problem to be solved.
Returns
An nda::array containing the real eigenvalues \( \lambda_i \) in ascending order.

Definition at line 257 of file eigh.hpp.

◆ get_geev_eigenvalues()

template<Vector WR, Vector WI>
requires (mem::have_host_compatible_addr_space<WR, WI> and AnyOf<get_value_t<WR>, float, double> and have_same_value_type_v<WR, WI>)
auto nda::linalg::get_geev_eigenvalues ( const WR & wr,
const WI & wi )

#include <nda/linalg/eig.hpp>

Get the complex eigenvalues from nda::lapack::geev output for real matrices.

For real matrices, nda::lapack::geev stores the computed eigenvalues in two real vectors, \(\mathbf{w}^{(r)} \) and \( \mathbf{w}^{(i)} \).

The actual (complex) eigenvalues \( \lambda_j \) are given by \( \lambda_j = w^{(r)}_j + i w^{(i)}_j \).

Use nda::linalg::unpack_eigenvectors to get corresponding eigenvectors.

Note
\( \mathbf{w}^{(r)} \) and \( \mathbf{w}^{(i)} \) are required to satisfy nda::mem::have_host_compatible_addr_space and to have the same real value type.
Template Parameters
WRnda::Vector type.
WInda::Vector type.
Parameters
wrInput vector \( \mathbf{w}^{(r)} \) containing the real parts of the computed eigenvalues, i.e. \(\mathrm{Re}(\lambda_j) \).
wiInput vector \( \mathbf{w}^{(i)} \) containing the imaginary parts of the computed eigenvalues, i.e. \( \mathrm{Im}(\lambda_j) \).
Returns
An nda::array containing the complex eigenvalues.

Definition at line 64 of file eig.hpp.

◆ get_ggev_eigenvalues() [1/2]

template<Vector A, Vector B>
requires (mem::have_host_compatible_addr_space<A, B> and AnyOf<get_value_t<A>, std::complex<float>, std::complex<double>> and
have_same_value_type_v<A, B>)
auto nda::linalg::get_ggev_eigenvalues ( const A & alpha,
const B & beta )

#include <nda/linalg/eig.hpp>

Get the complex eigenvalues from nda::lapack::ggev output for complex matrices.

For complex matrices, nda::lapack::ggev stores the computed generalized eigenvalues as two complex vectors \( \boldsymbol{\alpha} \) and \( \boldsymbol{\beta} \).

The actual eigenvalues \( \lambda_j \) are given by \( \lambda_j = \alpha_j / \beta_j \). We do not perform any checks if \( \beta_j \) is zero or if the quotient may over- or underflow.

Note
All input vectors are required to satisfy nda::mem::have_host_compatible_addr_space and to have the same complex value type.
Template Parameters
Anda::Vector type.
Bnda::Vector type.
Parameters
alphaInput vector \( \boldsymbol{\alpha} \) containing \( \alpha_j \).
betaInput vector \( \boldsymbol{\beta} \) containing \( \beta_j \).
Returns
An nda::array containing the complex eigenvalues.

Definition at line 199 of file eig.hpp.

◆ get_ggev_eigenvalues() [2/2]

template<Vector AR, Vector AI, Vector B>
requires (mem::have_host_compatible_addr_space<AR, AI, B> and FloatOrDouble<get_value_t<AR>> and have_same_value_type_v<AR, AI, B>)
auto nda::linalg::get_ggev_eigenvalues ( const AR & alphar,
const AI & alphai,
const B & beta )

#include <nda/linalg/eig.hpp>

Get the complex eigenvalues from nda::lapack::ggev output for real matrices.

For real matrices, nda::lapack::ggev stores the computed generalized eigenvalues as three real vectors \( \boldsymbol{\alpha}^{(r)} \), \( \boldsymbol{\alpha}^{(i)} \), and \( \boldsymbol{\beta} \).

The actual (complex) eigenvalues \( \lambda_j \) are given by \( \lambda_j = (\alpha^{(r)}_j + i \alpha^{(i)}_j) / \beta_j \). We do not perform any checks if \( \beta_j \) is zero or if the quotient may over- or underflow.

Use nda::linalg::unpack_eigenvectors to get corresponding eigenvectors (same packed format as geev).

Note
All input vectors are required to satisfy nda::mem::have_host_compatible_addr_space and to have the same real value type.
Template Parameters
ARnda::Vector type.
AInda::Vector type.
Bnda::Vector type.
Parameters
alpharInput vector \( \boldsymbol{\alpha}^{(r)} \) containing the real parts of \( \alpha_j \).
alphaiInput vector \( \boldsymbol{\alpha}^{(i)} \) containing the imaginary parts of \( \alpha_j \).
betaInput vector \( \boldsymbol{\beta} \) containing \( \beta_j \).
Returns
An nda::array containing the complex eigenvalues.

Definition at line 165 of file eig.hpp.

◆ unpack_eigenvectors()

template<Vector WI, Matrix VA>
requires (mem::have_host_compatible_addr_space<WI, VA> and FloatOrDouble<get_value_t<WI>> and have_same_value_type_v<WI, VA>)
auto nda::linalg::unpack_eigenvectors ( const WI & wi,
const VA & va )

#include <nda/linalg/eig.hpp>

Unpack eigenvectors of real matrices from nda::lapack::geev or nda::lapack::ggev output.

For real matrices, nda::lapack::geev and nda::lapack::ggev store the left and right eigenvectors in packed format in the columns \( \mathbf{v}^{(L)}_j \) and \( \mathbf{v}^{(R)}_j \) of real matrices \( \mathbf{V}_L \) and \( \mathbf{V}_R \), respectively.

The unpacking uses the imaginary parts of the eigenvalues ( \( \mathbf{w}^{(i)} \) for geev or \(\boldsymbol{\alpha}^{(i)} \) for ggev) to determine whether eigenvalues are real or form complex conjugate pairs:

  • If the eigenvalue \( \lambda_j \) is real, i.e. if the imaginary part is zero, then the corresponding
    • left eigenvector is given by \( \mathbf{u}_j = \mathbf{v}^{(L)}_j \).
    • right eigenvector is given by \( \mathbf{v}_j = \mathbf{v}^{(R)}_j \).
  • If the eigenvalues \( \lambda_j \) and \( \lambda_{j + 1} \) form a complex conjugate pair, i.e. if the imaginary part is positive, then the two corresponding
    • left eigenvectors are given by \( \mathbf{u}_j = \mathbf{v}^{(L)}_j + i \mathbf{v}^{(L)}_{j+1} \) and \(\mathbf{u}_{j+1} = \mathbf{v}^{(L)}_j - i \mathbf{v}^{(L)}_{j+1} \).
    • right eigenvectors are given by \( \mathbf{v}_j = \mathbf{v}^{(R)}_j + i \mathbf{v}^{(R)}_{j+1} \) and \(\mathbf{v}_{j+1} = \mathbf{v}^{(R)}_j - i \mathbf{v}^{(R)}_{j+1} \).

The resulting matrix is always returned in nda::F_layout.

Note
All input arrays are required to satisfy nda::mem::have_host_compatible_addr_space and to have the same real value type.
Template Parameters
WInda::Vector type.
VAnda::Matrix type.
Parameters
wiInput vector containing the imaginary parts of the eigenvalues ( \( \mathbf{w}^{(i)} \) for geev or \( \boldsymbol{\alpha}^{(i)} \) for ggev).
vaInput matrix \( \mathbf{V}_{L} \)/ \( \mathbf{V}_{R} \) containing the left/right eigenvectors in packed format.
Returns
An nda::matrix containing the complex left/right eigenvectors.

Definition at line 111 of file eig.hpp.