Actual source code: degr.c
1: #define PETSCMAT_DLL
3: /* degr.f -- translated by f2c (version of 25 March 1992 12:58:56). */
5: #include ../src/mat/color/color.h
9: PetscErrorCode MINPACKdegr(PetscInt *n,PetscInt * indrow,PetscInt * jpntr,PetscInt * indcol,PetscInt * ipntr,PetscInt * ndeg,PetscInt * iwa)
10: {
11: /* System generated locals */
12: PetscInt i__1, i__2, i__3;
14: /* Local variables */
15: PetscInt jcol, ic, ip, jp, ir;
17: /* subroutine degr */
18: /* Given the sparsity pattern of an m by n matrix A, */
19: /* this subroutine determines the degree sequence for */
20: /* the intersection graph of the columns of A. */
21: /* In graph-theory terminology, the intersection graph of */
22: /* the columns of A is the loopless graph G with vertices */
23: /* a(j), j = 1,2,...,n where a(j) is the j-th column of A */
24: /* and with edge (a(i),a(j)) if and only if columns i and j */
25: /* have a non-zero in the same row position. */
26: /* Note that the value of m is not needed by degr and is */
27: /* therefore not present in the subroutine statement. */
28: /* The subroutine statement is */
29: /* subroutine degr(n,indrow,jpntr,indcol,ipntr,ndeg,iwa) */
30: /* where */
31: /* n is a positive integer input variable set to the number */
32: /* of columns of A. */
33: /* indrow is an integer input array which contains the row */
34: /* indices for the non-zeroes in the matrix A. */
35: /* jpntr is an integer input array of length n + 1 which */
36: /* specifies the locations of the row indices in indrow. */
37: /* The row indices for column j are */
38: /* indrow(k), k = jpntr(j),...,jpntr(j+1)-1. */
39: /* Note that jpntr(n+1)-1 is then the number of non-zero */
40: /* elements of the matrix A. */
41: /* indcol is an integer input array which contains the */
42: /* column indices for the non-zeroes in the matrix A. */
43: /* ipntr is an integer input array of length m + 1 which */
44: /* specifies the locations of the column indices in indcol. */
45: /* The column indices for row i are */
46: /* indcol(k), k = ipntr(i),...,ipntr(i+1)-1. */
47: /* Note that ipntr(m+1)-1 is then the number of non-zero */
48: /* elements of the matrix A. */
49: /* ndeg is an integer output array of length n which */
50: /* specifies the degree sequence. The degree of the */
51: /* j-th column of A is ndeg(j). */
52: /* iwa is an integer work array of length n. */
53: /* Argonne National Laboratory. MINPACK Project. July 1983. */
54: /* Thomas F. Coleman, Burton S. Garbow, Jorge J. More' */
57: /* Parameter adjustments */
58: --iwa;
59: --ndeg;
60: --ipntr;
61: --indcol;
62: --jpntr;
63: --indrow;
65: /* Function Body */
66: i__1 = *n;
67: for (jp = 1; jp <= i__1; ++jp) {
68: ndeg[jp] = 0;
69: iwa[jp] = 0;
70: }
72: /* Compute the degree sequence by determining the contributions */
73: /* to the degrees from the current(jcol) column and further */
74: /* columns which have not yet been considered. */
76: i__1 = *n;
77: for (jcol = 2; jcol <= i__1; ++jcol) {
78: iwa[jcol] = *n;
80: /* Determine all positions (ir,jcol) which correspond */
81: /* to non-zeroes in the matrix. */
83: i__2 = jpntr[jcol + 1] - 1;
84: for (jp = jpntr[jcol]; jp <= i__2; ++jp) {
85: ir = indrow[jp];
87: /* For each row ir, determine all positions (ir,ic) */
88: /* which correspond to non-zeroes in the matrix. */
90: i__3 = ipntr[ir + 1] - 1;
91: for (ip = ipntr[ir]; ip <= i__3; ++ip) {
92: ic = indcol[ip];
94: /* Array iwa marks columns which have contributed to */
95: /* the degree count of column jcol. Update the degree */
96: /* counts of these columns as well as column jcol. */
98: if (iwa[ic] < jcol) {
99: iwa[ic] = jcol;
100: ++ndeg[ic];
101: ++ndeg[jcol];
102: }
103: }
104: }
105: }
106: return(0);
107: }