Date: 2021-09-20T09:43:55+00:00

Actual source code: test23.c
slepc-3.15.2 2021-09-20
Report Typos and Errors

      1: /*
      2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
      4:    Copyright (c) 2002-2021, 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[] = "Test EPS view and monitor functionality.\n\n";

     13: #include <slepceps.h>

     15: int main(int argc,char **argv)
     16: {
     17:   Mat            A;
     18:   EPS            eps;
     19:   PetscInt       n=6,Istart,Iend,i;

     22:   SlepcInitialize(&argc,&argv,(char*)0,help);if (ierr) return ierr;
     23:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
     24:   PetscPrintf(PETSC_COMM_WORLD,"\nEPS of diagonal problem, n=%D\n\n",n);

     26:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     27:         Generate the matrix
     28:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
     29:   MatCreate(PETSC_COMM_WORLD,&A);
     30:   MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n);
     31:   MatSetFromOptions(A);
     32:   MatSetUp(A);
     33:   MatGetOwnershipRange(A,&Istart,&Iend);
     34:   for (i=Istart;i<Iend;i++) {
     35:     MatSetValue(A,i,i,i+1,INSERT_VALUES);
     36:   }
     37:   MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);
     38:   MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);

     40:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     41:                      Create the EPS solver
     42:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
     43:   EPSCreate(PETSC_COMM_WORLD,&eps);
     44:   PetscObjectSetName((PetscObject)eps,"eps");
     45:   EPSSetOperators(eps,A,NULL);
     46:   EPSSetFromOptions(eps);

     48:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     49:                 Solve the eigensystem and display solution
     50:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
     51:   EPSSolve(eps);
     52:   EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);
     53:   EPSDestroy(&eps);
     54:   MatDestroy(&A);
     55:   SlepcFinalize();
     56:   return ierr;
     57: }

     59: /*TEST

     61:    test:
     62:       suffix: 1
     63:       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
     64:       requires: !single
     65:       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"

     67:    test:
     68:       suffix: 2
     69:       args: -n 20 -eps_largest_real -eps_monitor -eps_view_values ::ascii_matlab
     70:       requires: double
     71:       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/"

     73:    test:
     74:       suffix: 3
     75:       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
     76:       requires: double

     78: TEST*/