|
|
◆ Dhseqr()
| Sub Dhseqr |
( |
Job As |
String, |
|
|
Compz As |
String, |
|
|
N As |
Long, |
|
|
Ilo As |
Long, |
|
|
Ihi As |
Long, |
|
|
H() As |
Double, |
|
|
Wr() As |
Double, |
|
|
Wi() As |
Double, |
|
|
Z() As |
Double, |
|
|
Info As |
Long |
|
) |
| |
Eigenvalues and Schur factorization of Hessenberg matrix by QR method
- Purpose
- This routine computes the eigenvalues of a Hessenberg matrix H and, optionally, the matrices T and Z from the Schur decomposition H = Z T Z^T, where T is an upper quasi-triangular matrix (the Schur form), and Z is the orthogonal matrix of Schur vectors.
Optionally Z may be postmultiplied into an input orthogonal matrix Q so that this routine can give the Schur factorization of a matrix A which has been reduced to the Hessenberg form H by the orthogonal matrix Q: A = Q*H*Q^T = (QZ)*T*(QZ)^T.
- Parameters
-
| [in] | Job | = "E": Compute eigenvalues only.
= "S": Compute eigenvalues and the Schur form T. |
| [in] | Compz | = "N": No Schur vectors are computed.
= "I": Z() is initialized to the unit matrix and the matrix Z of Schur vectors of H is returned.
= "V": Z() must contain an orthogonal matrix Q on entry, and the product Q*Z is returned. |
| [in] | N | Order of the matrix H. (N >= 0) (If N = 0, returns without computation) |
| [in] | Ilo | |
| [in] | Ihi | It is assumed that H is already upper triangular in rows and columns 1〜Ilo-1 and Ihi+1〜N. Ilo and Ihi are normally set by a previous call to Dgebal, and then passed to Dgehrd when the matrix output by Dgebal is reduced to Hessenberg form. Otherwise they should be set to 1 and N respectively. (1 <= Ilo <= Ihi <= N, if N > 0. Ilo = 1 and Ihi = 0, if N = 0) |
| [in,out] | H() | Array H(LH1 - 1, LH2 - 1) (LH1 >= N, LH2 >= N)
[in] The upper Hessenberg matrix H.
[out] If Info = 0 and Job = "S", then H contains the upper quasi-triangular matrix T from the Schur decomposition (the Schur form). 2 x 2 diagonal blocks (corresponding to complex conjugate pairs of eigenvalues) are returned in standard form, with H(i, i) = H(i+1, i+1) and H(i+1, i)*H(i, i+1) < 0. If Info = 0 and Job = "E", the contents of H are unspecified on exit. (The output value of H when Info > 0 is given under the description of Info below.) |
| [out] | Wr() | Array Wr(LWr - 1) (LWr >= N) |
| [out] | Wi() | Array Wi(LWi - 1) (LWi >= N)
The real and imaginary parts, respectively, of the computed eigenvalues. If two eigenvalues are computed as a complex conjugate pair, they are stored in consecutive elements of Wr() and Wi(), say the i-th and (i+1)th, with Wi(i) > 0 and Wi(i+1) < 0. If Job = "S", the eigenvalues are stored in the same order as on the diagonal of the Schur form returned in H(), with Wr(i) = H(i, i) and, if H(i〜i+1, i〜i+1) is a 2 x 2 diagonal block, Wi(i) = sqrt(-H(i+1, i)*H(i, i+1)) and Wi(i+1) = -Wi(i). |
| [in,out] | Z() | Array Z(LZ1 - 1, LZ2 - 1) (LZ1 >= N, LZ2 >= N)
Compz = "I":
[in] Z() need not be set.
[out] if Info = 0, Z() contains the orthogonal matrix Z of the Schur vectors of H.
Compz = "V":
[in] Z() must contain an N x N matrix Q, which is assumed to be equal to the unit matrix except for the submatrix Z(Ilo〜Ihi, Ilo〜Ihi).
[out] If Info = 0, Z() contains Q*Z. Normally Q is the orthogonal matrix generated by Dorghr after the call to Dgehrd which formed the Hessenberg matrix H. (The output value of Z() when Info > 0 is given under the description of Info below.)
Compz = "N": Z() is not referenced. |
| [out] | Info | = 0: Successful exit.
= -1: The argument Job had an illegal value. (Job <> "E" nor "S")
= -2: The argument Compz had an illegal value. (Compz <> "N", "I" nor "V")
= -3: The argument N had an illegal value. (N < 0)
= -4: The argument Ilo had an illegal value. (Ilo < 1 or Ilo > N)
= -5: The argument Ihi had an illegal value. (Ihi < min(Ilo, N) or Ihi > N)
= -6: The argument H() is invalid.
= -7: The argument Wr() is invalid.
= -8: The argument Wi() is invalid.
= -9: The argument Z() is invalid.
= i > 0: Failed to compute all of the eigenvalues. Elements 1〜Ilo-1 and i+1〜N of Wr() and Wi() contain those eigenvalues which have been successfully computed. (Failures are rare.)
If Job = "E", the remaining unconverged eigenvalues are the eigenvalues of the upper Hessenberg matrix rows and columns Ilo through i of the final output value of H().
If Job = "S", then (initial value of H()) * U = U * (final value of H()) --- (*)
where U is an orthogonal matrix. The final value of H() is upper Hessenberg and quasi-triangular in rows and columns i+1 through Ihi.
If Compz = "V", then (final value of Z()) = (initial value of Z()) * U
where U is the orthogonal matrix in (*) (regardless of the value of Job.)
If Compz = "I", then where U is the orthogonal matrix in (*) (regardless of the value of Job.)
If Compz = "N", then Z() is not accessed. |
- Reference
- LAPACK
- Example Program
- Compute all eigenvalues and of the general matrix A, where
( 0.20 -0.11 -0.93 )
A = ( -0.32 0.81 0.37 )
( -0.80 -0.92 -0.29 )
See examples of Dtrevc3 and Dhsein which also compute eigenvectors. Sub Ex_Dgehrd_Dhseqr()
Const N = 3
Dim A(N - 1, N - 1) As Double, Tau(N - 2) As Double
Dim Wr(N - 1) As Double, Wi(N - 1) As Double, Z() As Double
Dim Ilo As Long, Ihi As Long, Info As Long
A(0, 0) = 0.2: A(0, 1) = -0.11: A(0, 2) = -0.93
A(1, 0) = -0.32: A(1, 1) = 0.81: A(1, 2) = 0.37
A(2, 0) = -0.8: A(2, 1) = -0.92: A(2, 2) = -0.29
Ilo = 1: Ihi = N
Call Dgehrd(N, Ilo, Ihi, A(), Tau(), Info)
If Info <> 0 Then
Debug.Print "Error in Dgehrd: Info =", Info
Exit Sub
End If
Call Dhseqr("E", "N", N, Ilo, Ihi, A(), Wr(), Wi(), Z(), Info)
If Info <> 0 Then
Debug.Print "Error in Dhseqr: Info =", Info
Exit Sub
End If
Debug.Print "Eigenvalues (r) =", Wr(0), Wr(1), Wr(2)
Debug.Print "Eigenvalues (i) =", Wi(0), Wi(1), Wi(2)
End Sub
- Example Results
Eigenvalues (r) = -0.904130023851345 0.812065011925673 0.812065011925673
Eigenvalues (i) = 0 0.48915757543818 -0.48915757543818
|