Actual source code: ex200.c

  1: #include <petscmat.h>

  3: int main(int argc, char **argv)
  4: {
  5:   Mat         A, B;
  6:   const char *pfx;

  8:   PetscFunctionBeginUser;
  9:   PetscCall(PetscInitialize(&argc, &argv, NULL, NULL));
 10:   PetscCall(MatCreate(PETSC_COMM_WORLD, &A));
 11:   PetscCall(MatSetSizes(A, 1, 1, PETSC_DECIDE, PETSC_DECIDE));
 12:   PetscCall(MatSetUp(A));
 13:   PetscCall(MatSetOptionsPrefix(A, "foo_"));
 14:   PetscCall(MatGetDiagonalBlock(A, &B));
 15:   /* Test set options prefix with the string obtained from get options prefix */
 16:   PetscCall(PetscObjectGetOptionsPrefix((PetscObject)A, &pfx));
 17:   PetscCall(MatSetOptionsPrefix(B, pfx));
 18:   PetscCall(MatDestroy(&A));

 20:   PetscCall(PetscFinalize());
 21:   return 0;
 22: }

 24: /*TEST

 26:    test:

 28: TEST*/