Actual source code: spqmd.c

  1: /*$Id: spqmd.c,v 1.40 2001/03/23 23:22:51 balay Exp $*/

 3:  #include petscmat.h
 4:  #include src/mat/order/order.h

  6: EXTERN_C_BEGIN
  7: /*
  8:     MatOrdering_QMD - Find the Quotient Minimum Degree ordering of a given matrix.
  9: */
 12: int MatOrdering_QMD(Mat mat,const MatOrderingType type,IS *row,IS *col)
 13: {
 14:   int        i,  *deg,*marker,*rchset,*nbrhd,*qsize,*qlink,nofsub,*iperm,nrow;
 15:   int        ierr,*ia,*ja,*perm;
 16:   PetscTruth done;

 19:   MatGetRowIJ(mat,1,PETSC_TRUE,&nrow,&ia,&ja,&done);
 20:   if (!done) SETERRQ(PETSC_ERR_SUP,"Cannot get rows for matrix");

 22:   PetscMalloc(nrow * sizeof(int),&perm);
 23:   PetscMalloc(nrow * sizeof(int),&iperm);
 24:   PetscMalloc(nrow * sizeof(int),&deg);
 25:   PetscMalloc(nrow * sizeof(int),&marker);
 26:   PetscMalloc(nrow * sizeof(int),&rchset);
 27:   PetscMalloc(nrow * sizeof(int),&nbrhd);
 28:   PetscMalloc(nrow * sizeof(int),&qsize);
 29:   PetscMalloc(nrow * sizeof(int),&qlink);
 30:   /* WARNING - genqmd trashes ja */
 31:   SPARSEPACKgenqmd(&nrow,ia,ja,perm,iperm,deg,marker,rchset,nbrhd,qsize,qlink,&nofsub);
 32:   MatRestoreRowIJ(mat,1,PETSC_TRUE,&nrow,&ia,&ja,&done);

 34:   PetscFree(deg);
 35:   PetscFree(marker);
 36:   PetscFree(rchset);
 37:   PetscFree(nbrhd);
 38:   PetscFree(qsize);
 39:   PetscFree(qlink);
 40:   PetscFree(iperm);
 41:   for (i=0; i<nrow; i++) perm[i]--;
 42:   ISCreateGeneral(PETSC_COMM_SELF,nrow,perm,row);
 43:   ISCreateGeneral(PETSC_COMM_SELF,nrow,perm,col);
 44:   PetscFree(perm);
 45:   return(0);
 46: }
 47: EXTERN_C_END