|
|
◆ Zgges_r()
| Sub Zgges_r |
( |
Jobvsl As |
String, |
|
|
Jobvsr As |
String, |
|
|
Sort As |
String, |
|
|
N As |
Long, |
|
|
A() As |
Complex, |
|
|
B() As |
Complex, |
|
|
Sdim As |
Long, |
|
|
Alpha() As |
Complex, |
|
|
Beta() As |
Complex, |
|
|
Vsl() As |
Complex, |
|
|
Vsr() As |
Complex, |
|
|
Info As |
Long, |
|
|
IRev As |
Long, |
|
|
Selct() As |
Long |
|
) |
| |
(Simple driver) Generalized Schur factorization of complex matrices (reverse communication version)
- Purpose
- This routine computes for a pair of n x n complex nonsymmetric matrices (A, B), the generalized eigenvalues, the generalized complex 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)^H, (VSL)*T*(VSR)^H)
where (VSR)^H is the conjugate-transpose of VSR.
Optionally, it also orders the eigenvalues so that a selected cluster of eigenvalues appear in the leading diagonal blocks of the upper triangular matrix S and the upper triangular matrix T. The leading columns of VSL and VSR then form an unitary basis for the corresponding left and right eigenspaces (deflating subspaces).
(If only the generalized eigenvalues are needed, use the driver Zggev 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, and even for both being zero.
A pair of matrices (S, T) is in generalized complex Schur form if S and T are upper triangular and, in addition, the diagonal elements of T are non-negative real numbers.
Zgges_r is the reverse communication version of Zgges.
- 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. |
| [out] | Alpha() | Array Alpha(LAlpha - 1) (LAlpha >= N) |
| [out] | Beta() | Array Beta(LBeta - 1) (LBeta >= N)
Alpha(j)/Beta(j), j = 0, ..., N-1, will be the generalized eigenvalues. Alpha(j) and Beta(j), j = 0, ..., N-1 are the diagonals of the complex Schur form (S, T). The Beta(j) will be non-negative real.
Note: The quotients Alpha(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, Alpha 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 Alpha() is invalid.
= -9: The argument Beta() is invalid.
= -10: The argument Vsl() is invalid.
= -11: The argument Vsr() is invalid.
= -14: The argument Selct() is invalid.
= i (0 < i <= N): The QZ iteration failed. (A, B) are not in Schur form, but Alpha(j) and Beta(j) should be correct for j = i, ..., N-1.
= N+1: Other than QZ iteration failed in Zhgeqz.
= 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 Ztgsen. |
| [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 Alpha(i) and Beta(i) (Alpha(i)/Beta(i) is 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.2-0.11i -0.93-0.32i 0.81+0.37i )
A = ( -0.8-0.92i -0.29+0.86i 0.64+0.51i )
( 0.71+0.59i -0.15+0.19i 0.2+0.94i )
( 0.57-0.91i -0.28-0.45i 0.25+0.91i )
B = ( 0.83-0.46i 0.63-0.19i -0.69+0.09i )
( 0.24-1.33i -0.56-0.67i 0.9+1.25i )
Sub Ex_Zgges_r()
Const N = 3
Dim A(N - 1, N - 1) As Complex, B(N - 1, N - 1) As Complex
Dim Alpha(N - 1) As Complex, Beta(N - 1) As Complex, Sdim As Long
Dim Vsl(N - 1, N - 1) As Complex, Vsr(N - 1, N - 1) As Complex
Dim IRev As Long, Selct(N - 1) As Long, Info As Long
A(0, 0) = Cmplx(0.2, -0.11): A(0, 1) = Cmplx(-0.93, -0.32): A(0, 2) = Cmplx(0.81, 0.37)
A(1, 0) = Cmplx(-0.8, -0.92): A(1, 1) = Cmplx(-0.29, 0.86): A(1, 2) = Cmplx(0.64, 0.51)
A(2, 0) = Cmplx(0.71, 0.59): A(2, 1) = Cmplx(-0.15, 0.19): A(2, 2) = Cmplx(0.2, 0.94)
B(0, 0) = Cmplx(0.57, -0.91): B(0, 1) = Cmplx(-0.28, -0.45): B(0, 2) = Cmplx(0.25, 0.91)
B(1, 0) = Cmplx(0.83, -0.46): B(1, 1) = Cmplx(0.63, -0.19): B(1, 2) = Cmplx(-0.69, 0.09)
B(2, 0) = Cmplx(0.24, -1.33): B(2, 1) = Cmplx(-0.56, -0.67): B(2, 2) = Cmplx(0.9, 1.25)
IRev = 0
Do
Call Zgges_r("V", "V", "S", N, A(), B(), Sdim, Alpha(), Beta(), Vsl(), Vsr(), Info, IRev, Selct())
If IRev = 1 Then Call Selctg_r(Alpha(), Beta(), Selct())
Loop While IRev <> 0
Debug.Print "Eigenvalues ="
Debug.Print "Schur form S ="
Debug.Print "Schur form T ="
Debug.Print "Left Schur vectors ="
Debug.Print "Right Schur vectors ="
Debug.Print "Sdim =", Sdim, "Info =", Info
End Sub
Sub Selctg_r(Alpha() As Complex, Beta() As Complex, Selct() As Long)
Const N = 3
Dim I As Long
For I = 0 To N - 1
Selct(I) = 0
If Cimag(Alpha(I)) <> 0 Then Selct(I) = 1
Next
End Sub
Function Cmplx(R As Double, Optional I As Double=0) As Complex Building complex number
Function Cdiv(A As Complex, B As Complex) As Complex Division of complex number by complex number
Function Cimag(A As Complex) As Double Imaginary part of complex number
Function Creal(A As Complex) As Double Real part of complex number
Function Beta(A As Double, B As Double, Optional Info As Long) As Double Beta function B(a, b)
Sub Zgges_r(Jobvsl As String, Jobvsr As String, Sort As String, N As Long, A() As Complex, B() As Complex, Sdim As Long, Alpha() As Complex, Beta() As Complex, Vsl() As Complex, Vsr() As Complex, Info As Long, IRev As Long, Selct() As Long) (Simple driver) Generalized Schur factorization of complex matrices (reverse communication version)
- Example Results
Eigenvalues =
-0.4784814787767 -0.640760182519056 1.62433774044009 1.10642263894432
-0.149178317709927 5.63446258373312
Schur form S =
-0.72797081435173 -0.974864717993083 -0.273608952637649 0.236841131861002
0 0 1.50621819846239 1.02596515027546
0 0 0 0
1.07441516363149E-02 4.41155734877746E-02
-0.689834642053671 -0.367063708571792
-2.75225804680911E-02 1.03952740743988
Schur form T =
1.5214190029108 0 -0.330233470430214 -1.05504057337832
0 0 0.927281415042602 0
0 0 0 0
0.359567173199973 1.92492599356072
-0.911905206658519 -8.20406969051636E-02
0.184494508924602 0
Left Schur vectors =
-0.129055100819468 0.380797390644917 0.459273707935736 -0.209026938555656
-0.693189782060827 0.176375779993619 -0.368487931998788 -0.564073489521078
0.149492866673543 0.551696946993847 0.512426331896747 -0.16980105101744
0.759605142163285 8.19362946843842E-02
-0.150340091122171 0.108697330557172
-0.614629176696597 6.40327579983544E-02
Right Schur vectors =
-0.609843105250231 -0.453993250889564 0.531526779080892 0.119433675168335
-0.264988296049601 -9.90695388688886E-02 -0.740613399363287 -0.14310787368587
0.289272174294141 -0.508202276391652 -5.56309308836406E-02 -0.362121539068532
-0.265832927214418 -0.233514989432741
-0.344926967779475 -0.481667671217571
-0.51570410282413 0.507813473877466
Sdim = 3 Info = 0
|