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