Actual source code: seq.c

petsc-3.9.4 2018-09-11
Report Typos and Errors

  2: /* seq.f -- translated by f2c (version of 25 March 1992  12:58:56).*/

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

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

 11:   /* Local variables */
 12:   PetscInt jcol, j, ic, ip, jp, ir;

 14: /*     Given the sparsity pattern of an m by n matrix A, this */
 15: /*     subroutine determines a consistent partition of the */
 16: /*     columns of A by a sequential algorithm. */
 17: /*     A consistent partition is defined in terms of the loopless */
 18: /*     graph G with vertices a(j), j = 1,2,...,n where a(j) is the */
 19: /*     j-th column of A and with edge (a(i),a(j)) if and only if */
 20: /*     columns i and j have a non-zero in the same row position. */
 21: /*     A partition of the columns of A into groups is consistent */
 22: /*     if the columns in any group are not adjacent in the graph G. */
 23: /*     In graph-theory terminology, a consistent partition of the */
 24: /*     columns of A corresponds to a coloring of the graph G. */
 25: /*     The subroutine examines the columns in the order specified */
 26: /*     by the array list, and assigns the current column to the */
 27: /*     group with the smallest possible number. */
 28: /*     Note that the value of m is not needed by seq and is */
 29: /*     therefore not present in the subroutine statement. */
 30: /*     The subroutine statement is */
 31: /*       subroutine seq(n,indrow,jpntr,indcol,ipntr,list,ngrp,maxgrp, */
 32: /*                      iwa) */
 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: /*       list is an integer input array of length n which specifies */
 53: /*         the order to be used by the sequential algorithm. */
 54: /*         The j-th column in this order is list(j). */
 55: /*       ngrp is an integer output array of length n which specifies */
 56: /*         the partition of the columns of A. Column jcol belongs */
 57: /*         to group ngrp(jcol). */
 58: /*       maxgrp is an integer output variable which specifies the */
 59: /*         number of groups in the partition of the columns of A. */
 60: /*       iwa is an integer work array of length n. */
 61: /*     Argonne National Laboratory. MINPACK Project. July 1983. */
 62: /*     Thomas F. Coleman, Burton S. Garbow, Jorge J. More' */

 65:   /* Parameter adjustments */
 66:   --iwa;
 67:   --ngrp;
 68:   --list;
 69:   --ipntr;
 70:   --indcol;
 71:   --jpntr;
 72:   --indrow;

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

 82:   /*     Beginning of iteration loop. */

 84:   i__1 = *n;
 85:   for (j = 1; j <= i__1; ++j) {
 86:     jcol = list[j];

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

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

 93:     i__2 = jpntr[jcol + 1] - 1;
 94:     for (jp = jpntr[jcol]; jp <= i__2; ++jp) {
 95:       ir = indrow[jp];

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

100:       i__3 = ipntr[ir + 1] - 1;
101:       for (ip = ipntr[ir]; ip <= i__3; ++ip) {
102:         ic = indcol[ip];

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

107:         iwa[ngrp[ic]] = j;
108:       }
109:     }

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

113:     i__2 = *maxgrp;
114:     for (jp = 1; jp <= i__2; ++jp) {
115:       if (iwa[jp] != j) goto L50;
116:     }
117:     ++(*maxgrp);
118: L50:
119:     ngrp[jcol] = jp;
120:   }

122:   /*        End of iteration loop. */
123:   return(0);
124: }