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