Actual source code: spqmd.c
1: #define PETSCMAT_DLL
3: #include petscmat.h
4: #include ../src/mat/order/order.h
7: /*
8: MatOrdering_QMD - Find the Quotient Minimum Degree ordering of a given matrix.
9: */
12: PetscErrorCode MatOrdering_QMD(Mat mat,const MatOrderingType type,IS *row,IS *col)
13: {
14: PetscInt i, *deg,*marker,*rchset,*nbrhd,*qsize,*qlink,nofsub,*iperm,nrow;
16: PetscInt *ia,*ja,*perm;
17: PetscTruth done;
20: MatGetRowIJ(mat,1,PETSC_TRUE,PETSC_TRUE,&nrow,&ia,&ja,&done);
21: if (!done) SETERRQ(PETSC_ERR_SUP,"Cannot get rows for matrix");
23: PetscMalloc(nrow * sizeof(PetscInt),&perm);
24: PetscMalloc5(nrow,PetscInt,&iperm,nrow,PetscInt,°,nrow,PetscInt,&marker,nrow,PetscInt,&rchset,nrow,PetscInt,&nbrhd);
25: PetscMalloc2(nrow,PetscInt,&qsize,nrow,PetscInt,&qlink);
26: /* WARNING - genqmd trashes ja */
27: SPARSEPACKgenqmd(&nrow,ia,ja,perm,iperm,deg,marker,rchset,nbrhd,qsize,qlink,&nofsub);
28: MatRestoreRowIJ(mat,1,PETSC_TRUE,PETSC_TRUE,&nrow,&ia,&ja,&done);
30: PetscFree2(qsize,qlink);
31: PetscFree5(iperm,deg,marker,rchset,nbrhd);
32: for (i=0; i<nrow; i++) perm[i]--;
33: ISCreateGeneral(PETSC_COMM_SELF,nrow,perm,row);
34: ISCreateGeneral(PETSC_COMM_SELF,nrow,perm,col);
35: PetscFree(perm);
36: return(0);
37: }