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

◆ Dpbsv()

Sub Dpbsv ( Uplo As  String,
N As  Long,
Kd As  Long,
Ab() As  Double,
B() As  Double,
Info As  Long,
Optional Nrhs As  Long = 1 
)

(Simple driver) Solution to system of linear equations AX = B for a symmetric positive definite band matrix

Purpose
This routine computes the solution to a real system of linear equations
A * X = B,
where A is an n x n symmetric positive definite band matrix, and X and B are n x nrhs matrices.

The Cholesky decomposition is used to factor A as
A = U^T*U, if Uplo = "U", or
A = L*L^T, if Uplo = "L",
where U is an upper triangular band matrix, and L is a lower triangular band matrix, with the same number of super-diagonals or sub-diagonals as A. The factored form of A is then used to solve the system of equations A * X = B.
Parameters
[in]Uplo= "U": Upper triangle of A is stored.
= "L": Lower triangle of A is stored.
[in]NNumber of linear equations, i.e., order of the matrix A. (N >= 0) (If N = 0, returns without computation)
[in]KdNumber of super-diagonals of the matrix A if Uplo = "U", or number of sub-diagonals if Uplo = "L". (Kd >= 0)
[in,out]Ab()Array Ab(LAb1 - 1, LAb2 - 1) (LAb1 >= Kd + 1, LAb2 >= N)
[in] N x N symmetric band matrix A in Kd+1 x N symmetric band matrix form. Upper or lower part is to be stored in accordance with uplo. See below for further details.
[out] If Info = 0, the triangular factor U or L from the Cholesky factorization A = U^T*U or A = L*L^T of the band matrix A, in the same storage format as A.
[in,out]B()Array B(LB1 - 1, LB2 - 1) (LB1 >= max(1, N), LB2 >= Nrhs) (2D array) or B(LB - 1) (LB >= max(1, N), Nrhs = 1) (1D array)
[in] N x Nrhs right hand side matrix B.
[out] If Info = 0, the N x Nrhs solution matrix X.
[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 Kd had an illegal value. (Kd < 0)
= -4: The argument Ab() is invalid.
= -5: The argument B() is invalid.
= -7: The argument Nrhs had an illegal value. (Nrhs < 0)
= i > 0: The leading minor of order i of A is not positive definite, so the factorization could not be completed, and the solution has not been computed.
[in]Nrhs(Optional)
Number of right hand sides, i.e., number of columns of the matrix B. (Nrhs >= 0) (If Nrhs = 0, returns without computation) (default = 1)
Further Details
The symmetric band matrix form is illustrated by the following example, when n = 6, kd = 2, and uplo = "U":
On entry:

   *    *   a13  a24  a35  a46
   *   a12  a23  a34  a45  a56
  a11  a22  a33  a44  a55  a66

On exit:

   *    *   u13  u24  u35  u46
   *   u12  u23  u34  u45  u56
  u11  u22  u33  u44  u55  u66
Similarly, if uplo = "L" the format of A is as follows:
On entry:

  a11  a22  a33  a44  a55  a66
  a21  a32  a43  a54  a65   *
  a31  a42  a53  a64   *    *

On exit:

  l11  l22  l33  l44  l55  l66
  l21  l32  l43  l54  l65   *
  l31  l42  l53  l64   *    *
Array elements marked * are not used by the routine.
Reference
LAPACK
Example Program
Solve the system of linear equations Ax = B and estimate the reciprocal of the condition number (RCond) of A, where A is banded symmetric positive definite and
( 0.61 0.79 0 ) ( 0.3034 )
A = ( 0.79 2.23 0.25 ), B = ( 0.8537 )
( 0 0.25 2.87 ) ( 0.8000 )
Sub Ex_Dpbsv()
Const N As Long = 3, Kd = 1
Dim Ab(Kd, N - 1) As Double, B(N - 1) As Double
Dim ANorm As Double, RCond As Double, Info As Long
Ab(0, 0) = 0.61: Ab(0, 1) = 2.23: Ab(0, 2) = 2.87
Ab(1, 0) = 0.79: Ab(1, 1) = 0.25
B(0) = 0.3034: B(1) = 0.8537: B(2) = 0.8
ANorm = Dlansb("1", "L", N, Kd, Ab())
Call Dpbsv("L", N, Kd, Ab(), B(), Info)
If Info = 0 Then Call Dpbcon("L", N, Kd, Ab(), ANorm, RCond, Info)
Debug.Print "X =", B(0), B(1), B(2)
Debug.Print "RCond =", RCond
Debug.Print "Info =", Info
End Sub
Function Dlansb(Norm As String, Uplo As String, N As Long, K As Long, Ab() As Double, Optional Info As Long) As Double
One norm, Frobenius norm, infinity norm, or largest absolute value of any element of a symmetric band...
Sub Dpbcon(Uplo As String, N As Long, Kd As Long, Ab() As Double, ANorm As Double, RCond As Double, Info As Long)
Condition number of a symmetric positive definite band matrix
Sub Dpbsv(Uplo As String, N As Long, Kd As Long, Ab() As Double, B() As Double, Info As Long, Optional Nrhs As Long=1)
(Simple driver) Solution to system of linear equations AX = B for a symmetric positive definite band ...
Example Results
X = 6.99999999999999E-02 0.33 0.25
RCond = 7.20810157140908E-02
Info = 0