XLPack 7.0
XLPack Numerical Library (Excel VBA) Reference Manual
Loading...
Searching...
No Matches

◆ Dggevx()

Sub Dggevx ( Balanc As  String,
Jobvl As  String,
Jobvr As  String,
Sense As  String,
N As  Long,
A() As  Double,
B() As  Double,
Alphar() As  Double,
Alphai() As  Double,
Beta() As  Double,
Vl() As  Double,
Vr() As  Double,
Ilo As  Long,
Ihi As  Long,
LScale() As  Double,
RScale() As  Double,
AbNrm As  Double,
BbNrm As  Double,
RConde() As  Double,
RCondv() As  Double,
Info As  Long 
)

(Expert driver) Generalized eigenvalue problem of general matrices

Purpose
This routine computes for a pair of n x n real nonsymmetric matrices (A, B) the generalized eigenvalues, and optionally, the left and/or right generalized eigenvectors.
Optionally, it also computes a balancing transformation to improve the conditioning of the eigenvalues and eigenvectors (Ilo, Ihi, Lscale, Rscale, AbNrm, and BbNrm), reciprocal condition numbers for the eigenvalues (RConde), and reciprocal condition numbers for the right eigenvectors (RCondv).

A generalized eigenvalue for a pair of matrices (A, B) is a scalar λ or a ratio α/β = λ, such that A - λ*B is singular. It is usually represented as the pair (α, β), as there is a reasonable interpretation for β = 0, and even for both being zero.

The right generalized eigenvector v(j) corresponding to the generalized eigenvalue λ(j) of (A, B) satisfies
A * v(j) = λ(j) * B * v(j)
The left generalized eigenvector u(j) corresponding to the generalized eigenvalue λ(j) of (A, B) satisfies
u(j)^H * A = λ(j) * u(j)^H * B
where u(j)^H is the conjugate-transpose of u(j).
Parameters
[in]BalancSpecifies the balance option to be performed.
= "N": Do not diagonally scale or permute.
= "P": Permute only.
= "S": Scale only.
= "B": Both permute and scale.
Computed reciprocal condition numbers will be for the matrices after permuting and/or balancing. Permuting does not change condition numbers (in exact arithmetic), but balancing does.
[in]JobVl= "N": Do not compute the left generalized eigenvectors.
= "V": Compute the left generalized eigenvectors.
[in]JobVr= "N": Do not compute the right generalized eigenvectors.
= "V": Compute the right generalized eigenvectors.
[in]SenseDetermines which reciprocal condition numbers are computed.
= "N": None are computed.
= "E": Computed for eigenvalues only.
= "V": Computed for right eigenvectors only.
= "B": Computed for eigenvalues and right eigenvectors.
[in]NOrder of the matrices A, B, VL and VR. (N >= 0) (If N = 0, returns without computation)
[in,out]A()Array A(LA1 - 1, LA2 - 1) (LA1 >= N, LA2 >= N)
[in] Matrix A in the pair (A, B).
[out] A() has been overwritten. If jobvl = "V" or jobvr = "V" or both, then A() contains the first part of the real Schur form of the "balanced" versions of the input A and B.
[in,out]B()Array B(LB1 - 1, LB2 - 1) (LB1 >= N, LB2 >= N)
[in] Matrix B in the pair (A, B).
[out] B() has been overwritten. If jobvl = "V" or jobvr = "V" or both, then B() contains the second part of the real Schur form of the "balanced" versions of the input A and B.
[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. 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]Vl()Array Vl(LVl1 - 1, LVl2 - 1) (LVl1 >= N, LVl2 >= N)
jobvl = "V": The left eigenvectors u(j) are stored one after another in the columns of Vl(), in the same order as their eigenvalues.
  If the j-th eigenvalue is real, then u(j) = (j-th column of Vl()).
  If the j-th and (j+1)-th eigenvalues form a complex conjugate pair, then u(j) = (j-th column of Vl()) + ((j+1)-th column of Vl())*i and u(j+1) = (j-th column of Vl()) - ((j+1)-st column of Vl())*i.
  Each eigenvector is scaled so the largest component has |real part| + |imaginary part| = 1.
jobvl = "N": Vl() is not referenced.
[out]Vr()Array Vr(LVr1 - 1, LVr2 - 1) (LVr1 >= N, LVr2 >= N)
jobvr = "V": The right eigenvectors v(j) are stored one after another in the columns of Vr() in the same order as their eigenvalues.
  If the j-th eigenvalue is real, then v(j) = (j-th column of Vr()). If the j-th and (j+1)-st eigenvalues form a complex conjugate pair, then v(j) = (j-th column of Vr()) + ((j+1)-st column of Vr())*i and v(j+1) = (j-th column of Vr()) - ((j+1)-st column of Vr())*i.
  Each eigenvector is scaled so the largest component has |real part| + |imaginary part| = 1.
jobvr = "N": Vr() is not referenced.
[out]IloIlo and Ihi are integer values such that on exit A(i, j) = 0 and B(i, j) = 0 if i > j and j = 0, ..., Ilo-2 or i = Ihi, ..., N-1.
If Balanc = "N" or "S", Ilo = 1 and Ihi = N.
[out]Ihi
[out]LScale()Array LScale(LLScale - 1) (LLScale >= N)
Details of the permutations and scaling factors applied to the left side of A and B. If Pl(j) is the index of the row interchanged with row j, and Dl(j) is the scaling factor applied to row j, then
  LScale(j) = Pl(j) for j = 0, ..., Ilo-2
    = Dl(j) for j = Ilo-1, ..., Ihi-1
    = Pl(j) for j = Ihi, ..., N-1
