Actual source code: setr.c

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

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

      5: PetscErrorCode MINPACKsetr(PetscInt *m, PetscInt *n, PetscInt *indrow, PetscInt *jpntr, PetscInt *indcol, PetscInt *ipntr, PetscInt *iwa)
      6: {
      7:   /* System generated locals */
      8:   PetscInt i__1, i__2;

     10:   /* Local variables */
     11:   PetscInt jcol, jp, ir;

     13:   /*     Given a column-oriented definition of the sparsity pattern */
     14:   /*     of an m by n matrix A, this subroutine determines a */
     15:   /*     row-oriented definition of the sparsity pattern of A. */
     16:   /*     On input the column-oriented definition is specified by */
     17:   /*     the arrays indrow and jpntr. On output the row-oriented */
     18:   /*     definition is specified by the arrays indcol and ipntr. */
     19:   /*     The subroutine statement is */
     20:   /*       subroutine setr(m,n,indrow,jpntr,indcol,ipntr,iwa) */
     21:   /*     where */
     22:   /*       m is a positive integer input variable set to the number */
     23:   /*         of rows of A. */
     24:   /*       n is a positive integer input variable set to the number */
     25:   /*         of columns of A. */
     26:   /*       indrow is an integer input array which contains the row */
     27:   /*         indices for the non-zeroes in the matrix A. */
     28:   /*       jpntr is an integer input array of length n + 1 which */
     29:   /*         specifies the locations of the row indices in indrow. */
     30:   /*         The row indices for column j are */
     31:   /*               indrow(k), k = jpntr(j),...,jpntr(j+1)-1. */
     32:   /*         Note that jpntr(n+1)-1 is then the number of non-zero */
     33:   /*         elements of the matrix A. */
     34:   /*       indcol is an integer output array which contains the */
     35:   /*         column indices for the non-zeroes in the matrix A. */
     36:   /*       ipntr is an integer output array of length m + 1 which */
     37:   /*         specifies the locations of the column indices in indcol. */
     38:   /*         The column indices for row i are */
     39:   /*               indcol(k), k = ipntr(i),...,ipntr(i+1)-1. */
     40:   /*         Note that ipntr(1) is set to 1 and that ipntr(m+1)-1 is */
     41:   /*         then the number of non-zero elements of the matrix A. */
     42:   /*       iwa is an integer work array of length m. */
     43:   /*     Argonne National Laboratory. MINPACK Project. July 1983. */
     44:   /*     Thomas F. Coleman, Burton S. Garbow, Jorge J. More' */

     46:   /*     Store in array iwa the counts of non-zeroes in the rows. */

     48:   PetscFunctionBegin;
     49:   /* Parameter adjustments */
     50:   --iwa;
     51:   --ipntr;
     52:   --indcol;
     53:   --jpntr;
     54:   --indrow;

     56:   /* Function Body */
     57:   i__1 = *m;
     58:   for (ir = 1; ir <= i__1; ++ir) iwa[ir] = 0;

     60:   i__1 = jpntr[*n + 1] - 1;
     61:   for (jp = 1; jp <= i__1; ++jp) ++iwa[indrow[jp]];

     63:   /*     Set pointers to the start of the rows in indcol. */

     65:   ipntr[1] = 1;
     66:   i__1     = *m;

     68:   for (ir = 1; ir <= i__1; ++ir) {
     69:     ipntr[ir + 1] = ipntr[ir] + iwa[ir];
     70:     iwa[ir]       = ipntr[ir];
     71:   }

     73:   /*     Fill indcol. */

     75:   i__1 = *n;
     76:   for (jcol = 1; jcol <= i__1; ++jcol) {
     77:     i__2 = jpntr[jcol + 1] - 1;
     78:     for (jp = jpntr[jcol]; jp <= i__2; ++jp) {
     79:       ir              = indrow[jp];
     80:       indcol[iwa[ir]] = jcol;
     81:       ++iwa[ir];
     82:     }
     83:   }
     84:   PetscFunctionReturn(PETSC_SUCCESS);
     85: }