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

◆ Zheev()

Sub Zheev ( Jobz As  String,
Uplo As  String,
N As  Long,
A() As  Complex,
W() As  Double,
Info As  Long 
)

(Simple driver) Eigenvalues and eigenvectors of a Hermitian matrix

Purpose
This routine computes all eigenvalues and, optionally, eigenvectors of a Hermitian matrix A.
Parameters
[in]Jobz= "N": Compute eigenvalues only.
= "V": Compute eigenvalues and eigenvectors.
[in]Uplo= "U": Upper triangle of A is stored.
= "L": Lower triangle of A is stored.
[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 Hermitian matrix A. The upper or lower triangular part is to be stored in accordance with Uplo.
[out] Jobz = "V": If Info = 0, A() contains the orthonormal eigenvectors of the matrix A.
  Jobz = "N": The lower triangle (if Uplo = "L") or the upper triangle (if Uplo = "U") of A(), including the diagonal, is destroyed.
[out]W()Array W(LW - 1) (LW >= N)
If Info = 0, the eigenvalues in ascending order.
[out]Info= 0: Successful exit.
= -1: The argument Jobz had an illegal value. (Jobz <> "V" nor "N")
= -2: The argument Uplo had an illegal value. (Uplo <> "U" nor "L")
= -3: The argument N had an illegal value. (N < 0)
= -4: The argument A() is invalid.
= -5: The argument W() is invalid.
= i > 0: The algorithm failed to converge; i off-diagonal elements of an intermediate tridiagonal form did not converge to zero.
Reference
LAPACK
Example Program
Compute all eigenvalues and eigenvectors of the Hermitian matrix A, where
( 0.20 -0.11+0.93i 0.81-0.37i )
A = ( -0.11-0.93i -0.32 -0.80+0.92i )
( 0.81+0.37i -0.80-0.92i -0.29 )
Sub Ex_Zheev()
Const N = 3
Dim A(N - 1, N - 1) As Complex, W(N - 1) As Double, Info As Long
A(0, 0) = Cmplx(0.2, 0)
A(1, 0) = Cmplx(-0.11, -0.93): A(1, 1) = Cmplx(-0.32, 0)
A(2, 0) = Cmplx(0.81, 0.37): A(2, 1) = Cmplx(-0.8, -0.92): A(2, 2) = Cmplx(-0.29, 0)
Call Zheev("V", "L", N, A(), W(), Info)
Debug.Print "Eigenvalues =", W(0), W(1), W(2)
Debug.Print "Eigenvectors ="
Debug.Print Creal(A(0, 0)), Cimag(A(0, 0)), Creal(A(0, 1)), Cimag(A(0, 1))
Debug.Print Creal(A(1, 0)), Cimag(A(1, 0)), Creal(A(1, 1)), Cimag(A(1, 1))
Debug.Print Creal(A(2, 0)), Cimag(A(2, 0)), Creal(A(2, 1)), Cimag(A(2, 1))
Debug.Print Creal(A(0, 2)), Cimag(A(0, 2))
Debug.Print Creal(A(1, 2)), Cimag(A(1, 2))
Debug.Print Creal(A(2, 2)), Cimag(A(2, 2))
Debug.Print "Info =", Info
End Sub
Example Results
Eigenvalues = -2.05348849668514 0.124622388617308 1.51886610806783
Eigenvectors =
0.449276526719113 0 0.654793596518192 0
-0.227247885813611 0.597641779578735 0.519997178670921 -3.19846835072553E-02
-0.621236109316912 5.83009495222984E-02 0.204907317474214 -0.507777757881847
0.607779522934083 0
-0.392237107311198 -0.407323787101333
0.23846608290599 0.503959683819116
Info = 0