Date: 2021-02-01T14:42:00+00:00

Actual source code: test19.c
slepc-3.14.2 2021-02-01
Report Typos and Errors

      1: /*
      2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
      4:    Copyright (c) 2002-2020, 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);if (ierr) return ierr;

     27:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
     28:   PetscPrintf(PETSC_COMM_WORLD,"\nDiagonal Eigenproblem, n=%D\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++) {
     36:     MatSetValue(A,i,i,i+1,INSERT_VALUES);
     37:   }
     38:   MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);
     39:   MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);

     41:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     42:            Create the eigensolver and mess up with the prefix
     43:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
     44:   EPSCreate(PETSC_COMM_WORLD,&eps);
     45:   EPSSetOptionsPrefix(eps,"check_");
     46:   EPSAppendOptionsPrefix(eps,"myprefix_");
     47:   EPSGetOptionsPrefix(eps,&prefix);
     48:   PetscPrintf(PETSC_COMM_WORLD,"EPS prefix is currently: %s\n\n",prefix);

     50:   EPSSetOperators(eps,A,NULL);
     51:   EPSSetProblemType(eps,EPS_HEP);
     52:   EPSSetFromOptions(eps);
     53:   EPSSolve(eps);

     55:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     56:                     Display solution and clean up
     57:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
     58:   EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);
     59:   EPSDestroy(&eps);
     60:   MatDestroy(&A);
     61:   SlepcFinalize();
     62:   return ierr;
     63: }

     65: /*TEST

     67:    test:
     68:       suffix: 1
     69:       args: -check_myprefix_eps_nev 2 -check_myprefix_st_type sinvert

     71: TEST*/