ParaMonte Fortran 2.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
pm_ziggurat.F90
Go to the documentation of this file.
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
40
41!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42
44
45 use pm_kind, only: SK, IK, LK
46
47 implicit none
48
49 character(*, SK), parameter :: MODULE_NAME = "@pm_ziggurat"
50
51!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
52
156 ! \example{getZig}
157 ! \include{lineno} example/pm_ziggurat/getZig/main.F90
158 ! \compile{getZig}
159 ! \output{getZig}
160 ! \include{lineno} example/pm_ziggurat/getZig/main.out.F90
161 ! \postproc{getZig}
162 ! \include{lineno} example/pm_ziggurat/getZig/main.py
163 ! \vis{getZig}
164 ! \image html pm_ziggurat/getZig/getZig.RK.png width=700
177 interface getZig
178
179 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
180
181#if RK5_ENABLED
182 impure module function getZig_RK5(nlay, getFunc, getFuncInv, getZigArea, abserr, abstol) result(zig)
183#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
184 !DEC$ ATTRIBUTES DLLEXPORT :: getZig_RK5
185#endif
186 use pm_kind, only: RKG => RK5
187 procedure(real(RKG)) :: getFunc, getFuncInv, getZigArea
188 integer(IK) , intent(in) :: nlay
189 real(RKG) , intent(out) :: abserr
190 real(RKG) , intent(in) , optional :: abstol
191 real(RKG) :: zig(2, 0 : nlay)
192 end function
193#endif
194
195#if RK4_ENABLED
196 impure module function getZig_RK4(nlay, getFunc, getFuncInv, getZigArea, abserr, abstol) result(zig)
197#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
198 !DEC$ ATTRIBUTES DLLEXPORT :: getZig_RK4
199#endif
200 use pm_kind, only: RKG => RK4
201 procedure(real(RKG)) :: getFunc, getFuncInv, getZigArea
202 integer(IK) , intent(in) :: nlay
203 real(RKG) , intent(out) :: abserr
204 real(RKG) , intent(in) , optional :: abstol
205 real(RKG) :: zig(2, 0 : nlay)
206 end function
207#endif
208
209#if RK3_ENABLED
210 impure module function getZig_RK3(nlay, getFunc, getFuncInv, getZigArea, abserr, abstol) result(zig)
211#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
212 !DEC$ ATTRIBUTES DLLEXPORT :: getZig_RK3
213#endif
214 use pm_kind, only: RKG => RK3
215 procedure(real(RKG)) :: getFunc, getFuncInv, getZigArea
216 integer(IK) , intent(in) :: nlay
217 real(RKG) , intent(out) :: abserr
218 real(RKG) , intent(in) , optional :: abstol
219 real(RKG) :: zig(2, 0 : nlay)
220 end function
221#endif
222
223#if RK2_ENABLED
224 impure module function getZig_RK2(nlay, getFunc, getFuncInv, getZigArea, abserr, abstol) result(zig)
225#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
226 !DEC$ ATTRIBUTES DLLEXPORT :: getZig_RK2
227#endif
228 use pm_kind, only: RKG => RK2
229 procedure(real(RKG)) :: getFunc, getFuncInv, getZigArea
230 integer(IK) , intent(in) :: nlay
231 real(RKG) , intent(out) :: abserr
232 real(RKG) , intent(in) , optional :: abstol
233 real(RKG) :: zig(2, 0 : nlay)
234 end function
235#endif
236
237#if RK1_ENABLED
238 impure module function getZig_RK1(nlay, getFunc, getFuncInv, getZigArea, abserr, abstol) result(zig)
239#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
240 !DEC$ ATTRIBUTES DLLEXPORT :: getZig_RK1
241#endif
242 use pm_kind, only: RKG => RK1
243 procedure(real(RKG)) :: getFunc, getFuncInv, getZigArea
244 integer(IK) , intent(in) :: nlay
245 real(RKG) , intent(out) :: abserr
246 real(RKG) , intent(in) , optional :: abstol
247 real(RKG) :: zig(2, 0 : nlay)
248 end function
249#endif
250
251 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
252
253 end interface
254
255!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
256
257! !> \brief
258! !> Generate and return an array of coordinates of the lower rightmost corners of rectangles corresponding to an input Ziggurat set,
259! !> including the highest point of the target density function.
260! !>
261! !> \brief
262! !> This is merely a convenience generic interface.<br>
263! !> The functionality of this interface can be identically generated via the expression
264! !> \code{.F90}
265! !> crd = transpose(reshape(zig(1:), [size(zig) / 2, 2]))
266! !> \endcode
267! !> assuming the starting index of `zig` is `0`.<br>
268! !>
269! !> \param[in] zig : The input vector of size `(0 : nlay * 2)` of type `real` of kind \RKALL,
270! !> that is the direct output of [getZig](@ref pm_ziggurat::getZig) or similar generic interfaces.<br>
271! !>
272! !> \return
273! !> `crd` : The output vector of shape `(2, nlay)` of the same type and kind as `zig`,
274! !> containing the Ziggurat rectangle lower-corner coordinates.<br>
275! !>
276! !> \interface{getZigCRD}
277! !> \code{.F90}
278! !>
279! !> use pm_ziggurat, only: getZigCRD
280! !>
281! !> crd(1:2, 1:size(zig)/2) = getZigCRD(zig)
282! !>
283! !> \endcode
284! !>
285! !> \warning
286! !> The condition `mod(size(zig), 2) == 1` must hold for the corresponding input arguments.<br>
287! !> \vericon
288! !>
289! !> \impure
290! !>
291! !> \see
292! !> [getZig](@ref pm_ziggurat::getZig)<br>
293! !> [getZigNorm](@ref pm_distNorm::getZigNorm)<br>
294! !>
295! ! \example{getZigCRD}
296! ! \include{lineno} example/pm_ziggurat/getZigCRD/main.F90
297! ! \compile{getZigCRD}
298! ! \output{getZigCRD}
299! ! \include{lineno} example/pm_ziggurat/getZigCRD/main.out.F90
300! ! \postproc{getZigCRD}
301! ! \include{lineno} example/pm_ziggurat/getZigCRD/main.py
302! ! \vis{getZigCRD}
303! ! \image html pm_ziggurat/getZigCRD/getZigCRD.RK.png width=700
304! !>
305! !> \test
306! !> [test_pm_ziggurat](@ref test_pm_ziggurat)<br>
307! !>
308! !> \todo
309! !> \pmed
310! !> Examples should be added to the documentation of this generic interface in future.<br>
311! !>
312! !> \final{getZigCRD}
313! !>
314! !> \author
315! !> \AmirShahmoradi, April 25, 2015, 2:21 PM, National Institute for Fusion Studies, The University of Texas Austin<br>
316! interface getZigCRD
317!
318! !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
319!
320!#if RK5_ENABLED
321! impure module function getZigCRD_RK5(zig) result(crd)
322!#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
323! !DEC$ ATTRIBUTES DLLEXPORT :: getZigCRD_RK5
324!#endif
325! use pm_kind, only: RKG => RK5
326! real(RKG) , intent(in) :: zig(0:)
327! real(RKG) :: crd(2, size(zig, 1, IK) / 2_IK)
328! end function
329!#endif
330!
331!#if RK4_ENABLED
332! impure module function getZigCRD_RK4(zig) result(crd)
333!#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
334! !DEC$ ATTRIBUTES DLLEXPORT :: getZigCRD_RK4
335!#endif
336! use pm_kind, only: RKG => RK4
337! real(RKG) , intent(in) :: zig(0:)
338! real(RKG) :: crd(2, size(zig, 1, IK) / 2_IK)
339! end function
340!#endif
341!
342!#if RK3_ENABLED
343! impure module function getZigCRD_RK3(zig) result(crd)
344!#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
345! !DEC$ ATTRIBUTES DLLEXPORT :: getZigCRD_RK3
346!#endif
347! use pm_kind, only: RKG => RK3
348! real(RKG) , intent(in) :: zig(0:)
349! real(RKG) :: crd(2, size(zig, 1, IK) / 2_IK)
350! end function
351!#endif
352!
353!#if RK2_ENABLED
354! impure module function getZigCRD_RK2(zig) result(crd)
355!#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
356! !DEC$ ATTRIBUTES DLLEXPORT :: getZigCRD_RK2
357!#endif
358! use pm_kind, only: RKG => RK2
359! real(RKG) , intent(in) :: zig(0:)
360! real(RKG) :: crd(2, size(zig, 1, IK) / 2_IK)
361! end function
362!#endif
363!
364!#if RK1_ENABLED
365! impure module function getZigCRD_RK1(zig) result(crd)
366!#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
367! !DEC$ ATTRIBUTES DLLEXPORT :: getZigCRD_RK1
368!#endif
369! use pm_kind, only: RKG => RK1
370! real(RKG) , intent(in) :: zig(0:)
371! real(RKG) :: crd(2, size(zig, 1, IK) / 2_IK)
372! end function
373!#endif
374!
375! !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
376!
377! end interface
378
379!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
380
381end module pm_ziggurat ! LCOV_EXCL_LINE
Generate and return a Ziggurat set for the specified distribution that can be subsequently used for r...
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
Definition: pm_kind.F90:268
integer, parameter RK5
Definition: pm_kind.F90:478
integer, parameter RK4
Definition: pm_kind.F90:489
integer, parameter RK2
Definition: pm_kind.F90:511
integer, parameter RK3
Definition: pm_kind.F90:500
integer, parameter LK
The default logical kind in the ParaMonte library: kind(.true.) in Fortran, kind(....
Definition: pm_kind.F90:541
integer, parameter IK
The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in C-Fortran Interoper...
Definition: pm_kind.F90:540
integer, parameter SK
The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in C-Fortran Intero...
Definition: pm_kind.F90:539
integer, parameter RK1
Definition: pm_kind.F90:522
This module contains procedures and generic interfaces for computing the Ziggurat set for for pseudo-...
Definition: pm_ziggurat.F90:43
character(*, SK), parameter MODULE_NAME
Definition: pm_ziggurat.F90:49