Date: 2021-02-01T14:41:41+00:00

Actual source code: test9.c
slepc-3.14.2 2021-02-01
Report Typos and Errors

      1: /*
      2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
      4:    Copyright (c) 2002-2020, 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 logarithm function.\n\n";

     13: #include <slepcfn.h>

     15: int main(int argc,char **argv)
     16: {
     18:   FN             fn;
     19:   PetscScalar    x,y,yp,tau,eta;
     20:   char           strx[50],str[50];

     22:   SlepcInitialize(&argc,&argv,(char*)0,help);if (ierr) return ierr;
     23:   FNCreate(PETSC_COMM_WORLD,&fn);

     25:   /* plain logarithm log(x) */
     26:   FNSetType(fn,FNLOG);
     27:   FNView(fn,NULL);
     28:   x = 2.2;
     29:   SlepcSNPrintfScalar(strx,sizeof(strx),x,PETSC_FALSE);
     30:   FNEvaluateFunction(fn,x,&y);
     31:   FNEvaluateDerivative(fn,x,&yp);
     32:   SlepcSNPrintfScalar(str,sizeof(str),y,PETSC_FALSE);
     33:   PetscPrintf(PETSC_COMM_WORLD,"  f(%s)=%s\n",strx,str);
     34:   SlepcSNPrintfScalar(str,sizeof(str),yp,PETSC_FALSE);
     35:   PetscPrintf(PETSC_COMM_WORLD,"  f'(%s)=%s\n",strx,str);

     37:   /* logarithm with scaling factors eta*log(tau*x) */
     38:   FNSetType(fn,FNLOG);
     39:   tau = 0.2;
     40:   eta = 1.3;
     41:   FNSetScale(fn,tau,eta);
     42:   FNView(fn,NULL);
     43:   x = 2.2;
     44:   SlepcSNPrintfScalar(strx,sizeof(strx),x,PETSC_FALSE);
     45:   FNEvaluateFunction(fn,x,&y);
     46:   FNEvaluateDerivative(fn,x,&yp);
     47:   SlepcSNPrintfScalar(str,sizeof(str),y,PETSC_FALSE);
     48:   PetscPrintf(PETSC_COMM_WORLD,"  f(%s)=%s\n",strx,str);
     49:   SlepcSNPrintfScalar(str,sizeof(str),yp,PETSC_FALSE);
     50:   PetscPrintf(PETSC_COMM_WORLD,"  f'(%s)=%s\n",strx,str);

     52:   FNDestroy(&fn);
     53:   SlepcFinalize();
     54:   return ierr;
     55: }

     57: /*TEST

     59:    test:
     60:       suffix: 1
     61:       nsize: 1
     62:       filter: grep -v "computing matrix functions"

     64: TEST*/