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

◆ Dspevd()

Sub Dspevd ( Jobz As  String,
Uplo As  String,
N As  Long,
Ap() As  Double,
W() As  Double,
Z() As  Double,
Info As  Long 
)

(Divide and conquer driver) Eigenvalues and eigenvectors of a symmetric matrix in packed form

Purpose
This routine computes all the eigenvalues and, optionally, eigenvectors of a real symmetric matrix A in packed form. If only eigenvalues are desired, it uses a QL or QR method. If eigenvectors are also desired, it uses a divide and conquer algorithm.
Parameters
[in]Jobz= "N": Compute eigenvalues only.
= "V": Compute eigenvalues and eigenvectors.
[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]Ap()Array Ap(LAp - 1) (LAp >= N(N + 1)/2)
[in] The upper or lower triangle of the symmetric matrix A, packed columnwise in a linear array. The j-th column of A is stored in the array Ap() as follows.
Uplo = "U": Ap(i + j*(j + 1)/2) = Aij for 0 <= i <= j <= N - 1.
Uplo = "L": Ap((i + j*(2*N - j - 1)/2) = Aij for 0 <= j < = i <= N - 1.
[out] Ap() is overwritten by values generated during the reduction to tridiagonal form. If Uplo = "U", the diagonal and first superdiagonal of the tridiagonal matrix T overwrite the corresponding elements of A. If Uplo = "L", the diagonal and first subdiagonal of T overwrite the corresponding elements of A.
[out]W()Array W(LW - 1) (LW >= N)
If Info = 0, the eigenvalues in ascending order.
[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 W(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 Uplo had an illegal value. (Uplo <> "U" nor "L")
= -3: The argument N had an illegal value. (N < 0)
= -4: The argument Ap() is invalid.
= -5: The argument W() is invalid.
= -6: The argument Z() is invalid.
= i > 0: The algorithm failed to converge. i off-diagonal elements of an intermediate tridiagonal form did not converge to zero
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 )
Sub Ex_Dspevd()
Const N = 3
Dim Ap(N * (N + 1) / 2) As Double, W(N - 1) As Double, Z(N - 1, N - 1) As Double
Dim Info As Long
Ap(0) = 2.2
Ap(1) = -0.11: Ap(3) = 2.93
Ap(2) = -0.32: Ap(4) = 0.81: Ap(5) = 2.37
Call Dspevd("V", "L", N, Ap(), W(), Z(), Info)
Debug.Print "Eigenvalues =", W(0), W(1), W(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 Dspevd(Jobz As String, Uplo As String, N As Long, Ap() As Double, W() As Double, Z() As Double, Info As Long)
(Divide and conquer driver) Eigenvalues and eigenvectors of a symmetric matrix in packed 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
Info = 0