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