Actual source code: spnd.c

  1: /*$Id: spnd.c,v 1.41 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_ND - Find the nested dissection ordering of a given matrix.
  9: */
 12: int MatOrdering_ND(Mat mat,const MatOrderingType type,IS *row,IS *col)
 13: {
 14:   int        ierr,i, *mask,*xls,*ls,nrow,*ia,*ja,*perm;
 15:   PetscTruth done;

 18:   MatGetRowIJ(mat,1,PETSC_TRUE,&nrow,&ia,&ja,&done);
 19:   if (!done) SETERRQ1(PETSC_ERR_SUP,"Cannot get rows for matrix type %s",((PetscObject)mat)->type_name);

 21:   PetscMalloc((4*nrow +1) * sizeof(int),&mask);
 22:   perm = mask + nrow;
 23:   xls  = perm + nrow;
 24:   ls   = xls  + nrow + 1;

 26:   SPARSEPACKgennd(&nrow,ia,ja,mask,perm,xls,ls);
 27:   MatRestoreRowIJ(mat,1,PETSC_TRUE,&nrow,&ia,&ja,&done);

 29:   /* shift because Sparsepack indices start at one */
 30:   for (i=0; i<nrow; i++) perm[i]--;

 32:   ISCreateGeneral(PETSC_COMM_SELF,nrow,perm,row);
 33:   ISCreateGeneral(PETSC_COMM_SELF,nrow,perm,col);
 34:   PetscFree(mask);

 36:   return(0);
 37: }
 38: EXTERN_C_END