186 PURE module subroutine setKnnSortedVal_RK5(distance)
187#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
188 !DEC$ ATTRIBUTES DLLEXPORT :: setKnnSortedVal_RK5
191 real(RKG) ,
intent(inout) ,
contiguous :: distance(:,:)
196 PURE module subroutine setKnnSortedVal_RK4(distance)
197#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
198 !DEC$ ATTRIBUTES DLLEXPORT :: setKnnSortedVal_RK4
201 real(RKG) ,
intent(inout) ,
contiguous :: distance(:,:)
206 PURE module subroutine setKnnSortedVal_RK3(distance)
207#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
208 !DEC$ ATTRIBUTES DLLEXPORT :: setKnnSortedVal_RK3
211 real(RKG) ,
intent(inout) ,
contiguous :: distance(:,:)
216 PURE module subroutine setKnnSortedVal_RK2(distance)
217#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
218 !DEC$ ATTRIBUTES DLLEXPORT :: setKnnSortedVal_RK2
221 real(RKG) ,
intent(inout) ,
contiguous :: distance(:,:)
226 PURE module subroutine setKnnSortedVal_RK1(distance)
227#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
228 !DEC$ ATTRIBUTES DLLEXPORT :: setKnnSortedVal_RK1
231 real(RKG) ,
intent(inout) ,
contiguous :: distance(:,:)
238 PURE module subroutine setKnnSortedKth_RK5(distance, k)
239#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
240 !DEC$ ATTRIBUTES DLLEXPORT :: setKnnSortedKth_RK5
243 real(RKG) ,
intent(inout) ,
contiguous :: distance(:,:)
244 integer(IK) ,
intent(in) :: k
249 PURE module subroutine setKnnSortedKth_RK4(distance, k)
250#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
251 !DEC$ ATTRIBUTES DLLEXPORT :: setKnnSortedKth_RK4
254 real(RKG) ,
intent(inout) ,
contiguous :: distance(:,:)
255 integer(IK) ,
intent(in) :: k
260 PURE module subroutine setKnnSortedKth_RK3(distance, k)
261#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
262 !DEC$ ATTRIBUTES DLLEXPORT :: setKnnSortedKth_RK3
265 real(RKG) ,
intent(inout) ,
contiguous :: distance(:,:)
266 integer(IK) ,
intent(in) :: k
271 PURE module subroutine setKnnSortedKth_RK2(distance, k)
272#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
273 !DEC$ ATTRIBUTES DLLEXPORT :: setKnnSortedKth_RK2
276 real(RKG) ,
intent(inout) ,
contiguous :: distance(:,:)
277 integer(IK) ,
intent(in) :: k
282 PURE module subroutine setKnnSortedKth_RK1(distance, k)
283#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
284 !DEC$ ATTRIBUTES DLLEXPORT :: setKnnSortedKth_RK1
287 real(RKG) ,
intent(inout) ,
contiguous :: distance(:,:)
288 integer(IK) ,
intent(in) :: k
295 PURE module subroutine setKnnSortedInd_RK5(distance, rank)
296#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
297 !DEC$ ATTRIBUTES DLLEXPORT :: setKnnSortedInd_RK5
300 real(RKG) ,
intent(in) ,
contiguous :: distance(:,:)
301 integer(IK) ,
intent(out) ,
contiguous ::
rank(:,:)
306 PURE module subroutine setKnnSortedInd_RK4(distance, rank)
307#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
308 !DEC$ ATTRIBUTES DLLEXPORT :: setKnnSortedInd_RK4
311 real(RKG) ,
intent(in) ,
contiguous :: distance(:,:)
312 integer(IK) ,
intent(out) ,
contiguous ::
rank(:,:)
317 PURE module subroutine setKnnSortedInd_RK3(distance, rank)
318#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
319 !DEC$ ATTRIBUTES DLLEXPORT :: setKnnSortedInd_RK3
322 real(RKG) ,
intent(in) ,
contiguous :: distance(:,:)
323 integer(IK) ,
intent(out) ,
contiguous ::
rank(:,:)
328 PURE module subroutine setKnnSortedInd_RK2(distance, rank)
329#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
330 !DEC$ ATTRIBUTES DLLEXPORT :: setKnnSortedInd_RK2
333 real(RKG) ,
intent(in) ,
contiguous :: distance(:,:)
334 integer(IK) ,
intent(out) ,
contiguous ::
rank(:,:)
339 PURE module subroutine setKnnSortedInd_RK1(distance, rank)
340#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
341 !DEC$ ATTRIBUTES DLLEXPORT :: setKnnSortedInd_RK1
344 real(RKG) ,
intent(in) ,
contiguous :: distance(:,:)
345 integer(IK) ,
intent(out) ,
contiguous ::
rank(:,:)
357 type :: minDisEdge_type
363 end type minDisEdge_type
365 interface minDisEdge_type
366 module procedure :: getMinDisEdge
367 end interface minDisEdge_type
379 integer(IK) ,
allocatable :: nodeIndex(:)
380 integer(IK) ,
allocatable :: edgeCount(:)
381 type(IV) ,
allocatable :: edgeIndex(:)
382 type(RV) ,
allocatable :: edgeLenSq(:)
383 type(minDisEdge_type) :: minDisEdge
387 module procedure :: getHub
388 end interface hub_type
401 pure function getMinDisEdge(pairDisSq)
result(minDisEdge)
402#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
403 !DEC$ ATTRIBUTES DLLEXPORT :: getMinDisEdge
405 real(RK),
intent(in) :: pairDisSq(:,:)
406 type(minDisEdge_type) :: minDisEdge
408 integer(IK) :: pindex1
409 integer(IK) :: pindex2
410 integer(IK) :: npnt, jp
412 npnt
= size(pairDisSq,
1, IK)
413 CHECK_ASSERTION(__LINE__,
size(pairDisSq,
1, IK)
== size(pairDisSq,
2, IK), SK_
"@setKnnSorted(): The condition `size(pairDisSq, 1) == size(pairDisSq, 2)` must hold. shape(pairDisSq) = "//getStr([
shape(pairDisSq, IK)]))
415 allocate(minDisEdge
%index
%val(npnt), minDisEdge
%lenSq
%val(npnt))
416 minDisEdge
%npnt
= npnt
419 pindex2
= minloc(pairDisSq(
2:npnt, jp),
dim = 1,
kind = IK)
+ 1_IK
420 minDisEdge
%index
%val(jp)
= pindex2
421 minDisEdge
%lenSq
%val(jp)
= pairDisSq(pindex2,jp)
424 pindex1
= minloc(pairDisSq(
1:jp
-1, jp),
dim = 1,
kind = IK)
425 minDisEdge
%index
%val(jp)
= pindex1
426 minDisEdge
%lenSq
%val(jp)
= pairDisSq(pindex1,jp)
428 do concurrent(jp
= 2 : npnt
- 1)
429 pindex1
= minloc(pairDisSq(
1 : jp
- 1, jp),
dim = 1,
kind = IK)
430 pindex2
= minloc(pairDisSq(jp
+ 1 : npnt, jp),
dim = 1,
kind = IK)
+ jp
431 if (pairDisSq(pindex1,jp)
< pairDisSq(pindex2,jp))
then
432 minDisEdge
%index
%val(jp)
= pindex1
433 minDisEdge
%lenSq
%val(jp)
= pairDisSq(pindex1,jp)
435 minDisEdge
%index
%val(jp)
= pindex2
436 minDisEdge
%lenSq
%val(jp)
= pairDisSq(pindex2,jp)
440 end function getMinDisEdge
444 PURE function getHub(npnt, pairDisSq)
result(hub)
445#if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
446 !DEC$ ATTRIBUTES DLLEXPORT :: getHub
453 integer(IK) ,
intent(in) :: npnt
454 real(RK) ,
intent(in) :: pairDisSq(npnt,npnt)
455 type(hub_type) :: hub
457 character(
*, SK),
parameter :: PROCEDURE_NAME
= MODULE_NAME
//SK_
"@getHub()"
460 hub
%minDisEdge
= minDisEdge_type(npnt,pairDisSq)
461 call setUnique( Array
= hub
%minDisEdge
%index
%val
&
462 , Unique
= hub
%nodeIndex
&
463 , count
= hub
%edgeCount
&
464 , index
= hub
%edgeIndex
&
467 hub
%nh
= size(hub
%nodeIndex,
kind = IK)
468 allocate(hub
%edgeLenSq(hub
%nh))
469 do concurrent(ih
= 1:hub
%nh)
470 hub
%edgeLenSq(ih)
%val
= hub
%minDisEdge
%lenSq
%val(hub
%edgeIndex(ih)
%val)
508end module pm_knn ! LCOV_EXCL_LINE
Return a vector of unique values in the input array in place of the array itself.
Return the input distance matrix whose columns are sorted in ascending order on output,...
This module contains procedures and generic interfaces for finding unique values of an input array of...
This module contains the derived types for generating allocatable containers of scalar,...
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 IK
The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in C-Fortran Interoper...
integer, parameter SK
The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in C-Fortran Intero...
This module contains procedures and generic interfaces for computing the nearest neighbor statistics ...
character(*, SK), parameter MODULE_NAME