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

◆ Dsptri()

Sub Dsptri ( Uplo As  String,
N As  Long,
Ap() As  Double,
IPiv() As  Long,
Info As  Long 
)

Inverse of a symmetric matrix in packed form

Purpose
This routine computes the inverse of a real symmetric indefinite matrix A in packed form using the factorization A = U*D*U^T or A = L*D*L^T computed by Dsptrf.

This method inverts U and then computes inv(A) by solving the system inv(A)*L = inv(U) for inv(A).
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,out]Ap()Array Ap(LAp - 1) (LAp >= N(N + 1)/2)
[in] The block diagonal matrix D and the multipliers used to obtain the factor U or L as computed by Dsptrf, stored as a packed triangular matrix.
[out] If Info = 0, the (symmetric) inverse of the original matrix, stored as a packed triangular matrix. The upper or lower triangular part of the inverse is stored 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 Ap() 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_Dsptri()
Const N = 3
Dim Ap(N * (N + 1) / 2) As Double, IPiv(N - 1) As Long, 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 Dsptrf("L", N, Ap(), IPiv(), Info)
If Info = 0 Then Call Dsptri("L", N, Ap(), IPiv(), Info)
Debug.Print "Inv(A) ="
Debug.Print Ap(0)
Debug.Print Ap(1), Ap(3)
Debug.Print Ap(2), Ap(4), Ap(5)
Debug.Print "Info =", Info
End Sub
Sub Dsptri(Uplo As String, N As Long, Ap() As Double, IPiv() As Long, Info As Long)
Inverse of a symmetric matrix in packed form
Sub Dsptrf(Uplo As String, N As Long, Ap() As Double, IPiv() As Long, Info As Long)
UDUT or LDLT factorization of a symmetric matrix in packed form
Example Results
Inv(A) =
0.463651335375572
1.10603849087679E-04 0.376908423331071
6.25649106339333E-02 -0.128801869057578 0.474409403096834
Info = 0