1
2libkd documentation
3===================
4
5C API
6-----
7
8.. highlight:: c
9
10.. c:function:: kdtree_t* kdtree_build(kdtree_t* kd, void *data, int N, int D, int Nleaf, int treetype, unsigned int options);
11
12    Build a tree from an array of data, of size N*D*sizeof(data_item).
13
14    *kd*: NULL to allocate a new *kdtree_t* structure, or the address
15       of the structure in which to store the result.
16
17    *data*: your N x D-dimensional data, stored in N-major direction:
18       data[n*D + d] is the address of data item "n", dimension "d".
19       If 3-dimensional data, eg, order is x0,y0,z0,x1,y1,z1,x2,y2,z2.
20
21    *N*: number of vectors
22
23    *D*: dimensionality of vectors
24
25    *Nleaf*: number of element in a kd-tree leaf node.  Typical value
26       would be about 32.
27
28    *treetype*:
29      * if your data are doubles, *KDTT_DOUBLE*
30      * if your data are floats,    *KDTT_FLOAT*
31
32    For fancier options, see *kd_tree_types*.
33
34    *options*: bitfield of *kd_build_options* values.  Specify one of:
35      * *KD_BUILD_BBOX*: keep a full bounding-box at each node;
36      * *KD_BUILD_SPLIT*: just keep the split dimension and value at each node.
37
38    see *kd_build_options* for additional fancy stuff.
39
40    NOTE that this function will *permute* the contents of the *data* array!
41
42    When you're done with your tree, be sure to *kdtree_free()* it.
43
44    Example:
45
46    .. code-block:: c
47
48       double mydata[] = { 1,1, 2,2, 3,3, 4,4, 5,5, 6,6, 7,7, 8,8 };
49       int D = 2;
50       int N = sizeof(mydata) / (D * sizeof(double));
51       kdtree_t* kd = kdtree_build(NULL, mydata, N, D, 4, KDTT_DOUBLE, KD_BUILD_BBOX);
52       kdtree_print(kd);
53       kdtree_free(kd);
54
55
56
57.. c:function:: void kdtree_free(kdtree_t *kd);
58
59    Frees the given *kd*.  By default, the *kd->data* is NOT freed.
60    Set *kd->free_data = 1* to free the data when *kdtree_free()* is called.
61
62
63Python API
64----------
65
66
67
68
69Code Internals
70--------------
71
72