https://www.cdslab.org/paramonte/fortran/2
Current view: top level - main - pm_distExp@routines.inc.F90 (source / functions) Hit Total Coverage
Test: ParaMonte 2.0.0 :: Serial Fortran - Code Coverage Report Lines: 38 38 100.0 %
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 the implementation of procedures in [pm_distExpPDF](@ref pm_distExpPDF).
      19             : !>
      20             : !>  \finmain
      21             : !>
      22             : !>  \author
      23             : !>  \AmirShahmoradi, Oct 16, 2009, 11:14 AM, Michigan
      24             : 
      25             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      26             : 
      27             :         !%%%%%%%%%%%%%%%%%%%
      28             : #if     getExpLogPDF_ENABLED
      29             :         !%%%%%%%%%%%%%%%%%%%
      30             : 
      31        4235 :         if (present(mu)) then
      32        2609 :             if (present(invSigma)) then
      33        2404 :                 call setExpLogPDF(logPDF, x, mu, invSigma, log(invSigma))
      34             :             else
      35         205 :                 call setExpLogPDF(logPDF, x, mu)
      36             :             end if
      37             :         else
      38        1626 :             if (present(invSigma)) then
      39         366 :                 call setExpLogPDF(logPDF, x, invSigma, log(invSigma))
      40             :             else
      41        1260 :                 call setExpLogPDF(logPDF, x)
      42             :             end if
      43             :         end if
      44             : 
      45             :         !%%%%%%%%%%%%%%%%%%%
      46             : #elif   setExpLogPDF_ENABLED
      47             :         !%%%%%%%%%%%%%%%%%%%
      48             : 
      49             :         ! Validate the input.
      50             : 
      51             : #if     XDD_ENABLED || XDI_ENABLED
      52        1894 :         CHECK_ASSERTION(__LINE__, 0 <= x, SK_"@setExpPDF(): The condition `0 <= x` must hold. x = "//getStr(x)) ! fpp
      53             : #elif   XMD_ENABLED || XMI_ENABLED
      54       15051 :         CHECK_ASSERTION(__LINE__, mu <= x, SK_"@setExpPDF(): The condition `mu <= x` must hold. mu, x = "//getStr([mu, x])) ! fpp
      55             : #else
      56             : #error  "Unrecognized interface."
      57             : #endif
      58             : 
      59             : #if     XDI_ENABLED || XMI_ENABLED
      60        5352 :         CHECK_ASSERTION(__LINE__, 0 < invSigma, SK_"@setExpPDF(): The condition `0 < invSigma` must hold. invSigma = "//getStr(invSigma)) ! fpp
      61       16056 :         CHECK_ASSERTION(__LINE__, abs(log(invSigma) - logInvSigma) < epsilon(0._TKC) * 10, SK_"@setExpPDF(): The condition `log(invSigma) == logInvSigma` must hold. invSigma, logInvSigma = "//getStr([invSigma, logInvSigma])) ! fpp
      62             : #elif   !(XDD_ENABLED || XMD_ENABLED)
      63             : #error  "Unrecognized interface."
      64             : #endif
      65             : 
      66             :         ! Compute the PDF.
      67             : 
      68             : #if     XDD_ENABLED
      69        1350 :         logPDF = -x
      70             : #elif   XMD_ENABLED
      71         209 :         logPDF = mu - x
      72             : #elif   XDI_ENABLED
      73         544 :         logPDF = logInvSigma - x * invSigma
      74             : #elif   XMI_ENABLED
      75        4808 :         logPDF = logInvSigma - (x - mu) * invSigma
      76             : #else
      77             : #error  "Unrecognized interface."
      78             : #endif
      79             : 
      80             :         !%%%%%%%%%%%%%%%%
      81             : #elif   getExpCDF_ENABLED
      82             :         !%%%%%%%%%%%%%%%%
      83             : 
      84        2949 :         if (present(mu)) then
      85        2619 :             if (present(invSigma)) then
      86        2404 :                 call setExpCDF(cdf, x, mu, invSigma)
      87             :             else
      88         215 :                 call setExpCDF(cdf, x - mu)
      89             :             end if
      90             :         else
      91         330 :             if (present(invSigma)) then
      92         211 :                 call setExpCDF(cdf, x, invSigma)
      93             :             else
      94         119 :                 call setExpCDF(cdf, x)
      95             :             end if
      96             :         end if
      97             : 
      98             :         !%%%%%%%%%%%%%%%%
      99             : #elif   setExpCDF_ENABLED
     100             :         !%%%%%%%%%%%%%%%%
     101             : 
     102             :         ! Validate the input.
     103             : 
     104             : #if     XDD_ENABLED || XDI_ENABLED
     105         855 :         CHECK_ASSERTION(__LINE__, 0 <= x, SK_"@setExpCDF(): The condition `0 <= x` must hold. x = "//getStr(x)) ! fpp
     106             : #elif   XMI_ENABLED
     107       14424 :         CHECK_ASSERTION(__LINE__, mu <= x, SK_"@setExpCDF(): The condition `mu <= x` must hold. mu, x = "//getStr([mu, x])) ! fpp
     108             : #else
     109             : #error  "Unrecognized interface."
     110             : #endif
     111             : 
     112             : #if     XDI_ENABLED || XMI_ENABLED
     113        5218 :         CHECK_ASSERTION(__LINE__, 0 < invSigma, SK_"@setExpCDF(): The condition `0 < invSigma` must hold. invSigma = "//getStr(invSigma)) ! fpp
     114             : #elif   !XDD_ENABLED
     115             : #error  "Unrecognized interface."
     116             : #endif
     117             : 
     118             :         ! Compute the CDF.
     119             : 
     120             : #if     XDD_ENABLED
     121         445 :         cdf = 1._TKC - exp(-x)
     122             : #elif   XDI_ENABLED
     123         410 :         cdf = 1._TKC - exp(-x * invSigma)
     124             : #elif   XMI_ENABLED
     125        4808 :         cdf = 1._TKC - exp(-(x - mu) * invSigma)
     126             : #else
     127             : #error  "Unrecognized interface."
     128             : #endif
     129             : 
     130             :         !%%%%%%%%%%%%%%%%%
     131             : #elif   getExpRand_ENABLED
     132             :         !%%%%%%%%%%%%%%%%%
     133             : 
     134      402006 :         call setUnifRand(rand)
     135      402006 :         rand = 1._TKC - rand
     136      402006 :         call setExpRand(rand, sigma)
     137      402006 :         if (present(mu)) rand = rand + mu
     138             : 
     139             :         !%%%%%%%%%%%%%%%%%
     140             : #elif   setExpRand_ENABLED
     141             :         !%%%%%%%%%%%%%%%%%
     142             : 
     143      844068 :         CHECK_ASSERTION(__LINE__, 0 < rand, SK_"@setExpRand(): The condition `0 < rand` must hold. rand = "//getStr(rand)) ! fpp
     144      844068 :         CHECK_ASSERTION(__LINE__, rand <= 1, SK_"@setExpRand(): The condition `rand <= 1` must hold. rand = "//getStr(rand)) ! fpp
     145             : #if     SD_ENABLED || SM_ENABLED
     146      804037 :         CHECK_ASSERTION(__LINE__, 0 < sigma, SK_"@setExpRand(): The condition `0 < sigma` must hold. sigma = "//getStr(sigma)) ! fpp
     147             : #endif
     148             : #if     DD_ENABLED
     149       40031 :         rand = -log(rand)
     150             : #elif   SD_ENABLED
     151      602037 :         rand = -log(rand) * sigma
     152             : #elif   SM_ENABLED
     153      202000 :         rand = -log(rand) * sigma + mu
     154             : #else
     155             : #error  "Unrecognized interface."
     156             : #endif
     157             : 
     158             : #else
     159             :         !%%%%%%%%%%%%%%%%%%%%%%%%
     160             : #error  "Unrecognized interface."
     161             :         !%%%%%%%%%%%%%%%%%%%%%%%%
     162             : #endif

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