Commit 03f51b3f authored by Julien Jerphanion's avatar Julien Jerphanion

Rename points to data

parent 91ea698f
......@@ -79,7 +79,7 @@ cdef cypclass Node activable:
void build_node(
self,
D_t * points,
D_t * data,
I_t * indices,
I_t depth,
I_t n_dims,
......@@ -96,18 +96,18 @@ cdef cypclass Node activable:
if (depth < 0) or (end - start <= 1):
return
partition_node_indices(points, indices, start, mid, end, dim, n_dims)
self.point = points + mid
partition_node_indices(data, indices, start, mid, end, dim, n_dims)
self.point = data + mid
self.left = consume Node()
self.right = consume Node()
self.left.build_node(NULL,
points, indices,
data, indices,
depth - 1, n_dims, next_dim,
start, mid)
self.right.build_node(NULL,
points, indices,
data, indices,
depth - 1, n_dims, next_dim,
mid, end)
......@@ -124,16 +124,18 @@ cdef cypclass KDTree:
This relies on a Cython+ runtime using actors.
"""
I_t n # number of points
I_t n # number of data
I_t d # number of dimensions / features
I_t depth # max_depth of the tree (to be unified with leaf_size)
np.ndarray data_arr
np.ndarray idx_array_arr
active Node root
D_t *points
D_t *data
I_t *indices
__init__(self,
......@@ -151,13 +153,13 @@ cdef cypclass KDTree:
# TODO: define it on the front-end
# Use Golden Spiral for the layout
cdef D_t golden_ratio = (1 + 5**0.5)/2
self.points = <D_t *> malloc(n * d * sizeof(D_t))
self.data = <D_t *> malloc(n * d * sizeof(D_t))
self.indices = <I_t *> malloc(n * sizeof(I_t))
for i in range(n):
self.indices[i] = i
self.points[i * d] = (i / golden_ratio) % 1
self.points[i * d + 1] = i / n
self.data[i * d] = (i / golden_ratio) % 1
self.data[i * d + 1] = i / n
# TODO: end
......@@ -182,7 +184,7 @@ cdef cypclass KDTree:
# a new argument is prepredend for the Promise,
# which we aren't using using here, hence the extra NULL.
self.root.build_node(NULL,
self.points,
self.data,
self.indices,
depth, n_dims=d, dim=0, start=0, end=n)
......@@ -191,12 +193,12 @@ cdef cypclass KDTree:
for i in range(n):
printf("X[indices[%d] = %d]= %f %f\n", i, self.indices[i]
self.points[self.indices[i] * d],
self.points[self.indices[i] * d + 1])
self.data[self.indices[i] * d],
self.data[self.indices[i] * d + 1])
void __dealloc__(self):
printf("Deallocating KDTree datastructures\n")
free(self.points)
free(self.data)
free(self.indices)
printf("Done deallocating KDTree datastructures\n")
# XXX It sometimes blocks over here and then segfaults
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment