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

◆ Zheevr()

Sub Zheevr ( Jobz As  String,
Range As  String,
Uplo As  String,
N As  Long,
A() As  Complex,
Vl As  Double,
Vu As  Double,
Il As  Long,
Iu As  Long,
Abstol As  Double,
M As  Long,
W() As  Double,
Z() As  Complex,
Isuppz() As  Long,
Info As  Long 
)

(MRRR driver) Eigenvalues and eigenvectors of a Hermitian matrix

Purpose
This routine computes all or selected eigenvalues and, optionally, eigenvectors of a Hermitian matrix A. Eigenvalues and eigenvectors can be selected by specifying either a Range of values or a Range of indices for the desired eigenvalues.
This routine first reduces the matrix A to tridiagonal form T. Then, if all eigenvalues and eigenvectors are desired, it uses an MRRR method(*). If only all eigenvalues are desired, it uses a QL or QR method. If selected eigenvalues and eigenvectors are desired, it uses a bisection and inverse iteration method.

(*) MRRR method: Eigenvalues are computed by the dqds algorithm. Eigenvectors are computed from various "good" LDL^T representations with shifts (known as RRR (Relatively Robust Representations)).
Parameters
[in]Jobz= "N": Compute eigenvalues only.
= "V": Compute eigenvalues and eigenvectors.
[in]Range= "A": All eigenvalues will be found.
= "V": All eigenvalues in the half-open interval (Vl, Vu] will be found.
= "I": The Il-th through Iu-th eigenvalues will be found.
For Range = "V" or "I" and Iu - Il < N - 1, Dstebz and Zstein are called.
[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] The Hermitian matrix A. If Uplo = "U", the leading N x N upper triangular part of A() contains the upper triangular part of the matrix A. If Uplo = "L", the leading N x N lower triangular part of A() contains the lower triangular part of the matrix A.
[out] The lower triangle (if Uplo = "L") or the upper triangle (if Uplo = "U") of A(), including the diagonal, is destroyed.
[in]VlRange = "V": The lower bound of the interval to be searched for eigenvalues. (Vl < Vu)
Range = "A" or "I": Not referenced.
[in]VuRange = "V": The upper bound of the interval to be searched for eigenvalues. (Vl < Vu)
Range = "A" or "I": Not referenced.
[in]IlRange = "I": The index of the smallest eigenvalue to be returned. (1 <= Il <= Iu <= N, if N > 0; Il = 1 and Iu = 0 if N = 0)
Range = "A" or "V": Not referenced.
[in]IuRange = "I": The index of the largest eigenvalues to be returned. (1 <= Il <= Iu <= N, if N > 0; Il = 1 and Iu = 0 if N = 0)
Range = "A" or "V": Not referenced.
[in]AbstolThe absolute error tolerance for the eigenvalues.
An approximate eigenvalue is accepted as converged when it is determined to lie in an interval [a, b] of width less than or equal to Abstol + eps * max(|a|, |b|), where eps is the machine precision. If Abstol is less than or equal to zero, then eps*|T| will be used in its place, where |T| is the 1-norm of the tridiagonal matrix obtained by reducing A to tridiagonal form.
See "Computing Small Singular Values of Bidiagonal Matrices with Guaranteed High Relative Accuracy" by Demmel and Kahan, LAPACK Working Note #3.
If high relative accuracy is important, set Abstol to Dlamch("S"). Doing so will guarantee that eigenvalues are computed to high relative accuracy when possible in future releases. The current code does not make any guarantees about high relative accuracy, but future releases will. See J. Barlow and J. Demmel, "Computing Accurate Eigensystems of Scaled Diagonally Dominant Matrices", LAPACK Working Note #7, for a discussion of which matrices define their eigenvalues to high relative accuracy.
[out]MThe total number of eigenvalues found. (0 <= M <= N)
If Range = "A", M = N, and if Range = "I", M = Iu - Il + 1.
[out]W()Array W(LW - 1) (LW >= N)
The first M elements contain the selected eigenvalues in ascending order.
[in]ldzLeading dimension of the two dimensional array Z(). (ldz >= 1 if Jobz = "N", ldz >= max(1, N) if Jobz = "V")
[out]Z()Array A(LZ1 - 1, LZ2 - 1) (LZ1 >= N, LZ2 >= M)
Jobz = "V": If Info = 0, the first M columns of Z() contain the orthonormal eigenvectors of the matrix A corresponding to the selected eigenvalues, with the i-th column of Z() holding the eigenvector associated with W(i).
Jobz = "N": Z() is not referenced.
Note: The user must ensure that at least max(1, M) columns are supplied in the array Z(); if Range = "V", the exact value of M is not known in advance and an upper bound must be used.
[out]Isuppz()Array Isuppz(LIsuppz - 1) (LIsuppz >= 2*max(1, M))
The support of the eigenvectors in Z(), i.e., the indices indicating the nonzero elements in Z(). The i-th eigenvector is nonzero only in elements isuppz[2*(i-1)] through isuppz[2*(i-1)+1]. This is an output of Zstemr (tridiagonal matrix). The support of the eigenvectors of A is typically 1:N because of the unitary transformations applied by Zunmtr.
Implemented only for Range = "A" or "I" and Iu - Il = N - 1.
[out]Info= 0: Successful exit.
= -1: The argument Jobz had an illegal value. (Jobz <> "N" nor "V")
= -2: The argument Range had an illegal value. (Range <> "A", "V" nor "I")
= -3: The argument Uplo had an illegal value. (Uplo <> "U" nor "L")
= -4: The argument N had an illegal value. (N < 0)
= -5: The argument A() is invalid.
= -7: The argument Vu had an illegal value. (Vu <= Vl)
= -8: The argument Il had an illegal value. (Il < 1 or Il > N)
= -9: The argument Iu had an illegal value. (Iu < min(N, Il) or Iu > N)
= -12: The argument W() is invalid.
= -13: The argument Z() is invalid.
= -14: The argument Isuppz() is invalid.
= > 0: Internal error.
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_Zheevr()
Const N = 3
Dim A(N - 1, N - 1) As Complex, W(N - 1) As Double
Dim Vl As Double, Vu As Double, Il As Long, Iu As Long, AbsTol As Double
Dim M As Long, Z(N - 1, N - 1) As Complex, Isuppz(2 * N - 1) As Long, 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)
AbsTol = 0
Call Zheevr("V", "A", "L", N, A(), Vl, Vu, Il, Iu, AbsTol, M, W(), Z(), Isuppz(), Info)
Debug.Print "Eigenvalues =", W(0), W(1), W(2)
Debug.Print "Eigenvectors ="
Debug.Print Creal(Z(0, 0)), Cimag(Z(0, 0)), Creal(Z(0, 1)), Cimag(Z(0, 1))
Debug.Print Creal(Z(1, 0)), Cimag(Z(1, 0)), Creal(Z(1, 1)), Cimag(Z(1, 1))
Debug.Print Creal(Z(2, 0)), Cimag(Z(2, 0)), Creal(Z(2, 1)), Cimag(Z(2, 1))
Debug.Print Creal(Z(0, 2)), Cimag(Z(0, 2))
Debug.Print Creal(Z(1, 2)), Cimag(Z(1, 2))
Debug.Print Creal(Z(2, 2)), Cimag(Z(2, 2))
Debug.Print "M =", M, "Info =", Info
End Sub
Example Results
Eigenvalues = -2.05348849668514 0.124622388617309 1.51886610806783
Eigenvectors =
-0.449276526719114 -0 0.654793596518192 0
0.227247885813611 -0.597641779578735 0.519997178670922 -3.19846835072559E-02
0.621236109316912 -5.83009495222977E-02 0.204907317474215 -0.507777757881847
0.607779522934083 0
-0.392237107311198 -0.407323787101333
0.23846608290599 0.503959683819116
M = 3 Info = 0