XLPack 7.0
XLPack Numerical Library (Excel VBA) Reference Manual
Loading...
Searching...
No Matches

◆ Dsteqr()

Sub Dsteqr ( Compz As  String,
N As  Long,
D() As  Double,
E() As  Double,
Z() As  Double,
Info As  Long 
)

Eigenvalues and eigenvectors of a symmetric tridiagonal matrix (QL or QR method)

Purpose
This routine computes all eigenvalues and, optionally, eigenvectors of a symmetric tridiagonal matrix using the implicit QL or QR method. The eigenvectors of a full or band symmetric matrix can also be found if Dsytrd, Dsptrd or Dsbtrd has been used to reduce this matrix to tridiagonal form.
Parameters
[in]Compz= "N": Compute eigenvalues only.
= "V": Compute eigenvalues and eigenvectors of the original symmetric matrix. On entry, Z() must contain the orthogonal matrix used to reduce the original matrix to tridiagonal form.
= "I": Compute eigenvalues and eigenvectors of the tridiagonal matrix. Z() is initialized to the identity matrix.
[in]NOrder of the matrix. (N >= 0) (If N = 0, returns without computation)
[in,out]D()Array D(LD - 1) (LD >= N)
[in] The diagonal elements of the tridiagonal matrix.
[out] If Info = 0, the eigenvalues in ascending order.
[in,out]E()Array E(LE - 1) (LE >= N - 1)
[in] The (N - 1) subdiagonal elements of the tridiagonal matrix.
[out] E() has been destroyed.
[in,out]Z()Array Z(LZ1 - 1, LZ2 - 1) (LZ1 >= N, LZ2 >= N)
[in] If Compz = "V", then Z() contains the orthogonal matrix used in the reduction to tridiagonal form.
[out] If Info = 0, then if Compz = "V", Z() contains the orthonormal eigenvectors of the original symmetric matrix, and if Compz = "I", Z() contains the orthonormal eigenvectors of the symmetric tridiagonal matrix. If Compz = "N", then Z() is not referenced.
[out]Info= 0: Successful exit.
= -1: The argument Compz had an illegal value. (Compz <> "N", "V" nor "I")
= -2: The argument N had an illegal value. (N < 0)
= -3: The argument D() is invalid.
= -4: The argument E() is invalid.
= -5: The argument Z() is invalid.
= i > 0: The algorithm has failed to find all the eigenvalues in a total of 30*N iterations. i elements of E() have not converged to zero. On exit, D() and E() contain the elements of a symmetric tridiagonal matrix which is orthogonally similar to the original matrix.
Reference
LAPACK
Example Program
Compute all eigenvalues and eigenvectors of the symmetric matrix A, where
( 2.20 -0.11 -0.32 )
A = ( -0.11 2.93 0.81 )
( -0.32 0.81 2.37 )
Reduces to tridiagonal form by Dsytrd, then Dorgtr and Dsteqr are applied.
Sub Ex_Dsytrd_Dsteqr()
Const N = 3
Dim A(N - 1, N - 1) As Double, Info As Long
Dim D(N - 1) As Double, E(N - 2) As Double, Tau(N - 2) As Double
A(0, 0) = 2.2
A(1, 0) = -0.11: A(1, 1) = 2.93
A(2, 0) = -0.32: A(2, 1) = 0.81: A(2, 2) = 2.37
Call Dsytrd("L", N, A(), D(), E(), Tau(), Info)
If Info <> 0 Then
Debug.Print "Error in Dsytrd: Info =", Info
Exit Sub
End If
Call Dorgtr("L", N, A(), Tau(), Info)
If Info <> 0 Then
Debug.Print "Error in Dorgtr: Info =", Info
Exit Sub
End If
Call Dsteqr("V", N, D(), E(), A(), Info)
If Info <> 0 Then
Debug.Print "Error in Dsterf: Info =", Info
Exit Sub
End If
Debug.Print "Eigenvalues =", D(0), D(1), D(2)
Debug.Print "Eigenvectors ="
Debug.Print A(0, 0), A(0, 1), A(0, 2)
Debug.Print A(1, 0), A(1, 1), A(1, 2)
Debug.Print A(2, 0), A(2, 1), A(2, 2)
End Sub
Sub Dsteqr(Compz As String, N As Long, D() As Double, E() As Double, Z() As Double, Info As Long)
Eigenvalues and eigenvectors of a symmetric tridiagonal matrix (QL or QR method)
Sub Dsterf(N As Long, D() As Double, E() As Double, Info As Long)
Eigenvalues of a symmetric tridiagonal matrix (QL or QR method)
Sub Dorgtr(Uplo As String, N As Long, A() As Double, Tau() As Double, Info As Long)
Generates a transform matrix from a real symmetric matrix to tridiagonal form
Sub Dsytrd(Uplo As String, N As Long, A() As Double, D() As Double, E() As Double, Tau() As Double, Info As Long)
Reduces a real symmetric matrix to tridiagonal form
Example Results
Eigenvalues = 1.70705954911046 2.22943643244226 3.56350401844728
Eigenvectors =
0.399322077213382 0.894521385341403 0.200931256445799
-0.481026444340548 0.390994588677271 -0.78468897753835
0.780484105216166 -0.216690384632057 -0.586421212707156