|
TRIQS/nda 2.0.0
Multi-dimensional array library for C++
|
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. | |
| 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.
| A | nda::Matrix type. |
| a | Input matrix \( \mathbf{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.
| A | nda::blas_lapack::BlasArray<2> type. |
| a | Input/output matrix. On entry, the matrix \( \mathbf{A} \). On exit, it is overwritten. |
| 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.
| A | nda::Matrix type. |
| a | Input matrix \( \mathbf{A} \). |
| 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.
| A | nda::Matrix type. |
| B | nda::Matrix type. |
| a | Input matrix \( \mathbf{A} \). |
| b | Input matrix \( \mathbf{B} \). |
| itype | Specifies the problem to be solved. |
| 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.
| A | nda::blas_lapack::BlasArray<2> type. |
| a | Input/output matrix. On entry, the matrix \( \mathbf{A} \). On exit, it contains the orthonormal eigenvectors \( \mathbf{v}_i \) in its columns. |
| 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:
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.
| A | nda::blas_lapack::BlasArray<2> type. |
| B | nda::blas_lapack::BlasArrayFor<A, 2> type. |
| a | Input/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). |
| b | Input/output matrix. On entry, the matrix \( \mathbf{B} \). On exit, it is overwritten (see nda::lapack::sygv or nda::lapack::hegv for details). |
| itype | Specifies the problem to be solved. |
| 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.
| A | nda::Matrix type. |
| a | Input matrix \( \mathbf{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.
| A | nda::blas_lapack::BlasArray<2> type. |
| a | Input/output matrix. On entry, the matrix \( \mathbf{A} \). On exit, it is overwritten. |
| 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.
| A | nda::Matrix type. |
| a | Input matrix \( \mathbf{A} \). |
| 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.
| A | nda::Matrix type. |
| B | nda::Matrix type. |
| a | Input matrix \( \mathbf{A} \). |
| b | Input matrix \( \mathbf{B} \). |
| itype | Specifies the problem to be solved. |
| 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.
| A | nda::blas_lapack::BlasArray<2> type. |
| a | Input/output matrix. On entry, the matrix \( \mathbf{A} \). On exit, the contents of \( \mathbf{A} \) are destroyed. |
| 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:
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.
| A | nda::blas_lapack::BlasArray<2> type. |
| B | nda::blas_lapack::BlasArrayFor<A, 2> type. |
| a | Input/output matrix. On entry, the matrix \( \mathbf{A} \). On exit, the contents of \( \mathbf{A} \) are destroyed. |
| b | Input/output matrix. On entry, the matrix \( \mathbf{B} \). On exit, it is overwritten (see nda::lapack::sygv or nda::lapack::hegv for details). |
| itype | Specifies the problem to be solved. |
| 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.
| WR | nda::Vector type. |
| WI | nda::Vector type. |
| wr | Input vector \( \mathbf{w}^{(r)} \) containing the real parts of the computed eigenvalues, i.e. \(\mathrm{Re}(\lambda_j) \). |
| wi | Input vector \( \mathbf{w}^{(i)} \) containing the imaginary parts of the computed eigenvalues, i.e. \( \mathrm{Im}(\lambda_j) \). |
| 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.
| A | nda::Vector type. |
| B | nda::Vector type. |
| alpha | Input vector \( \boldsymbol{\alpha} \) containing \( \alpha_j \). |
| beta | Input vector \( \boldsymbol{\beta} \) containing \( \beta_j \). |
| 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).
| AR | nda::Vector type. |
| AI | nda::Vector type. |
| B | nda::Vector type. |
| alphar | Input vector \( \boldsymbol{\alpha}^{(r)} \) containing the real parts of \( \alpha_j \). |
| alphai | Input vector \( \boldsymbol{\alpha}^{(i)} \) containing the imaginary parts of \( \alpha_j \). |
| beta | Input vector \( \boldsymbol{\beta} \) containing \( \beta_j \). |
| 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:
The resulting matrix is always returned in nda::F_layout.
| WI | nda::Vector type. |
| VA | nda::Matrix type. |
| wi | Input vector containing the imaginary parts of the eigenvalues ( \( \mathbf{w}^{(i)} \) for geev or \( \boldsymbol{\alpha}^{(i)} \) for ggev). |
| va | Input matrix \( \mathbf{V}_{L} \)/ \( \mathbf{V}_{R} \) containing the left/right eigenvectors in packed format. |