Date: 2013-07-02T14:44:47+00:00

Actual source code: degr.c
petsc-3.4.2 2013-07-02

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

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

      8: PetscErrorCode MINPACKdegr(PetscInt *n,const PetscInt * indrow,const PetscInt * jpntr,const PetscInt * indcol,const PetscInt * ipntr,PetscInt * ndeg,PetscInt * iwa)
      9: {
     10:   /* System generated locals */
     11:   PetscInt i__1, i__2, i__3;

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

     16: /*     subroutine degr */
     17: /*     Given the sparsity pattern of an m by n matrix A, */
     18: /*     this subroutine determines the degree sequence for */
     19: /*     the intersection graph of the columns of A. */
     20: /*     In graph-theory terminology, the intersection graph of */
     21: /*     the columns of A is the loopless graph G with vertices */
     22: /*     a(j), j = 1,2,...,n where a(j) is the j-th column of A */
     23: /*     and with edge (a(i),a(j)) if and only if columns i and j */
     24: /*     have a non-zero in the same row position. */
     25: /*     Note that the value of m is not needed by degr and is */
     26: /*     therefore not present in the subroutine statement. */
     27: /*     The subroutine statement is */
     28: /*       subroutine degr(n,indrow,jpntr,indcol,ipntr,ndeg,iwa) */
     29: /*     where */
     30: /*       n is a positive integer input variable set to the number */
     31: /*         of columns of A. */
     32: /*       indrow is an integer input array which contains the row */
     33: /*         indices for the non-zeroes in the matrix A. */
     34: /*       jpntr is an integer input array of length n + 1 which */
     35: /*         specifies the locations of the row indices in indrow. */
     36: /*         The row indices for column j are */
     37: /*               indrow(k), k = jpntr(j),...,jpntr(j+1)-1. */
     38: /*         Note that jpntr(n+1)-1 is then the number of non-zero */
     39: /*         elements of the matrix A. */
     40: /*       indcol is an integer input array which contains the */
     41: /*         column indices for the non-zeroes in the matrix A. */
     42: /*       ipntr is an integer input array of length m + 1 which */
     43: /*         specifies the locations of the column indices in indcol. */
     44: /*         The column indices for row i are */
     45: /*               indcol(k), k = ipntr(i),...,ipntr(i+1)-1. */
     46: /*         Note that ipntr(m+1)-1 is then the number of non-zero */
     47: /*         elements of the matrix A. */
     48: /*       ndeg is an integer output array of length n which */
     49: /*         specifies the degree sequence. The degree of the */
     50: /*         j-th column of A is ndeg(j). */
     51: /*       iwa is an integer work array of length n. */
     52: /*     Argonne National Laboratory. MINPACK Project. July 1983. */
     53: /*     Thomas F. Coleman, Burton S. Garbow, Jorge J. More' */

     56:   /* Parameter adjustments */
     57:   --iwa;
     58:   --ndeg;
     59:   --ipntr;
     60:   --indcol;
     61:   --jpntr;
     62:   --indrow;

     64:   /* Function Body */
     65:   i__1 = *n;
     66:   for (jp = 1; jp <= i__1; ++jp) {
     67:     ndeg[jp] = 0;
     68:     iwa[jp]  = 0;
     69:   }

     71: /*     Compute the degree sequence by determining the contributions */
     72: /*     to the degrees from the current(jcol) column and further */
     73: /*     columns which have not yet been considered. */

     75:   i__1 = *n;
     76:   for (jcol = 2; jcol <= i__1; ++jcol) {
     77:     iwa[jcol] = *n;

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

     82:     i__2 = jpntr[jcol + 1] - 1;
     83:     for (jp = jpntr[jcol]; jp <= i__2; ++jp) {
     84:       ir = indrow[jp];

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

     89:       i__3 = ipntr[ir + 1] - 1;
     90:       for (ip = ipntr[ir]; ip <= i__3; ++ip) {
     91:         ic = indcol[ip];

     93: /*              Array iwa marks columns which have contributed to */
     94: /*              the degree count of column jcol. Update the degree */
     95: /*              counts of these columns as well as column jcol. */

     97:         if (iwa[ic] < jcol) {
     98:           iwa[ic] = jcol;
     99:           ++ndeg[ic];
    100:           ++ndeg[jcol];
    101:         }
    102:       }
    103:     }
    104:   }
    105:   return(0);
    106: }