Actual source code: ex227.c

  1: static char help[] = "Test MatNullSpaceTest() with options prefixes.\n\n";

  3: #include <petscmat.h>

  5: int main(int argc, char **argv)
  6: {
  7:   Mat          mat;
  8:   MatNullSpace nsp;
  9:   PetscBool    prefix = PETSC_FALSE, flg;
 10:   PetscInt     zero   = 0;
 11:   PetscScalar  value  = 0;
 13:   PetscInitialize(&argc, &argv, NULL, help);

 15:   PetscOptionsGetBool(NULL, NULL, "-with_prefix", &prefix, NULL);
 16:   MatCreateDense(PETSC_COMM_WORLD, 1, 1, 1, 1, NULL, &mat);
 17:   MatSetOptionsPrefix(mat, prefix ? "prefix_" : NULL);
 18:   MatSetUp(mat);
 19:   MatSetValues(mat, 1, &zero, 1, &zero, &value, INSERT_VALUES);
 20:   MatAssemblyBegin(mat, MAT_FINAL_ASSEMBLY);
 21:   MatAssemblyEnd(mat, MAT_FINAL_ASSEMBLY);
 22:   MatNullSpaceCreate(PETSC_COMM_WORLD, PETSC_TRUE, 0, NULL, &nsp);
 23:   MatNullSpaceTest(nsp, mat, &flg);
 25:   MatNullSpaceDestroy(&nsp);
 26:   MatDestroy(&mat);
 27:   PetscFinalize();
 28:   return 0;
 29: }

 31: /*TEST

 33:    test:
 34:        suffix: no_prefix
 35:        output_file: output/ex227_no_prefix.out
 36:        args: -mat_null_space_test_view -mat_view

 38:    test:
 39:        suffix: prefix
 40:        output_file: output/ex227_prefix.out
 41:        args: -prefix_mat_null_space_test_view -with_prefix -prefix_mat_view

 43: TEST*/