https://www.cdslab.org/paramonte/fortran/2
Current view: top level - main - pm_mathLogAddExp@routines.inc.F90 (source / functions) Hit Total Coverage
Test: ParaMonte 2.0.0 :: Serial Fortran - Code Coverage Report Lines: 5 14 35.7 %
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_mathLogAddExp](@ref pm_mathLogAddExp).
      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             : #if     CK_ENABLED
      34             :         complex(CKC), parameter :: ONE = cmplx(1._CKC, 0._CKC, CKC)
      35             :         complex(CKC)            :: ratio, y, z
      36             : #define GET_REAL(x) x%re
      37             : #elif   RK_ENABLED
      38             :         real(RKC)   , parameter :: ONE = 1._RKC
      39             :         real(RKC)               :: ratio, y, z
      40             : #define GET_REAL(x) x
      41             : #else
      42             : #error  "Unrecognized interface."
      43             : #endif
      44             :         integer     , parameter :: TKC = kind(logAddExp) ! This kind current.
      45             :         real(TKC)   , parameter :: LOGTINY = log(tiny(0._TKC))
      46             :         real(TKC)   , parameter :: LOGEPS = log(epsilon(0._TKC))
      47      144093 :         CHECK_ASSERTION(__LINE__, real(smaller, TKC) <= real(larger, TKC), \
      48             :         SK_"@getLogAddExp(): The condition `real(smaller) <= real(larger)` must hold. smaller, larger = "//getStr([smaller, larger]))
      49             : #if     Seq_ENABLED
      50       48031 :         ratio = exp(smaller - larger)
      51       48031 :         y = ONE + ratio
      52       48031 :         z = y - ONE
      53       48031 :         logAddExp = larger + log(y) - (z - ratio) / y
      54             : #elif   Sel_ENABLED
      55           0 :         logAddExp = larger
      56           0 :         ratio = smaller - larger
      57           0 :         if (GET_REAL(ratio) > LOGEPS) then
      58           0 :             logAddExp = logAddExp + log(ONE + exp(ratio))
      59           0 :         elseif (GET_REAL(ratio) > LOGTINY) then
      60           0 :             ratio = exp(ratio)
      61           0 :             y = ONE + ratio
      62           0 :             z = y - ONE
      63           0 :             logAddExp = logAddExp + log(y) - (z - ratio) / y
      64             :         end if
      65             : #else
      66             : #error  "Unrecognized interface."
      67             : #endif
      68             : 
      69             : #undef  GET_REAL
      70             : #undef  smaller
      71             : #undef  larger

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