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