2: /* setr.f -- translated by f2c (version of 25 March 1992 12:58:56). */
4: #include <../src/mat/color/color.h>
8: PetscErrorCode MINPACKsetr(PetscInt*m,PetscInt* n,PetscInt* indrow,PetscInt* jpntr,PetscInt* indcol, PetscInt*ipntr,PetscInt* iwa) 9: {
10: /* System generated locals */
11: PetscInt i__1, i__2;
13: /* Local variables */
14: PetscInt jcol, jp, ir;
16: /* Given a column-oriented definition of the sparsity pattern */
17: /* of an m by n matrix A, this subroutine determines a */
18: /* row-oriented definition of the sparsity pattern of A. */
19: /* On input the column-oriented definition is specified by */
20: /* the arrays indrow and jpntr. On output the row-oriented */
21: /* definition is specified by the arrays indcol and ipntr. */
22: /* The subroutine statement is */
23: /* subroutine setr(m,n,indrow,jpntr,indcol,ipntr,iwa) */
24: /* where */
25: /* m is a positive integer input variable set to the number */
26: /* of rows of A. */
27: /* n is a positive integer input variable set to the number */
28: /* of columns of A. */
29: /* indrow is an integer input array which contains the row */
30: /* indices for the non-zeroes in the matrix A. */
31: /* jpntr is an integer input array of length n + 1 which */
32: /* specifies the locations of the row indices in indrow. */
33: /* The row indices for column j are */
34: /* indrow(k), k = jpntr(j),...,jpntr(j+1)-1. */
35: /* Note that jpntr(n+1)-1 is then the number of non-zero */
36: /* elements of the matrix A. */
37: /* indcol is an integer output array which contains the */
38: /* column indices for the non-zeroes in the matrix A. */
39: /* ipntr is an integer output array of length m + 1 which */
40: /* specifies the locations of the column indices in indcol. */
41: /* The column indices for row i are */
42: /* indcol(k), k = ipntr(i),...,ipntr(i+1)-1. */
43: /* Note that ipntr(1) is set to 1 and that ipntr(m+1)-1 is */
44: /* then the number of non-zero elements of the matrix A. */
45: /* iwa is an integer work array of length m. */
46: /* Argonne National Laboratory. MINPACK Project. July 1983. */
47: /* Thomas F. Coleman, Burton S. Garbow, Jorge J. More' */
49: /* Store in array iwa the counts of non-zeroes in the rows. */
52: /* Parameter adjustments */
53: --iwa;
54: --ipntr;
55: --indcol;
56: --jpntr;
57: --indrow;
59: /* Function Body */
60: i__1 = *m;
61: for (ir = 1; ir <= i__1; ++ir) {
62: iwa[ir] = 0;
63: }
64: i__1 = jpntr[*n + 1] - 1;
65: for (jp = 1; jp <= i__1; ++jp) {
66: ++iwa[indrow[jp]];
67: }
69: /* Set pointers to the start of the rows in indcol. */
71: ipntr[1] = 1;
72: i__1 = *m;
73: for (ir = 1; ir <= i__1; ++ir) {
74: ipntr[ir + 1] = ipntr[ir] + iwa[ir];
75: iwa[ir] = ipntr[ir];
76: }
78: /* Fill indcol. */
80: i__1 = *n;
81: for (jcol = 1; jcol <= i__1; ++jcol) {
82: i__2 = jpntr[jcol + 1] - 1;
83: for (jp = jpntr[jcol]; jp <= i__2; ++jp) {
84: ir = indrow[jp];
85: indcol[iwa[ir]] = jcol;
86: ++iwa[ir];
87: }
88: }
89: return(0);
90: }