|
|
◆ Dgges_r()
| Sub Dgges_r |
( |
Jobvsl As |
String, |
|
|
Jobvsr As |
String, |
|
|
Sort As |
String, |
|
|
N As |
Long, |
|
|
A() As |
Double, |
|
|
B() As |
Double, |
|
|
Sdim As |
Long, |
|
|
Alphar() As |
Double, |
|
|
Alphai() As |
Double, |
|
|
Beta() As |
Double, |
|
|
Vsl() As |
Double, |
|
|
Vsr() As |
Double, |
|
|
Info As |
Long, |
|
|
IRev As |
Long, |
|
|
Selct() As |
Long |
|
) |
| |
(Simple driver) Generalized Schur factorization of general matrices (reverse communication version)
- Purpose
- This routine computes for a pair of n x n real nonsymmetric matrices (A, B), the generalized eigenvalues, the generalized real Schur form (S, T), and optionally the left and/or right matrices of Schur vectors (VSL and VSR). This gives the generalized Schur factorization
(A, B) = ((VSL)*S*(VSR)^T, (VSL)*T*(VSR)^T)
Optionally, it also orders the eigenvalues so that a selected cluster of eigenvalues appear in the leading diagonal blocks of the upper quasi-triangular matrix S and the upper triangular matrix T. The leading columns of VSL and VSR then form an orthonormal basis for the corresponding left and right eigenspaces (deflating subspaces).
(If only the generalized eigenvalues are needed, use the driver dggev instead, which is faster.)
A generalized eigenvalue for a pair of matrices (A, B) is a scalar w or a ratio α/β = w, such that A - w*B is singular. It is usually represented as the pair (α, β), as there is a reasonable interpretation for β = 0 or both being zero.
A pair of matrices (S, T) is in generalized real Schur form if T is upper triangular with non-negative diagonal and S is block upper triangular with 1 x 1 and 2 x 2 blocks. 1 x 1 blocks correspond to real generalized eigenvalues, while 2 x 2 blocks of S will be "standardized" by making the corresponding elements of T have the form and the pair of corresponding 2 x 2 blocks in S and T will have a complex conjugate pair of generalized eigenvalues.
Dgges_r is the reverse communication version of Dgges.
- Parameters
-
| [in] | Jobvsl | = "N": Do not compute the left Schur vectors.
= "V": Compute the left Schur vectors. |
| [in] | Jobvsr | = "N": Do not compute the right Schur vectors.
= "V": Compute the right Schur vectors. |
| [in] | Sort | Specifies whether or not to order the eigenvalues on the diagonal of the generalized Schur form.
= "N": Eigenvalues are not ordered.
= "S": Eigenvalues are ordered (see selctg). |
| [in] | N | Order of the matrices A, B, VSL and VSR. (N >= 0) (If N = 0, returns without computation) |
| [in,out] | A() | Array A(LA1 - 1, LA2 - 1) (LA1 >= N, LA2 >= N)
[in] The first of the pair of matrices.
[out] A() has been overwritten by its generalized Schur form S. |
| [in,out] | B() | Array B(LB1 - 1, LB2 - 1) (LB1 >= N, LB2 >= N)
[in] The second of the pair of matrices.
[out] B() has been overwritten by its generalized Schur form T. |
| [in] | Sdim | Sort = "N": Sdim = 0.
Sort = "S": Sdim = number of eigenvalues (after sorting) for which Selct(i) is true. (Complex conjugate pairs for which Selct(i) is true for either eigenvalue count as 2.) |
| [out] | Alphar() | Array Alphar(LAlphar - 1) (LAlphar >= N) |
| [out] | Alphai() | Array Alphai(LAlphai - 1) (LAlphai >= N) |
| [out] | Beta() | Array Beta(LBeta - 1) (LBeta >= N)
(Alphar(j) + Alphai(j)*i)/Beta(j), j = 0, ..., N-1, will be the generalized eigenvalues. Alphar(j) + Alphai(j)*i and Beta(j), j = 0, ..., N-1 are the diagonals of the complex Schur form (S, T) that would result if the 2 x 2 diagonal blocks of the real Schur form of (A, B) were further reduced to triangular form using 2 x 2 complex unitary transformations.
If Alphai(j) is zero, then the j-th eigenvalue is real. If positive, then the j-th and (j+1)-st eigenvalues are a complex conjugate pair, with Alphai(j+1) negative.
Note: The quotients Alphar(j)/Beta(j) and Alphai(j)/Beta(j) may easily over- or underflow, and Beta(j) may even be zero. Thus, the user should avoid naively computing the ratio α/β. However, Alphar and Alphai will be always less than and usually comparable with norm(A) in magnitude, and Beta always less than and usually comparable with norm(B). |
| [out] | Vsl() | Array Vsl(LVsl1 - 1, LVsl2 - 1) (LVsl1 >= N, LVsl2 >= N)
Jobvsl = "V": Vsl() will contain the left Schur vectors.
Jobvsl = "N": Not referenced. |
| [out] | Vsr() | Array Vsr(LVsr1 - 1, LVsr2 - 1) (LVsr1 >= N, LVsr2 >= N)
Jobvsr = "V": Vsr() will contain the right Schur vectors.
Jobvsr = "N": Not referenced. |
| [out] | Info | = 0: Successful exit.
= -1: The argument Jobvsl had an illegal value. (Jobvsl <> "V" nor "N")
= -2: The argument Jobvsr had an illegal value. (Jobvsr <> "V" nor "N")
= -3: The argument Sort had an illegal value. (Sort <> "S" nor "N")
= -4: The argument N had an illegal value. (N < 0)
= -5: The argument A() is invalid.
= -6: The argument B() is invalid.
= -8: The argument Alphar() is invalid.
= -9: The argument Alphai() is invalid.
= -10: The argument Beta() is invalid.
= -11: The argument Vsl() is invalid.
= -12: The argument Vsr() is invalid.
= -15: The argument Selct() is invalid.
= i (0 < i <= N): The QZ iteration failed. (A, B) are not in Schur form, but Alphar(j), Alphai(j), and Beta(j) should be correct for j = i, ..., N-1.
= N+1: Other than QZ iteration failed in Dhgeqz.
= N+2: After reordering, roundoff changed values of some complex eigenvalues so that leading eigenvalues in the generalized Schur form no longer satisfy Selct(i) = true. This could also be caused due to scaling.
= N+3: Reordering failed in Dtgsen. |
| [in,out] | IRev | Control variable for reverse communication.
[in] Before first call, IRev should be initialized to zero. On succeeding calls, IRev should not be altered.
[out] If IRev is not zero, complete the following process and call this routine again.
= 0: Normal exit. See return code in Info
= 1: In the case of Sort = "S", to select eigenvalues to sort to the top left of the Schur form, the user should set Selct(i) (i = 0 To N-1). Decision should be made based on the values in Alphar(i), Alphai(i) and Beta(i) (Alphar(i)/Beta(i) and Alphai(i)/Beta(i) are real and imaginary part of the eigenvalue). Set Selct(i) = true (1) to select, or Selct(i) = false (0) not to select. Do not alter any variables other than Selct().
Always IRev = 0 if Sort = "N". |
| [in] | Selct() | Array Selct(LSelct - 1) (LSelct >= N)
If IRev = 1, set Selct(i) to true (1) or false (0) to select eigenvalues for sorting. |
- Reference
- LAPACK
- Example Program
- Compute for a pair of matrices (A, B), the generalized eigenvalues, the generalized Schur form (S, T), and the left and right matrices of Schur vectors, where
( 0.20 -0.11 -0.93 ) ( -0.58 -0.79 0.82 )
A = ( -0.32 0.81 0.37 ), B = ( 0.77 0.71 -0.55 )
( -0.80 -0.92 -0.29 ) ( -1.36 -1.22 1.66 )
Sub Ex_Dgges_r()
Const N = 3
Dim A(N - 1, N - 1) As Double, B(N - 1, N - 1) As Double
Dim Alphar(N - 1) As Double, Alphai(N - 1) As Double, Beta(N - 1) As Double
Dim Sdim As Long, Vsl(N - 1, N - 1) As Double, Vsr(N - 1, N - 1) As Double
Dim IRev As Long, Selct(N - 1) 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
B(0, 0) = -0.58: B(0, 1) = -0.79: B(0, 2) = 0.82
B(1, 0) = 0.77: B(1, 1) = 0.71: B(1, 2) = -0.55
B(2, 0) = -1.36: B(2, 1) = -1.22: B(2, 2) = 1.66
IRev = 0
Do
Call Dgges_r("V", "V", "S", N, A(), B(), Sdim, Alphar(), Alphai(), Beta(), Vsl(), Vsr(), Info, IRev, Selct())
If IRev = 1 Then Call Selctg_r(Alphar(), Alphai(), Beta(), Selct())
Loop While IRev <> 0
Debug.Print "Eigenvalues ="
Debug.Print " (r)", Alphar(0) / Beta(0), Alphar(1) / Beta(1), Alphar(2) / Beta(2)
Debug.Print " (i)", Alphai(0) / Beta(0), Alphai(1) / Beta(1), Alphai(2) / Beta(2)
Debug.Print "Schur form S ="
Debug.Print A(0, 0), A(0, 1), A(0, 2)
Debug.Print A(1, 0), A(1, 1), A(1, 2)
Debug.Print A(2, 0), A(2, 1), A(2, 2)
Debug.Print "Schur form T ="
Debug.Print B(0, 0), B(0, 1), B(0, 2)
Debug.Print B(1, 0), B(1, 1), B(1, 2)
Debug.Print B(2, 0), B(2, 1), B(2, 2)
Debug.Print "Left Schur vectors ="
Debug.Print Vsl(0, 0), Vsl(0, 1), Vsl(0, 2)
Debug.Print Vsl(1, 0), Vsl(1, 1), Vsl(1, 2)
Debug.Print Vsl(2, 0), Vsl(2, 1), Vsl(2, 2)
Debug.Print "Right Schur vectors ="
Debug.Print Vsr(0, 0), Vsr(0, 1), Vsr(0, 2)
Debug.Print Vsr(1, 0), Vsr(1, 1), Vsr(1, 2)
Debug.Print Vsr(2, 0), Vsr(2, 1), Vsr(2, 2)
Debug.Print "Sdim =", Sdim, "Info =", Info
End Sub
Sub Selctg_r(Alphar() As Double, Alphai() As Double, Beta() As Double, Selct() As Long)
Const N = 3
Dim I As Long
For I = 0 To N - 1
Selct(I) = 0
If Alphai(I) <> 0 Then Selct(I) = 1
Next
End Sub
Function Beta(A As Double, B As Double, Optional Info As Long) As Double Beta function B(a, b)
Sub Dgges_r(Jobvsl As String, Jobvsr As String, Sort As String, N As Long, A() As Double, B() As Double, Sdim As Long, Alphar() As Double, Alphai() As Double, Beta() As Double, Vsl() As Double, Vsr() As Double, Info As Long, IRev As Long, Selct() As Long) (Simple driver) Generalized Schur factorization of general matrices (reverse communication version)
- Example Results
Eigenvalues =
(r) 1.10765548065266 1.10765548065266 -1.74329621491312
(i) 1.40252005479606 -1.40252005479606 0
Schur form S =
0.61463908695189 -1.30352251020676 6.87282197451471E-02
0.715639689206334 0.422919612615492 0.382300104551802
0 0 -0.681226655778666
Schur form T =
1.62147306790067 -0 2.50284121079862
0 0.230317162252267 0.163903374557831
0 0 0.390769308136549
Left Schur vectors =
-0.352844167536935 0.427271157509602 -0.832430388318189
0.480836332469667 -0.680393780608842 -0.553046765369735
-0.802681390597968 -0.595402100491098 3.46254807692483E-02
Right Schur vectors =
0.988795256019328 0.1471244329068 2.52654490465408E-02
0.106663051199989 -0.814736341679618 0.569936564062371
0.104436273307598 -0.560855680891587 -0.821300170479256
Sdim = 2 Info = 0
|