Actual source code: test19.c
slepc-3.18.1 2022-11-02
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;
25: SlepcInitialize(&argc,&argv,(char*)0,help);
27: PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
28: PetscPrintf(PETSC_COMM_WORLD,"\nDiagonal Eigenproblem, n=%" PetscInt_FMT "\n\n",n);
30: MatCreate(PETSC_COMM_WORLD,&A);
31: MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n);
32: MatSetFromOptions(A);
33: MatSetUp(A);
34: MatGetOwnershipRange(A,&Istart,&Iend);
35: for (i=Istart;i<Iend;i++) MatSetValue(A,i,i,i+1,INSERT_VALUES);
36: MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);
37: MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);
39: /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
40: Create the eigensolver and mess up with the prefix
41: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
42: EPSCreate(PETSC_COMM_WORLD,&eps);
43: EPSSetOptionsPrefix(eps,"check_");
44: EPSAppendOptionsPrefix(eps,"myprefix_");
45: EPSGetOptionsPrefix(eps,&prefix);
46: PetscPrintf(PETSC_COMM_WORLD,"EPS prefix is currently: %s\n\n",prefix);
48: EPSSetOperators(eps,A,NULL);
49: EPSSetProblemType(eps,EPS_HEP);
50: EPSSetFromOptions(eps);
51: EPSSolve(eps);
53: /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
54: Display solution and clean up
55: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
56: EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);
57: EPSDestroy(&eps);
58: MatDestroy(&A);
59: SlepcFinalize();
60: return 0;
61: }
63: /*TEST
65: test:
66: suffix: 1
67: args: -check_myprefix_eps_nev 2 -check_myprefix_st_type sinvert
69: TEST*/