Actual source code: test1.c

slepc-3.5.2 2014-10-10
Report Typos and Errors
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2014, Universitat Politecnica de Valencia, Spain

  6:    This file is part of SLEPc.

  8:    SLEPc is free software: you can redistribute it and/or modify it under  the
  9:    terms of version 3 of the GNU Lesser General Public License as published by
 10:    the Free Software Foundation.

 12:    SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
 13:    WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
 14:    FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
 15:    more details.

 17:    You  should have received a copy of the GNU Lesser General  Public  License
 18:    along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
 19:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 20: */

 22: static char help[] = "Test RG interface functions.\n\n";

 24: #include <slepcrg.h>

 28: int main(int argc,char **argv)
 29: {
 31:   RG             rg;
 32:   PetscInt       i,inside;
 33:   PetscReal      re,im;
 34:   PetscScalar    ar,ai,cr[10],ci[10];

 36:   SlepcInitialize(&argc,&argv,(char*)0,help);
 37:   RGCreate(PETSC_COMM_WORLD,&rg);

 39:   /* ellipse */
 40:   RGSetType(rg,RGELLIPSE);
 41:   RGEllipseSetParameters(rg,1.1,2,0.1);
 42:   RGSetFromOptions(rg);
 43:   RGView(rg,NULL);
 44:   re = 0.1; im = 0.3;
 45: #if defined(PETSC_USE_COMPLEX)
 46:   ar = re+im*PETSC_i;
 47: #else
 48:   ar = re; ai = im;
 49: #endif
 50:   RGCheckInside(rg,1,&ar,&ai,&inside);
 51:   PetscPrintf(PETSC_COMM_WORLD,"Point (%g,%g) is %s the region\n",(double)re,(double)im,(inside>=0)?"inside":"outside");

 53:   PetscPrintf(PETSC_COMM_WORLD,"Contour points: ");
 54:   RGComputeContour(rg,10,cr,ci);
 55:   for (i=0;i<10;i++) {
 56: #if defined(PETSC_USE_COMPLEX)
 57:     re = PetscRealPart(cr[i]);
 58:     im = PetscImaginaryPart(cr[i]);
 59: #else
 60:     re = cr[i];
 61:     im = ci[i];
 62: #endif
 63:     PetscPrintf(PETSC_COMM_WORLD,"(%.3g,%.3g) ",(double)re,(double)im);
 64:   }
 65:   PetscPrintf(PETSC_COMM_WORLD,"\n");

 67:   /* interval */
 68:   RGSetType(rg,RGINTERVAL);
 69:   RGIntervalSetEndpoints(rg,-1,1,-0.1,0.1);
 70:   RGSetFromOptions(rg);
 71:   RGView(rg,NULL);
 72:   re = 0.2; im = 0;
 73: #if defined(PETSC_USE_COMPLEX)
 74:   ar = re+im*PETSC_i;
 75: #else
 76:   ar = re; ai = im;
 77: #endif
 78:   RGCheckInside(rg,1,&ar,&ai,&inside);
 79:   PetscPrintf(PETSC_COMM_WORLD,"Point (%g,%g) is %s the region\n",(double)re,(double)im,(inside>=0)?"inside":"outside");

 81:   RGDestroy(&rg);
 82:   SlepcFinalize();
 83:   return 0;
 84: }