LCOV - code coverage report
Current view: top level - sys/classes/fn/tests - test9.c (source / functions) Hit Total Coverage
Test: SLEPc Lines: 32 32 100.0 %
Date: 2024-11-21 00:40:22 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          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 logarithm function.\n\n";
      12             : 
      13             : #include <slepcfn.h>
      14             : 
      15           1 : int main(int argc,char **argv)
      16             : {
      17           1 :   FN             fn;
      18           1 :   PetscScalar    x,y,yp,tau,eta;
      19           1 :   char           strx[50],str[50];
      20             : 
      21           1 :   PetscFunctionBeginUser;
      22           1 :   PetscCall(SlepcInitialize(&argc,&argv,NULL,help));
      23           1 :   PetscCall(FNCreate(PETSC_COMM_WORLD,&fn));
      24             : 
      25             :   /* plain logarithm log(x) */
      26           1 :   PetscCall(FNSetType(fn,FNLOG));
      27           1 :   PetscCall(FNView(fn,NULL));
      28           1 :   x = 2.2;
      29           1 :   PetscCall(SlepcSNPrintfScalar(strx,sizeof(strx),x,PETSC_FALSE));
      30           1 :   PetscCall(FNEvaluateFunction(fn,x,&y));
      31           1 :   PetscCall(FNEvaluateDerivative(fn,x,&yp));
      32           1 :   PetscCall(SlepcSNPrintfScalar(str,sizeof(str),y,PETSC_FALSE));
      33           1 :   PetscCall(PetscPrintf(PETSC_COMM_WORLD,"  f(%s)=%s\n",strx,str));
      34           1 :   PetscCall(SlepcSNPrintfScalar(str,sizeof(str),yp,PETSC_FALSE));
      35           1 :   PetscCall(PetscPrintf(PETSC_COMM_WORLD,"  f'(%s)=%s\n",strx,str));
      36             : 
      37             :   /* logarithm with scaling factors eta*log(tau*x) */
      38           1 :   PetscCall(FNSetType(fn,FNLOG));
      39           1 :   tau = 0.2;
      40           1 :   eta = 1.3;
      41           1 :   PetscCall(FNSetScale(fn,tau,eta));
      42           1 :   PetscCall(FNView(fn,NULL));
      43           1 :   x = 2.2;
      44           1 :   PetscCall(SlepcSNPrintfScalar(strx,sizeof(strx),x,PETSC_FALSE));
      45           1 :   PetscCall(FNEvaluateFunction(fn,x,&y));
      46           1 :   PetscCall(FNEvaluateDerivative(fn,x,&yp));
      47           1 :   PetscCall(SlepcSNPrintfScalar(str,sizeof(str),y,PETSC_FALSE));
      48           1 :   PetscCall(PetscPrintf(PETSC_COMM_WORLD,"  f(%s)=%s\n",strx,str));
      49           1 :   PetscCall(SlepcSNPrintfScalar(str,sizeof(str),yp,PETSC_FALSE));
      50           1 :   PetscCall(PetscPrintf(PETSC_COMM_WORLD,"  f'(%s)=%s\n",strx,str));
      51             : 
      52           1 :   PetscCall(FNDestroy(&fn));
      53           1 :   PetscCall(SlepcFinalize());
      54             :   return 0;
      55             : }
      56             : 
      57             : /*TEST
      58             : 
      59             :    test:
      60             :       suffix: 1
      61             :       nsize: 1
      62             :       filter: grep -v "computing matrix functions"
      63             : 
      64             : TEST*/

Generated by: LCOV version 1.14