https://www.cdslab.org/paramonte/fortran/2
Current view: top level - test - test_pm_distGamma@routines.inc.F90 (source / functions) Hit Total Coverage
Test: ParaMonte 2.0.0 :: Serial Fortran - Code Coverage Report Lines: 23 23 100.0 %
Date: 2024-04-08 03:18:57 Functions: 8 8 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       2             : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       3             : !!!!                                                                                                                            !!!!
       4             : !!!!    ParaMonte: Parallel Monte Carlo and Machine Learning Library.                                                           !!!!
       5             : !!!!                                                                                                                            !!!!
       6             : !!!!    Copyright (C) 2012-present, The Computational Data Science Lab                                                          !!!!
       7             : !!!!                                                                                                                            !!!!
       8             : !!!!    This file is part of the ParaMonte library.                                                                             !!!!
       9             : !!!!                                                                                                                            !!!!
      10             : !!!!    LICENSE                                                                                                                 !!!!
      11             : !!!!                                                                                                                            !!!!
      12             : !!!!       https://github.com/cdslaborg/paramonte/blob/main/LICENSE.md                                                          !!!!
      13             : !!!!                                                                                                                            !!!!
      14             : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
      15             : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
      16             : 
      17             : !>  \brief
      18             : !>  This include file contains procedure implementations of the tests of [pm_distGamma](@ref pm_distGamma).
      19             : !>
      20             : !>  \fintest
      21             : !>
      22             : !>  \author
      23             : !>  \FatemehBagheri, 12:27 AM Tuesday, February 22, 2022, Dallas, TX
      24             : 
      25             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      26             : 
      27             : #if     CK_ENABLED
      28             :         use pm_complexAbs, only: abs, log, operator(<), operator(<=)
      29             : #elif   !RK_ENABLED
      30             : #error  "Unrecognized interface."
      31             : #endif
      32             :         integer(IK) , parameter :: NP = 10_IK
      33             :         integer(IK) :: i
      34             : #if     RK_ENABLED || RK_ENABLED
      35             :         real(RKC)   , parameter :: TOL = epsilon(0._RKC) * 100_IK
      36             :         real(RKC)   , parameter :: invOmega = 1._RKC
      37             :         real(RKC)               :: PDF_ref(NP)
      38             :         real(RKC)               :: diff(NP)
      39             :         real(RKC)               :: PDF(NP)
      40             :         real(RKC)               :: X(NP)
      41             :         real(RKC)               :: Kappa(NP)
      42             :         real(RKC)               :: invSigma(NP)
      43             : #else
      44             : #error  "Unrecognized interface."
      45             : #endif
      46             : 
      47          18 :         assertion = .true._LK
      48         198 :         call setUnifRand(X, epsilon(0._RKC), 1000._RKC)
      49         198 :         call setUnifRand(Kappa, epsilon(0._RKC), 10._RKC)
      50         198 :         call setUnifRand(invSigma, epsilon(0._RKC), 10._RKC)
      51             : 
      52             :         !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      53             : 
      54         396 :         PDF_ref = getGenGammaLogPDF(X)
      55             : #if     getGammaLogPDF_ENABLED
      56         220 :         PDF = getGammaLogPDF(X)
      57             : #elif   setGammaLogPDF_ENABLED
      58          88 :         call setGammaLogPDF(PDF, X)
      59             : #else
      60             : #error  "Unrecognized interface."
      61             : #endif
      62          18 :         call report(int(__LINE__, IK))
      63             : 
      64             :         !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      65             : 
      66         396 :         PDF_ref = getGenGammaLogPDF(X, Kappa)
      67             : #if     getGammaLogPDF_ENABLED
      68         220 :         PDF = getGammaLogPDF(X, Kappa)
      69             : #elif   setGammaLogPDF_ENABLED
      70          88 :         call setGammaLogPDF(PDF, X, getGammaLogPDFNF(Kappa), Kappa)
      71             : #else
      72             : #error  "Unrecognized interface."
      73             : #endif
      74          18 :         call report(int(__LINE__, IK))
      75             : 
      76             :         !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      77             : 
      78         396 :         PDF_ref = getGenGammaLogPDF(X, Kappa, invSigma = invSigma)
      79             : #if     getGammaLogPDF_ENABLED
      80         220 :         PDF = getGammaLogPDF(X, Kappa, invSigma)
      81             : #elif   setGammaLogPDF_ENABLED
      82          88 :         call setGammaLogPDF(PDF, X, getGammaLogPDFNF(Kappa, invSigma), Kappa, invSigma)
      83             : #else
      84             : #error  "Unrecognized interface."
      85             : #endif
      86          18 :         call report(int(__LINE__, IK))
      87             : 
      88             :         !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      89             : 
      90             :     contains
      91             : 
      92             :         !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      93             : 
      94          54 :         subroutine report(line)
      95             :             integer(IK), intent(in) :: line
      96         594 :             diff = abs(PDF - PDF_ref)
      97         594 :             do i = 1, NP
      98         540 :                 call test%assert(assertion, desc = "The PDF of the Gamma distribution must be computed correctly.", line = line)
      99         540 :                 assertion = assertion .and. diff(i) <= TOL
     100         594 :                 if (test%traceable .and. .not. assertion) then
     101             :                     ! LCOV_EXCL_START
     102             :                     write(test%disp%unit,"(*(g0,:,', '))")
     103             :                     write(test%disp%unit,"(*(g0,:,', '))") "invSigma   ", invSigma(i)
     104             :                     write(test%disp%unit,"(*(g0,:,', '))") "Kappa      ", Kappa(i)
     105             :                     write(test%disp%unit,"(*(g0,:,', '))") "PDF_ref    ", PDF_ref(i)
     106             :                     write(test%disp%unit,"(*(g0,:,', '))") "PDF        ", PDF(i)
     107             :                     write(test%disp%unit,"(*(g0,:,', '))") "X          ", X(i)
     108             :                     write(test%disp%unit,"(*(g0,:,', '))") "diff       ", diff(i)
     109             :                     write(test%disp%unit,"(*(g0,:,', '))")
     110             :                     ! LCOV_EXCL_STOP
     111             :                 end if
     112             :             end do
     113          54 :         end subroutine
     114             : 
     115             :         !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

ParaMonte: Parallel Monte Carlo and Machine Learning Library 
The Computational Data Science Lab
© Copyright 2012 - 2024