https://www.cdslab.org/paramonte/fortran/2
Current view: top level - main - pm_mathLogSubExp@routines.inc.F90 (source / functions) Hit Total Coverage
Test: ParaMonte 2.0.0 :: Serial Fortran - Code Coverage Report Lines: 2 5 40.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 procedure implementations of [pm_mathLogSubExp](@ref pm_mathLogSubExp).
      19             : !>
      20             : !>  \finmain
      21             : !>
      22             : !>  \author
      23             : !>  \AmirShahmoradi, Thursday 1:45 AM, August 22, 2019, Dallas, TX
      24             : 
      25             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      26             : 
      27             : #if     MM_ENABLED
      28             : #define smaller minMax(1)
      29             : #define larger minMax(2)
      30             : #elif   !SL_ENABLED
      31             : #error  "Unrecognized interface."
      32             : #endif
      33             :         use pm_math1mexp, only: get1mexp
      34             : #if     Sel_ENABLED && CK_ENABLED
      35             :         complex(CKC) :: logRatio
      36             : #define GET_REAL(x) x%re
      37             : #elif   Sel_ENABLED && RK_ENABLED
      38             :         real(RKC) :: logRatio
      39             : #define GET_REAL(x) x
      40             : #elif   !Seq_ENABLED
      41             : #error  "Unrecognized interface."
      42             : #endif
      43             :         integer, parameter :: TKC = kind(logSubExp) ! This kind current.
      44             :         real(TKC), parameter :: LOGTINY = log(tiny(0._TKC))
      45     1931088 :         CHECK_ASSERTION(__LINE__, real(smaller, TKC) < real(larger, TKC), \
      46             :         SK_"@getLogSubExp(): The condition `real(smaller) < real(larger)` must hold. smaller, larger = "//getStr([smaller, larger]))
      47             : #if     Seq_ENABLED
      48      643696 :         logSubExp = larger + log(get1mexp(smaller - larger)) ! log(1._TKC - exp(smaller - larger))
      49             :         !logSubExp = larger + log(1._TKC - exp(smaller - larger))
      50             : #elif   Sel_ENABLED
      51           0 :         logSubExp = larger
      52           0 :         logRatio = smaller - larger
      53           0 :         if (GET_REAL(logRatio) > LOGTINY) logSubExp = logSubExp + log(get1mexp(logRatio)) ! log(1._TKC - exp(logRatio))
      54             : #else
      55             : #error  "Unrecognized interface."
      56             : #endif
      57             : #undef  GET_REAL
      58             : #undef  smaller
      59             : #undef  larger

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