Actual source code: ex199.c

petsc-3.8.4 2018-03-24
Report Typos and Errors

  2: static char help[] = "Tests the different MatColoring implementatons.\n\n";

  4:  #include <petscmat.h>

  6: int main(int argc,char **args)
  7: {
  8:   Mat            C;
 10:   PetscViewer    viewer;
 11:   char           file[128];
 12:   PetscBool      flg;
 13:   MatColoring    ctx;
 14:   ISColoring     coloring;
 15: 
 16:   PetscInitialize(&argc,&args,(char*)0,help);if (ierr) return ierr;
 17:   PetscOptionsGetString(NULL,NULL,"-f",file,sizeof(file),&flg);
 18:   if (!flg) SETERRQ(PETSC_COMM_WORLD,PETSC_ERR_USER,"Must use -f filename to load sparse matrix");
 19:   PetscViewerBinaryOpen(PETSC_COMM_WORLD,file,FILE_MODE_READ,&viewer);
 20:   MatCreate(PETSC_COMM_WORLD,&C);
 21:   MatLoad(C,viewer);
 22:   PetscViewerDestroy(&viewer);

 24:   MatColoringCreate(C,&ctx);
 25:   MatColoringSetFromOptions(ctx);
 26:   MatColoringApply(ctx,&coloring);
 27:   MatColoringTestValid(ctx,coloring);

 29:   /* Free data structures */
 30:   ISColoringDestroy(&coloring);
 31:   MatColoringDestroy(&ctx);
 32:   MatDestroy(&C);
 33:   PetscFinalize();
 34:   return ierr;
 35: }