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

◆ Dsytri()

Sub Dsytri ( Uplo As  String,
N As  Long,
A() As  Double,
IPiv() As  Long,
Info As  Long 
)

Inverse of a symmetric matrix

Purpose
This routine computes the inverse of a real symmetric matrix A using the factorization A = U*D*U^T or A = L*D*L^T computed by Dsytrf.
Parameters
[in]UploSpecifies whether the details of the factorization are stored as an upper or lower triangular matrix.
= "U": Upper triangular, form is A = U*D*U^T.
= "L": Lower triangular, form is A = L*D*L^T.
[in]NOrder of the matrix A. (N >= 0) (If N = 0, returns without computation)
[in]A()Array A(LA1 - 1, LA2 - 1) (LA1 >= N, LA2 >= N)
[in] The block diagonal matrix D and the multipliers used to obtain the factor U or L as computed by Dsytrf.
[out] If Info = 0, the (symmetric) inverse of the original matrix A. The upper or lower triangular part of the inverse is formed and the other part of A() below or above the diagonal is not referenced in accordance with Uplo.
[in]IPiv()Array IPiv(LIPiv - 1) (LIPiv >= N)
Details of the interchanges and the block structure of D as determined by Dsytrf.
[out]Info= 0: Successful exit.
= -1: The argument Uplo had an illegal value. (Uplo <> "U" nor "L")
= -2: The argument N had an illegal value. (N < 0)
= -3: The argument A() is invalid.
= -4: The argument IPiv() is invalid.
= i > 0: The i-th element of D is exactly zero; the matrix is singular and its inverse could not be computed.
Reference
LAPACK
Example Program
Compute the inverse matrix of A, where
( 2.2 -0.11 -0.32 )
A = ( -0.11 2.93 0.81 )
( -0.32 0.81 -2.37 )
Sub Ex_Dsytri()
Const N = 3
Dim A(N - 1, N - 1) As Double, IPiv(N - 1) As Long, 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 Dsytrf("L", N, A(), IPiv(), Info)
If Info = 0 Then Call Dsytri("L", N, A(), IPiv(), Info)
Debug.Print "Inv(A) ="
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 Dsytri(Uplo As String, N As Long, A() As Double, IPiv() As Long, Info As Long)
Inverse of a symmetric matrix
Sub Dsytrf(Uplo As String, N As Long, A() As Double, IPiv() As Long, Info As Long)
UDUT or LDLT factorization of a symmetric matrix
Example Results
Inv(A) =
0.463651335375572 0 0
1.10603849087679E-04 0.376908423331071 0
6.25649106339333E-02 -0.128801869057578 0.474409403096834
Info = 0