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 file contains implementations of procedures [pm_knn](@ref pm_knn).
19 : !>
20 : !> \finmain
21 : !>
22 : !> \author
23 : !> \FatemehBagheri, Thursday 8:40 PM, July 20, 2023, Dallas, TX
24 : !> \AmirShahmoradi, Saturday 1:00 AM, September, 1, 2018, Dallas, TX
25 :
26 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
27 :
28 : !%%%%%%%%%%%%%%%%%%%
29 : #if setKnnSorted_ENABLED
30 : !%%%%%%%%%%%%%%%%%%%
31 :
32 : integer(IK) :: ipnt, nref, npnt
33 : #if Kth_ENABLED
34 : real(TKC) :: selection
35 90 : CHECK_ASSERTION(__LINE__, 0_IK < k .and. k <= size(distance, 1, IK), SK_"@setKnnSorted(): The condition `0 < k .and. k <= size(distance, 1)` must hold. k, shape(distance) = "//getStr([k, shape(distance, IK)]))
36 : #elif Ind_ENABLED
37 110 : CHECK_ASSERTION(__LINE__, all(shape(distance) == shape(rank)), SK_"@setKnnSorted(): The condition `all(shape(distance, IK) == shape(rank, IK))` must hold. shape(distance), shape(rank) = "//getStr([shape(distance), shape(rank)]))
38 : #endif
39 25 : nref = size(distance, 1, IK)
40 25 : npnt = size(distance, 2, IK)
41 190 : DO_CONCURRENT(ipnt,1,npnt)
42 : #if Val_ENABLED
43 0 : call setSorted(distance(1:nref, ipnt))
44 : #elif Ind_ENABLED
45 76 : call setSorted(distance(1:nref, ipnt), rank(1:nref, ipnt))
46 : #elif Kth_ENABLED
47 114 : call setSelected(selection, distance(1:nref, ipnt), k)
48 : #else
49 : #error "Unrecognized interface."
50 : #endif
51 : end do
52 :
53 : !%%%%%%%%%%%%%%%%
54 : #elif setKnnVal_ENABLED
55 : !%%%%%%%%%%%%%%%%
56 :
57 : integer(IK) :: ipnt, nref, npnt
58 : nref = size(distance, 1, IK)
59 : npnt = size(distance, 2, IK)
60 : CHECK_ASSERTION(__LINE__, size(val, 1, IK) == size(distance, 2, IK), SK_"@setKnnVal(): The condition `size(val) == size(distance, 2)` must hold. size(val), shape(distance) = "//getStr([shape(val, IK), shape(distance, IK)]))
61 : DO_CONCURRENT(ipnt,1,npnt)
62 : call setSelected(selection, distance(1:nref, ipnt), k)
63 : end do
64 :
65 : #else
66 : !%%%%%%%%%%%%%%%%%%%%%%%%
67 : #error "Unrecognized interface."
68 : !%%%%%%%%%%%%%%%%%%%%%%%%
69 : #endif
|