LCOV - code coverage report
Current view: top level - eps/tests - test30.c (source / functions) Hit Total Coverage
Test: SLEPc Lines: 38 38 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[] = "Test changing EPS type.\n\n";
      12             : 
      13             : #include <slepceps.h>
      14             : 
      15           1 : int main(int argc,char **argv)
      16             : {
      17           1 :   Mat            A;           /* problem matrix */
      18           1 :   EPS            eps;         /* eigenproblem solver context */
      19           1 :   ST             st;
      20           1 :   KSP            ksp;
      21           1 :   PetscInt       n=20,i,Istart,Iend,nrest;
      22             : 
      23           1 :   PetscFunctionBeginUser;
      24           1 :   PetscCall(SlepcInitialize(&argc,&argv,NULL,help));
      25           1 :   PetscCall(PetscPrintf(PETSC_COMM_WORLD,"\nDiagonal Eigenproblem, n=%" PetscInt_FMT "\n\n",n));
      26             : 
      27           1 :   PetscCall(MatCreate(PETSC_COMM_WORLD,&A));
      28           1 :   PetscCall(MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n));
      29           1 :   PetscCall(MatSetFromOptions(A));
      30           1 :   PetscCall(MatGetOwnershipRange(A,&Istart,&Iend));
      31          21 :   for (i=Istart;i<Iend;i++) PetscCall(MatSetValue(A,i,i,i+1,INSERT_VALUES));
      32           1 :   PetscCall(MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY));
      33           1 :   PetscCall(MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY));
      34             : 
      35             :   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      36             :              Create eigensolver and view options
      37             :      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
      38           1 :   PetscCall(EPSCreate(PETSC_COMM_WORLD,&eps));
      39           1 :   PetscCall(EPSSetOperators(eps,A,NULL));
      40           1 :   PetscCall(EPSSetProblemType(eps,EPS_HEP));
      41           1 :   PetscCall(EPSSetTarget(eps,4.8));
      42           1 :   PetscCall(EPSSetWhichEigenpairs(eps,EPS_TARGET_MAGNITUDE));
      43           1 :   PetscCall(EPSSetDimensions(eps,4,PETSC_DETERMINE,PETSC_DETERMINE));
      44             : 
      45           1 :   PetscCall(EPSSetType(eps,EPSRQCG));
      46           1 :   PetscCall(EPSRQCGSetReset(eps,10));
      47           1 :   PetscCall(EPSSetFromOptions(eps));
      48           1 :   PetscCall(EPSRQCGGetReset(eps,&nrest));
      49           1 :   PetscCall(PetscPrintf(PETSC_COMM_WORLD,"RQCG reset parameter = %" PetscInt_FMT "\n\n",nrest));
      50           1 :   PetscCall(EPSView(eps,NULL));
      51             : 
      52             :   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      53             :              Change eigensolver type and solve problem
      54             :      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
      55           1 :   PetscCall(EPSSetType(eps,EPSGD));
      56           1 :   PetscCall(EPSGetST(eps,&st));
      57           1 :   PetscCall(STGetKSP(st,&ksp));
      58           1 :   PetscCall(KSPSetType(ksp,KSPPREONLY));
      59           1 :   PetscCall(EPSSolve(eps));
      60           1 :   PetscCall(EPSView(eps,NULL));
      61             : 
      62             :   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      63             :                     Display solution and clean up
      64             :      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
      65           1 :   PetscCall(EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL));
      66           1 :   PetscCall(EPSDestroy(&eps));
      67           1 :   PetscCall(MatDestroy(&A));
      68           1 :   PetscCall(SlepcFinalize());
      69             :   return 0;
      70             : }
      71             : 
      72             : /*TEST
      73             : 
      74             :    test:
      75             :       suffix: 1
      76             :       args: -eps_harmonic -eps_conv_norm
      77             :       filter: grep -v tolerance | sed -e "s/symmetric/hermitian/"
      78             : 
      79             : TEST*/

Generated by: LCOV version 1.14