Actual source code: sp1wd.c
2: #include petscmat.h
3: #include src/mat/order/order.h
6: /*
7: MatOrdering_1WD - Find the 1-way dissection ordering of a given matrix.
8: */
11: PetscErrorCode MatOrdering_1WD(Mat mat,const MatOrderingType type,IS *row,IS *col)
12: {
14: PetscInt i,*mask,*xls,nblks,*xblk,*ls,nrow,*perm,*ia,*ja;
15: PetscTruth done;
18: MatGetRowIJ(mat,1,PETSC_TRUE,&nrow,&ia,&ja,&done);
19: if (!done) SETERRQ(PETSC_ERR_SUP,"Cannot get rows for matrix");
21: PetscMalloc((5*nrow+1) * sizeof(PetscInt),&mask);
22: xls = mask + nrow;
23: ls = xls + nrow + 1;
24: xblk = ls + nrow;
25: perm = xblk + nrow;
26: SPARSEPACKgen1wd(&nrow,ia,ja,mask,&nblks,xblk,perm,xls,ls);
27: MatRestoreRowIJ(mat,1,PETSC_TRUE,&nrow,&ia,&ja,&done);
29: for (i=0; i<nrow; i++) perm[i]--;
31: ISCreateGeneral(PETSC_COMM_SELF,nrow,perm,row);
32: ISCreateGeneral(PETSC_COMM_SELF,nrow,perm,col);
33: PetscFree(mask);
35: return(0);
36: }