forked from johannesgerer/jburkardt-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_nearest.html
195 lines (167 loc) · 5.27 KB
/
test_nearest.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
<html>
<head>
<title>
TEST_NEAREST - Test Functions for the Nearest Neighbor Calculation
</title>
</head>
<body bgcolor="#EEEEEE" link="#CC0000" alink="#FF3300" vlink="#000055">
<h1 align = "center">
TEST_NEAREST <br> Test Functions for the Nearest Neighbor Calculation
</h1>
<hr>
<p>
<b>TEST_NEAREST</b>
is a C++ program which
tests several functions that carry out the nearest neighbor calculation.
</p>
<p>
In a nearest neighbor calculation, we are given:
<p>
<li>
R, a set of NR points in M dimensions.
</li>
<li>
S, a set of NS points in M dimensions.
</li>
<li>
D(x,y), a norm for measuring distances between points in M dimensions.
</li>
</p>
and we are asked to compute, for each point S(JS),
<ul>
<li>
JR = NEAREST(JS), the index of the point in R for which
the distance D(S(JS),R(JR)) is minimized.
</li>
</ul>
</p>
<p>
Obviously, one method to determine the values in NEAREST is simply to
compute every distance and take the index of the minimum. But even
this simple idea can be implemented in many ways in MATLAB, and
implementations will vary in their cost in memory and time.
</p>
<p>
Also, note that if the dimension M is small, and if the size of the
R set is small relative to that of S, it may be much cheaper to
compute the Delaunay triangulation of R (or its higher-dimensional
generalization). Computing the triangulation is somewhat expensive,
but makes the search procedure extremely quick.
</p>
<p>
Lloyd's version of the Centroidal Voronoi Tessellation (CVT) algorithm
estimates the area or volume of the cells using sampling. This computation
is a nearest neighbor calculation.
</p>
<h3 align = "center">
Licensing:
</h3>
<p>
The computer code and data files described and made available on this web page
are distributed under
<a href = "../../txt/gnu_lgpl.txt">the GNU LGPL license.</a>
</p>
<h3 align = "center">
Languages:
</h3>
<p>
<b>TEST_NEAREST</b> is available in
<a href = "../../c_src/test_nearest/test_nearest.html">a C version</a> and
<a href = "../../cpp_src/test_nearest/test_nearest.html">a C++ version</a> and
<a href = "../../f77_src/test_nearest/test_nearest.html">a FORTRAN77 version</a> and
<a href = "../../f_src/test_nearest/test_nearest.html">a FORTRAN90 version</a> and
<a href = "../../m_src/test_nearest/test_nearest.html">a MATLAB version</a>.
</p>
<h3 align = "center">
Related Programs:
</h3>
<p>
<a href = "../../cpp_src/cvt/cvt.html">
CVT</a>,
a C++ library which
computes elements of a Centroidal Voronoi Tessellation (CVT).
</p>
<p>
<a href = "../../cpp_src/nearest_interp_1d/nearest_interp_1d.html">
NEAREST_INTERP_1D</a>,
a C++ library which
interpolates a set of data using a piecewise constant interpolant
defined by the nearest neighbor criterion.
</p>
<h3 align = "center">
References:
</h3>
<p>
<ol>
<li>
Sunil Arya, David Mount, Nathan Netanyahu, Ruth Silverman,
Angela Wu,<br>
An Optimal Algorithm for Approximate Nearest Neighbor Searching
in Fixed Dimensions,<br>
Journal of the ACM,<br>
Volume 45, Number 6, November 1998, pages 891-923.
</li>
<li>
Jon Bentley, Bruce Weide, Andrew Yao,<br>
Optimal Expected Time Algorithms for Closest Point Problems,<br>
ACM Transactions on Mathematical Software,<br>
Volume 6, Number 4, December 1980, pages 563-580.
</li>
<li>
Marc deBerg, Marc Krevald, Mark Overmars,
Otfried Schwarzkopf,<br>
Computational Geometry,<br>
Springer, 2000,<br>
ISBN: 3-540-65620-0,<br>
LC: QA448.D38.C65.
</li>
</ol>
</p>
<h3 align = "center">
Source Code:
</h3>
<p>
<ul>
<li>
<a href = "test_nearest.cpp">test_nearest.cpp</a>, the source code.
</li>
<li>
<a href = "test_nearest.sh">test_nearest.sh</a>,
BASH commands to compile the source code.
</li>
<li>
<a href = "test_nearest_output.txt">test_nearest_output.txt</a>,
the output file.
</li>
</ul>
</p>
<h3 align = "center">
List of Routines:
</h3>
<p>
<ul>
<li>
<b>TEST_NEAREST</b> compares the performance of nearest neighbor routines.
</li>
<li>
<b>FIND_CLOSEST1</b> finds the nearest R point to each S point.
</li>
<li>
<b>R8MAT_UNIFORM_01</b> fills an R8MAT with unit pseudorandom numbers.
</li>
<li>
<b>TIMESTAMP</b> prints the current YMDHMS date as a time stamp.
</li>
</ul>
</p>
<p>
You can go up one level to <a href = "../cpp_src.html">
the C++ source codes</a>.
</p>
<hr>
<i>
Last revised on 27 December 2012.
</i>
<!-- John Burkardt -->
</body>
</html>