Actual source code: seq.c

petsc-3.3-p7 2013-05-11
  2: /* seq.f -- translated by f2c (version of 25 March 1992  12:58:56).*/

  4: #include <../src/mat/color/color.h>

  8: PetscErrorCode MINPACKseq(PetscInt *n,PetscInt *indrow,PetscInt *jpntr,PetscInt *indcol,PetscInt *ipntr,PetscInt *list,PetscInt *ngrp,
  9:                           PetscInt *maxgrp,PetscInt *iwa)
 10: {
 11:     /* System generated locals */
 12:     PetscInt i__1, i__2, i__3;

 14:     /* Local variables */
 15:     PetscInt jcol, j, ic, ip, jp, ir;

 17: /*     Given the sparsity pattern of an m by n matrix A, this */
 18: /*     subroutine determines a consistent partition of the */
 19: /*     columns of A by a sequential algorithm. */
 20: /*     A consistent partition is defined in terms of the loopless */
 21: /*     graph G with vertices a(j), j = 1,2,...,n where a(j) is the */
 22: /*     j-th column of A and with edge (a(i),a(j)) if and only if */
 23: /*     columns i and j have a non-zero in the same row position. */
 24: /*     A partition of the columns of A into groups is consistent */
 25: /*     if the columns in any group are not adjacent in the graph G. */
 26: /*     In graph-theory terminology, a consistent partition of the */
 27: /*     columns of A corresponds to a coloring of the graph G. */
 28: /*     The subroutine examines the columns in the order specified */
 29: /*     by the array list, and assigns the current column to the */
 30: /*     group with the smallest possible number. */
 31: /*     Note that the value of m is not needed by seq and is */
 32: /*     therefore not present in the subroutine statement. */
 33: /*     The subroutine statement is */
 34: /*       subroutine seq(n,indrow,jpntr,indcol,ipntr,list,ngrp,maxgrp, */
 35: /*                      iwa) */
 36: /*     where */
 37: /*       n is a positive integer input variable set to the number */
 38: /*         of columns of A. */
 39: /*       indrow is an integer input array which contains the row */
 40: /*         indices for the non-zeroes in the matrix A. */
 41: /*       jpntr is an integer input array of length n + 1 which */
 42: /*         specifies the locations of the row indices in indrow. */
 43: /*         The row indices for column j are */
 44: /*               indrow(k), k = jpntr(j),...,jpntr(j+1)-1. */
 45: /*         Note that jpntr(n+1)-1 is then the number of non-zero */
 46: /*         elements of the matrix A. */
 47: /*       indcol is an integer input array which contains the */
 48: /*         column indices for the non-zeroes in the matrix A. */
 49: /*       ipntr is an integer input array of length m + 1 which */
 50: /*         specifies the locations of the column indices in indcol. */
 51: /*         The column indices for row i are */
 52: /*               indcol(k), k = ipntr(i),...,ipntr(i+1)-1. */
 53: /*         Note that ipntr(m+1)-1 is then the number of non-zero */
 54: /*         elements of the matrix A. */
 55: /*       list is an integer input array of length n which specifies */
 56: /*         the order to be used by the sequential algorithm. */
 57: /*         The j-th column in this order is list(j). */
 58: /*       ngrp is an integer output array of length n which specifies */
 59: /*         the partition of the columns of A. Column jcol belongs */
 60: /*         to group ngrp(jcol). */
 61: /*       maxgrp is an integer output variable which specifies the */
 62: /*         number of groups in the partition of the columns of A. */
 63: /*       iwa is an integer work array of length n. */
 64: /*     Argonne National Laboratory. MINPACK Project. July 1983. */
 65: /*     Thomas F. Coleman, Burton S. Garbow, Jorge J. More' */

 68:     /* Parameter adjustments */
 69:     --iwa;
 70:     --ngrp;
 71:     --list;
 72:     --ipntr;
 73:     --indcol;
 74:     --jpntr;
 75:     --indrow;

 77:     /* Function Body */
 78:     *maxgrp = 0;
 79:     i__1 = *n;
 80:     for (jp = 1; jp <= i__1; ++jp) {
 81:         ngrp[jp] = *n;
 82:         iwa[jp] = 0;
 83:     }

 85:     /*     Beginning of iteration loop. */

 87:     i__1 = *n;
 88:     for (j = 1; j <= i__1; ++j) {
 89:         jcol = list[j];

 91:         /*        Find all columns adjacent to column jcol. */

 93:         /*        Determine all positions (ir,jcol) which correspond */
 94:         /*        to non-zeroes in the matrix. */

 96:         i__2 = jpntr[jcol + 1] - 1;
 97:         for (jp = jpntr[jcol]; jp <= i__2; ++jp) {
 98:             ir = indrow[jp];

100:             /*           For each row ir, determine all positions (ir,ic) */
101:             /*           which correspond to non-zeroes in the matrix. */

103:             i__3 = ipntr[ir + 1] - 1;
104:             for (ip = ipntr[ir]; ip <= i__3; ++ip) {
105:                 ic = indcol[ip];

107:                 /*              Array iwa marks the group numbers of the */
108:                 /*              columns which are adjacent to column jcol. */

110:                 iwa[ngrp[ic]] = j;
111:             }
112:         }

114:         /*        Assign the smallest un-marked group number to jcol. */

116:         i__2 = *maxgrp;
117:         for (jp = 1; jp <= i__2; ++jp) {
118:             if (iwa[jp] != j) {
119:                 goto L50;
120:             }
121:         }
122:         ++(*maxgrp);
123: L50:
124:         ngrp[jcol] = jp;
125:     }

127:     /*        End of iteration loop. */

129:     return(0);
130: }