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

◆ Dsygv()

Sub Dsygv ( IType As  Long,
Jobz As  String,
Uplo As  String,
N As  Long,
A() As  Double,
B() As  Double,
W() As  Double,
Info As  Long 
)

(Simple driver) Generalized eigenvalue problem of symmetric matrices

Purpose
This routine computes all the eigenvalues, and optionally, the eigenvectors of a real generalized symmetric-definite eigenproblem, of the form
Ax = λBx, ABx = λx or BAx = λx.
Here A and B are assumed to be symmetric and B is also positive definite.
Parameters
[in]ITypeSpecifies the problem type to be solved.
= 1: Ax = λBx
= 2: ABx = λx
= 3: BAx = λx
[in]Jobz= "N": Compute eigenvalues only.
= "V": Compute eigenvalues and eigenvectors.
[in]Uplo= "U": Upper triangles of A and B are stored.
= "L": Lower triangles of A and B are stored.
[in]NOrder of the matrices A and B. (N >= 0) (If N = 0, returns without computation)
[in,out]A()Array A(LA1 - 1, LA2 - 1) (LA1 >= N, LA2 >= N)
[in] N x N symmetric matrix A. The upper or lower triangular part is to be stored in accordance with Uplo.
[out] jobz = "V": If Info = 0, A() contains the matrix Z of eigenvectors. The eigenvectors are normalized as follows:
  IType = 1 or 2: Z^T*B*Z = I
  IType = 3: Z^T*inv(B)*Z = I
Jobz = "N": The upper triangle (if Uplo = "U") or the lower triangle (if Uplo = "L") of A(), including the diagonal, is destroyed.
[in,out]B()Array B(LB1 - 1, LB2 - 1) (LB1 >= N, LB2 >= N)
[in] N x N symmetric positive definite matrix B. The upper or lower triangular part is to be stored in accordance with Uplo.
[out] If Info <= N, the part of B() containing the matrix is overwritten by the triangular factor U or L from the Cholesky factorization B = U^T*U or B = L*L^T.
[out]W()Array W(LW - 1) (LW >= N)
If Info = 0, the eigenvalues in ascending order.
[out]Info= 0: Successful exit.
= -1: The argument Itype had an illegal value. (Itype < 1 or Itype > 3)
= -2: The argument Jobz had an illegal value. (Jobz <> "V" nor "N")
= -3: The argument Uplo had an illegal value. (Uplo <> "U" nor "L")
= -4: The argument N had an illegal value. (N < 0)
= -5: The argument A() is invalid.
= -6: The argument B() is invalid.
= -7: The argument W() is invalid.
= i (0 < i <= N): Dsyev failed to converge; i off-diagonal elements of an intermediate tridiagonal form did not converge to zero.
= i (i > N): The leading minor of order i-N of B is not positive definite. The factorization of B could not be completed and no eigenvalues or eigenvectors were computed.
Reference
LAPACK
Example Program
Compute the eigenvalues and the eigenvectors of a generalized symmetric-definite eigenproblem of the form Ax = λBx, where A is a symmetric matrix and B is a symmetric positive definite matrix.
( 0.54 -0.90 -0.94 ) ( 1.18 0.54 -1.22 )
A = ( -0.90 0.70 1.04 ) B = ( 0.54 0.60 -0.71 )
( -0.94 1.04 1.65 ) ( -1.22 -0.71 1.66 )
Sub Ex_Dsygv()
Const N = 3
Dim A(N - 1, N - 1) As Double, B(N - 1, N - 1) As Double, W(N - 1) As Double
Dim Info As Long
A(0, 0) = 0.54
A(1, 0) = -0.9: A(1, 1) = 0.7
A(2, 0) = -0.94: A(2, 1) = 1.04: A(2, 2) = 1.65
B(0, 0) = 1.18
B(1, 0) = 0.54: B(1, 1) = 0.6
B(2, 0) = -1.22: B(2, 1) = -0.71: B(2, 2) = 1.66
Call Dsygv(1, "V", "L", N, A(), B(), 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 Dsygv(IType As Long, Jobz As String, Uplo As String, N As Long, A() As Double, B() As Double, W() As Double, Info As Long)
(Simple driver) Generalized eigenvalue problem of symmetric matrices
Example Results
Eigenvalues = -0.297963342573455 0.510423243055614 7.37370278804149
Eigenvectors =
1.17970064313729 1.46384155786189 9.13803098094183E-02
0.497345303675336 -0.442269445774234 -1.71612038711754
0.524910948248221 1.35130854246605 -0.947378600715302
Info = 0