Yale Sparse Matrix Package I The Symmetric Codes
Yale Sparse Matrix Package I The Symmetric Codes
INTRODUCTION
Consider the N x N system of linear equations
Mx=b (1)
where the coefficient matrix M is large, sparse, symmetric, and positive definite. Such systems
arise frequently in scientific computation, e.g. in finite difference and finite element approxima-
tions to elliptic boundary value problems. In this paper, we present a package of efficient,
reliable, well-documented and portable FORTRAN subroutines for solving these systems.
See Reference 3 for a corresponding package for nonsymmetric problems.
Direct methods for solving (1) are generally variations of symmetric Gaussian elimination.
One forms the U'DU decomposition of M, where U is unit upper triangular and D positive
diagonal, and then successively solves the triangular systems
U'y=b, Dz=y, Ux=z (2)
When M is large (N >> l ) , dense Gaussian elimination (in which zeros are not exploited) is
prohibitively expensive in terms of both the work (-1/6N3 multiples) and storage ( N 2words)
required. But, since M is sparse, most entries of M and U are zero, and there are significant
advantages to factoring M without storing or operating on the zeros appearing in M and U.
Recently, a number of implementations of sparse Gaussian elimination have appeared based
on this idea (cf. References 2 , 6 , 8 , 11 and 13-16).
In this paper, we first describe the scheme used for storing sparse matrices, and then we
give an overview of the package from the point of view of the user. The calling sequences for
the routines are detailed in the listing; for further details of the algorithms employed, see
References 5 a d 10. Finally, we illustrate the performance of the package on a typical model
problem and on randomly generated test matrices. Listings and machine-readable versions of
t This research was supported in part by ONR Grant N00014-76-0277, NSF Grant MCS 76-11460, AFOSR Grant
F49620-77-C-0037, and the Chevron Oil Field Research Company.
the subroutines and a demonstration driver may be obtained by sending a written request to
YSMP Librarian, Department of Computer Science, Box 2158 Yale Station, New Haven,
CT 06520.
1: : 1 :
For example, the 5 x 5 matrix
1 0 2 3 0
M = 2 0 5 6 0
0 0 0 8 9
is stored as
I 1 2 3 4 5 6 7 8 9 1 0 1 1 1 2 1 3
IA 1 4 5 8 1 2 1 4
JA 1 3 4 2 1 3 4 1 3 4 5 4 5
A 1 2 3 4 2 5 6 3 6 7 8 8 9
IA 1 4 5 7 9 1 0
JA 1 3 4 2 3 4 4 5 5
A 1 2 3 4 5 6 7 8 9
YALE SPARSE MATRIX PACKAGE 1147
The overhead in this storage scheme is the storage required for the INTEGER arrays IA
and JA. But since IA has N + 1 entries and JA has one entry for each element of A , the total
overhead is approximately equal to the number of nonzero entries in M that are stored. (We
note that our code will accept input matrices stored in either of the above forms, although
the latter form is clearly more efficient.)
driver (subroutine SDRV) is used to solve the (possibly permuted) system of linear equations.
The demonstration driver (program SDMO) sets up a model sparse symmetric positive definite
system of linear equations, calls ODR V to reorder the variables and equations, and calls
SDRV to solve the linear system. In the remainder of this section, we describe each of these
routines in somewhat greater detail. The codes themselves are extensively documented; for
further details about the algorithms employed, see References 5 , 10 and 17.
The ordering driver (subroutine ODRV) uses an important heuristic, the minimum degree
algorithm' (implemented in subroutines MD, MDI, MDM, MDU and MDP), to select Q. The
algorithm effectively does a symbolic elimination on the nonzero structure of the system. A t
each step, it chooses a pivot element from among those uneliminated diagonal matrix entries
which require the fewest arithmetic operations to eliminate (ties are broken arbitrarily). This
has the effect of locally optimizing the elimination process with respect to the number of
arithmetic operations performed. See References 9, 10 and 17 for more details.
MD returns two one-dimensional INTEGER arrays of length N : P contains the permutation
of the row and column indices of M, i.e. the sequence of pivots; and IP contains the inverse
permutation, i.e. I P ( P ( I ) =) I for I = 1 , 2 , . . . ,N. If only the upper triangle of M is being
stored, then the representation of A4 (i.e. the arrays IA, JA and A ) must be rearranged using
the subroutine SRO. (SRO may also be called when the entire matrix M is stored.) In
rearranging IA, JA and A, SRO places each matrix entry M ( I ,J) (Is J ) in row K, where
K = P ( L ) and L = min ( I P ( I )I, P ( J ) ) .Thus the rows of M are not reordered, but after SRO
is finished, each row contains only those entries which appear in the upper triangle of the
matrix QMQ'. Among the entries for each row, SRO places the diagonal entry first and leaves
the off-diagonal entries ordered by increasing column number in M.
To combine the ordering and reordering capabilities just described, ODRV has three possible
paths. If PATH = 1, then only a minimum degree ordering is performed, while if PATH = 2,
then S RO is called as well. Finally, if PATH = 3, only SRO is called.
The user may bypass ODRV entirely by setting P ( I )= IP(I)= I for I = 1 , 2 , 3 , . . . ,N,
Alternatively, the user may substitute another ordering subroutine for the minimum degree
ordering subroutines, as long as it produces the two permutations P and IP. But again, if only
the upper triangle of M is being stored, the representation of M must be rearranged using SRO.
the solution vector x is (1,2,3,4,5,6,7,8,9)‘. Since M is symmetric, one can store either
the entire matrix (CASE = 1) or only the upper triangle (CASE = 2). SDMO then calls ODRV
to reorder the variables and equations and SDRV to solve the linear system. At each stage,
the values of all relevant variables are printed out. It should be noted that SDMO is not a
thorough test routine for the package; it is only designed to ensure that every subroutine in
the package is called at least once.
PERFORMANCE
One of the most important aspects of any package is its performance in terms of both time
and storage. In this section we present results for two classes of linear systems. The first typifies
problems to which the package might be applied in practice, while the second allows us to
evaluate the effects of several design decisions in the software. The computations were
performed on a CDC 6600 using the FTN optimizing Fortran compiler with OPT = 2. For
reference, we note that with this compiler and machine, execution of the statement
for RE A L variable A , B and C requires 1.6 x sec, while execution of the body of inner
most loop of SNF
JUMUJ = JU(MU +J >
D(JUMUJ)= D(JUMUJ)+ UKIDI*U(J)
SNF/mults. Total
n N MD SRO SSF SNF Mults. (x10-6) SNS (excluding MD) LEQlPB SPBFA/SPBSL
15 225 0.220 0.049 0.079 0.154 24,520 6.28 0.017 0.299 0.236 0.293
25 625 0.637 0.148 0,244 0.732 133,280 5.49 0.082 1.206 1.343 1.474 v,
35 1,225 1.285 0.256 0.554 1.947 383,821 5.07 0.162 2.919 4.474 4.353 t,
t!
Density SNF/mults.
(%I MD SRO SSF SNF Mults. (x~O-~) SNS Total
Table IV. Storage required for 200 x 200 random systems-averages of 10 trials
~ ~~ ~~~
REFERENCES
1. A. Chang, ‘Application of sparse matrix methods in electric power system analysis’, in R. A. Willoughby, Ed.,
Sparse Matrix Proceedings, Report RA1, IBM Research, Yorktown Heights, New York, 1968.
2. A. R. Curtis and J. K. Reid, ‘Two FORTRAN subroutines for direct solution of linear equations whose matrix
is sparse, symmetric, and positive definite’, Harwell Report AERE-R7119, 1972.
3. S. C. Eisenstat, M. C. Gursky, M. H. Schultz and A. H. Sherman, ‘The Yale matrix package 11: the non-symmetric
codes’, Report 114, Yale University Department of Computer Science, 1977.
4. S. C. Eisenstat, M. H. Schultz and A. H. Sherman, ‘Application of sparse matrix methods to partial differential
equations’, Proc. AICA Int. Symp. on Computer Methods for Partial Differential Equations, Bethlehem,
Pennsylvania, 1975, pp. 40-45.
5 . S. C. Eisenstat, M. H. Schultz and A. H. Sherman, ‘Algorithms and data structures for sparse symmetric Gaussian
elimination’, SIAM J. Sci. Stat. Comput., 2, 225-237 (1981).
6. F. G. Gustavson, ‘Some basic techniques for solving sparse systems of linear equations’, in D. J. Rose and R.
A. Willoughby, Eds., Sparse Matrices and Their Applications, Plenum Press, 1972, pp. 41-52.
7. International Mathematical and Statistical Libraries, Inc. The IMSL Library 3, Edition 6, 1977.
8. W. C. Rheinboldt and C. K. Mesztenyi, ‘Programs for the solution of large sparse matrix problems based on the
arc-graph structure’, Technical Report TR-262, University of Maryland Computer Science, 1973.
9. D. J. Rose, ‘A graph-theoretic study of the numerical solution of sparse positive definite systems of linear
equations’, in R. Read, Ed., Graph Theory and Computing, Academic Press, 1972, pp. 183-217.
10. A. H. Sherman, ‘On the efficient solution of sparse systems of linear and nonlinear equations’, Ph.D. dissert.,
Department of Computer Science, Yale University, 1975.
11. A. H. Sherman, ‘Yale sparse matrix package user’s guide’, Report UCID-30114, Lawrence Livermore Laboratory,
1975.
12. J. J. Dongarra, J. R. Bunch, C. B. Moler and G. W. Stewart, ‘LINPACK user’s guide’, Society for Industrial
and Applied Mathematics, 1979.
13. I. S. Duff, ‘MA28-a set of Fortran subroutines for sparse unsymmetric linear equations’, A E R E Report R.8730,
HMSO, London, 1977.
14. J. A. George and J. W. H. Liu, Computer Solution ofLarge sparse Positioe Definite Systems, Prentice-Hall, 1981.
15. Z. Zlatev, V. A. Barker and P. G. Thomsen, ‘SSLEST: A Fortran IV subroutine for solving sparse systems of
linear equations. User’s guide’, Technical Report 78-01, Numersk Inst., Denmark, 1978.
16. N. Munksgaard, ‘Fortran subroutines for direct solution of sets of sparse and symmetric linear equations’, Reporf
NI-77-05, Technical University of Denmark, 1977.
17. S. C. Eisenstat, ‘An implementation of the minimum degree algorithm’ (to appear).