LFSRB
Solves a real system of linear equations given the LU factorization of the coefficient matrix in band storage mode.
Required Arguments
FACT — (2 * NLCA + NUCA + 1) by N array containing the LU factorization of the coefficient matrix A as output from routine LFCRB/DLFCRB or LFTRB/DLFTRB. (Input)
NLCA — Number of lower codiagonals of A. (Input)
NUCA — Number of upper codiagonals of A. (Input)
IPVT — Vector of length N containing the pivoting information for the LU factorization of A as output from routine LFCRB/DLFCRB or LFTRB/DLFTRB. (Input)
B — Vector of length N containing the right-hand side of the linear system. (Input)
X — Vector of length N containing the solution to the linear system. (Output)
If B is not needed, B and X can share the same storage locations.
Optional Arguments
N — Number of equations. (Input)
Default: N = size (FACT,2).
LDFACT — Leading dimension of FACT exactly as specified in the dimension statement of the calling program. (Input)
Default: LDFACT = size (FACT,1).
IPATH — Path indicator. (Input)
IPATH = 1 means the system AX = B is solved.
IPATH = 2 means the system ATX = B is solved.
Default: IPATH = 1.
FORTRAN 90 Interface
Generic: CALL LFSRB (FACT, NLCA, NUCA, IPVT, B, X [, …])
Specific: The specific interface names are S_LFSRB and D_LFSRB.
FORTRAN 77 Interface
Single: CALL LFSRB (N, FACT, LDFACT, NLCA, NUCA, IPVT, B, IPATH, X)
Double: The double precision name is DLFSRB.
Description
Routine
LFSRB computes the solution of a system of linear algebraic equations having a real banded coefficient matrix. To compute the solution, the coefficient matrix must first undergo an
LU factorization. This may be done by calling either
LFCRB or
LFTRB. The solution to
Ax =
b is found by solving the banded triangular systems
Ly =
b and
Ux =
y. The forward elimination step consists of solving the system
Ly =
b by applying the same permutations and elimination operations to
b that were applied to the columns of
A in the factorization routine. The backward substitution step consists of solving the banded triangular system
Ux =
y for
x.
LFSRB and
LFIRB both solve a linear system given its
LU factorization.
LFIRB generally takes more time and produces a more accurate answer than
LFSRB. Each iteration of the iterative refinement algorithm used by
LFIRB calls
LFSRB.
The underlying code is based on either LINPACK or LAPACK code depending upon which supporting libraries are used during linking. For a detailed explanation see
Using ScaLAPACK, LAPACK, LINPACK, and EISPACK in the Introduction section of this manual.
Example
The inverse is computed for a real banded 4
× 4 matrix with one upper and one lower codiagonal. The input matrix is assumed to be well-conditioned, hence
LFTRB is used rather than
LFCRB.
USE LFSRB_INT
USE LFTRB_INT
USE WRRRN_INT
! Declare variables
INTEGER LDA, LDFACT, N, NLCA, NUCA
PARAMETER (LDA=3, LDFACT=4, N=4, NLCA=1, NUCA=1)
INTEGER IPVT(N)
REAL A(LDA,N), AINV(N,N), FACT(LDFACT,N), RJ(N)
! Set values for A in band form
! A = ( 0.0 -1.0 -2.0 2.0)
! ( 2.0 1.0 -1.0 1.0)
! ( -3.0 0.0 2.0 0.0)
!
DATA A/0.0, 2.0, -3.0, -1.0, 1.0, 0.0, -2.0, -1.0, 2.0,&
2.0, 1.0, 0.0/
!
CALL LFTRB (A, NLCA, NUCA, FACT, IPVT)
! Set up the columns of the identity
! matrix one at a time in RJ
RJ = 0.0E0
DO 10 J=1, N
RJ(J) = 1.0E0
! RJ is the J-th column of the identity
! matrix so the following LFSRB
! reference places the J-th column of
! the inverse of A in the J-th column
! of AINV
CALL LFSRB (FACT, NLCA, NUCA, IPVT, RJ, AINV(:,J))
RJ(J) = 0.0E0
10 CONTINUE
! Print results
CALL WRRRN (’AINV’, AINV)
!
END
Output
AINV
1 2 3 4
1 -1.000 -1.000 0.400 -0.800
2 -3.000 -2.000 0.800 -1.600
3 0.000 0.000 -0.200 0.400
4 0.000 0.000 0.400 0.200