r
The solution of certain banded systems of linear
equations using the folding algorithm
D. J. Evans* and M. Hatzopoulosf
Department of Mathematics, University ofTechnology, Loughborough, Leicestershire, LE11 3TU
The problem of solving a banded system of linear equations Ax = b occurs frequently in the numerical
solution of partial and ordinary differential equations. In the case when the matrix A is banded with
semi-bandwidth/' and the elements satisfy the relationship atj = an-t+i.n-)+i, simple techniques of
folding enable a more compact version of Gaussian elimination to be constructed which possess
advantages of efficiency and accuracy.
(Received July 1974)
1. Introduction
The problem of solving a banded system of linear equations
Ax = b
(1.1)
occurs frequently in the numerical solution of partial and
ordinary differential equations.
In the following analysis we consider the special case when the
matrix A has the form:
\
\
N
Ipl
^ 0
>
N
s
a ,
\
N
" I
S
(1.2)
\o\\\
a
n,n-p+l
a
n,n-\
Q
nn
(2.3)
Similarly, if now n is even (n = 2m) then we have the situation
where the elimination processes when carried out produce the
matrix identity:
K+2Nm.2 .. . N^NiN'JftA = S'
(2.4)
where S' has the form:
Since the matrix (1.2) has the special property that the elements
satisfy the relationship au = a n _ i + l n _ J + 1 and is banded of
semi-bandwidth p, simple techniques of folding (i.e. working
from the top right and bottom left hand corners of the matrix
respectively) enable a more compact version of Gaussian
elimination to be constructed which possesses advantages of
efficiency and accuracy.
2. The eliminating transformation for matrix A full
Gaussian elimination can simply be described as a series of
transformations that takes the matrix A of (1.1) into a triangular
form, given by
=U
(2.1)
Nn.lNn_2...NiA
where Nt is the transformation that eliminates the element
a
(2.5)
n+ 2
We denote the coefficient matrix at any stage of the elimination
process by A. The transformations Nt and N* are given by
matrices of the elements, i.e.,
j,i i < j ^ n.
We now introduce a series of similar transformations; in
which N( is the transformation that eliminates the elements
aJti i <j ^ n, N* is the transformation that eliminates the
elements Oj>t I < j < i where n is the dimension of the matrix A
and these transformations are carried out alternately. Thus, the
new technique can be visualised as a Gaussian forward elimination process carried out from the top of the matrix and a
Gaussian backward elimination process performed on the
bottom of the matrix. For parallel processing or certain matrices
especially those with equal elements on the diagonal and offdiagonal positions these transformation processes can be
combined into one efficient process as we now indicate.
Suppose now that n is odd (n = 2m + 1) then we have the
situation where the elimination processes yield the identity:
K+i*»--- Nn- iN2KNtA = S'
where the matrix S has the form:
(2.2)
J
"J,k
L- — •
V
•<
(2.6)
> = (nkJ) =
0 , elsewhere ,
and
-aMkii,k, K =
= I,
i, 1
I S< j < i
ak
k
(2.7)
0
elsewhere
For the solution of the transformed system with coefficient
matrix as in (2.3), a backward and a forward substitution process
commencing at the (n + l)/2 element is required whilst for the
system (2.5), we first have to solve a 2 x 2 linear system before
•Department of Computer Studies, University of Technology, Loughborough, Leics., LEU 3TU
fDepartment of Mechanical Engineering, University ofTechnology, Loughborough, Leics., LEU 3TU
184
The Computer Journal
carrying out the necessary backward and forward solution
processes from the n/2 and n/2 + 1 elements respectively. The
algorithm that transforms the matrix A into the easily solvable
systems (2.3) or (2.5) will be denoted as the folding or
symmetric Gaussian elimination algorithm.
(3.6)
3. The folding algorithm for matrix A banded of semi-bandwidth p
We now apply similar techniques as above to transform the
system A with the form given by (1.2).
For the case when n is odd, we proceed as follows:
(a) The elements au are eliminated where i and j are in the
range:
+ \
and
i = [j +
(c) Finally at this stage the pivoting row eliminates only the
appropriate element of the other half process so that each
elimination does not recreate values in the zero elements
created by the other. The elimination procedure continues
now as in section 2 resulting with matrix A having the form:
p-l]
-p
as in section 2.
At this stage of the elimination procedure the transformed
matrix A has the form:
(3.7)
(3.2)
In a similar way the case when n is even can also be treated.
The steps a, b, c as discussed earlier are identical but with
the following differences at each step:
(a') Instead of (3.1), we eliminate elements atJ such that
(b) Now it is necessary to introduce slightly more sophisticated
elimination techniques as the two pivoting rows have to
eliminate elements of the same row and can interfere with
each other.
The element a^ j is eliminated such that:
+.p
and i=j+
1(W
+ p - 1],
then A has the form:
p-odd
(3.3)
/»+l)
l ^
(3.9)
,p— even
and Ojj such that:
— /> —
,-,,(,) ["-f!+,-i]
+ P) ,
4
(3.8)
*- p —
p^
•, - «
j = 1(0 |j - P +
JJ
— odd
(3.4)
__
' — even
_
(b') Then, instead of (3.3) the elements au are eliminated such
that
y - ,(1) g -p + 2J
.p - odd
(3.10)
Only one elimination procedure is necessary because we know
beforehand the two half loop procedures are identical resulting in the matrix A having the form:
•p
and instead of (3.4) we eliminate elements a,j as before
where
—
n-
p
p — even
+ 1
for p — odd
/='(!)-"+/>-
,]
^
— odd
(3.11)
(3.5)
= [„ +2-»-,-in)/-!
L
1+ P- + \,p — even
and then the matrix A has the form (3.6) for p—odd and
Volume 19 Number 2
185
(3.5) for/?—even,
(c') Finally, the matrix A has the easily solvable form:
n+ 1
n-odd
(3.12)
which is treated similarly to the even case given in section
2 of this paper.
4. Description of the algorithm.
We can arrange the elimination process such that at each stage
the matrix remains centro-symmetric and hence we need store
and work only on the first ^—— rows. The steps are as
Thus, the matrix is centro-symmetric, i.e. the lower part is
symmetric to the upper part.
However for p = 2 and n-even, only the first stage is needed
whilst for n-odd only the first and second stages are required.
This case has been presented recently by Andres et al. (1974).
Finally for p = 3 and n-even, !only the first two stages are
required.
follows (corresponding to a, b and c of section 3).
(a) We eliminate the elements al} for which:
5. Discussion
It is clear that the folding algorithm as described in section 4
requires storage of only the first
and
i = [J + l](l)[y
For
rows plus a ^-vector.
Since the ordinary Gaussian elimination process requires
operations of the order 0(\np2) then it follows that the folding
algorithm requires operations of the order 0(%np2), thus
producing a 50% reduction. In comparison the method
by Fox and Goodwin (1953) requires the solution of two
systems of linear equations.
we eliminate the elements atJ and a,k for which:
'-{'•'H4-1k = n- j +1
and
It is interesting to note that the solution process for the folding
Gaussian elimination is effected from the centre values of the
matrix outwards, hence reducing the growth of rounding error
in the forward and backward substitution processes (Wilkinson,
1965).
An even more important application concerns the parallel
processing machines projected for the near future. Here the
two elimination processes can be arranged to take place
simultaneously and thus the algorithm is then applicable for
more general forms of matrices.
The following program is given for the algorithm as described
in section 4. We assume that p < - , and A is stored as a
(c) For
-m+>}<•>
we store the elements of the pivot rov/j into an intermediate
vector v and using this vector we eliminate the element
a
j.n-j+i °f t n e pivot row and then the elements atJ and
'
for which
rectangular array. The program can easily be modified for
p #5 - when A is stored in the usual way row by row for the
first
rows.
6. Program
and
Finally, the first \n
186
+
rows of the matrix has the form:
c
c
c
c
c
c
c
c
c
SUBROUTINE F G A U S S ( A , B , N , P , N 1 , N 2 )
SUBROUTINE FGAUSS SOLVES, USING THE FOLDING ALGORITHM
A BANDED SYSTEM OF LINEAR EQUATIONS OF SEMIBANDWIDTH P
WHERE A HAS THE FORM ( 1 . 2 ) .
ON ENTRANCE B I S THE RIGHT
HAND SIDE OF THE SYSTEM AND ON EXIT THE SOLUTION I S STORED ON B
N IS THE ORDER OF THE SYSTEM.
THE COEFFICIENT MATRIX A I S STORED AS AN N2*N1 RECTANGULAR
ARRAY WITH THE DIAGONAL ON COLUMN P THE FIRST P - l COLUMNS
ARE THE P - l LOWER SUBDIAGONALS AND THE LAST P - l ARE THE P - l
UPPER SUBDIAGONALS.
N1=2*P-1,N2=FN+1)/2]
INTEGER P
The Computer Journal
DIMENSION A(N2,N1),B(N),VS(P)
L=N/2
LS=N-2*L
Ll=((N+2)/2)-P
L2=(N-P+l)/2
L3-(N-l)/2
L4=(N+l)/2
2
1
4
5
7
6
3
DO 1 1=1,L1
DO 1 J=I+1,I+P-1
S=-A(J,I+P-J)/A(I,P)
DO 2 K=1,P-1
A(J,I+P+K-J)=A(J,I+P+K-J)+S*A(I,P+K)
B(J)=B(J)+S*B(I)
B(N-J+1)=B(N-J+1) + S*B(N-I+1)
IF(P.EQ.2.AND.LS.EQ.O) GO TO 22
DO 3 I=L1+1,L2
DO 5 J=I+1,L4
S=-A(J,I+P-J)/A(I,P)
DO 4 K=1,P-1
A(J,I+P+K-J)=A(J,I+P+K-J)+S*A(I,P+K)
IF(LS.NE.O.AND.J.EQ.L4) GO TO 4
A(N-J+1,J+P-I-K)=A(J ,I+P+K-J)
CONTINUE
B(J)=B(J)+S*B(I)
IF(LS.NE.O.AND.J.EQ.L4) GO TO 5
B(N-J+1)=B(N-J+1)+S*B(N-I+1)
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(L+1)
S8=A(L,P)*B(L+1)-A(L,P+1)*B(L)
B(L)=S/D
B(L+1)=S8/D
IF(P.EQ.3.0R.P.EQ.2) GO TO 20
LS=2
GO TO 14
CONTINUE
B(L4)=B(L4)/A(U,P)
IF(P.EQ.2) GO TO 20
LS=1
CONTINUE
DO 15 I=LS, P-2
S1=O
S2=0
DO 16 J=1,I
S1=S1+A(L1+P-I,P+J)*B(L4+I-J)
S2=S2+A(L1+P-I,P+J)*B(L1+P+J-I)
B(L4+I)=(B(L4+I)-S1)/A(L1+P-I,P)
B(L1+P-I)=(B(L1+P-I)-S2)/A(L1+P-I,P)
CONTINUE
IF(LS.EQ.0.AND.P.EQ.2) L1=L1-1
DO 17 1=1,1,1+1
L=Ll+2-I
S1=O
S2=0
DO 18 J=1,P-1
S1=S1+A(L,P+J)*B (L+J)
S2=S2+A(L,P+J)*B(N-L+1-J)
B(L)=(B(L)-S1)/A(L,P)
B(N-L+1)=(B(N+1-L)-S2)/A(L,P)
RETURN
END
References
ANDR£S, T., HOSKINS, W. D., and MCMASTER, G. E. (1974). A Coupled Algorithm for the Solution of Certain Tridiagonal Systems of
Linear Equations, The Computer Journal, Vol. 17, Algorithm 84, pp. 378-379.
Fox, L., and GOODWIN, E. T. (1953). Numerical Solution of Non-Singular Integral Equations, Phil. Trans. Roy. Soc, Vol. A245, pp. 501-534.
WILKINSON, J. H. (1965). The Algebraic Eigenvalue Problem, Clarendon Press, Oxford.
Volume 19 Number 2
187
© Copyright 2026 Paperzz