PetscErrorCode XiMatchFontSize(XiFont *font,int w,int h) { int i,max,imax,tmp; PetscFunctionBegin; for (i=0; i<act_nfonts; i++) { if (nfonts[i].w == w && nfonts[i].h == h) { font->font_w = w; font->font_h = h; font->font_descent = nfonts[i].descent; PetscFunctionReturn(0); } } /* determine closest fit,per max. norm */ imax = 0; max = PetscMax(PetscAbsInt(nfonts[0].w - w),PetscAbsInt(nfonts[0].h - h)); for (i=1; i<act_nfonts; i++) { tmp = PetscMax(PetscAbsInt(nfonts[i].w - w),PetscAbsInt(nfonts[i].h - h)); if (tmp < max) {max = tmp; imax = i;} } /* should use font with closest match */ font->font_w = nfonts[imax].w; font->font_h = nfonts[imax].h; font->font_descent = nfonts[imax].descent; PetscFunctionReturn(0); }
PetscErrorCode SPARSEPACKfndsep(PetscInt *root, PetscInt *xadj, PetscInt *adjncy, PetscInt *mask, PetscInt *nsep, PetscInt *sep, PetscInt *xls, PetscInt *ls) { /* System generated locals */ PetscInt i__1, i__2; /* Local variables */ PetscInt node, nlvl, i, j, jstop, jstrt, mp1beg, mp1end, midbeg, midend, midlvl; PetscInt nbr; PetscFunctionBegin; /* Parameter adjustments */ --ls; --xls; --sep; --mask; --adjncy; --xadj; SPARSEPACKfnroot(root, &xadj[1], &adjncy[1], &mask[1], &nlvl, &xls[1], &ls[1]); /* IF THE NUMBER OF LEVELS IS LESS THAN 3, RETURN */ /* THE WHOLE COMPONENT AS THE SEPARATOR.*/ if (nlvl >= 3) { goto L200; } *nsep = xls[nlvl + 1] - 1; i__1 = *nsep; for (i = 1; i <= i__1; ++i) { node = ls[i]; sep[i] = node; mask[node] = 0; } PetscFunctionReturn(0); /* FIND THE MIDDLE LEVEL OF THE ROOTED LEVEL STRUCTURE.*/ L200: midlvl = (nlvl + 2) / 2; midbeg = xls[midlvl]; mp1beg = xls[midlvl + 1]; midend = mp1beg - 1; mp1end = xls[midlvl + 2] - 1; /* THE SEPARATOR IS OBTAINED BY INCLUDING ONLY THOSE*/ /* MIDDLE-LEVEL NODES WITH NEIGHBORS IN THE MIDDLE+1*/ /* LEVEL. XADJ IS USED TEMPORARILY TO MARK THOSE*/ /* NODES IN THE MIDDLE+1 LEVEL.*/ i__1 = mp1end; for (i = mp1beg; i <= i__1; ++i) { node = ls[i]; xadj[node] = -xadj[node]; } *nsep = 0; i__1 = midend; for (i = midbeg; i <= i__1; ++i) { node = ls[i]; jstrt = xadj[node]; jstop = (i__2 = xadj[node + 1], (PetscInt)PetscAbsInt(i__2)) - 1; i__2 = jstop; for (j = jstrt; j <= i__2; ++j) { nbr = adjncy[j]; if (xadj[nbr] > 0) { goto L400; } ++(*nsep); sep[*nsep] = node; mask[node] = 0; goto L500; L400: ; } L500: ; } /* RESET XADJ TO ITS CORRECT SIGN.*/ i__1 = mp1end; for (i = mp1beg; i <= i__1; ++i) { node = ls[i]; xadj[node] = -xadj[node]; } PetscFunctionReturn(0); }
PetscErrorCode SPARSEPACKdegree(const PetscInt *root,const PetscInt *inxadj,const PetscInt *adjncy,PetscInt *mask,PetscInt *deg,PetscInt *ccsize,PetscInt *ls) { PetscInt *xadj = (PetscInt*)inxadj; /* Used as temporary and reset within this function */ /* System generated locals */ PetscInt i__1,i__2; /* Local variables */ PetscInt ideg,node,i,j,jstop,jstrt,lbegin,lvlend,lvsize,nbr; /* INITIALIZATION ...*/ /* THE ARRAY XADJ IS USED AS A TEMPORARY MARKER TO*/ /* INDICATE WHICH NODES HAVE BEEN CONSIDERED SO FAR.*/ PetscFunctionBegin; /* Parameter adjustments */ --ls; --deg; --mask; --adjncy; --xadj; ls[1] = *root; xadj[*root] = -xadj[*root]; lvlend = 0; *ccsize = 1; /* LBEGIN IS THE POINTER TO THE BEGINNING OF THE CURRENT*/ /* LEVEL, AND LVLEND POINTS TO THE END OF THIS LEVEL.*/ L100: lbegin = lvlend + 1; lvlend = *ccsize; /* FIND THE DEGREES OF NODES IN THE CURRENT LEVEL,*/ /* AND AT THE SAME TIME, GENERATE THE NEXT LEVEL.*/ i__1 = lvlend; for (i = lbegin; i <= i__1; ++i) { node = ls[i]; jstrt = -xadj[node]; jstop = (i__2 = xadj[node + 1], (PetscInt)PetscAbsInt(i__2)) - 1; ideg = 0; if (jstop < jstrt) { goto L300; } i__2 = jstop; for (j = jstrt; j <= i__2; ++j) { nbr = adjncy[j]; if (!mask[nbr]) { goto L200; } ++ideg; if (xadj[nbr] < 0) { goto L200; } xadj[nbr] = -xadj[nbr]; ++(*ccsize); ls[*ccsize] = nbr; L200: ; } L300: deg[node] = ideg; } /* COMPUTE THE CURRENT LEVEL WIDTH. */ /* IF IT IS NONZERO, GENERATE ANOTHER LEVEL.*/ lvsize = *ccsize - lvlend; if (lvsize > 0) { goto L100; } /* RESET XADJ TO ITS CORRECT SIGN AND RETURN. */ /* ------------------------------------------*/ i__1 = *ccsize; for (i = 1; i <= i__1; ++i) { node = ls[i]; xadj[node] = -xadj[node]; } PetscFunctionReturn(0); }