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

◆ Dpbsvx()

Sub Dpbsvx ( Fact As  String,
Uplo As  String,
N As  Long,
Kd As  Long,
Ab() As  Double,
Afb() As  Double,
Equed As  String,
S() As  Double,
B() As  Double,
X() As  Double,
RCond As  Double,
FErr() As  Double,
BErr() As  Double,
Info As  Long,
Optional Nrhs As  Long = 1 
)

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

Purpose
This routine uses the Cholesky factorization A = U^T*U or A = L*L^T to compute 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.
Error bounds on the solution and a condition estimate are also provided.
Description
The following steps are performed:

  1. If Fact = "E", real scaling factors are computed to equilibrate the system:
    diag(S) * A * diag(S) * inv(diag(S)) * X = diag(S) * B
    Whether or not the system will be equilibrated depends on the scaling of the matrix A, but if equilibration is used, A is overwritten by diag(S)*A*diag(S) and B by diag(S)*B.

  2. If Fact = "N" or "E", the Cholesky decomposition is used to factor the matrix A (after equilibration if Fact = "E") 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.

  3. If the leading i x i principal minor is not positive definite, then the routine returns with Info = i. Otherwise, the factored form of A is used to estimate the condition number of the matrix A. If the reciprocal of the condition number is less than machine precision, Info = n+1 is returned as a warning, but the routine still goes on to solve for X and compute error bounds as described below.

  4. The system of equations is solved for X using the factored form of A.

  5. Iterative refinement is applied to improve the computed solution matrix and calculate error bounds and backward error estimates for it.

  6. If equilibration was used, the matrix X is premultiplied by diag(S) so that it solves the original system before equilibration.
Parameters
[in]FactSpecifies whether or not the factored form of the matrix A is supplied on entry, and if not, whether the matrix A should be equilibrated before it is factored.
= "F": Afb() contains the factored form of A. If Equed = "Y", the matrix A has been equilibrated with scaling factors given by S(). Ab() and Afb() will not be modified.
= "N": The matrix A will be copied to Afb() and factored.
= "E": The matrix A will be equilibrated if necessary, then copied to Afb() and factored.
[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 positive definite band matrix A in Kd+1 x N symmetric band matrix form, except if Fact = "F" and Equed = "Y", then Ab() must contain the equilibrated matrix diag(S)*A*diag(S). The upper or lower triangular part is stored in accordance with Uplo.
[out] If Fact = "E" and Equed = "Y", Ab() is overwritten by diag(S)*A*diag(S). Otherwise, Ab() is not modified.
[in,out]Afb()Array Afb(LAfb1 - 1, LAfb2 - 1) (LAfb1 >= Kd + 1, LAfb2 >= N)
[in] If Fact = "F", Afb() contains 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 Ab(). If Equed="Y", then Afb() is the factored form of the equilibrated matrix A.
[out] If Fact = "N", Afb() returns the triangular factor U or L from the Cholesky factorization A = U^T*U or A = L*L^T.
  If Fact = "E", Afb() returns the triangular factor U or L from the Cholesky factorization A = U^T*U or A = L*L^T of the equilibrated matrix A (see the description of Ab() for the form of the equilibrated matrix).
[in,out]EquedSpecifies the form of equilibration that was done.
= "N": No equilibration.
= "Y": Equilibration was done, i.e., A has been replaced by diag(S)*A*diag(S).
[in] If Fact = "F", the form of equilibration of given matrix A.
[out] If Fact = "E", returns the result of equilibration. If Fact = "N", always returns "N".
[in,out]S()Array S(LS - 1) (LS >= N)
The scale factors for A. Not accessed if Fact = "N".
[in] If Fact = "F", the scale factors for given matrix A. (Each element > 0)
[out] If Fact = "E", the resulted scale factors.
[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 Equed = "N", B() is not modified. If Eequed = "Y", B() is overwritten by diag(S)*B.
[out]X()Array X(LX1 - 1, LX2 - 1) (LX1 >= max(1, N), LX2 >= Nrhs) (2D array) or X(LX - 1) (LX >= max(1, N), Nrhs = 1) (1D array)
If Info = 0 or Info = N+1, the N x Nrhs solution matrix X to the original system of equations. Note that if Equed = "Y", A() and B() are modified on exit, and the solution to the equilibrated system is inv(diag(S))*X.
[out]RCondThe estimate of the reciprocal condition number of the matrix A after equilibration (if done). If RCond is less than the machine precision (in particular, if RCond = 0), the matrix is singular to working precision. This condition is indicated by a return code of Info > 0.
[out]FErr()Array FErr(LFErr - 1) (LFErr >= Nrhs)
The estimated forward error bound for each solution vector X(j) (the j-th column of the solution matrix X). If Xtrue is the true solution corresponding to X(j), FErr(j-1) is an estimated upper bound for the magnitude of the largest element in (X(j) - Xtrue) divided by the magnitude of the largest element in X(j). The estimate is as reliable as the estimate for rcond, and is almost always a slight overestimate of the true error.
[out]BErr()Array BErr(LBErr - 1) (LBErr >= Nrhs)
The componentwise relative backward error of each solution vector X(j) (i.e., the smallest relative change in any element of A or B that makes X(j) an exact solution).
[out]Info= 0: Successful exit.
= -1: The argument Fact had an illegal value. (Fact <> "F", "N" nor "E")
= -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 Kd had an illegal value. (Kd < 0)
= -5: The argument Ab() is invalid.
= -6: The argument Afb() is invalid.
= -7: The argument Equed had an illegal value. (Fact = "F" and Equed <> "N" nor "Y")
= -8: The argument S() had an illegal value. (S(i) <= 0 when Fact = "F" and Equed = "Y")
= -9: The argument B() is invalid.
= -10: The argument X() is invalid.
= -12: The argument FErr() is invalid.
= -13: The argument BErr() is invalid.
= -15: The argument Nrhs had an illegal value. (Nrhs < 0)
= i (0 < i <= N): 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. RCond = 0 is returned.
= N+1: U is nonsingular, but RCond is less than machine precision, meaning that the matrix is singular to working precision. Nevertheless, the solution and error bounds are computed because there are a number of situations where the computed solution can be more accurate than the value of RCond would suggest.
[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)
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_Dpbsvx()
Const N As Long = 3, Kd = 1
Dim Ab(Kd, N - 1) As Double, Afb(Kd, N - 1) As Double
Dim B(N - 1) As Double, X(N - 1) As Double
Dim S(N - 1) As Double, Equed As String
Dim FErr(0) As Double, BErr(0) As Double
Dim 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
Call Dpbsvx("N", "L", N, Kd, Ab(), Afb(), Equed, S(), B(), X(), RCond, FErr(), BErr(), Info)
Debug.Print "X =", X(0), X(1), X(2)
Debug.Print "RCond =", RCond, "Equed = ", Equed
Debug.Print "Info =", Info
End Sub
Sub Dpbsvx(Fact As String, Uplo As String, N As Long, Kd As Long, Ab() As Double, Afb() As Double, Equed As String, S() As Double, B() As Double, X() As Double, RCond As Double, FErr() As Double, BErr() As Double, Info As Long, Optional Nrhs As Long=1)
(Expert 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 Equed = N
Info = 0