-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSPKDArray.h
77 lines (60 loc) · 1.88 KB
/
SPKDArray.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
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
#ifndef SPKDARRAY_H_
#define SPKDARRAY_H_
#include "SPPoint.h"
typedef struct kd_array_t *SPKDArray;
typedef struct kd_array_pair_t *SPKDArrayPair;
/*
* A Comparator function for the qsort function.
*
* The function compare doubles
*
* @param aIn - The index of the first element
* @param bIn - The index of the second element
* @param thunkIn - The array of the elements we are comparing
*
* @return 1 If thunk[aIn] > thunk[bIn]
* -1 If thunk[aIn] < thunk[bIn]
* 0 If thunk[aIn] = thunk[bIn]
*/
int spKDArrayCompare(const void *aIn, const void *bIn, const void *thunkIn);
/*
* Initializes the kd-array with the data given by arr. The complexity of
* this operation is O(d X nlog(n))
*
* @param arr - Array of the features
* @param size - The size of the array (number of features)
*
* @return The kd array on success
* NULL on failure
*/
SPKDArray spKDArrayInit(SPPoint* arr, int size);
/*
* Returns two kd-arrays (kdLeft, kdRight) such that the first [n/2] points
* with respect to the coordinate coor are in kdLeft , and the rest of the
* points are in kdRight.
*
* @param kdArr - The KDArray we are splitting
* @param coor - The coordinate we are splitting wit respect to
*
* @return a structure that hold the 2 new KDArrays
*/
SPKDArrayPair spKDArraySplit(SPKDArray kdArr, int coor);
/*
* Free all the memory associated with the KDArray
*
* @param array - The array we are freeing
*
*/
void spKDArrayDestroy(SPKDArray array);
/*
* Getters function
*/
int spKDArrayGetDimension(SPKDArray array);
int spKDArrayGetSize(SPKDArray array);
double* spKDArrayGetMinSpread(SPKDArray array);
double* spKDArrayGetMaxSpread(SPKDArray array);
SPPoint* spKDArrayGetPoints(SPKDArray array);
int** spKDArrayGetMatrix(SPKDArray array);
SPKDArray spKDArrayPairGetLeft(SPKDArrayPair array);
SPKDArray spKDArrayPairGetRight(SPKDArrayPair array);
#endif /* SPKDARRAY_H_ */