Actual source code: sp1wd.c

  1: #define PETSCMAT_DLL

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

  7: /*
  8:     MatOrdering_1WD - Find the 1-way dissection ordering of a given matrix.
  9: */
 12: PetscErrorCode  MatOrdering_1WD(Mat mat,const MatOrderingType type,IS *row,IS *col)
 13: {
 15:   PetscInt       i,*mask,*xls,nblks,*xblk,*ls,nrow,*perm,*ia,*ja;
 16:   PetscTruth     done;

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

 22:   PetscMalloc5(nrow,PetscInt,&mask,nrow+1,PetscInt,&xls,nrow,PetscInt,&ls,nrow+1,PetscInt,&xblk,nrow,PetscInt,&perm);
 23:   SPARSEPACKgen1wd(&nrow,ia,ja,mask,&nblks,xblk,perm,xls,ls);
 24:   MatRestoreRowIJ(mat,1,PETSC_TRUE,PETSC_TRUE,&nrow,&ia,&ja,&done);

 26:   for (i=0; i<nrow; i++) perm[i]--;

 28:   ISCreateGeneral(PETSC_COMM_SELF,nrow,perm,row);
 29:   ISCreateGeneral(PETSC_COMM_SELF,nrow,perm,col);
 30:   PetscFree5(mask,xls,ls,xblk,perm);
 31:   return(0);
 32: }