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

◆ Zstein()

Sub Zstein ( N As  Long,
D() As  Double,
E() As  Double,
M As  Long,
W() As  Double,
Iblock() As  Long,
Isplit() As  Long,
Z() As  Complex,
Ifail() As  Long,
Info As  Long 
)

Eigenvectors of a symmetric tridiagonal matrix to which a Hermitian matrix was reduced (Inverse iteration method)

Purpose
This routine computes the eigenvectors of a real symmetric tridiagonal matrix T to which a Hermitian matrix was reduced, corresponding to specified eigenvalues, using inverse iteration.
The maximum number of iterations allowed for each eigenvector is specified by an internal parameter Maxits (currently set to 5).
Parameters
[in]NOrder of the tridiagonal matrix. (N >= 0) (If N = 0, returns without computation)
[in]D()Array D(LD - 1) (LD >= N)
The N diagonal elements of the tridiagonal matrix T.
[in]E()Array E(LE - 1) (LE >= N - 1)
The (N - 1) off-diagonal elements of the tridiagonal matrix T.
[in]MThe number of eigenvectors to be found. (0 <= M <= N)
[in]W()Array W(LW - 1) (LW >= N)
The first M elements of W() contain the eigenvalues for which eigenvectors are to be computed. The eigenvalues should be grouped by split-off block and ordered from smallest to largest within the block. (The output array w[] from Dstebz with Order = "B" is expected here.)
[in]Iblock()Array Iblock(LIblock - 1) (LIblock >= N)
The submatrix indices associated with the corresponding eigenvalues in W(). Iblock(i) = 1 if eigenvalue w(i) belongs to the first submatrix from the top, = 2 if w(i) belongs to the second submatrix, etc. (The output array Iblock() from Dstebz is expected here.)
[in]Isplit()Array Isplit(LIsplit - 1) (LIsplit >= N)
The splitting points, at which T breaks up into submatrices. The first submatrix consists of rows/columns 1 to Isplit(0), the second of rows/columns Isplit(0) + 1 through Isplit(1), etc. (The output array Isplit() from Dstebz is expected here.)
[out]Z()Array Z(LZ1 - 1, LZ2 - 1) (LZ1 >= N, LZ2 >= M)
The computed eigenvectors. The eigenvector associated with the eigenvalue W(i) is stored in the i-th column of Z(). Any vector which fails to converge is set to its current iterate after Maxits iterations.
[out]Ifail()Array Ifail(LIfail - 1) (LIfail >= M)
On normal exit, all elements of Ifail() are zero. If one or more eigenvectors fail to converge after Maxits iterations, then their indices are stored in array Ifail().
[out]Info= 0: Successful exit.
= -1: The argument N had an illegal value. (N < 0)
= -2: The argument D() is invalid.
= -3: The argument E() is invalid.
= -4: The argument M had an illegal value. (M < 0 or M > N)
= -5: The argument W() is invalid.
= -6: The argument Iblock() is invalid.
= -7: The argument Isplit() is invalid.
= -8: The argument Z() is invalid.
= -9: The argument Ifail() is invalid.
= i > 0: Eigenvectors failed to converge in Maxits iterations. Their indices are stored in array ifail().
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 )
Reduces to real tridiagonal form by Zhetrd, then computes eigenvalues by Dstebz and those eigenvectors by Zstein and Zunmtr.
Sub Ex_Zhetrd_Dstebz_Zstein()
Const N = 3
Dim A(N - 1, N - 1) As Complex, W(N - 1) As Double, Z(N - 1, N - 1) As Complex
Dim D(N - 1) As Double, E(N - 2) As Double, Tau(N - 2) As Complex
Dim Vl As Double, Vu As Double, Il As Long, Iu As Long, Abstol As Double
Dim Iblock(N - 1) As Long, Isplit(N - 1) As Long, Ifail(N - 1) As Long
Dim M As Long, Nsplit 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)
Call Zhetrd("L", N, A(), D(), E(), Tau(), Info)
If Info <> 0 Then
Debug.Print "Error in Zhetrd: Info =", Info
Exit Sub
End If
Abstol = 0
Call Dstebz("A", "E", N, Vl, Vu, Il, Iu, Abstol, D(), E(), M, Nsplit, W(), Iblock(), Isplit(), Info)
If Info <> 0 Then
Debug.Print "Error in Dstebz: Info =", Info
Exit Sub
End If
Call Zstein(N, D(), E(), M, W(), Iblock(), Isplit(), Z(), Ifail(), Info)
If Info <> 0 Then
Debug.Print "Error in Zstein: Info =", Info
Exit Sub
End If
Call Zunmtr("L", "L", "N", N, N, A(), Tau(), Z(), Info)
If Info <> 0 Then
Debug.Print "Error in Zunmtr: Info =", Info
Exit Sub
End If
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, "Nsplit =", Nsplit
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.19846835072554E-02
0.621236109316912 -5.83009495222983E-02 -0.204907317474214 0.507777757881846
0.607779522934083 0
-0.392237107311198 -0.407323787101333
0.23846608290599 0.503959683819116
M = 3 Nsplit = 1