Actual source code: seq.c
1: #define PETSCMAT_DLL
3: /* seq.f -- translated by f2c (version of 25 March 1992 12:58:56).*/
5: #include ../src/mat/color/color.h
9: PetscErrorCode MINPACKseq(PetscInt *n,PetscInt *indrow,PetscInt *jpntr,PetscInt *indcol,PetscInt *ipntr,PetscInt *list,PetscInt *ngrp,
10: PetscInt *maxgrp,PetscInt *iwa)
11: {
12: /* System generated locals */
13: PetscInt i__1, i__2, i__3;
15: /* Local variables */
16: PetscInt jcol, j, ic, ip, jp, ir;
18: /* Given the sparsity pattern of an m by n matrix A, this */
19: /* subroutine determines a consistent partition of the */
20: /* columns of A by a sequential algorithm. */
21: /* A consistent partition is defined in terms of 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: /* A partition of the columns of A into groups is consistent */
26: /* if the columns in any group are not adjacent in the graph G. */
27: /* In graph-theory terminology, a consistent partition of the */
28: /* columns of A corresponds to a coloring of the graph G. */
29: /* The subroutine examines the columns in the order specified */
30: /* by the array list, and assigns the current column to the */
31: /* group with the smallest possible number. */
32: /* Note that the value of m is not needed by seq and is */
33: /* therefore not present in the subroutine statement. */
34: /* The subroutine statement is */
35: /* subroutine seq(n,indrow,jpntr,indcol,ipntr,list,ngrp,maxgrp, */
36: /* iwa) */
37: /* where */
38: /* n is a positive integer input variable set to the number */
39: /* of columns of A. */
40: /* indrow is an integer input array which contains the row */
41: /* indices for the non-zeroes in the matrix A. */
42: /* jpntr is an integer input array of length n + 1 which */
43: /* specifies the locations of the row indices in indrow. */
44: /* The row indices for column j are */
45: /* indrow(k), k = jpntr(j),...,jpntr(j+1)-1. */
46: /* Note that jpntr(n+1)-1 is then the number of non-zero */
47: /* elements of the matrix A. */
48: /* indcol is an integer input array which contains the */
49: /* column indices for the non-zeroes in the matrix A. */
50: /* ipntr is an integer input array of length m + 1 which */
51: /* specifies the locations of the column indices in indcol. */
52: /* The column indices for row i are */
53: /* indcol(k), k = ipntr(i),...,ipntr(i+1)-1. */
54: /* Note that ipntr(m+1)-1 is then the number of non-zero */
55: /* elements of the matrix A. */
56: /* list is an integer input array of length n which specifies */
57: /* the order to be used by the sequential algorithm. */
58: /* The j-th column in this order is list(j). */
59: /* ngrp is an integer output array of length n which specifies */
60: /* the partition of the columns of A. Column jcol belongs */
61: /* to group ngrp(jcol). */
62: /* maxgrp is an integer output variable which specifies the */
63: /* number of groups in the partition of the columns of A. */
64: /* iwa is an integer work array of length n. */
65: /* Argonne National Laboratory. MINPACK Project. July 1983. */
66: /* Thomas F. Coleman, Burton S. Garbow, Jorge J. More' */
69: /* Parameter adjustments */
70: --iwa;
71: --ngrp;
72: --list;
73: --ipntr;
74: --indcol;
75: --jpntr;
76: --indrow;
78: /* Function Body */
79: *maxgrp = 0;
80: i__1 = *n;
81: for (jp = 1; jp <= i__1; ++jp) {
82: ngrp[jp] = *n;
83: iwa[jp] = 0;
84: }
86: /* Beginning of iteration loop. */
88: i__1 = *n;
89: for (j = 1; j <= i__1; ++j) {
90: jcol = list[j];
92: /* Find all columns adjacent to column jcol. */
94: /* Determine all positions (ir,jcol) which correspond */
95: /* to non-zeroes in the matrix. */
97: i__2 = jpntr[jcol + 1] - 1;
98: for (jp = jpntr[jcol]; jp <= i__2; ++jp) {
99: ir = indrow[jp];
101: /* For each row ir, determine all positions (ir,ic) */
102: /* which correspond to non-zeroes in the matrix. */
104: i__3 = ipntr[ir + 1] - 1;
105: for (ip = ipntr[ir]; ip <= i__3; ++ip) {
106: ic = indcol[ip];
108: /* Array iwa marks the group numbers of the */
109: /* columns which are adjacent to column jcol. */
111: iwa[ngrp[ic]] = j;
112: }
113: }
115: /* Assign the smallest un-marked group number to jcol. */
117: i__2 = *maxgrp;
118: for (jp = 1; jp <= i__2; ++jp) {
119: if (iwa[jp] != j) {
120: goto L50;
121: }
122: }
123: ++(*maxgrp);
124: L50:
125: ngrp[jcol] = jp;
126: }
128: /* End of iteration loop. */
130: return(0);
131: }