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

◆ Zgeevx()

Sub Zgeevx ( Balanc As  String,
Jobvl As  String,
Jobvr As  String,
Sense As  String,
N As  Long,
A() As  Complex,
W() As  Complex,
Vl() As  Complex,
Vr() As  Complex,
Ilo As  Long,
Ihi As  Long,
Scal() As  Double,
AbNrm As  Double,
RConde() As  Double,
RCondv() As  Double,
Info As  Long 
)

(Expert 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.
Optionally also, it computes a balancing transformation to improve the conditioning of the eigenvalues and eigenvectors (Ilo, Ihi, Scal, and AbNrm), reciprocal condition numbers for the eigenvalues (RConde), and reciprocal condition numbers for the right eigenvectors (RCondv).

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.

Balancing a matrix means permuting the rows and columns to make it more nearly upper triangular, and applying a diagonal similarity transformation D*A*D^(-1), where D is a diagonal matrix, to make its rows and columns closer in norm and the condition numbers of its eigenvalues and eigenvectors smaller. The computed reciprocal condition numbers correspond to the balanced matrix. Permuting rows and columns will not change the condition numbers (in exact arithmetic) but diagonal scaling will. For further explanation of balancing, see Section 4.8.1 of the LAPACK Users' Guide Third Edition.
Parameters
[in]BalancIndicates how the input matrix should be diagonally scaled and/or permuted to improve the conditioning of its eigenvalues.
= "N": Do not diagonally scale or permute.
= "P": Perform permutations to make the matrix more nearly upper triangular. Do not diagonally scale.
= "S": Diagonally scale the matrix, i.e. replace A by D*A*D^(-1), where D is a diagonal matrix chosen to make the rows and columns of A more equal in norm. Do not permute.
= "B": Both diagonally scale and permute A.
[in]JobVl= "N": Left eigenvectors of A are not computed.
= "V": Left eigenvectors of A are computed.
If Sense = "E" or "B", Jobvl must = "V".
[in]JobVr= "N": Right eigenvectors of A are not computed.
= "V": Right eigenvectors of A are computed.
If Sense = "E" or "B", Jobvr must = "V".
[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.
If Sense = "E" or "B", both left and right eigenvectors must also be computed (Jobvl = "V" and Jobvr = "V").
[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. If Jobvl = "V" or Jobvr = "V", A() contains the real Schur form of the balanced version of the input matrix A.
[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]Ilo
[out]IhiIlo and Ihi are integer values determined when A was balanced. The balanced A(i, j) = 0 if i > j and j = 0, ..., Ilo-2 or i = Ihi, ..., N-1.
[out]Scal()Array Scal(LScal - 1) (LScal >= N)
Details of the permutations and scaling factors applied when balancing A. If p(j) is the index of the row and column interchanged with row and column j, and d(j) is the scaling factor applied to row and column j, then
  Scal[j] = p(j), for j = 0 to Ilo-2
    = d(j), for j = Ilo-1 to Ihi-1
    = p(j), for j = Ihi to N-1
The order in which the interchanges are made is N-1 to Ihi, then 0 to Ilo-2.
[out]AbNrmThe one-norm of the balanced matrix (the maximum of the sum of absolute values of elements of any column).
[out]RConde()Array RConde(LRConde - 1) (LRConde >= N)
RConde(j) is the reciprocal condition number of the j-th eigenvalue.
Not referenced if sense = "N" or "V".
[out]RCondv()Array RCondv(LRCondv - 1) (LRCondv >= N)
RCondv(j) is the reciprocal condition number of the j-th right eigenvector.
Not referenced if sense = "N" or "E".
[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 W() is invalid.
= -8: The argument Vl() is invalid.
= -9: The argument Vr() is invalid.
= -12: The argument Scal() is invalid.
= -14: The argument RConde() is invalid.
= -15: The argument RCondv() is invalid.
= i > 0: The QR algorithm failed to compute all the eigenvalues, and no eigenvectors or condition numbers have been computed. Elements 0 to Ilo-2 and i to N-1 of Wr() and Wi() 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_Zgeevx()
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
Dim Ilo As Long, Ihi As Long, Scal(N - 1) As Double, AbNrm As Double
Dim RConde(N - 1) As Double, RCondv(N - 1) As Double
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 Zgeevx("N", "V", "V", "N", N, A(), W(), Vl(), Vr(), Ilo, Ihi, Scal(), AbNrm, RConde(), RCondv(), 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(0, 2)), Cimag(Vr(0, 2))
Debug.Print Creal(Vr(1, 0)), Cimag(Vr(1, 0)), Creal(Vr(1, 1)), Cimag(Vr(1, 1))
Debug.Print Creal(Vr(1, 2)), Cimag(Vr(1, 2))
Debug.Print Creal(Vr(2, 0)), Cimag(Vr(2, 0)), Creal(Vr(2, 1)), Cimag(Vr(2, 1))
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