Actual source code: test19.c
slepc-3.17.0 2022-03-31
1: /*
2: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3: SLEPc - Scalable Library for Eigenvalue Problem Computations
4: Copyright (c) 2002-, Universitat Politecnica de Valencia, Spain
6: This file is part of SLEPc.
7: SLEPc is distributed under a 2-clause BSD license (see LICENSE).
8: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
9: */
11: static char help[] = "Tests the usage of object prefix.\n\n"
12: "The command line options are:\n"
13: " -n <n>, where <n> = matrix dimension.\n\n";
15: #include <slepceps.h>
17: int main(int argc,char **argv)
18: {
19: Mat A; /* problem matrix */
20: EPS eps; /* eigenproblem solver context */
21: PetscInt n=30,i,Istart,Iend;
22: const char *prefix;
24: SlepcInitialize(&argc,&argv,(char*)0,help);
26: PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
27: PetscPrintf(PETSC_COMM_WORLD,"\nDiagonal Eigenproblem, n=%" PetscInt_FMT "\n\n",n);
29: MatCreate(PETSC_COMM_WORLD,&A);
30: MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n);
31: MatSetFromOptions(A);
32: MatSetUp(A);
33: MatGetOwnershipRange(A,&Istart,&Iend);
34: for (i=Istart;i<Iend;i++) MatSetValue(A,i,i,i+1,INSERT_VALUES);
35: MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);
36: MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);
38: /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
39: Create the eigensolver and mess up with the prefix
40: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
41: EPSCreate(PETSC_COMM_WORLD,&eps);
42: EPSSetOptionsPrefix(eps,"check_");
43: EPSAppendOptionsPrefix(eps,"myprefix_");
44: EPSGetOptionsPrefix(eps,&prefix);
45: PetscPrintf(PETSC_COMM_WORLD,"EPS prefix is currently: %s\n\n",prefix);
47: EPSSetOperators(eps,A,NULL);
48: EPSSetProblemType(eps,EPS_HEP);
49: EPSSetFromOptions(eps);
50: EPSSolve(eps);
52: /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
53: Display solution and clean up
54: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
55: EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);
56: EPSDestroy(&eps);
57: MatDestroy(&A);
58: SlepcFinalize();
59: return 0;
60: }
62: /*TEST
64: test:
65: suffix: 1
66: args: -check_myprefix_eps_nev 2 -check_myprefix_st_type sinvert
68: TEST*/