Actual source code: spqmd.c
petsc-3.11.4 2019-09-28
2: #include <petscmat.h>
3: #include <petsc/private/matorderimpl.h>
5: /*
6: MatGetOrdering_QMD - Find the Quotient Minimum Degree ordering of a given matrix.
7: */
8: PETSC_INTERN PetscErrorCode MatGetOrdering_QMD(Mat mat,MatOrderingType type,IS *row,IS *col)
9: {
10: PetscInt i, *deg,*marker,*rchset,*nbrhd,*qsize,*qlink,nofsub,*iperm,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) SETERRQ(PetscObjectComm((PetscObject)mat),PETSC_ERR_SUP,"Cannot get rows for matrix");
19: PetscMalloc1(nrow,&perm);
20: PetscMalloc5(nrow,&iperm,nrow,°,nrow,&marker,nrow,&rchset,nrow,&nbrhd);
21: PetscMalloc2(nrow,&qsize,nrow,&qlink);
22: /* WARNING - genqmd trashes ja */
23: SPARSEPACKgenqmd(&nrow,ia,ja,perm,iperm,deg,marker,rchset,nbrhd,qsize,qlink,&nofsub);
24: MatRestoreRowIJ(mat,1,PETSC_TRUE,PETSC_TRUE,NULL,&ia,&ja,&done);
26: PetscFree2(qsize,qlink);
27: PetscFree5(iperm,deg,marker,rchset,nbrhd);
28: for (i=0; i<nrow; i++) perm[i]--;
29: ISCreateGeneral(PETSC_COMM_SELF,nrow,perm,PETSC_COPY_VALUES,row);
30: ISCreateGeneral(PETSC_COMM_SELF,nrow,perm,PETSC_OWN_POINTER,col);
31: return(0);
32: }