36 integer(
IK) :: np
= 10
37 integer(
IK) :: HubMinDistEdgeIndex(
10)
= [
5,
8,
7,
7,
10,
9,
3,
2,
3,
5]
38 real(
RK) :: HubMinDistEdgeLenSq(
10)
= [
0.693595837531895E-1_RK &
39 ,
0.411631653715387E-2_RK &
40 ,
0.324022691025059E-2_RK &
41 ,
0.122396412769469E-1_RK &
42 ,
0.106512144573307E-1_RK &
43 ,
0.442485474967571000_RK &
44 ,
0.324022691025059E-2_RK &
45 ,
0.411631653715387E-2_RK &
46 ,
0.375960647686508E-1_RK &
47 ,
0.106512144573307E-1_RK &
49 integer(
IK) :: HubNodeIndex(
7)
= [
3,
7,
5,
2,
9,
10,
8]
50 integer(
IK) :: HubEdgeCount(
7)
= [
2,
2,
2,
1,
1,
1,
1]
51 type(IV),
allocatable :: HubEdgeIndex(:)
52 type(RV),
allocatable :: HubEdgeLenSq(:)
53 real(
RK) :: Point(
2,
10)
= reshape( [
0.278498218867048_RK,
0.421761282626275_RK &
54 ,
0.546881519204984_RK,
0.915735525189067_RK &
55 ,
0.957506835434298_RK,
0.792207329559554_RK &
56 ,
0.964888535199277_RK,
0.959492426392903_RK &
57 ,
0.157613081677548_RK,
0.655740699156587_RK &
58 ,
0.970592781760616_RK,
0.035711678574190_RK &
59 ,
0.957166948242946_RK,
0.849129305868777_RK &
60 ,
0.485375648722841_RK,
0.933993247757551_RK &
61 ,
0.800280468888800_RK,
0.678735154857773_RK &
62 ,
0.141886338627215_RK,
0.757740130578333_RK &
64 real(
RK) :: Dist(
10,
10)
= reshape( [
0._RK &
65 ,
0.562174482003378_RK &
66 ,
0.773487540339897_RK &
67 ,
0.871944063189390_RK &
68 ,
0.263362077287504_RK &
69 ,
0.792482921440967_RK &
70 ,
0.802019121669115_RK &
71 ,
0.552430861815293_RK &
72 ,
0.581628994675654_RK &
73 ,
0.362690766485521_RK &
74 ,
0.562174482003378_RK &
76 ,
0.428803411185017_RK &
77 ,
0.420291008496988_RK &
78 ,
0.468110271216848_RK &
79 ,
0.976715518780844_RK &
80 ,
0.415656735459690_RK &
81 ,
0.064158526613022_RK &
82 ,
0.346958503625479_RK &
83 ,
0.434722487351898_RK &
84 ,
0.773487540339897_RK &
85 ,
0.428803411185017_RK &
87 ,
0.167447881784044_RK &
88 ,
0.811451266874729_RK &
89 ,
0.756608823601091_RK &
90 ,
0.056922991051512_RK &
91 ,
0.492961564490394_RK &
92 ,
0.193897046828080_RK &
93 ,
0.816348444365176_RK &
94 ,
0.871944063189390_RK &
95 ,
0.420291008496988_RK &
96 ,
0.167447881784044_RK &
98 ,
0.862530445641055_RK &
99 ,
0.923798359204721_RK &
100 ,
0.110632912268217_RK &
101 ,
0.480190395997296_RK &
102 ,
0.325454237972598_RK &
103 ,
0.847370405683894_RK &
104 ,
0.263362077287504_RK &
105 ,
0.468110271216848_RK &
106 ,
0.811451266874729_RK &
107 ,
0.862530445641055_RK &
109 ,
1.022434339755630_RK &
110 ,
0.822608982898776_RK &
111 ,
0.429945090865161_RK &
112 ,
0.643078623169773_RK &
113 ,
0.103204721100010_RK &
114 ,
0.792482921440967_RK &
115 ,
0.976715518780844_RK &
116 ,
0.756608823601091_RK &
117 ,
0.923798359204721_RK &
118 ,
1.02243433975563_RK &
120 ,
0.813528419539970_RK &
121 ,
1.020953203495600_RK &
122 ,
0.665195817009978_RK &
123 ,
1.099126678046850_RK &
124 ,
0.802019121669115_RK &
125 ,
0.415656735459690_RK &
126 ,
0.056922991051512_RK &
127 ,
0.110632912268217_RK &
128 ,
0.822608982898776_RK &
129 ,
0.813528419539970_RK &
131 ,
0.479363034594627_RK &
132 ,
0.231619373332412_RK &
133 ,
0.820386770843889_RK &
134 ,
0.552430861815293_RK &
135 ,
0.064158526613022_RK &
136 ,
0.492961564490394_RK &
137 ,
0.480190395997296_RK &
138 ,
0.429945090865161_RK &
139 ,
1.020953203495600_RK &
140 ,
0.479363034594627_RK &
142 ,
0.405366179835696_RK &
143 ,
0.386070029224440_RK &
144 ,
0.581628994675654_RK &
145 ,
0.346958503625479_RK &
146 ,
0.193897046828080_RK &
147 ,
0.325454237972598_RK &
148 ,
0.643078623169773_RK &
149 ,
0.665195817009978_RK &
150 ,
0.231619373332412_RK &
151 ,
0.405366179835696_RK &
153 ,
0.663117347798649_RK &
154 ,
0.362690766485521_RK &
155 ,
0.434722487351898_RK &
156 ,
0.816348444365176_RK &
157 ,
0.847370405683894_RK &
158 ,
0.103204721100010_RK &
159 ,
1.099126678046850_RK &
160 ,
0.820386770843889_RK &
161 ,
0.386070029224440_RK &
162 ,
0.663117347798649_RK &
189 call test%summarize()
199 TestData%HubEdgeIndex(
1)
%val
= [
7,
9]
200 TestData%HubEdgeIndex(
2)
%val
= [
3,
4]
201 TestData%HubEdgeIndex(
3)
%val
= [
1,
10]
207 TestData%HubEdgeLenSq(
1)
%val
= [
0.324022691025059E-2_RK,
0.375960647686508E-1_RK]
208 TestData%HubEdgeLenSq(
2)
%val
= [
0.324022691025059E-2_RK,
0.122396412769469E-1_RK]
209 TestData%HubEdgeLenSq(
3)
%val
= [
0.693595837531895E-1_RK,
0.106512144573307E-1_RK]
210 TestData%HubEdgeLenSq(
4)
%val
= [
0.411631653715387E-2_RK]
211 TestData%HubEdgeLenSq(
5)
%val
= [
0.442485474967571_RK]
212 TestData%HubEdgeLenSq(
6)
%val
= [
0.106512144573307E-1_RK]
213 TestData%HubEdgeLenSq(
7)
%val
= [
0.411631653715387E-2_RK]
221 logical(
LK) :: assertion
222 real(
RK),
parameter :: Point1(
*)
= [
0._RK,
1._RK,
2._RK,
3._RK,
4._RK]
223 real(
RK),
parameter :: Point2(
*)
= Point1
+ 1._RK
224 real(
RK),
parameter :: tolerance
= 1.e-10_RK
225 real(
RK),
parameter :: distanceSq_ref
= norm2(Point2
-Point1)
**2
226 real(
RK) :: distanceSq
227 real(
RK) :: difference
228 distanceSq
= getDisEuclid(point1, point2, euclidsq)
229 difference
= abs(distanceSq
- distanceSq_ref)
/ distanceSq_ref
230 assertion
= difference
< tolerance
231 if (
test%traceable
.and. .not. assertion)
then
233 write(
test%disp
%unit,
"(*(g0,:,' '))")
234 write(
test%disp
%unit,
"(*(g0,:,' '))")
"distanceSq_ref = ", distanceSq_ref
235 write(
test%disp
%unit,
"(*(g0,:,' '))")
"distanceSq = ", distanceSq
236 write(
test%disp
%unit,
"(*(g0,:,' '))")
"difference = ", difference
237 write(
test%disp
%unit,
"(*(g0,:,' '))")
249 logical(
LK) :: assertion
250 real(
RK),
allocatable :: Dist(:,:)
251 real(
RK),
allocatable :: diff(:,:)
252 real(
RK),
parameter :: tolerance
= 1.e-10_RK
253 integer(
IK) :: ip, jp
255 assertion
= .true._LK
258 diff
= abs( (Dist
- TestData%Dist) )
260 assertion
= all( diff
< tolerance )
262 if (
test%traceable
.and. .not. assertion)
then
264 write(
test%disp
%unit,
"(*(g0.15,:,' '))")
265 write(
test%disp
%unit,
"(*(g0.15,:,' '))")
"Distance, Distance_ref, diff"
268 write(
test%disp
%unit,
"(*(g0.15,:,' '))") Dist(ip,jp),
TestData%Dist(ip,jp), diff(ip,jp)
271 write(
test%disp
%unit,
"(*(g0.15,:,' '))")
284 logical(
LK) :: assertion
285 real(
RK),
allocatable :: diff(:)
286 real(
RK),
allocatable :: RefPoint(:)
287 real(
RK),
allocatable :: disSortedExpDiff(:)
288 real(
RK),
parameter :: DistSortedExpDiff_ref(
*)
= [
0.05518433594135580_RK &
289 ,
0.06693027963675390_RK &
290 ,
0.01936935163401820_RK &
291 ,
0.03354993653506870_RK &
292 ,
0.01353010700222810_RK &
293 ,
0.00611135862293311_RK &
294 ,
0.10002225854507400_RK &
295 ,
0.03619526286475090_RK &
296 ,
0.09636174928998410_RK &
297 ,
0.00976657158542438_RK &
299 real(
RK),
parameter :: tolerance
= 1.e-10_RK
300 integer(
IK),
allocatable ::
index(:)
304 assertion
= .true._LK
306 if (
allocated(RefPoint))
deallocate(RefPoint)
307 allocate(RefPoint(
TestData%nd),
source = 0.5_RK)
308 if (
allocated(disSortedExpDiff))
deallocate(disSortedExpDiff)
309 allocate(disSortedExpDiff(
TestData%np))
310 if (
allocated(index))
deallocate(index)
313 call setDisSortedExpDiff( nd
= TestData%nd
&
316 , RefPoint
= RefPoint
&
317 , disSortedExpDiff
= disSortedExpDiff
&
320 assertion
= .not. err
%occurred
321 call test%assert(assertion)
323 diff
= abs( (disSortedExpDiff
- DistSortedExpDiff_ref) )
324 assertion
= all( diff
< tolerance )
325 call test%assert(assertion)
327 if (
test%traceable
.and. .not. assertion)
then
329 write(
test%disp
%unit,
"(*(g0.15,:,' '))")
330 write(
test%disp
%unit,
"(*(g0.15,:,' '))")
"disSortedExpDiff, DistSortedExpDiff_ref, diff"
332 write(
test%disp
%unit,
"(*(g0.15,:,' '))") disSortedExpDiff(ip), DistSortedExpDiff_ref(ip), diff(ip)
334 write(
test%disp
%unit,
"(*(g0.15,:,' '))")
347 logical(
LK) :: assertion
348 real(
RK),
allocatable :: diff(:)
349 real(
RK),
allocatable :: RefPoint(:)
350 real(
RK),
allocatable :: disSortedExpDiff(:)
351 real(
RK),
parameter :: DistSortedExpDiff_ref(
*)
= [
0.0000000000000000_RK &
352 ,
0.0693595837531895_RK &
353 ,
0.0621850083406652_RK &
354 ,
0.1736352649921330_RK &
355 ,
0.0108602911297795_RK &
356 ,
0.0222521392316455_RK &
357 ,
0.2599906876136520_RK &
358 ,
0.0297462057145467_RK &
359 ,
0.0152054907472889_RK &
360 ,
0.1170517778083240_RK &
362 real(
RK),
parameter :: tolerance
= 1.e-10_RK
363 integer(
IK),
allocatable ::
index(:)
367 assertion
= .true._LK
369 if (
allocated(RefPoint))
deallocate(RefPoint)
371 if (
allocated(disSortedExpDiff))
deallocate(disSortedExpDiff)
372 allocate(disSortedExpDiff(
TestData%np))
373 if (
allocated(index))
deallocate(index)
376 call setDisSortedExpDiff( nd
= TestData%nd
&
379 , RefPoint
= RefPoint
&
380 , disSortedExpDiff
= disSortedExpDiff
&
383 assertion
= .not. err
%occurred
384 call test%assert(assertion)
386 diff
= abs( (disSortedExpDiff
- DistSortedExpDiff_ref) )
387 assertion
= all( diff
< tolerance )
388 call test%assert(assertion)
390 if (
test%traceable
.and. .not. assertion)
then
392 write(
test%disp
%unit,
"(*(g0.15,:,' '))")
393 write(
test%disp
%unit,
"(*(g0.15,:,' '))")
"disSortedExpDiff, DistSortedExpDiff_ref, diff"
395 write(
test%disp
%unit,
"(*(g0.15,:,' '))") disSortedExpDiff(ip), DistSortedExpDiff_ref(ip), diff(ip)
397 write(
test%disp
%unit,
"(*(g0.15,:,' '))")
410 logical(
LK) :: assertion
411 real(
RK),
allocatable :: diff(:)
412 real(
RK),
allocatable :: Point(:)
413 real(
RK),
allocatable :: RefPoint(:)
414 real(
RK),
allocatable :: disSortedExpDiff(:)
415 real(
RK),
parameter :: DistSortedExpDiff_ref(
*)
= [
0.000000000000000000_RK &
416 ,
0.120885137189500000_RK &
417 ,
0.015726743050333000_RK &
418 ,
0.070265549615960000_RK &
419 ,
0.061505870482143000_RK &
420 ,
0.253398949683816000_RK &
421 ,
0.156886479354146000_RK &
422 ,
0.000339887191352029_RK &
423 ,
0.007381699764978930_RK &
424 ,
0.005704246561339060_RK &
426 real(
RK),
parameter :: tolerance
= 1.e-10_RK
427 integer(
IK),
allocatable ::
index(:)
431 assertion
= .true._LK
433 if (
allocated(RefPoint))
deallocate(RefPoint)
435 if (
allocated(disSortedExpDiff))
deallocate(disSortedExpDiff)
436 allocate(disSortedExpDiff(
TestData%np))
437 if (
allocated(index))
deallocate(index)
441 call setDisSortedExpDiff( nd
= 1_IK &
444 , RefPoint
= RefPoint
&
445 , disSortedExpDiff
= disSortedExpDiff
&
448 assertion
= .not. err
%occurred
449 call test%assert(assertion)
451 diff
= abs( (disSortedExpDiff
- DistSortedExpDiff_ref) )
452 assertion
= all( diff
< tolerance )
453 call test%assert(assertion)
455 if (
test%traceable
.and. .not. assertion)
then
457 write(
test%disp
%unit,
"(*(g0.15,:,' '))")
458 write(
test%disp
%unit,
"(*(g0.15,:,' '))")
"disSortedExpDiff, DistSortedExpDiff_ref, diff"
460 write(
test%disp
%unit,
"(*(g0.15,:,' '))") disSortedExpDiff(ip), DistSortedExpDiff_ref(ip), diff(ip)
462 write(
test%disp
%unit,
"(*(g0.15,:,' '))")
475 logical(
LK) :: assertion
476 real(
RK),
parameter :: tolerance
= 1.e-10_RK
477 type(hub_type) :: Hub
480 assertion
= .true._LK
486 assertion
= .not. Hub
%err
%occurred
487 call test%assert(assertion)
489 assertion
= assertion
.and. all( Hub
%minDisEdge
%index
%val
== TestData%HubMinDistEdgeIndex )
490 if (
test%traceable
.and. .not. assertion)
then
492 write(
test%disp
%unit,
"(*(g0.15,:,' '))")
493 write(
test%disp
%unit,
"(*(g0.15,:,' '))")
"Hub%minDisEdge%index ", Hub
%minDisEdge
%index
%val
494 write(
test%disp
%unit,
"(*(g0.15,:,' '))")
"TestData%HubMinDistEdgeIndex ",
TestData%HubMinDistEdgeIndex
495 write(
test%disp
%unit,
"(*(g0.15,:,' '))")
498 call test%assert(assertion)
500 assertion
= assertion
.and. all( abs((Hub
%minDisEdge
%LenSq
%val
- TestData%HubMinDistEdgeLenSq)
/TestData%HubMinDistEdgeLenSq)
< tolerance )
501 if (
test%traceable
.and. .not. assertion)
then
503 write(
test%disp
%unit,
"(*(g0.15,:,' '))")
504 write(
test%disp
%unit,
"(*(g0.15,:,' '))")
"Hub%minDisEdge%LenSq ", Hub
%minDisEdge
%LenSq
%val
505 write(
test%disp
%unit,
"(*(g0.15,:,' '))")
"TestData%HubMinDistEdgeLenSq ",
TestData%HubMinDistEdgeLenSq
506 write(
test%disp
%unit,
"(*(g0.15,:,' '))")
509 call test%assert(assertion)
511 assertion
= assertion
.and. all( Hub
%NodeIndex
== TestData%HubNodeIndex )
512 if (
test%traceable
.and. .not. assertion)
then
514 write(
test%disp
%unit,
"(*(g0.15,:,' '))")
515 write(
test%disp
%unit,
"(*(g0.15,:,' '))")
"Hub%NodeIndex ", Hub
%NodeIndex
516 write(
test%disp
%unit,
"(*(g0.15,:,' '))")
"TestData%HubNodeIndex",
TestData%HubNodeIndex
517 write(
test%disp
%unit,
"(*(g0.15,:,' '))")
520 call test%assert(assertion)
522 assertion
= assertion
.and. all( Hub
%EdgeCount
== TestData%HubEdgeCount )
523 if (
test%traceable
.and. .not. assertion)
then
525 write(
test%disp
%unit,
"(*(g0.15,:,' '))")
526 write(
test%disp
%unit,
"(*(g0.15,:,' '))")
"Hub%EdgeCount ", Hub
%EdgeCount
527 write(
test%disp
%unit,
"(*(g0.15,:,' '))")
"TestData%HubEdgeCount",
TestData%HubEdgeCount
528 write(
test%disp
%unit,
"(*(g0.15,:,' '))")
531 call test%assert(assertion)
534 assertion
= assertion
.and. all(Hub
%EdgeIndex(i)
%val
== TestData%HubEdgeIndex(i)
%val)
535 if (
test%traceable
.and. .not. assertion)
then
537 write(
test%disp
%unit,
"(*(g0.15,:,' '))")
538 write(
test%disp
%unit,
"(*(g0.15,:,' '))")
"Hub%EdgeIndex(i)%val ", Hub
%EdgeIndex(i)
%val
539 write(
test%disp
%unit,
"(*(g0.15,:,' '))")
"TestData%HubEdgeIndex(i)%val ",
TestData%HubEdgeIndex(i)
%val
540 write(
test%disp
%unit,
"(*(g0.15,:,' '))")
543 if (
.not. assertion)
exit
545 call test%assert(assertion)
548 assertion
= assertion
.and. all( abs((Hub
%EdgeLenSq(i)
%val
- TestData%HubEdgeLenSq(i)
%val)
/TestData%HubEdgeLenSq(i)
%val)
< tolerance )
549 if (
test%traceable
.and. .not. assertion)
then
551 write(
test%disp
%unit,
"(*(g0.15,:,' '))")
552 write(
test%disp
%unit,
"(*(g0.15,:,' '))")
"Hub%EdgeLenSq(i)%val ", Hub
%EdgeLenSq(i)
%val
553 write(
test%disp
%unit,
"(*(g0.15,:,' '))")
"TestData%HubEdgeLenSq(i)%val ",
TestData%HubEdgeLenSq(i)
%val
554 write(
test%disp
%unit,
"(*(g0.15,:,' '))")
557 if (
.not. assertion)
exit
Return the full or a subset of the Euclidean (squared) distance matrix of the input set of npnt point...
This module contains the derived types for generating allocatable containers of scalar,...
This module contains procedures and generic interfaces for computing the Euclidean norm of a single p...
type(euclidsq_type), parameter euclidsq
This is a scalar parameter object of type euclidsq_typethat is exclusively used to request computing ...
This module contains classes and procedures for reporting and handling errors.
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
integer, parameter RK
The default real kind in the ParaMonte library: real64 in Fortran, c_double in C-Fortran Interoperati...
integer, parameter LK
The default logical kind in the ParaMonte library: kind(.true.) in Fortran, kind(....
integer, parameter IK
The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in C-Fortran Interoper...
This module contains procedures and generic interfaces for computing the nearest neighbor statistics ...
character(*, SK), parameter MODULE_NAME
This module contains a simple unit-testing framework for the Fortran libraries, including the ParaMon...
This module contains tests of the module pm_knn.
logical(LK) function test_getDistSortedExpDiff_1()
Test setDisSortedExpDiff() for an even value of nd.
type(TestData_type) function contructTestData()
logical(LK) function test_getDistSortedExpDiff_2()
Test setDisSortedExpDiff() for an even value of nd but with a reference point from within input set o...
logical(LK) function test_getEucDistSq_1()
type(TestData_type) TestData
logical(LK) function test_getHub_1()
Test getHub().
logical(LK) function test_getPairDistSq_1()
Test getPairDistSq().
logical(LK) function test_getDistSortedExpDiff_3()
Test setDisSortedExpDiff() for an odd value of nd with a reference point from within input set of poi...
This is the parameterized derived type for generating a container of a vector component of type integ...
This is the parameterized derived type for generating a container of an allocatable vector component ...
This is the derived type for generating objects to gracefully and verbosely handle runtime unexpected...
This is the derived type test_type for generating objects that facilitate testing of a series of proc...