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