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

◆ Dgeev()

Sub Dgeev ( Jobvl As  String,
Jobvr As  String,
N As  Long,
A() As  Double,
Wr() As  Double,
Wi() As  Double,
Vl() As  Double,
Vr() As  Double,
Info As  Long 
)

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

Purpose
This routine computes for an n x n real 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]Wr()Array Wr(LWr - 1) (LWr >= N)
[out]Wi()Array Wi(LWi - 1) (LWi >= N)
Wr() and Wi() contain the real and imaginary parts, respectively, of the computed eigenvalues. Complex conjugate pairs of eigenvalues appear consecutively with the eigenvalue having the positive imaginary part first.
[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)-st eigenvalues form a complex conjugate pair, then u(j) = (j-th column of Vl()) + i*((j+1)-th column of Vl()) and u(j+1) = (j-th column of Vl()) - i*((j+1)-st 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.
  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()) + i*((j+1)-st column of Vr()) and v(j+1) = (j-th column of Vr()) - i*((j+1)-st 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 Wr() is invalid.
= -6: The argument Wi() is invalid.
= -7: The argument Vl() is invalid.
= -8: 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 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.11 -0.93 )
A = ( -0.32 0.81 0.37 )
( -0.80 -0.92 -0.29 )
Sub Ex_Dgeev()
Const N = 3
Dim A(N - 1, N - 1) As Double, Wr(N - 1) As Double, Wi(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
Call Dgeev("V", "V", N, A(), Wr(), Wi(), Vl(), Vr(), Info)
Debug.Print "Eigenvalues (r) =", Wr(0), Wr(1), Wr(2)
Debug.Print "Eigenvalues (i) =", Wi(0), Wi(1), Wi(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
Example Results
Eigenvalues (r) = -0.904130023851345 0.812065011925673 0.812065011925673
Eigenvalues (i) = 0 0.48915757543818 -0.48915757543818
Eigenvectors (L) =
-0.610555216308549 6.20242550062375E-02 -0.532191939813679
-0.404592057902723 0.7174496715502 0
-0.680828608770563 -9.02631541142068E-03 0.445094625232521
Eigenvectors (R) =
-0.640873419668578 -0.22876069887917 -0.504184181286349
4.57634889263765E-02 0.671832713345003 0
-0.766281255834689 -0.194097516422216 0.45214357607639
Info = 0