NAG Library Routine Document
F02ECF
1 Purpose
F02ECF computes selected eigenvalues and eigenvectors of a real general matrix.
2 Specification
SUBROUTINE F02ECF ( |
CRIT, N, A, LDA, WL, WU, MEST, M, WR, WI, VR, LDVR, VI, LDVI, WORK, LWORK, IWORK, BWORK, IFAIL) |
INTEGER |
N, LDA, MEST, M, LDVR, LDVI, LWORK, IWORK(N), IFAIL |
REAL (KIND=nag_wp) |
A(LDA,N), WL, WU, WR(N), WI(N), VR(LDVR,MEST), VI(LDVI,MEST), WORK(LWORK) |
LOGICAL |
BWORK(N) |
CHARACTER(1) |
CRIT |
|
3 Description
F02ECF computes selected eigenvalues and the corresponding right eigenvectors of a real general matrix
A:
Eigenvalues
λi may be selected either by
modulus, satisfying:
or by
real part, satisfying:
Note that even though A is real, λi and xi may be complex. If xi is an eigenvector corresponding to a complex eigenvalue λi, then the complex conjugate vector x-i is the eigenvector corresponding to the complex conjugate eigenvalue λ-i. The eigenvalues in a complex conjugate pair λi and λ-i are either both selected or both not selected.
4 References
Golub G H and Van Loan C F (1996)
Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore
5 Parameters
- 1: CRIT – CHARACTER(1)Input
On entry: indicates the criterion for selecting eigenvalues.
- CRIT='M'
- Eigenvalues are selected according to their moduli: wl≤λi≤wu.
- CRIT='R'
- Eigenvalues are selected according to their real parts: wl≤Reλi≤wu.
Constraint:
CRIT='M' or 'R'.
- 2: N – INTEGERInput
On entry: n, the order of the matrix A.
Constraint:
N≥0.
- 3: A(LDA,N) – REAL (KIND=nag_wp) arrayInput/Output
On entry: the n by n general matrix A.
On exit: contains the Hessenberg form of the balanced input matrix
A′ (see
Section 8).
- 4: LDA – INTEGERInput
On entry: the first dimension of the array
A as declared in the (sub)program from which F02ECF is called.
Constraint:
LDA≥max1,N.
- 5: WL – REAL (KIND=nag_wp)Input
- 6: WU – REAL (KIND=nag_wp)Input
On entry:
wl and
wu, the lower and upper bounds on the criterion for the selected eigenvalues (see
CRIT).
Constraint:
WU>WL.
- 7: MEST – INTEGERInput
On entry: the second dimension of the arrays
VR and
VI as declared in the (sub)program from which F02ECF is called.
MEST must be an upper bound on
m, the number of eigenvalues and eigenvectors selected. No eigenvectors are computed if
MEST<m.
Constraint:
MEST≥max1,m.
- 8: M – INTEGEROutput
On exit: m, the number of eigenvalues actually selected.
- 9: WR(N) – REAL (KIND=nag_wp) arrayOutput
- 10: WI(N) – REAL (KIND=nag_wp) arrayOutput
On exit: the first
M elements of
WR and
WI hold the real and imaginary parts, respectively, of the selected eigenvalues; elements
M+1 to
N contain the other eigenvalues. Complex conjugate pairs of eigenvalues are stored in consecutive elements of the arrays, with the eigenvalue having positive imaginary part first. See also
Section 8.
- 11: VR(LDVR,MEST) – REAL (KIND=nag_wp) arrayOutput
On exit: contains the real parts of the selected eigenvectors, with the ith column holding the real part of the eigenvector associated with the eigenvalue λi (stored in WRi and WIi).
- 12: LDVR – INTEGERInput
On entry: the first dimension of the array
VR as declared in the (sub)program from which F02ECF is called.
Constraint:
LDVR≥max1,N.
- 13: VI(LDVI,MEST) – REAL (KIND=nag_wp) arrayOutput
On exit: contains the imaginary parts of the selected eigenvectors, with the ith column holding the imaginary part of the eigenvector associated with the eigenvalue λi (stored in WRi and WIi).
- 14: LDVI – INTEGERInput
On entry: the first dimension of the array
VI as declared in the (sub)program from which F02ECF is called.
Constraint:
LDVI≥max1,N.
- 15: WORK(LWORK) – REAL (KIND=nag_wp) arrayWorkspace
- 16: LWORK – INTEGERInput
On entry: the dimension of the array
WORK as declared in the (sub)program from which F02ECF is called.
Constraint:
LWORK≥max1,N×N+4.
- 17: IWORK(N) – INTEGER arrayWorkspace
- 18: BWORK(N) – LOGICAL arrayWorkspace
- 19: IFAIL – INTEGERInput/Output
-
On entry:
IFAIL must be set to
0,
-1 or 1. If you are unfamiliar with this parameter you should refer to
Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value
-1 or 1 is recommended. If the output of error messages is undesirable, then the value
1 is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is
0.
When the value -1 or 1 is used it is essential to test the value of IFAIL on exit.
On exit:
IFAIL=0 unless the routine detects an error or a warning has been flagged (see
Section 6).
6 Error Indicators and Warnings
If on entry
IFAIL=0 or
-1, explanatory error messages are output on the current error message unit (as defined by
X04AAF).
Errors or warnings detected by the routine:
- IFAIL=1
On entry, | CRIT≠'M' or 'R', |
or | N<0, |
or | LDA<max1,N, |
or | WU≤WL, |
or | MEST<1, |
or | LDVR<max1,N, |
or | LDVI<max1,N, |
or | LWORK<max1,N×N+4. |
- IFAIL=2
The QR algorithm failed to compute all the eigenvalues. No eigenvectors have been computed.
- IFAIL=3
There are more than
MEST eigenvalues in the specified range. The actual number of eigenvalues in the range is returned in
M. No eigenvectors have been computed. Rerun with the second dimension of
VR and
VI=MEST≥M.
- IFAIL=4
Inverse iteration failed to compute all the specified eigenvectors. If an eigenvector failed to converge, the corresponding column of
VR and
VI is set to zero.
7 Accuracy
If
λi is an exact eigenvalue, and
λ~i is the corresponding computed value, then
where
cn is a modestly increasing function of
n,
ε is the
machine precision, and
si is the reciprocal condition number of
λi;
A′ is the balanced form of the original matrix
A (see
Section 8), and
A′≤A.
If
xi is the corresponding exact eigenvector, and
x~i is the corresponding computed eigenvector, then the angle
θx~i,xi between them is bounded as follows:
where
sepi is the reciprocal condition number of
xi.
The condition numbers
si and
sepi may be computed from the Hessenberg form of the balanced matrix
A′ which is returned in the array
A. This requires calling
F08PEF (DHSEQR) with
JOB='S' to compute the Schur form of
A′, followed by
F08QLF (DTRSNA).
8 Further Comments
F02ECF
calls routines from LAPACK in
Chapter F08. It
first balances the matrix, using a diagonal similarity transformation to reduce its norm; and then reduces the balanced matrix
A′ to upper Hessenberg form
H, using an orthogonal similarity transformation:
A′=QHQT. The routine uses the Hessenberg
QR algorithm to compute all the eigenvalues of
H, which are the same as the eigenvalues of
A. It computes the eigenvectors of
H which correspond to the selected eigenvalues, using inverse iteration. It premultiplies the eigenvectors by
Q to form the eigenvectors of
A′; and finally transforms the eigenvectors to those of the original matrix
A.
Each eigenvector x (real or complex) is normalized so that x2=1, and the element of largest absolute value is real and positive.
The inverse iteration routine may make a small perturbation to the real parts of close eigenvalues, and this may shift their moduli just outside the specified bounds. If you are relying on eigenvalues being within the bounds, you should test them on return from F02ECF.
The time taken by the routine is approximately proportional to n3.
The routine can be used to compute
all eigenvalues and eigenvectors, by setting
WL large and negative, and
WU large and positive.
9 Example
This example computes those eigenvalues of the matrix
A whose moduli lie in the range
0.2,0.5, and their corresponding eigenvectors, where
9.1 Program Text
Program Text (f02ecfe.f90)
9.2 Program Data
Program Data (f02ecfe.d)
9.3 Program Results
Program Results (f02ecfe.r)