https://www.cdslab.org/paramonte/fortran/2
Current view: top level - main - pm_sampleWeight@routines.inc.F90 (source / functions) Hit Total Coverage
Test: ParaMonte 2.0.0 :: Serial Fortran - Code Coverage Report Lines: 22 24 91.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 file contains the implementation details of the routines under the generic interfaces of [pm_sampleWeight](@ref pm_sampleWeight).
      19             : !>
      20             : !>  \finmain
      21             : !>
      22             : !>  \author
      23             : !>  \AmirShahmoradi, Saturday 2:33 AM, August 22, 2021, Dallas, TX
      24             : 
      25             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      26             : 
      27             : #if     IK_ENABLED
      28             : #define TYPE_OF_SKIP integer(IKC)
      29             : #elif   RK_ENABLED || IK_RK_ENABLED
      30             : #define TYPE_OF_SKIP real(RKC)
      31             : #else
      32             : #error  "Unrecognized interface."
      33             : #endif
      34             :         !%%%%%%%%%%%%%%%%%%
      35             : #if     getReweight_ENABLED
      36             :         !%%%%%%%%%%%%%%%%%%
      37             : 
      38          95 :         reweight = weight
      39          20 :         call setReweight(reweight, skip)
      40             : 
      41             :         !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      42             : #elif   setReweight_ENABLED && (IK_ENABLED || IK_RK_ENABLED)
      43             :         !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      44             : 
      45             :         TYPE_OF_SKIP :: current
      46             :         integer(IK) :: isam
      47           0 :         current = 0
      48         339 :         CHECK_ASSERTION(__LINE__, 0 < skip, SK_": The condition `0 < skip` must hold. skip = "//getStr(skip))
      49      440599 :         loopOverWeight: do isam = 1, size(weight, 1, IK)
      50      440599 :             if (0_IKC < weight(isam)) then
      51      440014 :                 current = current + weight(isam)
      52      440014 :                 weight(isam) = 0_IKC
      53      266087 :                 loopOverElement: do
      54      706101 :                     if (current < skip) exit loopOverElement
      55      266087 :                     weight(isam) = weight(isam) + 1_IKC
      56      706101 :                     current = current - skip
      57             :                 end do loopOverElement
      58             :             else
      59         246 :                 weight(isam) = 0_IKC
      60             :             end if
      61             :         end do loopOverWeight
      62             : 
      63             :         !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      64             : #elif   setReweight_ENABLED && RK_ENABLED
      65             :         !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      66             : 
      67             :         TYPE_OF_SKIP :: current
      68             :         integer(IK) :: isam
      69           0 :         current = 0
      70          20 :         CHECK_ASSERTION(__LINE__, 0 < skip, SK_": The condition `0 < skip` must hold. skip = "//getStr(skip))
      71         115 :         loopOverWeight: do isam = 1, size(weight, 1, IK)
      72         115 :             if (0._RKC < weight(isam)) then
      73          86 :                 current = current + weight(isam)
      74          86 :                 weight(isam) = 0._RKC
      75         217 :                 loopOverElement: do
      76         303 :                     if (current < skip) exit loopOverElement
      77         217 :                     weight(isam) = weight(isam) + 1._RKC
      78         303 :                     current = current - skip
      79             :                 end do loopOverElement
      80             :             else
      81           9 :                 weight(isam) = 0._RKC
      82             :             end if
      83             :         end do loopOverWeight
      84             : #else
      85             :         !%%%%%%%%%%%%%%%%%%%%%%%%
      86             : #error  "Unrecognized interface."
      87             :         !%%%%%%%%%%%%%%%%%%%%%%%%
      88             : #endif
      89             : #undef  TYPE_OF_SKIP

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