Actual source code: spnd.c
2: #include petscmat.h
3: #include src/mat/order/order.h
6: /*
7: MatOrdering_ND - Find the nested dissection ordering of a given matrix.
8: */
11: PetscErrorCode MatOrdering_ND(Mat mat,const MatOrderingType type,IS *row,IS *col)
12: {
14: PetscInt i, *mask,*xls,*ls,nrow,*ia,*ja,*perm;
15: PetscTruth done;
18: MatGetRowIJ(mat,1,PETSC_TRUE,&nrow,&ia,&ja,&done);
19: if (!done) SETERRQ1(PETSC_ERR_SUP,"Cannot get rows for matrix type %s",((PetscObject)mat)->type_name);
21: PetscMalloc((4*nrow +1) * sizeof(PetscInt),&mask);
22: perm = mask + nrow;
23: xls = perm + nrow;
24: ls = xls + nrow + 1;
26: SPARSEPACKgennd(&nrow,ia,ja,mask,perm,xls,ls);
27: MatRestoreRowIJ(mat,1,PETSC_TRUE,&nrow,&ia,&ja,&done);
29: /* shift because Sparsepack indices start at one */
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: }