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 EPS view and monitor functionality.\n\n"; 12 : 13 : #include <slepceps.h> 14 : 15 2 : int main(int argc,char **argv) 16 : { 17 2 : Mat A; 18 2 : EPS eps; 19 2 : PetscInt n=6,Istart,Iend,i; 20 : 21 2 : PetscFunctionBeginUser; 22 2 : PetscCall(SlepcInitialize(&argc,&argv,NULL,help)); 23 2 : PetscCall(PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL)); 24 2 : PetscCall(PetscPrintf(PETSC_COMM_WORLD,"\nEPS of diagonal problem, n=%" PetscInt_FMT "\n\n",n)); 25 : 26 : /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 27 : Generate the matrix 28 : - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ 29 2 : PetscCall(MatCreate(PETSC_COMM_WORLD,&A)); 30 2 : PetscCall(MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n)); 31 2 : PetscCall(MatSetFromOptions(A)); 32 2 : PetscCall(MatGetOwnershipRange(A,&Istart,&Iend)); 33 28 : for (i=Istart;i<Iend;i++) PetscCall(MatSetValue(A,i,i,i+1,INSERT_VALUES)); 34 2 : PetscCall(MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY)); 35 2 : PetscCall(MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY)); 36 : 37 : /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 38 : Create the EPS solver 39 : - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ 40 2 : PetscCall(EPSCreate(PETSC_COMM_WORLD,&eps)); 41 2 : PetscCall(PetscObjectSetName((PetscObject)eps,"eps")); 42 2 : PetscCall(EPSSetOperators(eps,A,NULL)); 43 2 : PetscCall(EPSSetFromOptions(eps)); 44 : 45 : /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 46 : Solve the eigensystem and display solution 47 : - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ 48 2 : PetscCall(EPSSolve(eps)); 49 2 : PetscCall(EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL)); 50 2 : PetscCall(EPSDestroy(&eps)); 51 2 : PetscCall(MatDestroy(&A)); 52 2 : PetscCall(SlepcFinalize()); 53 : return 0; 54 : } 55 : 56 : /*TEST 57 : 58 : test: 59 : suffix: 1 60 : args: -eps_error_backward ::ascii_info_detail -eps_largest_real -eps_balance oneside -eps_view_values -eps_monitor_conv -eps_error_absolute ::ascii_matlab -eps_monitor_all -eps_converged_reason -eps_view 61 : requires: !single 62 : filter: grep -v "tolerance" | sed -e "s/hermitian/symmetric/" -e "s/[+-]0\.0*i//g" -e "s/\([1-6]\.\)[+-][0-9]\.[0-9]*e-[0-9]*i/\\1/g" -e "s/[0-9]\.[0-9]*e-\([0-9]*\)/removed/g" 63 : 64 : test: 65 : suffix: 2 66 : args: -n 20 -eps_largest_real -eps_monitor -eps_view_values ::ascii_matlab 67 : requires: double 68 : filter: sed -e "s/[+-][0-9]\.[0-9]*e-[0-9]*i//" -e "s/[0-9]\.[0-9]*e-\([0-9]*\)/removed/g" -e "s/2\.[0-9]*e+01/2.0000000000000000e+01/" -e "s/1\.9999999999[0-9]*e+01/2.0000000000000000e+01/" 69 : 70 : test: 71 : suffix: 3 72 : args: -n 20 -eps_largest_real -eps_monitor draw::draw_lg -eps_monitor_all draw::draw_lg -eps_view_values draw -draw_save myeigen.ppm -draw_virtual 73 : requires: x double 74 : 75 : TEST*/