1 2 #include <petscmat.h> 3 4 int main(int argc, char **argv) 5 { 6 Mat A, B; 7 const char *pfx; 8 9 PetscFunctionBeginUser; 10 PetscCall(PetscInitialize(&argc, &argv, NULL, NULL)); 11 PetscCall(MatCreate(PETSC_COMM_WORLD, &A)); 12 PetscCall(MatSetSizes(A, 1, 1, PETSC_DECIDE, PETSC_DECIDE)); 13 PetscCall(MatSetUp(A)); 14 PetscCall(MatSetOptionsPrefix(A, "foo_")); 15 PetscCall(MatGetDiagonalBlock(A, &B)); 16 /* Test set options prefix with the string obtained from get options prefix */ 17 PetscCall(PetscObjectGetOptionsPrefix((PetscObject)A, &pfx)); 18 PetscCall(MatSetOptionsPrefix(B, pfx)); 19 PetscCall(MatDestroy(&A)); 20 21 PetscCall(PetscFinalize()); 22 return 0; 23 } 24 25 /*TEST 26 27 test: 28 29 TEST*/ 30