https://www.cdslab.org/paramonte/fortran/2
Current view: top level - main - pm_distLogNorm@routines.inc.F90 (source / functions) Hit Total Coverage
Test: ParaMonte 2.0.0 :: Serial Fortran - Code Coverage Report Lines: 27 28 96.4 %
Date: 2024-04-08 03:18:57 Functions: 0 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 [pm_distLogNorm](@ref pm_distLogNorm).
      19             : !>
      20             : !>  \author
      21             : !>  \AmirShahmoradi, Oct 16, 2009, 11:14 AM, Michigan
      22             : 
      23             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      24             : 
      25             :         !%%%%%%%%%%%%%%%%%%%%%%%
      26             : #if     getLogNormLogPDF_ENABLED
      27             :         !%%%%%%%%%%%%%%%%%%%%%%%
      28             : 
      29             :         real(RKC) :: mu_def, invSigma
      30       22018 :         CHECK_ASSERTION(__LINE__, x > 0._RKC, SK_"@getLogNormLogPDF(): The condition `x > 0._RKC` must hold. x = "//getStr(x))
      31       22018 :         if (present(mu)) then
      32        4017 :             mu_def = mu
      33             :         else
      34       18001 :             mu_def = 0._RKC
      35             :         end if
      36       22018 :         if (present(sigma)) then
      37        4017 :             invSigma = 1._RKC / sigma
      38             :         else
      39       18001 :             invSigma = 1._RKC
      40             :         end if
      41       22018 :         call setLogNormLogPDF(logPDF, log(x), mu_def, invSigma, log(invSigma))
      42             : 
      43             :         !%%%%%%%%%%%%%%%%%%%%%%%
      44             : #elif   setLogNormLogPDF_ENABLED
      45             :         !%%%%%%%%%%%%%%%%%%%%%%%
      46             : 
      47             :         real(RKC)   , parameter :: PI = acos(-1._RKC)
      48             :         real(RKC)   , parameter :: INVERSE_SQRT_TWO_PI = 1._RKC / sqrt(2._RKC * PI)
      49             :         real(RKC)   , parameter :: LOG_INVERSE_SQRT_TWO_PI = log(INVERSE_SQRT_TWO_PI)
      50             : #if     DS_ENABLED || MS_ENABLED
      51       64943 :         CHECK_ASSERTION(__LINE__, invSigma > 0._RKC, SK_"@setLogNormLogPDF(): The condition `invSigma > 0._RKC` must hold. invSigma = "//getStr(invSigma))
      52      194829 :         CHECK_ASSERTION(__LINE__, abs(logInvSigma - log(invSigma)) <= epsilon(0._RKC)*100, SK_"@setLogNormLogPDF(): The condition `abs(logInvSigma - log(invSigma)) <= epsilon(0._RKC)*100` must hold. logInvSigma, log(invSigma) = "//getStr([logInvSigma, log(invSigma)]))
      53             : #endif
      54             : #if     DD_ENABLED
      55           1 :         logPDF = LOG_INVERSE_SQRT_TWO_PI - 0.5_RKC * logx**2 - logx
      56             : #elif   DS_ENABLED
      57           1 :         logPDF = logInvSigma + LOG_INVERSE_SQRT_TWO_PI - 0.5_RKC * (logx * invSigma)**2 - logx
      58             : #elif   MD_ENABLED
      59           1 :         logPDF = LOG_INVERSE_SQRT_TWO_PI - 0.5_RKC * (logx - mu)**2 - logx
      60             : #elif   MS_ENABLED
      61       64942 :         logPDF = logInvSigma + LOG_INVERSE_SQRT_TWO_PI - 0.5_RKC * ((logx - mu) * invSigma)**2 - logx
      62             : #else
      63             : #error  "Unrecognized interface"
      64             : #endif
      65             : 
      66             :         !%%%%%%%%%%%%%%%%%%%%
      67             : #elif   getLogNormCDF_ENABLED
      68             :         !%%%%%%%%%%%%%%%%%%%%
      69             : 
      70        4039 :         CHECK_ASSERTION(__LINE__, x >= 0._RKC, SK_"@getLogNormCDF(): The condition `x >= 0._RKC` must hold. x = "//getStr(x))
      71        4039 :         if (x > 0._RKC) then
      72        4037 :             if (present(mu) .and. present(sigma)) then
      73        4022 :                 call setLogNormCDF(cdf, log(x), mu, 1._RKC / sigma)
      74          15 :             elseif (present(sigma)) then
      75           0 :                 call setLogNormCDF(cdf, log(x), 0._RKC, 1._RKC / sigma)
      76          15 :             elseif (present(mu)) then
      77           2 :                 call setLogNormCDF(cdf, log(x), mu)
      78             :             else
      79          13 :                 call setLogNormCDF(cdf, log(x))
      80             :             end if
      81             :         else
      82           2 :             cdf = 0._RKC
      83             :         end if
      84             : 
      85             :         !%%%%%%%%%%%%%%%%%%%%
      86             : #elif   setLogNormCDF_ENABLED
      87             :         !%%%%%%%%%%%%%%%%%%%%
      88             : 
      89             :         real(RKC)   , parameter :: INVERSE_SQRT_TWO = 1._RKC / sqrt(2._RKC)
      90             : #if     DD_ENABLED
      91          14 :         cdf = 0.5_RKC * (1._RKC + erf(logx * INVERSE_SQRT_TWO))
      92             : #elif   MD_ENABLED
      93           4 :         cdf = 0.5_RKC * (1._RKC + erf((logx - mu) * INVERSE_SQRT_TWO))
      94             : #elif   MS_ENABLED
      95        8038 :         CHECK_ASSERTION(__LINE__, invSigma > 0._RKC, SK_"@setLogNormCDF(): The condition `invSigma > 0._RKC` must hold. invSigma = "//getStr(invSigma))
      96        8038 :         cdf = 0.5_RKC * (1._RKC + erf((logx - mu) * invSigma * INVERSE_SQRT_TWO))
      97             : #else
      98             : #error "Unrecognized interface"
      99             : #endif
     100             : 
     101             : #else
     102             :         !%%%%%%%%%%%%%%%%%%%%%%%
     103             : #error  "Unrecognized interface"
     104             :         !%%%%%%%%%%%%%%%%%%%%%%%
     105             : #endif

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