Actual source code: slo.c
1: #define PETSCMAT_DLL
3: /* slo.f -- translated by f2c (version of 25 March 1992 12:58:56).*/
5: #include ../src/mat/color/color.h
9: PetscErrorCode MINPACKslo(PetscInt *n,PetscInt * indrow,PetscInt * jpntr,PetscInt * indcol, PetscInt *ipntr, PetscInt *ndeg,PetscInt * list,
10: PetscInt * maxclq,PetscInt *iwa1,PetscInt * iwa2,PetscInt * iwa3,PetscInt * iwa4)
11: {
12: /* System generated locals */
13: PetscInt i__1, i__2, i__3, i__4;
15: /* Local variables */
16: PetscInt jcol, ic, ip, jp, ir, mindeg, numdeg, numord;
18: /* Given the sparsity pattern of an m by n matrix A, this */
19: /* subroutine determines the smallest-last ordering of the */
20: /* columns of A. */
21: /* The smallest-last ordering is defined for the loopless */
22: /* graph G with vertices a(j), j = 1,2,...,n where a(j) is the */
23: /* j-th column of A and with edge (a(i),a(j)) if and only if */
24: /* columns i and j have a non-zero in the same row position. */
25: /* The smallest-last ordering is determined recursively by */
26: /* letting list(k), k = n,...,1 be a column with least degree */
27: /* in the subgraph spanned by the un-ordered columns. */
28: /* Note that the value of m is not needed by slo and is */
29: /* therefore not present in the subroutine statement. */
30: /* The subroutine statement is */
31: /* subroutine slo(n,indrow,jpntr,indcol,ipntr,ndeg,list, */
32: /* maxclq,iwa1,iwa2,iwa3,iwa4) */
33: /* where */
34: /* n is a positive integer input variable set to the number */
35: /* of columns of A. */
36: /* indrow is an integer input array which contains the row */
37: /* indices for the non-zeroes in the matrix A. */
38: /* jpntr is an integer input array of length n + 1 which */
39: /* specifies the locations of the row indices in indrow. */
40: /* The row indices for column j are */
41: /* indrow(k), k = jpntr(j),...,jpntr(j+1)-1. */
42: /* Note that jpntr(n+1)-1 is then the number of non-zero */
43: /* elements of the matrix A. */
44: /* indcol is an integer input array which contains the */
45: /* column indices for the non-zeroes in the matrix A. */
46: /* ipntr is an integer input array of length m + 1 which */
47: /* specifies the locations of the column indices in indcol. */
48: /* The column indices for row i are */
49: /* indcol(k), k = ipntr(i),...,ipntr(i+1)-1. */
50: /* Note that ipntr(m+1)-1 is then the number of non-zero */
51: /* elements of the matrix A. */
52: /* ndeg is an integer input array of length n which specifies */
53: /* the degree sequence. The degree of the j-th column */
54: /* of A is ndeg(j). */
55: /* list is an integer output array of length n which specifies */
56: /* the smallest-last ordering of the columns of A. The j-th */
57: /* column in this order is list(j). */
58: /* maxclq is an integer output variable set to the size */
59: /* of the largest clique found during the ordering. */
60: /* iwa1,iwa2,iwa3, and iwa4 are integer work arrays of length n. */
61: /* Subprograms called */
62: /* FORTRAN-supplied ... min */
63: /* Argonne National Laboratory. MINPACK Project. August 1984. */
64: /* Thomas F. Coleman, Burton S. Garbow, Jorge J. More' */
67: /* Parameter adjustments */
68: --iwa4;
69: --iwa3;
70: --iwa2;
71: --list;
72: --ndeg;
73: --ipntr;
74: --indcol;
75: --jpntr;
76: --indrow;
78: /* Function Body */
79: mindeg = *n;
80: i__1 = *n;
81: for (jp = 1; jp <= i__1; ++jp) {
82: iwa1[jp - 1] = 0;
83: iwa4[jp] = *n;
84: list[jp] = ndeg[jp];
85: /* Computing MIN */
86: i__2 = mindeg, i__3 = ndeg[jp];
87: mindeg = PetscMin(i__2,i__3);
88: }
90: /* Create a doubly-linked list to access the degrees of the */
91: /* columns. The pointers for the linked list are as follows. */
93: /* Each un-ordered column ic is in a list (the degree list) */
94: /* of columns with the same degree. */
96: /* iwa1(numdeg) is the first column in the numdeg list */
97: /* unless iwa1(numdeg) = 0. In this case there are */
98: /* no columns in the numdeg list. */
100: /* iwa2(ic) is the column before ic in the degree list */
101: /* unless iwa2(ic) = 0. In this case ic is the first */
102: /* column in this degree list. */
104: /* iwa3(ic) is the column after ic in the degree list */
105: /* unless iwa3(ic) = 0. In this case ic is the last */
106: /* column in this degree list. */
108: /* If ic is an un-ordered column, then list(ic) is the */
109: /* degree of ic in the graph induced by the un-ordered */
110: /* columns. If jcol is an ordered column, then list(jcol) */
111: /* is the smallest-last order of column jcol. */
113: i__1 = *n;
114: for (jp = 1; jp <= i__1; ++jp) {
115: numdeg = ndeg[jp];
116: iwa2[jp] = 0;
117: iwa3[jp] = iwa1[numdeg];
118: if (iwa1[numdeg] > 0) {
119: iwa2[iwa1[numdeg]] = jp;
120: }
121: iwa1[numdeg] = jp;
122: }
123: *maxclq = 0;
124: numord = *n;
126: /* Beginning of iteration loop. */
128: L30:
130: /* Choose a column jcol of minimal degree mindeg. */
132: L40:
133: jcol = iwa1[mindeg];
134: if (jcol > 0) {
135: goto L50;
136: }
137: ++mindeg;
138: goto L40;
139: L50:
140: list[jcol] = numord;
142: /* Mark the size of the largest clique */
143: /* found during the ordering. */
145: if (mindeg + 1 == numord && !*maxclq) {
146: *maxclq = numord;
147: }
149: /* Termination test. */
151: --numord;
152: if (!numord) {
153: goto L80;
154: }
156: /* Delete column jcol from the mindeg list. */
158: iwa1[mindeg] = iwa3[jcol];
159: if (iwa3[jcol] > 0) {
160: iwa2[iwa3[jcol]] = 0;
161: }
163: /* Find all columns adjacent to column jcol. */
165: iwa4[jcol] = 0;
167: /* Determine all positions (ir,jcol) which correspond */
168: /* to non-zeroes in the matrix. */
170: i__1 = jpntr[jcol + 1] - 1;
171: for (jp = jpntr[jcol]; jp <= i__1; ++jp) {
172: ir = indrow[jp];
174: /* For each row ir, determine all positions (ir,ic) */
175: /* which correspond to non-zeroes in the matrix. */
177: i__2 = ipntr[ir + 1] - 1;
178: for (ip = ipntr[ir]; ip <= i__2; ++ip) {
179: ic = indcol[ip];
181: /* Array iwa4 marks columns which are adjacent to */
182: /* column jcol. */
184: if (iwa4[ic] > numord) {
185: iwa4[ic] = numord;
187: /* Update the pointers to the current degree lists. */
189: numdeg = list[ic];
190: --list[ic];
191: /* Computing MIN */
192: i__3 = mindeg, i__4 = list[ic];
193: mindeg = PetscMin(i__3,i__4);
195: /* Delete column ic from the numdeg list. */
197: if (!iwa2[ic]) {
198: iwa1[numdeg] = iwa3[ic];
199: } else {
200: iwa3[iwa2[ic]] = iwa3[ic];
201: }
202: if (iwa3[ic] > 0) {
203: iwa2[iwa3[ic]] = iwa2[ic];
204: }
206: /* Add column ic to the numdeg-1 list. */
208: iwa2[ic] = 0;
209: iwa3[ic] = iwa1[numdeg - 1];
210: if (iwa1[numdeg - 1] > 0) {
211: iwa2[iwa1[numdeg - 1]] = ic;
212: }
213: iwa1[numdeg - 1] = ic;
214: }
215: }
216: }
218: /* End of iteration loop. */
220: goto L30;
221: L80:
223: /* Invert the array list. */
225: i__1 = *n;
226: for (jcol = 1; jcol <= i__1; ++jcol) {
227: iwa2[list[jcol]] = jcol;
228: }
229: i__1 = *n;
230: for (jp = 1; jp <= i__1; ++jp) {
231: list[jp] = iwa2[jp];
232: }
233: return(0);
234: }