ParaMonte Fortran 2.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
test_pm_polation.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
24
25!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
26
28
29 use pm_polation
30 use pm_err, only: err_type
31 use pm_test, only: test_type, LK
32 implicit none
33
34 private
35 public :: setTest
36 type(test_type) :: test
37
38 real(RK), parameter :: SortedX(*) = [ +3.178053830347950_RK &
39 , +3.218875824868200_RK &
40 , +3.295836866004330_RK &
41 , +3.433987204485150_RK &
42 , +3.663561646129650_RK &
43 , +4.007333185232470_RK &
44 , +4.465908118654580_RK &
45 , +5.017279836814920_RK &
46 , +5.631211781821370_RK &
47 , +6.282266746896010_RK &
48 , +6.953684210870540_RK &
49 , +7.635786861395590_RK &
50 , +8.323365694436080_RK &
51 , +9.013717030471370_RK &
52 , +9.705463352014880_RK ]
53 real(RK), parameter :: SortedY(*) = [ +1.426588681046810_RK &
54 , +1.168902956625920_RK &
55 , +0.882431985413412_RK &
56 , +0.587833620221075_RK &
57 , +0.229810034869442_RK &
58 , -0.174864514871957_RK &
59 , -0.605947339379271_RK &
60 , -1.074884950466410_RK &
61 , -1.510025316819630_RK &
62 , -1.948747191172130_RK &
63 , -2.382173017436780_RK &
64 , -2.805304379208950_RK &
65 , -3.199663563773090_RK &
66 , -3.602191628213170_RK &
67 , -3.989064786493580_RK ]
68
69!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
70
71contains
72
73!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
74
75 subroutine setTest()
76
78 call test%run(test_InterpLinear_type_1, SK_"test_InterpLinear_type_1")
79 call test%summarize()
80
81 end subroutine setTest
82
83!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
84
85 function test_InterpLinear_type_1() result(assertion)
86
87 use pm_kind, only: RK, IK, LK
88
89 implicit none
90
91 logical(LK) :: assertion
92 real(RK), parameter :: TOLERANCE = 1.e-10_RK
93 real(RK), parameter :: QueryX(*) = [ +3.17805383034795_RK &
94 , +7.61283103040736_RK &
95 , +8.30003171177958_RK &
96 , +8.70350676947973_RK &
97 , +8.99019232964177_RK &
98 , +9.21273749657591_RK &
99 , +9.39465993143281_RK &
100 , +9.54852542660107_RK &
101 , +9.68184287734565_RK &
102 , +9.79945948211208_RK ]
103 real(RK), parameter :: QueryY_ref(*) = [ +1.42658868104681_RK &
104 , -2.79106410024333_RK &
105 , -3.18628041418956_RK &
106 , -3.42131512460047_RK &
107 , -3.58847491355328_RK &
108 , -3.71349785982781_RK &
109 , -3.81524167073542_RK &
110 , -3.90129406915411_RK &
111 , -3.97585455703407_RK &
112 , -4.04163402840252_RK ]
113 real(RK) :: QueryY(size(QueryX))
114 type(InterpLinear_type) :: Interp
115
116 Interp = InterpLinear_type(SortedX, SortedY)
117 QueryY = Interp%predict(QueryX)
118 assertion = all(abs(QueryY - QueryY_ref) <= TOLERANCE)
119
120 if (test%traceable .and. .not. assertion) then
121 ! LCOV_EXCL_START
122 write(test%disp%unit,"(*(g0,:,', '))")
123 write(test%disp%unit,"(*(g0,:,', '))") "QueryY_ref ", QueryY_ref
124 write(test%disp%unit,"(*(g0,:,', '))") "QueryY ", QueryY
125 write(test%disp%unit,"(*(g0,:,', '))") "diff ", QueryY_ref - QueryY
126 write(test%disp%unit,"(*(g0,:,', '))")
127 ! LCOV_EXCL_STOP
128 end if
129
130 end function test_InterpLinear_type_1
131
132!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
133
134end module test_pm_polation
This module contains classes and procedures for reporting and handling errors.
Definition: pm_err.F90:52
character(*, SK), parameter MODULE_NAME
Definition: pm_err.F90:58
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
Definition: pm_kind.F90:268
integer, parameter RK
The default real kind in the ParaMonte library: real64 in Fortran, c_double in C-Fortran Interoperati...
Definition: pm_kind.F90:543
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
This module contains procedures and data types for interpolation of finite samples of data.
This module contains a simple unit-testing framework for the Fortran libraries, including the ParaMon...
Definition: pm_test.F90:42
This module contains tests of the module pm_polation.
real(RK), dimension(*), parameter SortedY
type(test_type) test
logical(LK) function test_InterpLinear_type_1()
subroutine setTest()
real(RK), dimension(*), parameter SortedX
This is the derived type for generating objects to gracefully and verbosely handle runtime unexpected...
Definition: pm_err.F90:157
This is the derived type test_type for generating objects that facilitate testing of a series of proc...
Definition: pm_test.F90:209