Commit d03116f0 authored by Julien Jerphanion's avatar Julien Jerphanion

[DEBUG] Recursive build

We still have the prom on the secondf n the array.

```
 → p main.py 2> /dev/null
D 0x5609e0520450, 0x5609e05204b0, 0x5609e0520510
I 0x5609e064a580, 0x5609e064a5b0, 0x5609e064a5e0
Depth 10 on dim 0: [0, 24) med: 12 -531495856 -531495760 -531495664     [1, 0, 7, 3, 4, 5, 6, 2, 10, 9, 8, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]
               [1.000000, 0.000000, 7.000000, 3.000000, 4.000000, 5.000000, 6.000000, 2.000000, 10.000000, 9.000000, 8.000000, 11.000000]

D 0x5609e05204b0, 0x5609e05204e0, 0x5609e0520510
I 0x5609e064a5b0, 0x5609e064a5c8, 0x5609e064a5e0
Depth 9 on dim 1: [12, 24) med: 18 -531495760 -531495712 -531495664     [1, 0, 7, 3, 4, 5, 6, 2, 10, 9, 8, 11, 23, 22, 21, 20, 19, 18, 12, 13, 14, 17, 15, 16]
               [1.000000, 0.000000, 7.000000, 3.000000, 4.000000, 5.000000, 6.000000, 2.000000, 10.000000, 9.000000, 8.000000, 11.000000]

D 0x5609e0520450, 0x5609e0520480, 0x5609e05204b0
I 0x5609e064a580, 0x5609e064a598, 0x5609e064a5b0
Depth 9 on dim 1: [0, 12) med: 6 -531495856 -531495808 -531495760       [1, 0, 4, 3, 2, 5, 6, 7, 10, 9, 8, 11, 23, 22, 21, 20, 19, 18, 12, 13, 14, 17, 15, 16]
               [1.000000, 0.000000, 4.000000, 3.000000, 2.000000, 5.000000, 6.000000, 7.000000, 10.000000, 9.000000, 8.000000, 11.000000]

D 0x5609e05204b0, 0x5609e05204c8, 0x5609e05204e0
I 0x5609e064a5b0, 0x5609e064a5bc, 0x5609e064a5c8
Depth 8 on dim 0: [12, 18) med: 15 -531495760 -531495736 -531495712     [1, 0, 4, 3, 2, 5, 6, 7, 10, 9, 8, 11, 23, 21, 19, 20, 18, 22, 12, 13, 14, 17, 15, 16]
               [1.000000, 0.000000, 4.000000, 3.000000, 2.000000, 5.000000, 6.000000, 7.000000, 10.000000, 9.000000, 8.000000, 11.000000]

...
...
...
```
parent 9c0a1ca1
......@@ -22,6 +22,7 @@ DEF DEBUG = True
cdef extern from *:
"""
#include <algorithm>
#include <iostream>
template<class D, class I>
class IndexComparator {
private:
......@@ -45,6 +46,10 @@ cdef extern from *:
const I &n_features,
const I &n_points) {
IndexComparator<D, I> index_comparator(data, split_dim, n_features);
std::cout << "D " << data << ", " << data +
split_index << ", " << data + n_points << std::endl
<< "I " << node_indices << ", " << node_indices +
split_index << ", " << node_indices + n_points << std::endl;
std::nth_element(
node_indices,
node_indices + split_index,
......@@ -103,8 +108,9 @@ cdef cypclass Node activable:
self.point = points + split_index
if DEBUG:
printf("Depth %d on dim %d: [%d, %d) med: %d %d %d %d\t[%d, %d, %d, "
"%d, %d, %d, %d, %d, %d, %d, %d, %d]\n "
printf("Depth %d on dim %d: [%d, %d) med: %d %d %d %d\t"
"[%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d,"
" %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d]\n "
"[%f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f]\n\n",
depth, dim, start, end, split_index,
rel_points, rel_points + n_mid, rel_points + nn,
......@@ -112,6 +118,10 @@ cdef cypclass Node activable:
indices[3], indices[4], indices[5],
indices[6], indices[7], indices[8],
indices[9], indices[10], indices[11],
indices[12], indices[13], indices[14],
indices[15], indices[16], indices[17],
indices[18], indices[19], indices[20],
indices[21], indices[22], indices[23],
points[n_dims * indices[0] + dim],
points[n_dims * indices[1] + dim],
points[n_dims * indices[2] + dim],
......
......@@ -2,5 +2,5 @@ import numpy as np
import kdtree
if __name__ == "__main__":
X = np.random.randint(0, 100, size=(12, 2))
X = np.random.randint(0, 100, size=(24, 2))
tree = kdtree.KDTree(X, depth=10)
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