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_distBern](@ref pm_distBern).
19 : !>
20 : !> \finmain
21 : !>
22 : !> \author
23 : !> \FatemehBagheri, Wednesday 12:20 PM, September 22, 2021, Dallas, TX
24 :
25 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
26 :
27 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
28 : #if getBernRand_ENABLED || isHead_ENABLED
29 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
30 :
31 : #if PD_ENABLED
32 : real(RKC) :: urand
33 : #elif PS_ENABLED
34 58 : real(RKC) :: urand(size)
35 : #else
36 : #error "Unrecognized interface."
37 : #endif
38 480141 : call random_number(urand)
39 960166 : call setBernRand(rand, urand, p)
40 :
41 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42 : #elif setBernRand_ENABLED && RUP_ENABLED
43 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
44 :
45 6240155 : CHECK_ASSERTION(__LINE__, 0._RKC <= p .and. p <= 1._RKC, SK_": The condition `0. <= p .and. p <= 1.` must hold. p = "//getStr(p)) ! fpp
46 6240155 : CHECK_ASSERTION(__LINE__, 0._RKC <= urand .and. urand < 1._RKC, SK_": The condition `0. <= urand .and. urand < 1.` must hold. urand = "//getStr(urand)) ! fpp
47 :
48 : #if IK_ENABLED
49 2880024 : if (urand < p) then
50 1440267 : rand = 1_IKC
51 : else
52 1439757 : rand = 0_IKC
53 : end if
54 : #elif LK_ENABLED
55 2880125 : rand = logical(urand < p, kind = LKC)
56 : #elif RK_ENABLED
57 480006 : if (urand < p) then
58 239783 : rand = 1._RKC
59 : else
60 240223 : rand = 0._RKC
61 : end if
62 : #else
63 : #error "Unrecognized interface."
64 : #endif
65 :
66 : #else
67 : !%%%%%%%%%%%%%%%%%%%%%%%%
68 : #error "Unrecognized interface."
69 : !%%%%%%%%%%%%%%%%%%%%%%%%
70 : #endif
|