LCOV - code coverage report
Current view: top level - eps/tests - test19.c (source / functions) Hit Total Coverage
Test: SLEPc Lines: 29 29 100.0 %
Date: 2024-11-21 00:34:55 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       3             :    SLEPc - Scalable Library for Eigenvalue Problem Computations
       4             :    Copyright (c) 2002-, Universitat Politecnica de Valencia, Spain
       5             : 
       6             :    This file is part of SLEPc.
       7             :    SLEPc is distributed under a 2-clause BSD license (see LICENSE).
       8             :    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       9             : */
      10             : 
      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";
      14             : 
      15             : #include <slepceps.h>
      16             : 
      17           1 : int main(int argc,char **argv)
      18             : {
      19           1 :   Mat            A;           /* problem matrix */
      20           1 :   EPS            eps;         /* eigenproblem solver context */
      21           1 :   PetscInt       n=30,i,Istart,Iend;
      22           1 :   const char     *prefix;
      23             : 
      24           1 :   PetscFunctionBeginUser;
      25           1 :   PetscCall(SlepcInitialize(&argc,&argv,NULL,help));
      26             : 
      27           1 :   PetscCall(PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL));
      28           1 :   PetscCall(PetscPrintf(PETSC_COMM_WORLD,"\nDiagonal Eigenproblem, n=%" PetscInt_FMT "\n\n",n));
      29             : 
      30           1 :   PetscCall(MatCreate(PETSC_COMM_WORLD,&A));
      31           1 :   PetscCall(MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n));
      32           1 :   PetscCall(MatSetFromOptions(A));
      33           1 :   PetscCall(MatGetOwnershipRange(A,&Istart,&Iend));
      34          31 :   for (i=Istart;i<Iend;i++) PetscCall(MatSetValue(A,i,i,i+1,INSERT_VALUES));
      35           1 :   PetscCall(MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY));
      36           1 :   PetscCall(MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY));
      37             : 
      38             :   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      39             :            Create the eigensolver and mess up with the prefix
      40             :      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
      41           1 :   PetscCall(EPSCreate(PETSC_COMM_WORLD,&eps));
      42           1 :   PetscCall(EPSSetOptionsPrefix(eps,"check_"));
      43           1 :   PetscCall(EPSAppendOptionsPrefix(eps,"myprefix_"));
      44           1 :   PetscCall(EPSGetOptionsPrefix(eps,&prefix));
      45           1 :   PetscCall(PetscPrintf(PETSC_COMM_WORLD,"EPS prefix is currently: %s\n\n",prefix));
      46             : 
      47           1 :   PetscCall(EPSSetOperators(eps,A,NULL));
      48           1 :   PetscCall(EPSSetProblemType(eps,EPS_HEP));
      49           1 :   PetscCall(EPSSetFromOptions(eps));
      50           1 :   PetscCall(EPSSolve(eps));
      51             : 
      52             :   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      53             :                     Display solution and clean up
      54             :      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
      55           1 :   PetscCall(EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL));
      56           1 :   PetscCall(EPSDestroy(&eps));
      57           1 :   PetscCall(MatDestroy(&A));
      58           1 :   PetscCall(SlepcFinalize());
      59             :   return 0;
      60             : }
      61             : 
      62             : /*TEST
      63             : 
      64             :    test:
      65             :       suffix: 1
      66             :       args: -check_myprefix_eps_nev 2 -check_myprefix_st_type sinvert
      67             : 
      68             : TEST*/

Generated by: LCOV version 1.14