XLPack 6.1
Excel VBA Numerical Library Reference Manual
Loading...
Searching...
No Matches

◆ Zggesx_r()

Sub Zggesx_r ( Jobvsl As  String,
Jobvsr As  String,
Sort As  String,
Sense 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,
RConde() As  Double,
RCondv() As  Double,
Info As  Long,
IRev As  Long,
Selct() As  Long 
)

(Expert 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; computes a reciprocal condition number for the average of the selected eigenvalues (RConde); and computes a reciprocal condition number for the right and left deflating subspaces corresponding to the selected eigenvalues (RCondv). The leading columns of VSL and VSR then form an unitary basis for the corresponding left and right eigenspaces (deflating subspaces).

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 complex Schur form if T is upper triangular with non-negative diagonal and S is upper triangular.

Zggesx_r is the reverse communication version of Zggesx.
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]SortSpecifies 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]SenseDetermines which reciprocal condition numbers are computed.
= "N": None are computed.
= "E": Computed for average of selected eigenvalues only.
= "V": Computed for selected deflating subspaces only.
= "B": Computed for both.
If Sense = "E", "V", or "B", Sort must equal "S".
[in]NOrder 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]SdimSort = "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]RConde()Array RConde(LRConde - 1) (LRConde >= 2)
Sense = "E" or "B": RConde(0) and RConde(1) contain the reciprocal condition numbers for the average of the selected eigenvalues.
Sense = "N" or "V": Not referenced.
[out]RCondv()Array RCondv(LRCondv - 1) (LRCondv >= 2)
Sense = "V" or "B": RCondv(0) and RCondv(1) contain the reciprocal condition numbers for the selected deflating subspaces.
Sense = "N" or "E": 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 Sense had an illegal value. (Sense <> "E", "V", "B" nor "N")
= -5: The argument N had an illegal value. (N < 0)
= -6: The argument A() is invalid.
= -7: The argument B() is invalid.
= -9: The argument Alpha() is invalid.
= -10: The argument Beta() is invalid.
= -11: The argument Vsl() is invalid.
= -12: The argument Vsr() is invalid.
= -13: The argument RConde() is invalid.
= -14: The argument RCondv() is invalid.
= -17: 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]IRevControl 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_Zggesx_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 RConde(1) As Double, RCondv(1) As Double, Info As Long
Dim IRev As Long, Selct(N - 1) 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 Zggesx_r("V", "V", "S", "B", N, A(), B(), Sdim, Alpha(), Beta(), Vsl(), Vsr(), RConde(), RCondv(), Info, IRev, Selct())
If IRev = 1 Then Call Selctg_r(Alpha(), Beta(), Selct())
Loop While IRev <> 0
Debug.Print "Eigenvalues ="
Debug.Print Creal(Cdiv(Alpha(0), Beta(0))), Cimag(Cdiv(Alpha(0), Beta(0))),
Debug.Print Creal(Cdiv(Alpha(1), Beta(1))), Cimag(Cdiv(Alpha(1), Beta(1)))
Debug.Print Creal(Cdiv(Alpha(2), Beta(2))), Cimag(Cdiv(Alpha(2), Beta(2)))
Debug.Print "Schur form S ="
Debug.Print Creal(A(0, 0)), Cimag(A(0, 0)), Creal(A(0, 1)), Cimag(A(0, 1))
Debug.Print Creal(A(1, 0)), Cimag(A(1, 0)), Creal(A(1, 1)), Cimag(A(1, 1))
Debug.Print Creal(A(2, 0)), Cimag(A(2, 0)), Creal(A(2, 1)), Cimag(A(2, 1))
Debug.Print Creal(A(0, 2)), Cimag(A(0, 2))
Debug.Print Creal(A(1, 2)), Cimag(A(1, 2))
Debug.Print Creal(A(2, 2)), Cimag(A(2, 2))
Debug.Print "Schur form T ="
Debug.Print Creal(B(0, 0)), Cimag(B(0, 0)), Creal(B(0, 1)), Cimag(B(0, 1))
Debug.Print Creal(B(1, 0)), Cimag(B(1, 0)), Creal(B(1, 1)), Cimag(B(1, 1))
Debug.Print Creal(B(2, 0)), Cimag(B(2, 0)), Creal(B(2, 1)), Cimag(B(2, 1))
Debug.Print Creal(B(0, 2)), Cimag(B(0, 2))
Debug.Print Creal(B(1, 2)), Cimag(B(1, 2))
Debug.Print Creal(B(2, 2)), Cimag(B(2, 2))
Debug.Print "Left Schur vectors ="
Debug.Print Creal(Vsl(0, 0)), Cimag(Vsl(0, 0)), Creal(Vsl(0, 1)), Cimag(Vsl(0, 1))
Debug.Print Creal(Vsl(1, 0)), Cimag(Vsl(1, 0)), Creal(Vsl(1, 1)), Cimag(Vsl(1, 1))
Debug.Print Creal(Vsl(2, 0)), Cimag(Vsl(2, 0)), Creal(Vsl(2, 1)), Cimag(Vsl(2, 1))
Debug.Print Creal(Vsl(0, 2)), Cimag(Vsl(0, 2))
Debug.Print Creal(Vsl(1, 2)), Cimag(Vsl(1, 2))
Debug.Print Creal(Vsl(2, 2)), Cimag(Vsl(2, 2))
Debug.Print "Right Schur vectors ="
Debug.Print Creal(Vsr(0, 0)), Cimag(Vsr(0, 0)), Creal(Vsr(0, 1)), Cimag(Vsr(0, 1))
Debug.Print Creal(Vsr(1, 0)), Cimag(Vsr(1, 0)), Creal(Vsr(1, 1)), Cimag(Vsr(1, 1))
Debug.Print Creal(Vsr(2, 0)), Cimag(Vsr(2, 0)), Creal(Vsr(2, 1)), Cimag(Vsr(2, 1))
Debug.Print Creal(Vsr(0, 2)), Cimag(Vsr(0, 2))
Debug.Print Creal(Vsr(1, 2)), Cimag(Vsr(1, 2))
Debug.Print Creal(Vsr(2, 2)), Cimag(Vsr(2, 2))
Debug.Print "Rconde =", RConde(0), RConde(1)
Debug.Print "Rcondv =", RCondv(0), RCondv(1)
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
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
Rconde = 1 1
Rcondv = 3.96614422329799 3.96614422329799
Sdim = 3 Info = 0