Date: 2022-08-02T03:14:12+00:00

Actual source code: seq.c

      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' */

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

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

     81:   /*     Beginning of iteration loop. */

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

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

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

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

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

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

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

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

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

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

    121:   /*        End of iteration loop. */
    122:   return 0;
    123: }