Professional Documents
Culture Documents
1981 ALGORITHM 575 - Permutations For A Zero-Free Diagonal (F1)
1981 ALGORITHM 575 - Permutations For A Zero-Free Diagonal (F1)
Key Words and Phrases unsymmetrlc permutahons, maximum transversal, maximum assignment,
block if)angular form, sparse matr)ces
CRCategor)es 5 0 , 5 1 , 5 3 , 5 4
Language FORTRAN
DESCR)PTION
T h e subroutine is evoked by the F O R T R A N s t a t e m e n t
CALL MC21A(N, ICN, LICN, IP, LENR, IPERM, NUMNZ, IW)
where the p a r a m e t e r s are described in the listing given here.
Given the p a t t e r n of nonzeros of a sparse matrix, this subroutine a t t e m p t s to
find a row p e r m u t a t i o n t h a t makes the matrix have no zeros on its diagonal. It is
possible t h a t the user m a y input a matrix for which there is no p e r m u t a t i o n t h a t
makes the diagonal zero-free. An example of this is
0)
In such instances the algorithm will produce a p e r m u t a t i o n t h a t will p u t as m a n y
nonzeros on the diagonal as possible (1 in the above example). This n u m b e r will
be o u t p u t in N U M N Z . T h e array I P E R M will still hold a p e r m u t a t i o n of the
integers 1, 2 . . . . , N, but in this case N - N U M N Z of the elements (IPERM(I), I)
will be zero.
It is envisaged that a c o m m o n use of the subroutine will be as the first part of
a two-stage process for the determination of the block triangular form of a sparse
matrix (see, for example, [1]). T h e second stage could be p e r f o r m e d by Harwell
subroutine MC13D [4], and the two stages are combined by using subroutine
MC23A in the Harwell package MA28 [2].
T h e subroutine is based on a d e p t h first search with look-ahead technique and
is described in detail in [3]. There, numerical results from using this subroutine,
which has been tested on a wide range of both structured and randomly generated
matrices, are also discussed.
This subroutine has been written in American National Standard FORTRAN.
Special comment cards have been included so that Harwell subroutine OE04A
can be used to make an IBM FORTRAN version that uses half-length integers
(INTEGER*2) for all the arrays except IP. This approximately halves the core
requirements at the cost of restricting the order of the system to 2 ~5 - 1.
REFERENCES
1 DUFF, LS On permutations to block triangular form. J Inst Math, AppL 19 (1977), 339-342.
2 DUFF, I.S MA28--A set of Fortran subroutines for sparse unsymmetrlc hnear equations. AERE
Rep R 8730, Her MaJesty's Stationery Office, London, 1977.
3 DUFF, I S On algorithms for obtaining a maximum transversal A C M Trans. Math Softw. 7, 3
(Sept. 1981), 315-330.
4. DUFF, I.S., AND REID, J K. Algorithm 529. Permutations to block triangular form A C M Trans.
Math Softw 4, 2 {June 1978), 189-192.
ALGORITHM
[A part of the listing is printed here. The complete listing is available from the
ACM Algorithms Distribution Service (see page 407 for order form).]
INTEGER*2 I C N ( L I C N ) , L E N R ( N ) , I P E R M ( N ) , P R ( N ) , C V ( N ) , I /
IARP(N),OUT(N) I/
INTEGER I C N ( L I C N ) , LENR(N), IPERM(N), PR(N), CV(N), ARP(N), OUI(N)
I N I T I A L I Z A T I O N OF ARRAYS
DO 10 I = I , N
ARP(1) = LENR(1) - I
CV(1) = 0
IPERM(1) = 0
I0 CONTINUE
NUMNZ = O
MAIN LOOP
EACH PASS ROUND THIS LOOP EITHER RESULTS IN A NEW ASSIGNMENT
C OR gIVES A ROW WITH NO ASSIGNMENT
DO 100 JORD=I,N
J = JORD
PR(J) = -!
DO 70 K=I,JORD
C LOOK FOR A CHEAP ASSIGNMENT
IN1 = ARP(J)
I F ( I N I LT O) gO TO 30
IN2 = I P ( J ) + LENR(J) - 1
I N I = IN2 -- I N I
DO 20 I I = I N I , IN2
I = ICN(II)
I F ( I P E R M ( 1 ) EQ 07 gO TO 80
20 CONTINUE
C NO CHEAP ASSIGNMENT IN ROW
ARP(J) . . . . I
C BEGIN LOOKING FOR ASSIGNMENT CHAIN STARTING WITH ROW d.
30 OUT(J) = LENR(J) - i
C INNER L O O P EXTENDSCHAIN BY ONE OR BACKTRACKS
DO 60 KK=I, JORD
INI = OUT(O)
IF (INI IT O) gO TO 50
IN~ = If~(J) + LENR(U) "- I
INI = ]N2 - INI
C FORWARD SCAN
DO 40 I I = INJ, IN2
I =- T C N ( I I )
IF ( C V ( I ) EQ JORD) gO TO 40
ACM Transactlo~on MathematmalSo~ware, Vol. 7, No. 3 ~ B ~ m b e r 1 9 8 1 .
390 Algorithms
BACKTRACKING SIEP
50 J = PR(J)
I F (O E ~ - 1 ) GO T O I00
6O CONTINUE
70 CONTINUE
100 CONTINUE
C
C I F MATRIX I S STRUCTURALLY SINGULAR, WE NOW COMPLETE THE
C PERMUTATION IPERM
I F (NUMNZ EQ N) CO TO 150
DO 110 I=I,N
ARP(1) = 0
110 CONTINUE
K=O
DO 130 I = I , N
I F ( I P E R M ( I ) NE O) GO TO 120
K = K ~ I
OUT(K) : I
GO TO 130
120 J = IPERM(I)
AHP(J) = 1
130 CONTINUE
K=O
DO 140 I = I , N
I F ( A R P ( 1 ) NE O) GO TO 140
K=K+I
IOUTK = OUI(K)
IPERM(IOUIK) = I
140 CONTINUE
150 RETURN
END