Date: 2020-01-13T12:01:31+00:00

Actual source code: test5.c
slepc-3.12.2 2020-01-13
Report Typos and Errors

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

     13: #include <slepcpep.h>

     15: int main(int argc,char **argv)
     16: {
     17:   Mat            A[3];
     18:   PEP            pep;
     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,"\nPEP of diagonal problem, n=%D\n\n",n);

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

     40:   MatCreate(PETSC_COMM_WORLD,&A[1]);
     41:   MatSetSizes(A[1],PETSC_DECIDE,PETSC_DECIDE,n,n);
     42:   MatSetFromOptions(A[1]);
     43:   MatSetUp(A[1]);
     44:   for (i=Istart;i<Iend;i++) {
     45:     MatSetValue(A[1],i,i,-1.5,INSERT_VALUES);
     46:   }
     47:   MatAssemblyBegin(A[1],MAT_FINAL_ASSEMBLY);
     48:   MatAssemblyEnd(A[1],MAT_FINAL_ASSEMBLY);

     50:   MatCreate(PETSC_COMM_WORLD,&A[2]);
     51:   MatSetSizes(A[2],PETSC_DECIDE,PETSC_DECIDE,n,n);
     52:   MatSetFromOptions(A[2]);
     53:   MatSetUp(A[2]);
     54:   for (i=Istart;i<Iend;i++) {
     55:     MatSetValue(A[2],i,i,-1.0/(i+1),INSERT_VALUES);
     56:   }
     57:   MatAssemblyBegin(A[2],MAT_FINAL_ASSEMBLY);
     58:   MatAssemblyEnd(A[2],MAT_FINAL_ASSEMBLY);

     60:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     61:                      Create the PEP solver
     62:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
     63:   PEPCreate(PETSC_COMM_WORLD,&pep);
     64:   PetscObjectSetName((PetscObject)pep,"pep");
     65:   PEPSetOperators(pep,3,A);
     66:   PEPSetFromOptions(pep);

     68:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     69:                 Solve the eigensystem and display solution
     70:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
     71:   PEPSolve(pep);
     72:   PEPErrorView(pep,PEP_ERROR_RELATIVE,NULL);
     73:   PEPDestroy(&pep);
     74:   MatDestroy(&A[0]);
     75:   MatDestroy(&A[1]);
     76:   MatDestroy(&A[2]);
     77:   SlepcFinalize();
     78:   return ierr;
     79: }

     81: /*TEST

     83:    test:
     84:       suffix: 1
     85:       args: -pep_error_backward ::ascii_info_detail -pep_largest_real -pep_view_values -pep_monitor_conv -pep_error_absolute ::ascii_matlab -pep_monitor_all -pep_converged_reason -pep_view
     86:       requires: !single
     87:       filter: grep -v "tolerance" | grep -v "problem type" | sed -e "s/[+-]0.000000i//" -e "s/\([0-9]\.[5]*\)[+-][0-9]\.[0-9]*e-[0-9]*i/\\1/g" -e "s/[0-9]\.[0-9]*e-\([0-9]*\)/removed/g"

     89:    test:
     90:       suffix: 2
     91:       args: -n 12 -pep_largest_real -pep_monitor -pep_view_values ::ascii_matlab
     92:       requires: double
     93:       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/5\.\([49]\)999999[0-9]*e+00/5.\\1999999999999999e+00/"

     95: TEST*/