-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKdTree.h
36 lines (33 loc) · 848 Bytes
/
KdTree.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
#ifndef _INC_KDTREE
#define _INC_KDTREE
#include "KdTree.h"
using namespace std;
struct KdTreeNode
{
int index;
KdTreeNode* leftTree;
KdTreeNode* rightTree;
};
class KdTree
{
private:
int totalDimensions;
int numObservations;
int rootNodeIndex;
int K;
KdTreeNode endOfTree;
vector<vector<double> > data;
vector<vector<double> > dataForNormCalc;
struct KdTreeNode* tree;
public:
KdTree(vector<vector<double> >);
~KdTree();
int constructKdTree(int, int&, vector<vector<int> >&);
double norm(int&, int&);
double findKNearestNeighbour(int, int);
void findKNearestNeighboursCalc(int&, vector<pair<double, int> >&, double&, int&, KdTreeNode&, int);
void fastSort(vector<pair<double, int> >&);
int countPointsWithinR(int, double);
void countPointsWithinRCalc(int&, double&, KdTreeNode&, int&, int);
};
#endif