| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This chapter describes functions for computing eigenvalues and eigenvectors of matrices. There are routines for real symmetric, real nonsymmetric, complex hermitian, real generalized symmetric-definite, complex generalized hermitian-definite, and real generalized nonsymmetric eigensystems. Eigenvalues can be computed with or without eigenvectors. The hermitian and real symmetric matrix algorithms are symmetric bidiagonalization followed by QR reduction. The nonsymmetric algorithm is the Francis QR double-shift. The generalized nonsymmetric algorithm is the QZ method due to Moler and Stewart.
The functions described in this chapter are declared in the header file ‘gsl_eigen.h’.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
For real symmetric matrices, the library uses the symmetric
bidiagonalization and QR reduction method. This is described in Golub
& van Loan, section 8.3. The computed eigenvalues are accurate to an
absolute accuracy of
, where
is
the machine precision.
This function allocates a workspace for computing eigenvalues of
n-by-n real symmetric matrices. The size of the workspace
is
.
This function frees the memory associated with the workspace w.
This function computes the eigenvalues of the real symmetric matrix A. Additional workspace of the appropriate size must be provided in w. The diagonal and lower triangular part of A are destroyed during the computation, but the strict upper triangular part is not referenced. The eigenvalues are stored in the vector eval and are unordered.
This function allocates a workspace for computing eigenvalues and
eigenvectors of n-by-n real symmetric matrices. The size of
the workspace is
.
This function frees the memory associated with the workspace w.
This function computes the eigenvalues and eigenvectors of the real symmetric matrix A. Additional workspace of the appropriate size must be provided in w. The diagonal and lower triangular part of A are destroyed during the computation, but the strict upper triangular part is not referenced. The eigenvalues are stored in the vector eval and are unordered. The corresponding eigenvectors are stored in the columns of the matrix evec. For example, the eigenvector in the first column corresponds to the first eigenvalue. The eigenvectors are guaranteed to be mutually orthogonal and normalised to unit magnitude.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This function allocates a workspace for computing eigenvalues of
n-by-n complex hermitian matrices. The size of the workspace
is
.
This function frees the memory associated with the workspace w.
This function computes the eigenvalues of the complex hermitian matrix A. Additional workspace of the appropriate size must be provided in w. The diagonal and lower triangular part of A are destroyed during the computation, but the strict upper triangular part is not referenced. The imaginary parts of the diagonal are assumed to be zero and are not referenced. The eigenvalues are stored in the vector eval and are unordered.
This function allocates a workspace for computing eigenvalues and
eigenvectors of n-by-n complex hermitian matrices. The size of
the workspace is
.
This function frees the memory associated with the workspace w.
This function computes the eigenvalues and eigenvectors of the complex hermitian matrix A. Additional workspace of the appropriate size must be provided in w. The diagonal and lower triangular part of A are destroyed during the computation, but the strict upper triangular part is not referenced. The imaginary parts of the diagonal are assumed to be zero and are not referenced. The eigenvalues are stored in the vector eval and are unordered. The corresponding complex eigenvectors are stored in the columns of the matrix evec. For example, the eigenvector in the first column corresponds to the first eigenvalue. The eigenvectors are guaranteed to be mutually orthogonal and normalised to unit magnitude.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The solution of the real nonsymmetric eigensystem problem for a
matrix
involves computing the Schur decomposition
where
is an orthogonal matrix of Schur vectors and
,
the Schur form, is quasi upper triangular with diagonal
-by-
blocks which are real eigenvalues of
, and
diagonal
-by-
blocks whose eigenvalues are complex
conjugate eigenvalues of
. The algorithm used is the double
shift Francis method.
This function allocates a workspace for computing eigenvalues of
n-by-n real nonsymmetric matrices. The size of the workspace
is
.
This function frees the memory associated with the workspace w.
This function sets some parameters which determine how the eigenvalue
problem is solved in subsequent calls to gsl_eigen_nonsymm.
If compute_t is set to 1, the full Schur form
will be
computed by gsl_eigen_nonsymm. If it is set to 0,
will not be computed (this is the default setting). Computing
the full Schur form
requires approximately 1.5-2 times the
number of flops.
If balance is set to 1, a balancing transformation is applied
to the matrix prior to computing eigenvalues. This transformation is
designed to make the rows and columns of the matrix have comparable
norms, and can result in more accurate eigenvalues for matrices
whose entries vary widely in magnitude. See Balancing for more
information. Note that the balancing transformation does not preserve
the orthogonality of the Schur vectors, so if you wish to compute the
Schur vectors with gsl_eigen_nonsymm_Z you will obtain the Schur
vectors of the balanced matrix instead of the original matrix. The
relationship will be
where Q is the matrix of Schur vectors for the balanced matrix, and
D is the balancing transformation. Then gsl_eigen_nonsymm_Z
will compute a matrix Z which satisfies
with
. Note that Z will not be orthogonal. For
this reason, balancing is not performed by default.
This function computes the eigenvalues of the real nonsymmetric matrix
A and stores them in the vector eval. If
is
desired, it is stored in the upper portion of A on output.
Otherwise, on output, the diagonal of A will contain the
-by-
real eigenvalues and
-by-
complex conjugate eigenvalue systems, and the rest of A is
destroyed. In rare cases, this function may fail to find all
eigenvalues. If this happens, an error code is returned
and the number of converged eigenvalues is stored in w->n_evals.
The converged eigenvalues are stored in the beginning of eval.
This function is identical to gsl_eigen_nonsymm except it also
computes the Schur vectors and stores them into Z.
This function allocates a workspace for computing eigenvalues and
eigenvectors of n-by-n real nonsymmetric matrices. The
size of the workspace is
.
This function frees the memory associated with the workspace w.
This function computes eigenvalues and right eigenvectors of the
n-by-n real nonsymmetric matrix A. It first calls
gsl_eigen_nonsymm to compute the eigenvalues, Schur form
, and
Schur vectors. Then it finds eigenvectors of
and backtransforms
them using the Schur vectors. The Schur vectors are destroyed in the
process, but can be saved by using gsl_eigen_nonsymmv_Z. The
computed eigenvectors are normalized to have unit magnitude. On
output, the upper portion of A contains the Schur form
. If gsl_eigen_nonsymm fails, no eigenvectors are
computed, and an error code is returned.
This function is identical to gsl_eigen_nonsymmv except it also saves
the Schur vectors into Z.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The real generalized symmetric-definite eigenvalue problem is to find
eigenvalues
and eigenvectors
such that
where
and
are symmetric matrices, and
is
positive-definite. This problem reduces to the standard symmetric
eigenvalue problem by applying the Cholesky decomposition to
:
Therefore, the problem becomes
where
is symmetric, and
. The standard
symmetric eigensolver can be applied to the matrix
.
The resulting eigenvectors are backtransformed to find the
vectors of the original problem. The eigenvalues and eigenvectors
of the generalized symmetric-definite eigenproblem are always real.
This function allocates a workspace for computing eigenvalues of
n-by-n real generalized symmetric-definite eigensystems. The
size of the workspace is
.
This function frees the memory associated with the workspace w.
This function computes the eigenvalues of the real generalized symmetric-definite matrix pair (A, B), and stores them in eval, using the method outlined above. On output, B contains its Cholesky decomposition and A is destroyed.
This function allocates a workspace for computing eigenvalues and
eigenvectors of n-by-n real generalized symmetric-definite
eigensystems. The size of the workspace is
.
This function frees the memory associated with the workspace w.
This function computes the eigenvalues and eigenvectors of the real generalized symmetric-definite matrix pair (A, B), and stores them in eval and evec respectively. The computed eigenvectors are normalized to have unit magnitude. On output, B contains its Cholesky decomposition and A is destroyed.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The complex generalized hermitian-definite eigenvalue problem is to find
eigenvalues
and eigenvectors
such that
where
and
are hermitian matrices, and
is
positive-definite. Similarly to the real case, this can be reduced
to
where
is hermitian, and
. The standard
hermitian eigensolver can be applied to the matrix
.
The resulting eigenvectors are backtransformed to find the
vectors of the original problem. The eigenvalues
of the generalized hermitian-definite eigenproblem are always real.
This function allocates a workspace for computing eigenvalues of
n-by-n complex generalized hermitian-definite eigensystems. The
size of the workspace is
.
This function frees the memory associated with the workspace w.
This function computes the eigenvalues of the complex generalized hermitian-definite matrix pair (A, B), and stores them in eval, using the method outlined above. On output, B contains its Cholesky decomposition and A is destroyed.
This function allocates a workspace for computing eigenvalues and
eigenvectors of n-by-n complex generalized hermitian-definite
eigensystems. The size of the workspace is
.
This function frees the memory associated with the workspace w.
This function computes the eigenvalues and eigenvectors of the complex generalized hermitian-definite matrix pair (A, B), and stores them in eval and evec respectively. The computed eigenvectors are normalized to have unit magnitude. On output, B contains its Cholesky decomposition and A is destroyed.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Given two square matrices (
,
), the generalized
nonsymmetric eigenvalue problem is to find eigenvalues
and
eigenvectors
such that
We may also define the problem as finding eigenvalues
and
eigenvectors
such that
Note that these two problems are equivalent (with
)
if neither
nor
is zero. If say,
is zero, then it is still a well defined eigenproblem, but its alternate
problem involving
is not. Therefore, to allow for zero
(and infinite) eigenvalues, the problem which is actually solved is
The eigensolver routines below will return two values
and
and leave it to the user to perform the divisions
and
.
If the determinant of the matrix pencil
is zero
for all
, the problem is said to be singular; otherwise
it is called regular. Singularity normally leads to some
which means the eigenproblem is ill-conditioned
and generally does not have well defined eigenvalue solutions. The
routines below are intended for regular matrix pencils and could yield
unpredictable results when applied to singular pencils.
The solution of the real generalized nonsymmetric eigensystem problem for a
matrix pair
involves computing the generalized Schur
decomposition
where
and
are orthogonal matrices of left and right
Schur vectors respectively, and
is the generalized Schur
form whose diagonal elements give the
and
values. The algorithm used is the QZ method due to Moler and Stewart
(see references).
This function allocates a workspace for computing eigenvalues of
n-by-n real generalized nonsymmetric eigensystems. The
size of the workspace is
.
This function frees the memory associated with the workspace w.
This function sets some parameters which determine how the eigenvalue
problem is solved in subsequent calls to gsl_eigen_gen.
If compute_s is set to 1, the full Schur form
will be
computed by gsl_eigen_gen. If it is set to 0,
will not be computed (this is the default setting).
is a quasi upper triangular matrix with 1-by-1 and 2-by-2 blocks
on its diagonal. 1-by-1 blocks correspond to real eigenvalues, and
2-by-2 blocks correspond to complex eigenvalues.
If compute_t is set to 1, the full Schur form
will be
computed by gsl_eigen_gen. If it is set to 0,
will not be computed (this is the default setting).
is an upper triangular matrix with non-negative elements on its diagonal.
Any 2-by-2 blocks in
will correspond to a 2-by-2 diagonal
block in
.
The balance parameter is currently ignored, since generalized balancing is not yet implemented.
This function computes the eigenvalues of the real generalized nonsymmetric
matrix pair (A, B), and stores them as pairs in
(alpha, beta), where alpha is complex and beta is
real. If
is non-zero, then
is an eigenvalue. Likewise,
if
is non-zero, then
is an eigenvalue of the alternate
problem
. The elements of beta are normalized
to be non-negative.
If
is desired, it is stored in A on output. If
is desired, it is stored in B on output. The ordering of
eigenvalues in (alpha, beta) follows the ordering
of the diagonal blocks in the Schur forms
and
. In rare
cases, this function may fail to find all eigenvalues. If this occurs, an
error code is returned.
This function is identical to gsl_eigen_gen except it also
computes the left and right Schur vectors and stores them into Q
and Z respectively.
This function allocates a workspace for computing eigenvalues and
eigenvectors of n-by-n real generalized nonsymmetric
eigensystems. The size of the workspace is
.
This function frees the memory associated with the workspace w.
This function computes eigenvalues and right eigenvectors of the
n-by-n real generalized nonsymmetric matrix pair
(A, B). The eigenvalues are stored in (alpha, beta)
and the eigenvectors are stored in evec. It first calls
gsl_eigen_gen to compute the eigenvalues, Schur forms, and
Schur vectors. Then it finds eigenvectors of the Schur forms and
backtransforms them using the Schur vectors. The Schur vectors are
destroyed in the process, but can be saved by using
gsl_eigen_genv_QZ. The computed eigenvectors are normalized
to have unit magnitude. On output, (A, B) contains
the generalized Schur form (
,
). If gsl_eigen_gen
fails, no eigenvectors are computed, and an error code is returned.
This function is identical to gsl_eigen_genv except it also
computes the left and right Schur vectors and stores them into Q
and Z respectively.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This function simultaneously sorts the eigenvalues stored in the vector eval and the corresponding real eigenvectors stored in the columns of the matrix evec into ascending or descending order according to the value of the parameter sort_type,
GSL_EIGEN_SORT_VAL_ASCascending order in numerical value
GSL_EIGEN_SORT_VAL_DESCdescending order in numerical value
GSL_EIGEN_SORT_ABS_ASCascending order in magnitude
GSL_EIGEN_SORT_ABS_DESCdescending order in magnitude
This function simultaneously sorts the eigenvalues stored in the vector eval and the corresponding complex eigenvectors stored in the columns of the matrix evec into ascending or descending order according to the value of the parameter sort_type as shown above.
This function simultaneously sorts the eigenvalues stored in the vector
eval and the corresponding complex eigenvectors stored in the
columns of the matrix evec into ascending or descending order
according to the value of the parameter sort_type as shown above.
Only GSL_EIGEN_SORT_ABS_ASC and GSL_EIGEN_SORT_ABS_DESC are
supported due to the eigenvalues being complex.
This function simultaneously sorts the eigenvalues stored in the vector eval and the corresponding real eigenvectors stored in the columns of the matrix evec into ascending or descending order according to the value of the parameter sort_type as shown above.
This function simultaneously sorts the eigenvalues stored in the vector eval and the corresponding complex eigenvectors stored in the columns of the matrix evec into ascending or descending order according to the value of the parameter sort_type as shown above.
This function simultaneously sorts the eigenvalues stored in the vectors
(alpha, beta) and the corresponding complex eigenvectors
stored in the columns of the matrix evec into ascending or
descending order according to the value of the parameter sort_type
as shown above. Only GSL_EIGEN_SORT_ABS_ASC and
GSL_EIGEN_SORT_ABS_DESC are supported due to the eigenvalues being
complex.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The following program computes the eigenvalues and eigenvectors of the 4-th order Hilbert matrix,
.
|
Here is the beginning of the output from the program,
$ ./a.out eigenvalue = 9.67023e-05 eigenvector = -0.0291933 0.328712 -0.791411 0.514553 ... |
This can be compared with the corresponding output from GNU OCTAVE,
octave> [v,d] = eig(hilb(4)); octave> diag(d) ans = 9.6702e-05 6.7383e-03 1.6914e-01 1.5002e+00 octave> v v = 0.029193 0.179186 -0.582076 0.792608 -0.328712 -0.741918 0.370502 0.451923 0.791411 0.100228 0.509579 0.322416 -0.514553 0.638283 0.514048 0.252161 |
Note that the eigenvectors can differ by a change of sign, since the sign of an eigenvector is arbitrary.
The following program illustrates the use of the nonsymmetric
eigensolver, by computing the eigenvalues and eigenvectors of
the Vandermonde matrix
with
.
|
Here is the beginning of the output from the program,
$ ./a.out eigenvalue = -6.41391 + 0i eigenvector = -0.0998822 + 0i -0.111251 + 0i 0.292501 + 0i 0.944505 + 0i eigenvalue = 5.54555 + 3.08545i eigenvector = -0.043487 + -0.0076308i 0.0642377 + -0.142127i -0.515253 + 0.0405118i -0.840592 + -0.00148565i ... |
This can be compared with the corresponding output from GNU OCTAVE,
octave> [v,d] = eig(vander([-1 -2 3 4])); octave> diag(d) ans = -6.4139 + 0.0000i 5.5456 + 3.0854i 5.5456 - 3.0854i 2.3228 + 0.0000i octave> v v = Columns 1 through 3: -0.09988 + 0.00000i -0.04350 - 0.00755i -0.04350 + 0.00755i -0.11125 + 0.00000i 0.06399 - 0.14224i 0.06399 + 0.14224i 0.29250 + 0.00000i -0.51518 + 0.04142i -0.51518 - 0.04142i 0.94451 + 0.00000i -0.84059 + 0.00000i -0.84059 - 0.00000i Column 4: -0.14493 + 0.00000i 0.35660 + 0.00000i 0.91937 + 0.00000i 0.08118 + 0.00000i |
Note that the eigenvectors corresponding to the eigenvalue
are slightly different. This is because
they differ by the multiplicative constant
which has magnitude 1.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Further information on the algorithms described in this section can be found in the following book,
Further information on the generalized eigensystems QZ algorithm can be found in this paper,
Eigensystem routines for very large matrices can be found in the Fortran library LAPACK. The LAPACK library is described in,
The LAPACK source code can be found at the website above along with an online copy of the users guide.
| [ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated by Autobuild on December, 3 2008 using texi2html 1.78.