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

◆ Dggev()

Sub Dggev ( Jobvl As  String,
Jobvr 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,
Info As  Long 
)

(Simple 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.

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]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]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.
[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.
[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]Info= 0: Successful exit.
= -1: The argument Jobvl had an illegal value. (Jobvl <> "V" nor "N")
= -2: The argument Jobvr had an illegal value. (Jobvr <> "V" nor "N")
= -3: The argument N had an illegal value. (N < 0)
= -4: The argument A() is invalid.
= -5: The argument B() is invalid.
= -6: The argument Alphar() is invalid.
= -7: The argument Alphai() is invalid.
= -8: The argument Beta() is invalid.
= -9: The argument Vl() is invalid.
= -10: The argument Vr() 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_Dggev()
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
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 Dggev("V", "V", N, A(), B(), Alphar(), Alphai(), Beta(), Vl(), Vr(), 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 Dggev(Jobvl As String, Jobvr 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, Info As Long)
(Simple 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