Date: 2022-03-31T04:47:23+00:00

Actual source code: spqmd.c

      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;
     11:   const PetscInt *ia,*ja;
     12:   PetscBool      done;

     14:   MatGetRowIJ(mat,1,PETSC_TRUE,PETSC_TRUE,&nrow,&ia,&ja,&done);

     17:   PetscMalloc1(nrow,&perm);
     18:   PetscMalloc5(nrow,&iperm,nrow,&deg,nrow,&marker,nrow,&rchset,nrow,&nbrhd);
     19:   PetscMalloc2(nrow,&qsize,nrow,&qlink);
     20:   /* WARNING - genqmd trashes ja */
     21:   SPARSEPACKgenqmd(&nrow,ia,ja,perm,iperm,deg,marker,rchset,nbrhd,qsize,qlink,&nofsub);
     22:   MatRestoreRowIJ(mat,1,PETSC_TRUE,PETSC_TRUE,NULL,&ia,&ja,&done);

     24:   PetscFree2(qsize,qlink);
     25:   PetscFree5(iperm,deg,marker,rchset,nbrhd);
     26:   for (i=0; i<nrow; i++) perm[i]--;
     27:   ISCreateGeneral(PETSC_COMM_SELF,nrow,perm,PETSC_COPY_VALUES,row);
     28:   ISCreateGeneral(PETSC_COMM_SELF,nrow,perm,PETSC_OWN_POINTER,col);
     29:   return 0;
     30: }