-
Notifications
You must be signed in to change notification settings - Fork 0
/
knnring.h
48 lines (39 loc) · 1.34 KB
/
knnring.h
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
/*
* knnring.h
*
* Created on: Nov 21, 2019
* Author: Lambis
*/
#ifndef KNNRING_H_
#define KNNRING_H_
// Definition of the kNN result struct.
typedef struct knnresult{
int *nidx; //!< Indices (0-based) of nearest neighbors [m-by-k]
double *ndist; //!< Distance of nearest neighbors [m-by-k]
int m; //!< Number of query points [scalar]
int k; //!< Number of nearest neighbors [scalar]
} knnresult;
//! Compute k nearest neighbors of each point in X [n-by-d]
/*!
\param X Corpus data points [n-by-d]
\param Y Query data points [m-by-d]
\param n Number of corpus points [scalar]
\param m Number of query points [scalar]
\param d Number of dimensions [scalar]
\param k Number of neighbors [scalar]
\return The kNN result
*/
knnresult kNN(double * X, double * Y, int n, int m, int d, int k);
//! Compute distributed all-kNN of points in X
/*!
\param X Data points [n-by-d]
\param n Number of data points [scalar]
\param d Number of dimensions [scalar]
\param k Number of neighbors [scalar]
\return The kNN result
*/
knnresult distrAllkNN(double * X, int n, int d, int k);
void swap(void* a, void* b, size_t s);
int partition(double *arr, int low, int high, int *idx);
void quickSort(double *arr, int low, int high, int *idx);
#endif /* KNNRING_H_ */