The order in which the interchanges are made is N-1 to Ihi, then 0 to Ilo-2.
[out]RScale()Array RScale(LRScale - 1) (LRScale >= N)
Details of the permutations and scaling factors applied to the right side of A and B. If Pr(j) is the index of the column interchanged with column j, and Dr(j) is the scaling factor applied to column j, then
  RScale(j) = Pr(j) for j = 0, ..., Ilo-2
    = Dr(j) for j = Ilo-1, ..., Ihi-1
    = Pr(j) for j = Ihi, ..., N-1
The order in which the interchanges are made is N-1 to Ihi, then 0 to Ilo-2.
[out]AbNrmOne-norm of the balanced matrix A.
[out]BbNrmOne-norm of the balanced matrix B.
[out]RConde()Array RConde(LRConde - 1) (LRConde >= N)
Sense = "E" or "B": The reciprocal condition numbers of the eigenvalues, stored in consecutive elements of the array. For a complex conjugate pair of eigenvalues two consecutive elements of RConde() are set to the same value. Thus RConde(j), RCondv(j), and the j-th columns of Vl() and Vr() all correspond to the j-th eigenpair.
If Sense = "N" or "V": RConde() is not referenced.
[out]RCondv()Array RCondv(LRCondv - 1) (LRCondv >= N)
Sense = "V" or "B": The estimated reciprocal condition numbers of the eigenvectors, stored in consecutive elements of the array. For a complex eigenvector two consecutive elements of RCondv() are set to the same value. If the eigenvalues cannot be reordered to compute RCondv(j), RCondv(j) is set to 0. This can only occur when the true value would be very small anyway.
If Sense = "N" or "V": RCondv() is not referenced.
[out]Info= 0: Successful exit.
= -1: The argument Balanc had an illegal value. (Balanc <> "N", "P", "S" nor "B")
= -2: The argument Jobvl had an illegal value. (Jobvl <> "V" nor "N")
= -3: The argument Jobvr had an illegal value. (Jobvr <> "V" nor "N")
= -4: The argument Sense had an illegal value. (Sense <> "N", "E", "V" nor "B")
= -5: The argument N had an illegal value. (N < 0)
= -6: The argument A() is invalid.
= -7: 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 Vl() is invalid.
= -12: The argument Vr() is invalid.
= -15: The argument LScale() is invalid.
= -16: The argument RScale() is invalid.
= -19: The argument RConde() is invalid.
= -20: The argument RCondv() is invalid.
= i (0 < i <= N): The QZ iteration failed. No eigenvectors have been calculated, 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: Error return from Dtgevc.
Reference
LAPACK
Example Program
Compute for a pair of matrices (A, B) the generalized eigenvalues and the left and right generalized eigenvectors, 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_Dggevx()
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 Vl(N - 1, N - 1) As Double, Vr(N - 1, N - 1) As Double, Info As Long
Dim Ilo As Long, Ihi As Long, LScale(N - 1) As Double, RScale(N - 1) As Double
Dim AbNrm As Double, BbNrm As Double
Dim RConde(N - 1) As Double, RCondv(N - 1) As Double
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
Call Dggevx("N", "V", "V", "N", N, A(), B(), Alphar(), Alphai(), Beta(), Vl(), Vr(), Ilo, Ihi, LScale(), RScale(), AbNrm, BbNrm, RConde(), RCondv(), Info)
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 "Eigenvectors (L) ="
Debug.Print Vl(0, 0), Vl(0, 1), Vl(0, 2)
Debug.Print Vl(1, 0), Vl(1, 1), Vl(1, 2)
Debug.Print Vl(2, 0), Vl(2, 1), Vl(2, 2)
Debug.Print "Eigenvectors (R) ="
Debug.Print Vr(0, 0), Vr(0, 1), Vr(0, 2)
Debug.Print Vr(1, 0), Vr(1, 1), Vr(1, 2)
Debug.Print Vr(2, 0), Vr(2, 1), Vr(2, 2)
Debug.Print "Info =", Info
End Sub
Function Beta(A As Double, B As Double, Optional Info As Long) As Double
Beta function B(a, b)
Sub Dggevx(Balanc As String, Jobvl As String, Jobvr As String, Sense As String, N As Long, A() As Double, B() As Double, Alphar() As Double, Alphai() As Double, Beta() As Double, Vl() As Double, Vr() As Double, Ilo As Long, Ihi As Long, LScale() As Double, RScale() As Double, AbNrm As Double, BbNrm As Double, RConde() As Double, RCondv() As Double, Info As Long)
(Expert driver) Generalized eigenvalue problem of general matrices
Example Results
Eigenvalues =
(r) 1.10765548065266 1.10765548065266 -1.74329621491312
(i) 1.40252005479606 -1.40252005479606 0
Eigenvectors (L) =
0.828456655019124 0.171543344980876 -1
-0.174134648086565 0.261212076890975 -0.66437599243234
-0.601718475294568 -0.175396675418769 4.15956472218708E-02
Eigenvectors (R) =
-9.54330235945138E-02 0.502674461662748 -1
-0.945775638065751 5.42243619342491E-02 0.224694817103864
-0.659251386021417 5.30923334667921E-02 -0.954838851339161
Info = 0