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

◆ Zgeev()

Sub Zgeev ( Jobvl As  String,
Jobvr As  String,
N As  Long,
A() As  Complex,
W() As  Complex,
Vl() As  Complex,
Vr() As  Complex,
Info As  Long 
)

(Simple driver) Eigenvalues and left and/or right eigenvectors of a complex matrix

Purpose
This routine computes for an N x N complex nonsymmetric matrix A, the eigenvalues and, optionally, the left and/or right eigenvectors.

The right eigenvector v(j) of A satisfies
A * v(j) = λ(j) * v(j)
where λ(j) is its eigenvalue.
The left eigenvector u(j) of A satisfies
u(j)^H * A = λ(j) * u(j)^H
where u(j)^H denotes the conjugate transpose of u(j).
The computed eigenvectors are normalized to have Euclidean norm equal to 1 and largest component real.
Parameters
[in]JobVl= "N": Left eigenvectors of A are not computed.
= "V": Left eigenvectors of A are computed.
[in]JobVr= "N": Right eigenvectors of A are not computed.
= "V": Right eigenvectors of A are computed.
[in]NOrder of the matrix A. (N >= 0) (If N = 0, returns without computation)
[in,out]A()Array A(LA1 - 1, LA2 - 1) (LA1 >= N, LA2 >= N)
[in] N x N matrix A.
[out] A() has been overwritten.
[out]W()Array W(LW - 1) (LW >= N)
W() contains the computed eigenvalues.
[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 (u(j) = j-th column of Vl()).
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 (v(j) = j-th column of Vr()).
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 W() is invalid.
= -6: The argument Vl() is invalid.
= -7: The argument Vr() is invalid.
= i > 0: The QR algorithm failed to compute all the eigenvalues, and no eigenvectors have been computed; elements i to N-1 of W() contain eigenvalues which have converged.
Reference
LAPACK
Example Program
Compute all eigenvalues and eigenvectors of the general matrix A, where
( 0.20-0.11i -0.93-0.32i 0.81+0.37i )
A = ( -0.80-0.92i -0.29+0.86i 0.64+0.51i )
( 0.71+0.59i -0.15+0.19i 0.20+0.94i )
Sub Ex_Zgeev()
Const N = 3
Dim A(N - 1, N - 1) As Complex, W(N - 1) As Complex
Dim Vl(N - 1, N - 1) As Complex, Vr(N - 1, N - 1) As Complex, 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)
Call Zgeev("V", "V", N, A(), W(), Vl(), Vr(), Info)
Debug.Print "Eigenvalues ="
Debug.Print Creal(W(0)), Cimag(W(0)), Creal(W(1)), Cimag(W(1))
Debug.Print Creal(W(2)), Cimag(W(2))
Debug.Print "Eigenvectors (L) ="
Debug.Print Creal(Vl(0, 0)), Cimag(Vl(0, 0)), Creal(Vl(0, 1)), Cimag(Vl(0, 1))
Debug.Print Creal(Vl(1, 0)), Cimag(Vl(1, 0)), Creal(Vl(1, 1)), Cimag(Vl(1, 1))
Debug.Print Creal(Vl(2, 0)), Cimag(Vl(2, 0)), Creal(Vl(2, 1)), Cimag(Vl(2, 1))
Debug.Print Creal(Vl(0, 2)), Cimag(Vl(0, 2))
Debug.Print Creal(Vl(1, 2)), Cimag(Vl(1, 2))
Debug.Print Creal(Vl(2, 2)), Cimag(Vl(2, 2))
Debug.Print "Eigenvectors (R) ="
Debug.Print Creal(Vr(0, 0)), Cimag(Vr(0, 0)), Creal(Vr(0, 1)), Cimag(Vr(0, 1))
Debug.Print Creal(Vr(1, 0)), Cimag(Vr(1, 0)), Creal(Vr(1, 1)), Cimag(Vr(1, 1))
Debug.Print Creal(Vr(2, 0)), Cimag(Vr(2, 0)), Creal(Vr(2, 1)), Cimag(Vr(2, 1))
Debug.Print Creal(Vr(0, 2)), Cimag(Vr(0, 2))
Debug.Print Creal(Vr(1, 2)), Cimag(Vr(1, 2))
Debug.Print Creal(Vr(2, 2)), Cimag(Vr(2, 2))
Debug.Print "Info =", Info
End Sub
Example Results
Eigenvalues =
-1.15894122423918 -0.50662892448174 1.05593587167591 0.900255855387815
0.21300535256327 1.29637306909393
Eigenvectors (L) =
0.726762536559492 0 0.745087513477756 0
0.40101372244835 0.223056722666262 -0.548738777432301 0.10279479855183
-0.452267225989726 -0.238126572710138 0.359068258370214 6.50658637328971E-02
-0.391231614535526 2.26113409959926E-02
0.678149166093442 0
0.525054725907303 0.332953141411018
Eigenvectors (R) =
0.655198201453898 0.10938206993791 0.525205999936112 -0.383296457133484
0.66866018276349 0 -0.232889741084349 0.144310270362231
-0.320734618856182 -0.093668264858228 0.708646172603559 0
0.144705961537036 4.20675407039488E-02
0.647153050768732 -0.150897418413783
0.731924452871704 0
Info = 0