Commit 228d5de5 authored by Julien Jerphanion's avatar Julien Jerphanion

Correct comments

parent bccfff3d
......@@ -21,7 +21,7 @@ cdef lock Scheduler scheduler
cdef D_t INF = 1e38
# NOTE: The following extern definition is used to interface
# std::nth_element, a robust partitioning algorithm, in Cython
# std::nth_element, a robust partitioning algorithm, in Cython
cdef extern from *:
"""
#include <algorithm>
......@@ -73,10 +73,10 @@ cdef extern from *:
cdef cypclass Counter activable:
""" A simple Counter.
This can be useful for synchronisation for the caller after
triggering the actors logic as it wait for the value of
the Coutner to reach a given one before moving on.
the Counter to reach a given one before moving on.
"""
I_t _n
......@@ -98,7 +98,7 @@ cdef cypclass Counter activable:
cdef cypclass Container activable:
""" A simple wrapper of an array.
The wrapped array is passed by the initial caller which then
trigger the actors logic modifying it.
......@@ -331,17 +331,17 @@ cdef cypclass NeighborsHeap activable:
cdef cypclass Node activable:
"""A KDTree Node
Node delegate tasks to their children Nodes.
Node delegates tasks to their children Nodes.
Some Nodes are set as Leaves when they are associated
to ``leaf_size`` or less points.
Leafs are terminal Nodes and do not have children.
"""
# Reference to the head of the allocated arrays
# data gets not modified via _data_ptr
# data gets not modified via _data_ptr
D_t * _data_ptr
I_t * _indices_ptr
......@@ -369,7 +369,7 @@ cdef cypclass Node activable:
# We use this to allow using actors for initialisation
# because __init__ can't be reified.
# because __init__ can't be reified.
void build_node(
self,
D_t * data_ptr,
......@@ -396,19 +396,19 @@ cdef cypclass Node activable:
if (end - start <= leaf_size):
self._is_leaf = True
# Adding to the global counter the number
# of samples the leaf is responsible of
# of samples the leaf is responsible of.
counter.add(NULL, end - start)
return
# We partition the samples in two nodes on a given dimension,
# with the middle point as a pivot
# with the middle point as a pivot.
partition_node_indices(data_ptr, indices_ptr, start, mid, end, dim, n_dims)
self._point = data_ptr + mid
self._left = consume Node()
self._right = consume Node()
# Recursing on both partition
# Recursing on both partitions.
self._left.build_node(NULL,
data_ptr, indices_ptr,
leaf_size, n_dims, next_dim,
......@@ -429,23 +429,23 @@ cdef cypclass Node activable:
D_t tmp
if self._is_leaf:
# Computing all the euclideans distances here
# Computing all the euclideans distances here.
for j in range(self._start, self._end):
dist = 0
for k in range(self._n_dims):
tmp = (
query_points[i * self._n_dims + k] -
query_points[i * self._n_dims + k] -
self._data_ptr[self._indices_ptr[j] * self._n_dims + k]
)
dist += tmp * tmp
# The heap is doing the smart work of keeping
# the closest points for each query point i
# The heap is responsible for keeping the closest
# points for each query point i.
heaps.push(NULL, i, dist, self._indices_ptr[j])
return
# TODO: one can implement a pruning strategy here
# TODO: one can implement a pruning strategy here.
self._left.query(NULL, query_points, i, heaps)
self._right.query(NULL, query_points, i, heaps)
......@@ -481,10 +481,10 @@ cdef cypclass KDTree:
cdef I_t n = X.shape[0]
cdef I_t d = X.shape[1]
cdef I_t initialised = 0
# Accessing _SC_NPROCESSORS_ONLN does not return the
# Accessing _SC_NPROCESSORS_ONLN does not return the
# effective number of threads which were assigned to
# this task using `taskset(1)` for instance.
#
# this task using `taskset(1)` for instance.
#
# This OpenMP API is a workable way to access it.
cdef I_t num_workers = omp_get_max_threads()
......@@ -509,10 +509,10 @@ cdef cypclass KDTree:
# When object are activated (set as Actors), methods
# are reified. When using those reified methods
# a new argument is prepredend for a predicate,
# which we aren't using using here, hence the extra NULL.
# which we aren't using here, hence the extra NULL.
#
# Also using this separate method allowing using actors
# because __init__ can't be reified.
# because __init__ can't be reified.
self._root.build_node(NULL,
self._data_ptr,
self._indices_ptr,
......@@ -526,7 +526,7 @@ cdef cypclass KDTree:
initialised = counter.value(NULL).getIntResult()
counter.reset(NULL)
void __dealloc__(self):
scheduler.finish()
......@@ -557,7 +557,7 @@ cdef cypclass KDTree:
completed_queries = heaps.n_pushes(NULL).getIntResult()
heaps.sort(NULL)
while not(heaps.is_sorted(NULL).getIntResult()):
pass
......
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