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

◆ Dstev()

Sub Dstev ( Jobz As  String,
N As  Long,
D() As  Double,
E() As  Double,
Z() As  Double,
Info As  Long 
)

(Simple driver) Eigenvalues and eigenvectors of a symmetric tridiagonal matrix

Purpose
This routine computes all eigenvalues and, optionally, eigenvectors of a real symmetric tridiagonal matrix A.
Parameters
[in]Jobz= "N": Compute eigenvalues only.
= "V": Compute eigenvalues and eigenvectors.
[in]NOrder of the matrix A. (N >= 0) (If N = 0, returns without computation)
[in,out]D()Array D(LD - 1) (LD >= N)
[in] N diagonal elements of the symmetric tridiagonal matrix A.
[out] If Info = 0, the eigenvalues in ascending order.
[in,out]E()Array E(LE - 1) (LE >= N - 1)
[in] N-1 subdiagonal elements of the symmetric tridiagonal matrix A stored in elements 0 to n-2 of E().
[out] The contents of E() are destroyed.
[out]Z()Array Z(LZ1 - 1, LZ2 - 1) (LZ1 >= N, LZ2 >= N)
Jobz = "V": If Info = 0, Z() contains the orthonormal eigenvectors of the matrix A, with the i-th column of Z() holding the eigenvector associated with D(i).
Jobz = "N": Z() is not referenced.
[out]Info= 0: Successful exit.
= -1: The argument Jobz had an illegal value. (Jobz <> "V" nor "N")
= -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 failed to converge; i off-diagonal elements of E() did not converge to zero.
Reference
LAPACK
Example Program
Compute all eigenvalues and eigenvectors of the symmetric tridiagonal matrix A, where
( 2.58 -0.99 0 )
A = ( -0.99 0.69 -0.03 )
( 0 -0.03 0.18 )
Sub Ex_Dstev()
Const N = 3
Dim D(N - 1) As Double, E(N - 2) As Double, Z(N - 1, N - 1) As Double
Dim Info As Long
D(0) = 2.58: D(1) = 0.69: D(2) = 0.18
E(0) = -0.99: E(1) = -0.03
Call Dstev("V", N, D(), E(), Z(), Info)
Debug.Print "Eigenvalues =", D(0), D(1), D(2)
Debug.Print "Eigenvectors ="
Debug.Print Z(0, 0), Z(0, 1), Z(0, 2)
Debug.Print Z(1, 0), Z(1, 1), Z(1, 2)
Debug.Print Z(2, 0), Z(2, 1), Z(2, 2)
Debug.Print "Info =", Info
End Sub
Sub Dstev(Jobz As String, N As Long, D() As Double, E() As Double, Z() As Double, Info As Long)
(Simple driver) Eigenvalues and eigenvectors of a symmetric tridiagonal matrix
Example Results
Eigenvalues = 0.171899161473039 0.274429936398504 3.00367090212846
Eigenvectors =
0.106563041190365 -0.378750155986403 -0.919343590608286
0.259206614996466 -0.882055576996615 0.393433463029321
0.959925126764757 0.280225406466732 -4.18002107893757E-03
Info = 0