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

◆ Dsyevd()

Sub Dsyevd ( Jobz As  String,
Uplo As  String,
N As  Long,
A() As  Double,
W() As  Double,
Info As  Long 
)

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

Purpose
This routine computes all eigenvalues and, optionally, eigenvectors of a real symmetric matrix A. 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]A()Array A(LA1 - 1, LA2 - 1) (LA1 >= N, LA2 >= N)
[in] The symmetric matrix A. If Uplo = "U", the leading N x N upper triangular part of A() contains the upper triangular part of the matrix A. If Uplo = "L", the leading N x N lower triangular part of A() contains the lower triangular part of the matrix A.
[out] Jobz = "V": If Info = 0, A() contains the orthonormal eigenvectors of the matrix A.
  Jobz = "N": The lower triangle (if Uplo = "L") or the upper triangle (if Uplo = "U") of A(), including the diagonal, is destroyed.
[out]W()Array W(LW - 1) (LW >= N)
If Info = 0, the eigenvalues in ascending order.
[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 A() is invalid.
= -5: The argument W() is invalid.
= i > 0: If Jobz = "N", the algorithm failed to converge; i off-diagonal elements of an intermediate tridiagonal form did not converge to zero.
  If Jobz = "V", the algorithm failed to compute an eigenvalue while working on the submatrix lying in rows and columns i/(N+1) through mod(i, N+1).
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_Dsyevd()
Const N = 3
Dim A(N - 1, N - 1) As Double, W(N - 1) As Double, Info As Long
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 Dsyevd("V", "L", N, A(), W(), Info)
Debug.Print "Eigenvalues =", W(0), W(1), W(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)
Debug.Print "Info =", Info
End Sub
Sub Dsyevd(Jobz As String, Uplo As String, N As Long, A() As Double, W() As Double, Info As Long)
(Divide and conquer driver) Eigenvalues and eigenvectors of a symmetric matrix
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