Actual source code: spnd.c
petsc-3.11.4 2019-09-28
2: #include <petscmat.h>
3: #include <petsc/private/matorderimpl.h>
5: /*
6: MatGetOrdering_ND - Find the nested dissection ordering of a given matrix.
7: */
8: PETSC_INTERN PetscErrorCode MatGetOrdering_ND(Mat mat,MatOrderingType type,IS *row,IS *col)
9: {
11: PetscInt i, *mask,*xls,*ls,nrow,*perm;
12: const PetscInt *ia,*ja;
13: PetscBool done;
16: MatGetRowIJ(mat,1,PETSC_TRUE,PETSC_TRUE,&nrow,&ia,&ja,&done);
17: if (!done) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_SUP,"Cannot get rows for matrix type %s",((PetscObject)mat)->type_name);
19: PetscMalloc4(nrow,&mask,nrow,&perm,nrow+1,&xls,nrow,&ls);
20: SPARSEPACKgennd(&nrow,ia,ja,mask,perm,xls,ls);
21: MatRestoreRowIJ(mat,1,PETSC_TRUE,PETSC_TRUE,NULL,&ia,&ja,&done);
23: /* shift because Sparsepack indices start at one */
24: for (i=0; i<nrow; i++) perm[i]--;
26: ISCreateGeneral(PETSC_COMM_SELF,nrow,perm,PETSC_COPY_VALUES,row);
27: ISCreateGeneral(PETSC_COMM_SELF,nrow,perm,PETSC_COPY_VALUES,col);
28: PetscFree4(mask,perm,xls,ls);
29: return(0);
30: }