|
Packit |
67cb25 |
.. index:: eigenvalues and eigenvectors
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
************
|
|
Packit |
67cb25 |
Eigensystems
|
|
Packit |
67cb25 |
************
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. include:: include.rst
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This chapter describes functions for computing eigenvalues and
|
|
Packit |
67cb25 |
eigenvectors of matrices. There are routines for real symmetric,
|
|
Packit |
67cb25 |
real nonsymmetric, complex hermitian, real generalized symmetric-definite,
|
|
Packit |
67cb25 |
complex generalized hermitian-definite, and real generalized nonsymmetric
|
|
Packit |
67cb25 |
eigensystems. Eigenvalues can be computed with or without eigenvectors.
|
|
Packit |
67cb25 |
The hermitian and real symmetric matrix algorithms are symmetric bidiagonalization
|
|
Packit |
67cb25 |
followed by QR reduction. The nonsymmetric algorithm is the Francis QR
|
|
Packit |
67cb25 |
double-shift. The generalized nonsymmetric algorithm is the QZ method due
|
|
Packit |
67cb25 |
to Moler and Stewart.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
The functions described in this chapter are declared in the header file
|
|
Packit |
67cb25 |
:file:`gsl_eigen.h`.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
Real Symmetric Matrices
|
|
Packit |
67cb25 |
=======================
|
|
Packit |
67cb25 |
.. index::
|
|
Packit |
67cb25 |
single: symmetric matrix, real, eigensystem
|
|
Packit |
67cb25 |
single: real symmetric matrix, eigensystem
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
For real symmetric matrices, the library uses the symmetric
|
|
Packit |
67cb25 |
bidiagonalization and QR reduction method. This is described in Golub
|
|
Packit |
67cb25 |
& van Loan, section 8.3. The computed eigenvalues are accurate to an
|
|
Packit |
67cb25 |
absolute accuracy of :math:`\epsilon ||A||_2`, where :math:`\epsilon` is
|
|
Packit |
67cb25 |
the machine precision.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. type:: gsl_eigen_symm_workspace
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This workspace contains internal parameters used for solving symmetric eigenvalue
|
|
Packit |
67cb25 |
problems.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: gsl_eigen_symm_workspace * gsl_eigen_symm_alloc (const size_t n)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function allocates a workspace for computing eigenvalues of
|
|
Packit |
67cb25 |
:data:`n`-by-:data:`n` real symmetric matrices. The size of the workspace
|
|
Packit |
67cb25 |
is :math:`O(2n)`.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: void gsl_eigen_symm_free (gsl_eigen_symm_workspace * w)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function frees the memory associated with the workspace :data:`w`.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: int gsl_eigen_symm (gsl_matrix * A, gsl_vector * eval, gsl_eigen_symm_workspace * w)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function computes the eigenvalues of the real symmetric matrix
|
|
Packit |
67cb25 |
:data:`A`. Additional workspace of the appropriate size must be provided
|
|
Packit |
67cb25 |
in :data:`w`. The diagonal and lower triangular part of :data:`A` are
|
|
Packit |
67cb25 |
destroyed during the computation, but the strict upper triangular part
|
|
Packit |
67cb25 |
is not referenced. The eigenvalues are stored in the vector :data:`eval`
|
|
Packit |
67cb25 |
and are unordered.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. type:: gsl_eigen_symmv_workspace
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This workspace contains internal parameters used for solving symmetric eigenvalue
|
|
Packit |
67cb25 |
and eigenvector problems.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: gsl_eigen_symmv_workspace * gsl_eigen_symmv_alloc (const size_t n)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function allocates a workspace for computing eigenvalues and
|
|
Packit |
67cb25 |
eigenvectors of :data:`n`-by-:data:`n` real symmetric matrices. The size of
|
|
Packit |
67cb25 |
the workspace is :math:`O(4n)`.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: void gsl_eigen_symmv_free (gsl_eigen_symmv_workspace * w)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function frees the memory associated with the workspace :data:`w`.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: int gsl_eigen_symmv (gsl_matrix * A, gsl_vector * eval, gsl_matrix * evec, gsl_eigen_symmv_workspace * w)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function computes the eigenvalues and eigenvectors of the real
|
|
Packit |
67cb25 |
symmetric matrix :data:`A`. Additional workspace of the appropriate size
|
|
Packit |
67cb25 |
must be provided in :data:`w`. The diagonal and lower triangular part of
|
|
Packit |
67cb25 |
:data:`A` are destroyed during the computation, but the strict upper
|
|
Packit |
67cb25 |
triangular part is not referenced. The eigenvalues are stored in the
|
|
Packit |
67cb25 |
vector :data:`eval` and are unordered. The corresponding eigenvectors are
|
|
Packit |
67cb25 |
stored in the columns of the matrix :data:`evec`. For example, the
|
|
Packit |
67cb25 |
eigenvector in the first column corresponds to the first eigenvalue.
|
|
Packit |
67cb25 |
The eigenvectors are guaranteed to be mutually orthogonal and normalised
|
|
Packit |
67cb25 |
to unit magnitude.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
Complex Hermitian Matrices
|
|
Packit |
67cb25 |
==========================
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
For hermitian matrices, the library uses the complex form of
|
|
Packit |
67cb25 |
the symmetric bidiagonalization and QR reduction method.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. index::
|
|
Packit |
67cb25 |
single: hermitian matrix, complex, eigensystem
|
|
Packit |
67cb25 |
single: complex hermitian matrix, eigensystem
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. type:: gsl_eigen_herm_workspace
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This workspace contains internal parameters used for solving hermitian eigenvalue
|
|
Packit |
67cb25 |
problems.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: gsl_eigen_herm_workspace * gsl_eigen_herm_alloc (const size_t n)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function allocates a workspace for computing eigenvalues of
|
|
Packit |
67cb25 |
:data:`n`-by-:data:`n` complex hermitian matrices. The size of the workspace
|
|
Packit |
67cb25 |
is :math:`O(3n)`.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: void gsl_eigen_herm_free (gsl_eigen_herm_workspace * w)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function frees the memory associated with the workspace :data:`w`.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: int gsl_eigen_herm (gsl_matrix_complex * A, gsl_vector * eval, gsl_eigen_herm_workspace * w)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function computes the eigenvalues of the complex hermitian matrix
|
|
Packit |
67cb25 |
:data:`A`. Additional workspace of the appropriate size must be provided
|
|
Packit |
67cb25 |
in :data:`w`. The diagonal and lower triangular part of :data:`A` are
|
|
Packit |
67cb25 |
destroyed during the computation, but the strict upper triangular part
|
|
Packit |
67cb25 |
is not referenced. The imaginary parts of the diagonal are assumed to be
|
|
Packit |
67cb25 |
zero and are not referenced. The eigenvalues are stored in the vector
|
|
Packit |
67cb25 |
:data:`eval` and are unordered.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. type:: gsl_eigen_hermv_workspace
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This workspace contains internal parameters used for solving hermitian eigenvalue
|
|
Packit |
67cb25 |
and eigenvector problems.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: gsl_eigen_hermv_workspace * gsl_eigen_hermv_alloc (const size_t n)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function allocates a workspace for computing eigenvalues and
|
|
Packit |
67cb25 |
eigenvectors of :data:`n`-by-:data:`n` complex hermitian matrices. The size of
|
|
Packit |
67cb25 |
the workspace is :math:`O(5n)`.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: void gsl_eigen_hermv_free (gsl_eigen_hermv_workspace * w)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function frees the memory associated with the workspace :data:`w`.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: int gsl_eigen_hermv (gsl_matrix_complex * A, gsl_vector * eval, gsl_matrix_complex * evec, gsl_eigen_hermv_workspace * w)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function computes the eigenvalues and eigenvectors of the complex
|
|
Packit |
67cb25 |
hermitian matrix :data:`A`. Additional workspace of the appropriate size
|
|
Packit |
67cb25 |
must be provided in :data:`w`. The diagonal and lower triangular part of
|
|
Packit |
67cb25 |
:data:`A` are destroyed during the computation, but the strict upper
|
|
Packit |
67cb25 |
triangular part is not referenced. The imaginary parts of the diagonal
|
|
Packit |
67cb25 |
are assumed to be zero and are not referenced. The eigenvalues are
|
|
Packit |
67cb25 |
stored in the vector :data:`eval` and are unordered. The corresponding
|
|
Packit |
67cb25 |
complex eigenvectors are stored in the columns of the matrix :data:`evec`.
|
|
Packit |
67cb25 |
For example, the eigenvector in the first column corresponds to the
|
|
Packit |
67cb25 |
first eigenvalue. The eigenvectors are guaranteed to be mutually
|
|
Packit |
67cb25 |
orthogonal and normalised to unit magnitude.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
Real Nonsymmetric Matrices
|
|
Packit |
67cb25 |
==========================
|
|
Packit |
67cb25 |
.. index::
|
|
Packit |
67cb25 |
single: nonsymmetric matrix, real, eigensystem
|
|
Packit |
67cb25 |
single: real nonsymmetric matrix, eigensystem
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
The solution of the real nonsymmetric eigensystem problem for a
|
|
Packit |
67cb25 |
matrix :math:`A` involves computing the Schur decomposition
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. math:: A = Z T Z^T
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
where :math:`Z` is an orthogonal matrix of Schur vectors and :math:`T`,
|
|
Packit |
67cb25 |
the Schur form, is quasi upper triangular with diagonal
|
|
Packit |
67cb25 |
:math:`1`-by-:math:`1` blocks which are real eigenvalues of :math:`A`, and
|
|
Packit |
67cb25 |
diagonal :math:`2`-by-:math:`2` blocks whose eigenvalues are complex
|
|
Packit |
67cb25 |
conjugate eigenvalues of :math:`A`. The algorithm used is the double-shift
|
|
Packit |
67cb25 |
Francis method.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. type:: gsl_eigen_nonsymm_workspace
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This workspace contains internal parameters used for solving nonsymmetric eigenvalue
|
|
Packit |
67cb25 |
problems.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: gsl_eigen_nonsymm_workspace * gsl_eigen_nonsymm_alloc (const size_t n)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function allocates a workspace for computing eigenvalues of
|
|
Packit |
67cb25 |
:data:`n`-by-:data:`n` real nonsymmetric matrices. The size of the workspace
|
|
Packit |
67cb25 |
is :math:`O(2n)`.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: void gsl_eigen_nonsymm_free (gsl_eigen_nonsymm_workspace * w)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function frees the memory associated with the workspace :data:`w`.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: void gsl_eigen_nonsymm_params (const int compute_t, const int balance, gsl_eigen_nonsymm_workspace * w)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function sets some parameters which determine how the eigenvalue
|
|
Packit |
67cb25 |
problem is solved in subsequent calls to :func:`gsl_eigen_nonsymm`.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
If :data:`compute_t` is set to 1, the full Schur form :math:`T` will be
|
|
Packit |
67cb25 |
computed by :func:`gsl_eigen_nonsymm`. If it is set to 0,
|
|
Packit |
67cb25 |
:math:`T` will not be computed (this is the default setting). Computing
|
|
Packit |
67cb25 |
the full Schur form :math:`T` requires approximately 1.5--2 times the
|
|
Packit |
67cb25 |
number of flops.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
If :data:`balance` is set to 1, a balancing transformation is applied
|
|
Packit |
67cb25 |
to the matrix prior to computing eigenvalues. This transformation is
|
|
Packit |
67cb25 |
designed to make the rows and columns of the matrix have comparable
|
|
Packit |
67cb25 |
norms, and can result in more accurate eigenvalues for matrices
|
|
Packit |
67cb25 |
whose entries vary widely in magnitude. See :ref:`Balancing <balancing>` for more
|
|
Packit |
67cb25 |
information. Note that the balancing transformation does not preserve
|
|
Packit |
67cb25 |
the orthogonality of the Schur vectors, so if you wish to compute the
|
|
Packit |
67cb25 |
Schur vectors with :func:`gsl_eigen_nonsymm_Z` you will obtain the Schur
|
|
Packit |
67cb25 |
vectors of the balanced matrix instead of the original matrix. The
|
|
Packit |
67cb25 |
relationship will be
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. math:: T = Q^T D^{-1} A D Q
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
where :data:`Q` is the matrix of Schur vectors for the balanced matrix, and
|
|
Packit |
67cb25 |
:data:`D` is the balancing transformation. Then :func:`gsl_eigen_nonsymm_Z`
|
|
Packit |
67cb25 |
will compute a matrix :data:`Z` which satisfies
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. math:: T = Z^{-1} A Z
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
with :math:`Z = D Q`. Note that :data:`Z` will not be orthogonal. For
|
|
Packit |
67cb25 |
this reason, balancing is not performed by default.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: int gsl_eigen_nonsymm (gsl_matrix * A, gsl_vector_complex * eval, gsl_eigen_nonsymm_workspace * w)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function computes the eigenvalues of the real nonsymmetric matrix
|
|
Packit |
67cb25 |
:data:`A` and stores them in the vector :data:`eval`. If :math:`T` is
|
|
Packit |
67cb25 |
desired, it is stored in the upper portion of :data:`A` on output.
|
|
Packit |
67cb25 |
Otherwise, on output, the diagonal of :data:`A` will contain the
|
|
Packit |
67cb25 |
:math:`1`-by-:math:`1` real eigenvalues and :math:`2`-by-:math:`2`
|
|
Packit |
67cb25 |
complex conjugate eigenvalue systems, and the rest of :data:`A` is
|
|
Packit |
67cb25 |
destroyed. In rare cases, this function may fail to find all
|
|
Packit |
67cb25 |
eigenvalues. If this happens, an error code is returned
|
|
Packit |
67cb25 |
and the number of converged eigenvalues is stored in :code:`w->n_evals`.
|
|
Packit |
67cb25 |
The converged eigenvalues are stored in the beginning of :data:`eval`.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: int gsl_eigen_nonsymm_Z (gsl_matrix * A, gsl_vector_complex * eval, gsl_matrix * Z, gsl_eigen_nonsymm_workspace * w)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function is identical to :func:`gsl_eigen_nonsymm` except that it also
|
|
Packit |
67cb25 |
computes the Schur vectors and stores them into :data:`Z`.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. type:: gsl_eigen_nonsymmv_workspace
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This workspace contains internal parameters used for solving nonsymmetric eigenvalue
|
|
Packit |
67cb25 |
and eigenvector problems.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: gsl_eigen_nonsymmv_workspace * gsl_eigen_nonsymmv_alloc (const size_t n)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function allocates a workspace for computing eigenvalues and
|
|
Packit |
67cb25 |
eigenvectors of :data:`n`-by-:data:`n` real nonsymmetric matrices. The
|
|
Packit |
67cb25 |
size of the workspace is :math:`O(5n)`.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: void gsl_eigen_nonsymmv_free (gsl_eigen_nonsymmv_workspace * w)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function frees the memory associated with the workspace :data:`w`.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: void gsl_eigen_nonsymmv_params (const int balance, gsl_eigen_nonsymm_workspace * w)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function sets parameters which determine how the eigenvalue
|
|
Packit |
67cb25 |
problem is solved in subsequent calls to :func:`gsl_eigen_nonsymmv`.
|
|
Packit |
67cb25 |
If :data:`balance` is set to 1, a balancing transformation is applied
|
|
Packit |
67cb25 |
to the matrix. See :func:`gsl_eigen_nonsymm_params` for more information.
|
|
Packit |
67cb25 |
Balancing is turned off by default since it does not preserve the
|
|
Packit |
67cb25 |
orthogonality of the Schur vectors.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: int gsl_eigen_nonsymmv (gsl_matrix * A, gsl_vector_complex * eval, gsl_matrix_complex * evec, gsl_eigen_nonsymmv_workspace * w)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function computes eigenvalues and right eigenvectors of the
|
|
Packit |
67cb25 |
:data:`n`-by-:data:`n` real nonsymmetric matrix :data:`A`. It first calls
|
|
Packit |
67cb25 |
:func:`gsl_eigen_nonsymm` to compute the eigenvalues, Schur form :math:`T`, and
|
|
Packit |
67cb25 |
Schur vectors. Then it finds eigenvectors of :math:`T` and backtransforms
|
|
Packit |
67cb25 |
them using the Schur vectors. The Schur vectors are destroyed in the
|
|
Packit |
67cb25 |
process, but can be saved by using :func:`gsl_eigen_nonsymmv_Z`. The
|
|
Packit |
67cb25 |
computed eigenvectors are normalized to have unit magnitude. On
|
|
Packit |
67cb25 |
output, the upper portion of :data:`A` contains the Schur form
|
|
Packit |
67cb25 |
:math:`T`. If :func:`gsl_eigen_nonsymm` fails, no eigenvectors are
|
|
Packit |
67cb25 |
computed, and an error code is returned.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: int gsl_eigen_nonsymmv_Z (gsl_matrix * A, gsl_vector_complex * eval, gsl_matrix_complex * evec, gsl_matrix * Z, gsl_eigen_nonsymmv_workspace * w)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function is identical to :func:`gsl_eigen_nonsymmv` except that it also saves
|
|
Packit |
67cb25 |
the Schur vectors into :data:`Z`.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
Real Generalized Symmetric-Definite Eigensystems
|
|
Packit |
67cb25 |
================================================
|
|
Packit |
67cb25 |
.. index:: generalized symmetric eigensystems
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
The real generalized symmetric-definite eigenvalue problem is to find
|
|
Packit |
67cb25 |
eigenvalues :math:`\lambda` and eigenvectors :math:`x` such that
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. math:: A x = \lambda B x
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
where :math:`A` and :math:`B` are symmetric matrices, and :math:`B` is
|
|
Packit |
67cb25 |
positive-definite. This problem reduces to the standard symmetric
|
|
Packit |
67cb25 |
eigenvalue problem by applying the Cholesky decomposition to :math:`B`:
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. only:: not texinfo
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. math::
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
A x & = \lambda B x \\
|
|
Packit |
67cb25 |
A x & = \lambda L L^T x \\
|
|
Packit |
67cb25 |
\left( L^{-1} A L^{-T} \right) L^T x & = \lambda L^T x
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. only:: texinfo
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
::
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
A x = \lambda B x
|
|
Packit |
67cb25 |
A x = \lambda L L^T x
|
|
Packit |
67cb25 |
( L^{-1} A L^{-T} ) L^T x = \lambda L^T x
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
Therefore, the problem becomes :math:`C y = \lambda y` where
|
|
Packit |
67cb25 |
:math:`C = L^{-1} A L^{-T}`
|
|
Packit |
67cb25 |
is symmetric, and :math:`y = L^T x`. The standard
|
|
Packit |
67cb25 |
symmetric eigensolver can be applied to the matrix :math:`C`.
|
|
Packit |
67cb25 |
The resulting eigenvectors are backtransformed to find the
|
|
Packit |
67cb25 |
vectors of the original problem. The eigenvalues and eigenvectors
|
|
Packit |
67cb25 |
of the generalized symmetric-definite eigenproblem are always real.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. type:: gsl_eigen_gensymm_workspace
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This workspace contains internal parameters used for solving generalized symmetric eigenvalue
|
|
Packit |
67cb25 |
problems.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: gsl_eigen_gensymm_workspace * gsl_eigen_gensymm_alloc (const size_t n)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function allocates a workspace for computing eigenvalues of
|
|
Packit |
67cb25 |
:data:`n`-by-:data:`n` real generalized symmetric-definite eigensystems. The
|
|
Packit |
67cb25 |
size of the workspace is :math:`O(2n)`.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: void gsl_eigen_gensymm_free (gsl_eigen_gensymm_workspace * w)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function frees the memory associated with the workspace :data:`w`.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: int gsl_eigen_gensymm (gsl_matrix * A, gsl_matrix * B, gsl_vector * eval, gsl_eigen_gensymm_workspace * w)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function computes the eigenvalues of the real generalized
|
|
Packit |
67cb25 |
symmetric-definite matrix pair (:data:`A`, :data:`B`), and stores them
|
|
Packit |
67cb25 |
in :data:`eval`, using the method outlined above. On output, :data:`B`
|
|
Packit |
67cb25 |
contains its Cholesky decomposition and :data:`A` is destroyed.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. type:: gsl_eigen_gensymmv_workspace
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This workspace contains internal parameters used for solving generalized symmetric eigenvalue
|
|
Packit |
67cb25 |
and eigenvector problems.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: gsl_eigen_gensymmv_workspace * gsl_eigen_gensymmv_alloc (const size_t n)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function allocates a workspace for computing eigenvalues and
|
|
Packit |
67cb25 |
eigenvectors of :data:`n`-by-:data:`n` real generalized symmetric-definite
|
|
Packit |
67cb25 |
eigensystems. The size of the workspace is :math:`O(4n)`.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: void gsl_eigen_gensymmv_free (gsl_eigen_gensymmv_workspace * w)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function frees the memory associated with the workspace :data:`w`.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: int gsl_eigen_gensymmv (gsl_matrix * A, gsl_matrix * B, gsl_vector * eval, gsl_matrix * evec, gsl_eigen_gensymmv_workspace * w)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function computes the eigenvalues and eigenvectors of the real
|
|
Packit |
67cb25 |
generalized symmetric-definite matrix pair (:data:`A`, :data:`B`), and
|
|
Packit |
67cb25 |
stores them in :data:`eval` and :data:`evec` respectively. The computed
|
|
Packit |
67cb25 |
eigenvectors are normalized to have unit magnitude. On output,
|
|
Packit |
67cb25 |
:data:`B` contains its Cholesky decomposition and :data:`A` is destroyed.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
Complex Generalized Hermitian-Definite Eigensystems
|
|
Packit |
67cb25 |
===================================================
|
|
Packit |
67cb25 |
.. index:: generalized hermitian definite eigensystems
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
The complex generalized hermitian-definite eigenvalue problem is to find
|
|
Packit |
67cb25 |
eigenvalues :math:`\lambda` and eigenvectors :math:`x` such that
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. math:: A x = \lambda B x
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
where :math:`A` and :math:`B` are hermitian matrices, and :math:`B` is
|
|
Packit |
67cb25 |
positive-definite. Similarly to the real case, this can be reduced
|
|
Packit |
67cb25 |
to :math:`C y = \lambda y` where
|
|
Packit |
67cb25 |
:math:`C = L^{-1} A L^{-\dagger}`
|
|
Packit |
67cb25 |
is hermitian, and
|
|
Packit |
67cb25 |
:math:`y = L^{\dagger} x`. The standard
|
|
Packit |
67cb25 |
hermitian eigensolver can be applied to the matrix :math:`C`.
|
|
Packit |
67cb25 |
The resulting eigenvectors are backtransformed to find the
|
|
Packit |
67cb25 |
vectors of the original problem. The eigenvalues
|
|
Packit |
67cb25 |
of the generalized hermitian-definite eigenproblem are always real.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. type:: gsl_eigen_genherm_workspace
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This workspace contains internal parameters used for solving generalized hermitian eigenvalue
|
|
Packit |
67cb25 |
problems.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: gsl_eigen_genherm_workspace * gsl_eigen_genherm_alloc (const size_t n)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function allocates a workspace for computing eigenvalues of
|
|
Packit |
67cb25 |
:data:`n`-by-:data:`n` complex generalized hermitian-definite eigensystems. The
|
|
Packit |
67cb25 |
size of the workspace is :math:`O(3n)`.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: void gsl_eigen_genherm_free (gsl_eigen_genherm_workspace * w)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function frees the memory associated with the workspace :data:`w`.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: int gsl_eigen_genherm (gsl_matrix_complex * A, gsl_matrix_complex * B, gsl_vector * eval, gsl_eigen_genherm_workspace * w)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function computes the eigenvalues of the complex generalized
|
|
Packit |
67cb25 |
hermitian-definite matrix pair (:data:`A`, :data:`B`), and stores them
|
|
Packit |
67cb25 |
in :data:`eval`, using the method outlined above. On output, :data:`B`
|
|
Packit |
67cb25 |
contains its Cholesky decomposition and :data:`A` is destroyed.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. type:: gsl_eigen_genhermv_workspace
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This workspace contains internal parameters used for solving generalized hermitian eigenvalue
|
|
Packit |
67cb25 |
and eigenvector problems.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: gsl_eigen_genhermv_workspace * gsl_eigen_genhermv_alloc (const size_t n)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function allocates a workspace for computing eigenvalues and
|
|
Packit |
67cb25 |
eigenvectors of :data:`n`-by-:data:`n` complex generalized hermitian-definite
|
|
Packit |
67cb25 |
eigensystems. The size of the workspace is :math:`O(5n)`.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: void gsl_eigen_genhermv_free (gsl_eigen_genhermv_workspace * w)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function frees the memory associated with the workspace :data:`w`.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: int gsl_eigen_genhermv (gsl_matrix_complex * A, gsl_matrix_complex * B, gsl_vector * eval, gsl_matrix_complex * evec, gsl_eigen_genhermv_workspace * w)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function computes the eigenvalues and eigenvectors of the complex
|
|
Packit |
67cb25 |
generalized hermitian-definite matrix pair (:data:`A`, :data:`B`), and
|
|
Packit |
67cb25 |
stores them in :data:`eval` and :data:`evec` respectively. The computed
|
|
Packit |
67cb25 |
eigenvectors are normalized to have unit magnitude. On output,
|
|
Packit |
67cb25 |
:data:`B` contains its Cholesky decomposition and :data:`A` is destroyed.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
Real Generalized Nonsymmetric Eigensystems
|
|
Packit |
67cb25 |
==========================================
|
|
Packit |
67cb25 |
.. index:: generalized eigensystems
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
Given two square matrices (:math:`A`, :math:`B`), the generalized
|
|
Packit |
67cb25 |
nonsymmetric eigenvalue problem is to find eigenvalues :math:`\lambda` and
|
|
Packit |
67cb25 |
eigenvectors :math:`x` such that
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. math:: A x = \lambda B x
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
We may also define the problem as finding eigenvalues :math:`\mu` and
|
|
Packit |
67cb25 |
eigenvectors :math:`y` such that
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. math:: \mu A y = B y
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
Note that these two problems are equivalent (with :math:`\lambda = 1/\mu`)
|
|
Packit |
67cb25 |
if neither :math:`\lambda` nor :math:`\mu` is zero. If say, :math:`\lambda`
|
|
Packit |
67cb25 |
is zero, then it is still a well defined eigenproblem, but its alternate
|
|
Packit |
67cb25 |
problem involving :math:`\mu` is not. Therefore, to allow for zero
|
|
Packit |
67cb25 |
(and infinite) eigenvalues, the problem which is actually solved is
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. math:: \beta A x = \alpha B x
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
The eigensolver routines below will return two values :math:`\alpha`
|
|
Packit |
67cb25 |
and :math:`\beta` and leave it to the user to perform the divisions
|
|
Packit |
67cb25 |
:math:`\lambda = \alpha / \beta` and :math:`\mu = \beta / \alpha`.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
If the determinant of the matrix pencil :math:`A - \lambda B` is zero
|
|
Packit |
67cb25 |
for all :math:`\lambda`, the problem is said to be singular; otherwise
|
|
Packit |
67cb25 |
it is called regular. Singularity normally leads to some
|
|
Packit |
67cb25 |
:math:`\alpha = \beta = 0` which means the eigenproblem is ill-conditioned
|
|
Packit |
67cb25 |
and generally does not have well defined eigenvalue solutions. The
|
|
Packit |
67cb25 |
routines below are intended for regular matrix pencils and could yield
|
|
Packit |
67cb25 |
unpredictable results when applied to singular pencils.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
The solution of the real generalized nonsymmetric eigensystem problem for a
|
|
Packit |
67cb25 |
matrix pair :math:`(A, B)` involves computing the generalized Schur
|
|
Packit |
67cb25 |
decomposition
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. only:: not texinfo
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. math::
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
A &= Q S Z^T \\
|
|
Packit |
67cb25 |
B &= Q T Z^T
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. only:: texinfo
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
::
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
A = Q S Z^T
|
|
Packit |
67cb25 |
B = Q T Z^T
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
where :math:`Q` and :math:`Z` are orthogonal matrices of left and right
|
|
Packit |
67cb25 |
Schur vectors respectively, and :math:`(S, T)` is the generalized Schur
|
|
Packit |
67cb25 |
form whose diagonal elements give the :math:`\alpha` and :math:`\beta`
|
|
Packit |
67cb25 |
values. The algorithm used is the QZ method due to Moler and Stewart
|
|
Packit |
67cb25 |
(see references).
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. type:: gsl_eigen_gen_workspace
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This workspace contains internal parameters used for solving generalized eigenvalue
|
|
Packit |
67cb25 |
problems.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: gsl_eigen_gen_workspace * gsl_eigen_gen_alloc (const size_t n)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function allocates a workspace for computing eigenvalues of
|
|
Packit |
67cb25 |
:data:`n`-by-:data:`n` real generalized nonsymmetric eigensystems. The
|
|
Packit |
67cb25 |
size of the workspace is :math:`O(n)`.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: void gsl_eigen_gen_free (gsl_eigen_gen_workspace * w)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function frees the memory associated with the workspace :data:`w`.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: void gsl_eigen_gen_params (const int compute_s, const int compute_t, const int balance, gsl_eigen_gen_workspace * w)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function sets some parameters which determine how the eigenvalue
|
|
Packit |
67cb25 |
problem is solved in subsequent calls to :func:`gsl_eigen_gen`.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
If :data:`compute_s` is set to 1, the full Schur form :math:`S` will be
|
|
Packit |
67cb25 |
computed by :func:`gsl_eigen_gen`. If it is set to 0,
|
|
Packit |
67cb25 |
:math:`S` will not be computed (this is the default setting). :math:`S`
|
|
Packit |
67cb25 |
is a quasi upper triangular matrix with 1-by-1 and 2-by-2 blocks
|
|
Packit |
67cb25 |
on its diagonal. 1-by-1 blocks correspond to real eigenvalues, and
|
|
Packit |
67cb25 |
2-by-2 blocks correspond to complex eigenvalues.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
If :data:`compute_t` is set to 1, the full Schur form :math:`T` will be
|
|
Packit |
67cb25 |
computed by :func:`gsl_eigen_gen`. If it is set to 0,
|
|
Packit |
67cb25 |
:math:`T` will not be computed (this is the default setting). :math:`T`
|
|
Packit |
67cb25 |
is an upper triangular matrix with non-negative elements on its diagonal.
|
|
Packit |
67cb25 |
Any 2-by-2 blocks in :math:`S` will correspond to a 2-by-2 diagonal
|
|
Packit |
67cb25 |
block in :math:`T`.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
The :data:`balance` parameter is currently ignored, since generalized
|
|
Packit |
67cb25 |
balancing is not yet implemented.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: int gsl_eigen_gen (gsl_matrix * A, gsl_matrix * B, gsl_vector_complex * alpha, gsl_vector * beta, gsl_eigen_gen_workspace * w)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function computes the eigenvalues of the real generalized nonsymmetric
|
|
Packit |
67cb25 |
matrix pair (:data:`A`, :data:`B`), and stores them as pairs in
|
|
Packit |
67cb25 |
(:data:`alpha`, :data:`beta`), where :data:`alpha` is complex and :data:`beta` is
|
|
Packit |
67cb25 |
real. If :math:`\beta_i` is non-zero, then
|
|
Packit |
67cb25 |
:math:`\lambda = \alpha_i / \beta_i` is an eigenvalue. Likewise,
|
|
Packit |
67cb25 |
if :math:`\alpha_i` is non-zero, then
|
|
Packit |
67cb25 |
:math:`\mu = \beta_i / \alpha_i` is an eigenvalue of the alternate
|
|
Packit |
67cb25 |
problem :math:`\mu A y = B y`. The elements of :data:`beta` are normalized
|
|
Packit |
67cb25 |
to be non-negative.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
If :math:`S` is desired, it is stored in :data:`A` on output. If :math:`T`
|
|
Packit |
67cb25 |
is desired, it is stored in :data:`B` on output. The ordering of
|
|
Packit |
67cb25 |
eigenvalues in (:data:`alpha`, :data:`beta`) follows the ordering
|
|
Packit |
67cb25 |
of the diagonal blocks in the Schur forms :math:`S` and :math:`T`. In rare
|
|
Packit |
67cb25 |
cases, this function may fail to find all eigenvalues. If this occurs, an
|
|
Packit |
67cb25 |
error code is returned.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: int gsl_eigen_gen_QZ (gsl_matrix * A, gsl_matrix * B, gsl_vector_complex * alpha, gsl_vector * beta, gsl_matrix * Q, gsl_matrix * Z, gsl_eigen_gen_workspace * w)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function is identical to :func:`gsl_eigen_gen` except that it also
|
|
Packit |
67cb25 |
computes the left and right Schur vectors and stores them into :data:`Q`
|
|
Packit |
67cb25 |
and :data:`Z` respectively.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. type:: gsl_eigen_genv_workspace
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This workspace contains internal parameters used for solving generalized eigenvalue
|
|
Packit |
67cb25 |
and eigenvector problems.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: gsl_eigen_genv_workspace * gsl_eigen_genv_alloc (const size_t n)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function allocates a workspace for computing eigenvalues and
|
|
Packit |
67cb25 |
eigenvectors of :data:`n`-by-:data:`n` real generalized nonsymmetric
|
|
Packit |
67cb25 |
eigensystems. The size of the workspace is :math:`O(7n)`.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: void gsl_eigen_genv_free (gsl_eigen_genv_workspace * w)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function frees the memory associated with the workspace :data:`w`.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: int gsl_eigen_genv (gsl_matrix * A, gsl_matrix * B, gsl_vector_complex * alpha, gsl_vector * beta, gsl_matrix_complex * evec, gsl_eigen_genv_workspace * w)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function computes eigenvalues and right eigenvectors of the
|
|
Packit |
67cb25 |
:data:`n`-by-:data:`n` real generalized nonsymmetric matrix pair
|
|
Packit |
67cb25 |
(:data:`A`, :data:`B`). The eigenvalues are stored in (:data:`alpha`, :data:`beta`)
|
|
Packit |
67cb25 |
and the eigenvectors are stored in :data:`evec`. It first calls
|
|
Packit |
67cb25 |
:func:`gsl_eigen_gen` to compute the eigenvalues, Schur forms, and
|
|
Packit |
67cb25 |
Schur vectors. Then it finds eigenvectors of the Schur forms and
|
|
Packit |
67cb25 |
backtransforms them using the Schur vectors. The Schur vectors are
|
|
Packit |
67cb25 |
destroyed in the process, but can be saved by using
|
|
Packit |
67cb25 |
:func:`gsl_eigen_genv_QZ`. The computed eigenvectors are normalized
|
|
Packit |
67cb25 |
to have unit magnitude. On output, (:data:`A`, :data:`B`) contains
|
|
Packit |
67cb25 |
the generalized Schur form (:math:`S`, :math:`T`). If :func:`gsl_eigen_gen`
|
|
Packit |
67cb25 |
fails, no eigenvectors are computed, and an error code is returned.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: int gsl_eigen_genv_QZ (gsl_matrix * A, gsl_matrix * B, gsl_vector_complex * alpha, gsl_vector * beta, gsl_matrix_complex * evec, gsl_matrix * Q, gsl_matrix * Z, gsl_eigen_genv_workspace * w)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function is identical to :func:`gsl_eigen_genv` except that it also
|
|
Packit |
67cb25 |
computes the left and right Schur vectors and stores them into :data:`Q`
|
|
Packit |
67cb25 |
and :data:`Z` respectively.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
Sorting Eigenvalues and Eigenvectors
|
|
Packit |
67cb25 |
====================================
|
|
Packit |
67cb25 |
.. index:: sorting eigenvalues and eigenvectors
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: int gsl_eigen_symmv_sort (gsl_vector * eval, gsl_matrix * evec, gsl_eigen_sort_t sort_type)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function simultaneously sorts the eigenvalues stored in the vector
|
|
Packit |
67cb25 |
:data:`eval` and the corresponding real eigenvectors stored in the columns
|
|
Packit |
67cb25 |
of the matrix :data:`evec` into ascending or descending order according to
|
|
Packit |
67cb25 |
the value of the parameter :data:`sort_type`,
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. type:: gsl_eigen_sort_t
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
================================= ===================================
|
|
Packit |
67cb25 |
:macro:`GSL_EIGEN_SORT_VAL_ASC` ascending order in numerical value
|
|
Packit |
67cb25 |
:macro:`GSL_EIGEN_SORT_VAL_DESC` descending order in numerical value
|
|
Packit |
67cb25 |
:macro:`GSL_EIGEN_SORT_ABS_ASC` ascending order in magnitude
|
|
Packit |
67cb25 |
:macro:`GSL_EIGEN_SORT_ABS_DESC` descending order in magnitude
|
|
Packit |
67cb25 |
================================= ===================================
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: int gsl_eigen_hermv_sort (gsl_vector * eval, gsl_matrix_complex * evec, gsl_eigen_sort_t sort_type)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function simultaneously sorts the eigenvalues stored in the vector
|
|
Packit |
67cb25 |
:data:`eval` and the corresponding complex eigenvectors stored in the
|
|
Packit |
67cb25 |
columns of the matrix :data:`evec` into ascending or descending order
|
|
Packit |
67cb25 |
according to the value of the parameter :data:`sort_type` as shown above.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: int gsl_eigen_nonsymmv_sort (gsl_vector_complex * eval, gsl_matrix_complex * evec, gsl_eigen_sort_t sort_type)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function simultaneously sorts the eigenvalues stored in the vector
|
|
Packit |
67cb25 |
:data:`eval` and the corresponding complex eigenvectors stored in the
|
|
Packit |
67cb25 |
columns of the matrix :data:`evec` into ascending or descending order
|
|
Packit |
67cb25 |
according to the value of the parameter :data:`sort_type` as shown above.
|
|
Packit |
67cb25 |
Only :macro:`GSL_EIGEN_SORT_ABS_ASC` and :macro:`GSL_EIGEN_SORT_ABS_DESC` are
|
|
Packit |
67cb25 |
supported due to the eigenvalues being complex.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: int gsl_eigen_gensymmv_sort (gsl_vector * eval, gsl_matrix * evec, gsl_eigen_sort_t sort_type)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function simultaneously sorts the eigenvalues stored in the vector
|
|
Packit |
67cb25 |
:data:`eval` and the corresponding real eigenvectors stored in the columns
|
|
Packit |
67cb25 |
of the matrix :data:`evec` into ascending or descending order according to
|
|
Packit |
67cb25 |
the value of the parameter :data:`sort_type` as shown above.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: int gsl_eigen_genhermv_sort (gsl_vector * eval, gsl_matrix_complex * evec, gsl_eigen_sort_t sort_type)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function simultaneously sorts the eigenvalues stored in the vector
|
|
Packit |
67cb25 |
:data:`eval` and the corresponding complex eigenvectors stored in the columns
|
|
Packit |
67cb25 |
of the matrix :data:`evec` into ascending or descending order according to
|
|
Packit |
67cb25 |
the value of the parameter :data:`sort_type` as shown above.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. function:: int gsl_eigen_genv_sort (gsl_vector_complex * alpha, gsl_vector * beta, gsl_matrix_complex * evec, gsl_eigen_sort_t sort_type)
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This function simultaneously sorts the eigenvalues stored in the vectors
|
|
Packit |
67cb25 |
(:data:`alpha`, :data:`beta`) and the corresponding complex eigenvectors
|
|
Packit |
67cb25 |
stored in the columns of the matrix :data:`evec` into ascending or
|
|
Packit |
67cb25 |
descending order according to the value of the parameter :data:`sort_type`
|
|
Packit |
67cb25 |
as shown above. Only :macro:`GSL_EIGEN_SORT_ABS_ASC` and
|
|
Packit |
67cb25 |
:macro:`GSL_EIGEN_SORT_ABS_DESC` are supported due to the eigenvalues being
|
|
Packit |
67cb25 |
complex.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
Examples
|
|
Packit |
67cb25 |
========
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
The following program computes the eigenvalues and eigenvectors of the 4-th order Hilbert matrix, :math:`H(i,j) = 1/(i + j + 1)`.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. include:: examples/eigen.c
|
|
Packit |
67cb25 |
:code:
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
Here is the beginning of the output from the program::
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
$ ./a.out
|
|
Packit |
67cb25 |
eigenvalue = 9.67023e-05
|
|
Packit |
67cb25 |
eigenvector =
|
|
Packit |
67cb25 |
-0.0291933
|
|
Packit |
67cb25 |
0.328712
|
|
Packit |
67cb25 |
-0.791411
|
|
Packit |
67cb25 |
0.514553
|
|
Packit |
67cb25 |
...
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This can be compared with the corresponding output from |octave|::
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
octave> [v,d] = eig(hilb(4));
|
|
Packit |
67cb25 |
octave> diag(d)
|
|
Packit |
67cb25 |
ans =
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
9.6702e-05
|
|
Packit |
67cb25 |
6.7383e-03
|
|
Packit |
67cb25 |
1.6914e-01
|
|
Packit |
67cb25 |
1.5002e+00
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
octave> v
|
|
Packit |
67cb25 |
v =
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
0.029193 0.179186 -0.582076 0.792608
|
|
Packit |
67cb25 |
-0.328712 -0.741918 0.370502 0.451923
|
|
Packit |
67cb25 |
0.791411 0.100228 0.509579 0.322416
|
|
Packit |
67cb25 |
-0.514553 0.638283 0.514048 0.252161
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
Note that the eigenvectors can differ by a change of sign, since the
|
|
Packit |
67cb25 |
sign of an eigenvector is arbitrary.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
The following program illustrates the use of the nonsymmetric
|
|
Packit |
67cb25 |
eigensolver, by computing the eigenvalues and eigenvectors of
|
|
Packit |
67cb25 |
the Vandermonde matrix
|
|
Packit |
67cb25 |
:math:`V(x;i,j) = x_i^{n - j}`
|
|
Packit |
67cb25 |
with :math:`x = (-1,-2,3,4)`.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. include:: examples/eigen_nonsymm.c
|
|
Packit |
67cb25 |
:code:
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
Here is the beginning of the output from the program::
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
$ ./a.out
|
|
Packit |
67cb25 |
eigenvalue = -6.41391 + 0i
|
|
Packit |
67cb25 |
eigenvector =
|
|
Packit |
67cb25 |
-0.0998822 + 0i
|
|
Packit |
67cb25 |
-0.111251 + 0i
|
|
Packit |
67cb25 |
0.292501 + 0i
|
|
Packit |
67cb25 |
0.944505 + 0i
|
|
Packit |
67cb25 |
eigenvalue = 5.54555 + 3.08545i
|
|
Packit |
67cb25 |
eigenvector =
|
|
Packit |
67cb25 |
-0.043487 + -0.0076308i
|
|
Packit |
67cb25 |
0.0642377 + -0.142127i
|
|
Packit |
67cb25 |
-0.515253 + 0.0405118i
|
|
Packit |
67cb25 |
-0.840592 + -0.00148565i
|
|
Packit |
67cb25 |
...
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
This can be compared with the corresponding output from |octave|::
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
octave> [v,d] = eig(vander([-1 -2 3 4]));
|
|
Packit |
67cb25 |
octave> diag(d)
|
|
Packit |
67cb25 |
ans =
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
-6.4139 + 0.0000i
|
|
Packit |
67cb25 |
5.5456 + 3.0854i
|
|
Packit |
67cb25 |
5.5456 - 3.0854i
|
|
Packit |
67cb25 |
2.3228 + 0.0000i
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
octave> v
|
|
Packit |
67cb25 |
v =
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
Columns 1 through 3:
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
-0.09988 + 0.00000i -0.04350 - 0.00755i -0.04350 + 0.00755i
|
|
Packit |
67cb25 |
-0.11125 + 0.00000i 0.06399 - 0.14224i 0.06399 + 0.14224i
|
|
Packit |
67cb25 |
0.29250 + 0.00000i -0.51518 + 0.04142i -0.51518 - 0.04142i
|
|
Packit |
67cb25 |
0.94451 + 0.00000i -0.84059 + 0.00000i -0.84059 - 0.00000i
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
Column 4:
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
-0.14493 + 0.00000i
|
|
Packit |
67cb25 |
0.35660 + 0.00000i
|
|
Packit |
67cb25 |
0.91937 + 0.00000i
|
|
Packit |
67cb25 |
0.08118 + 0.00000i
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
Note that the eigenvectors corresponding to the eigenvalue
|
|
Packit |
67cb25 |
:math:`5.54555 + 3.08545i` differ by the multiplicative constant
|
|
Packit |
67cb25 |
:math:`0.9999984 + 0.0017674i` which is an arbitrary phase factor
|
|
Packit |
67cb25 |
of magnitude 1.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
References and Further Reading
|
|
Packit |
67cb25 |
==============================
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
Further information on the algorithms described in this section can be
|
|
Packit |
67cb25 |
found in the following book,
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
* G. H. Golub, C. F. Van Loan, "Matrix Computations" (3rd Ed, 1996),
|
|
Packit |
67cb25 |
Johns Hopkins University Press, ISBN 0-8018-5414-8.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
Further information on the generalized eigensystems QZ algorithm
|
|
Packit |
67cb25 |
can be found in this paper,
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
* C. Moler, G. Stewart, "An Algorithm for Generalized Matrix Eigenvalue
|
|
Packit |
67cb25 |
Problems", SIAM J. Numer. Anal., Vol 10, No 2, 1973.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
.. index:: LAPACK
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
Eigensystem routines for very large matrices can be found in the
|
|
Packit |
67cb25 |
Fortran library |lapack|. The |lapack| library is described in,
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
* LAPACK Users' Guide (Third Edition, 1999), Published by SIAM,
|
|
Packit |
67cb25 |
ISBN 0-89871-447-8.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
The |lapack| source code can be found at the website http://www.netlib.org/lapack
|
|
Packit |
67cb25 |
along with an online copy of the users guide.
|