[WIP] KDTree implementation
There's a problem with the third partial sort: ``` Depth 9 on dim 1: [6, 12) med: 9 27141056 27141080 27141104 [1, 0, 2, 3, 4, 5, 11, 10, 9, 6, 7, 8] ``` The second hald of the array i.e of indices in [6, 12) is wrong. It looks like it's actually reverted. It should not be: [11, 10, 9, 6, 7, 8] But something with the pivot (9) in the middle: [ 7, 6, 8, 9,11,10] From there, it just mess with the second half of the indices' array. ``` C 0x19e2460, 0x19e2478, 0x19e2490 Depth 10 on dim 0: [0, 12) med: 6 27141008 27141056 27141104 [1, 0, 4, 3, 2, 5, 6, 7, 8, 9, 10, 11] [1.000000, 0.000000, 4.000000, 3.000000, 2.000000, 5.000000, 6.000000, 7.000000, 8.000000, 9.000000, 10.000000, 11.000000] C 0x19e2460, 0x19e246c, 0x19e2478 Depth 9 on dim 1: [0, 6) med: 3 27141008 27141032 27141056 [1, 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] [1.000000, 0.000000, 2.000000, 3.000000, 4.000000, 5.000000, 6.000000, 7.000000, 8.000000, 9.000000, 10.000000, 11.000000] C 0x19e2478, 0x19e2484, 0x19e2490 Depth 9 on dim 1: [6, 12) med: 9 27141056 27141080 27141104 [1, 0, 2, 3, 4, 5, 11, 10, 9, 6, 7, 8] [1.000000, 0.000000, 2.000000, 3.000000, 4.000000, 5.000000, 11.000000, 10.000000, 9.000000, 6.000000, 7.000000, 8.000000] C 0x19e246c, 0x19e2470, 0x19e2478 Depth 8 on dim 0: [3, 6) med: 4 27141032 27141040 27141056 [1, 0, 2, 3, 4, 5, 11, 10, 9, 6, 7, 8] [1.000000, 0.000000, 2.000000, 3.000000, 4.000000, 5.000000, 11.000000, 10.000000, 9.000000, 6.000000, 7.000000, 8.000000] C 0x19e2484, 0x19e2488, 0x19e2490 Depth 8 on dim 0: [9, 12) med: 10 27141080 27141088 27141104 [1, 0, 2, 3, 4, 5, 11, 10, 9, 8, 6, 7] [1.000000, 0.000000, 2.000000, 3.000000, 4.000000, 5.000000, 11.000000, 10.000000, 9.000000, 8.000000, 6.000000, 7.000000] C 0x19e2470, 0x19e2474, 0x19e2478 Depth 7 on dim 1: [4, 6) med: 5 27141040 27141048 27141056 [1, 0, 2, 3, 4, 5, 11, 10, 9, 8, 6, 7] [1.000000, 0.000000, 2.000000, 3.000000, 4.000000, 5.000000, 11.000000, 10.000000, 9.000000, 8.000000, 6.000000, 7.000000] C 0x19e2488, 0x19e248c, 0x19e2490 Depth 7 on dim 1: [10, 12) med: 11 27141088 27141096 27141104 [1, 0, 2, 3, 4, 5, 11, 10, 9, 8, 7, 6] [1.000000, 0.000000, 2.000000, 3.000000, 4.000000, 5.000000, 11.000000, 10.000000, 9.000000, 8.000000, 7.000000, 6.000000] C 0x19e2478, 0x19e247c, 0x19e2484 Depth 8 on dim 0: [6, 9) med: 7 27141056 27141064 27141080 [1, 0, 2, 3, 4, 5, 9, 10, 11, 8, 7, 6] [1.000000, 0.000000, 2.000000, 3.000000, 4.000000, 5.000000, 9.000000, 10.000000, 11.000000, 8.000000, 7.000000, 6.000000] C 0x19e247c, 0x19e2480, 0x19e2484 Depth 7 on dim 1: [7, 9) med: 8 27141064 27141072 27141080 [1, 0, 2, 3, 4, 5, 9, 10, 11, 8, 7, 6] [1.000000, 0.000000, 2.000000, 3.000000, 4.000000, 5.000000, 9.000000, 10.000000, 11.000000, 8.000000, 7.000000, 6.000000] C 0x19e2460, 0x19e2464, 0x19e246c Depth 8 on dim 0: [0, 3) med: 1 27141008 27141016 27141032 [0, 1, 2, 3, 4, 5, 9, 10, 11, 8, 7, 6] [0.000000, 1.000000, 2.000000, 3.000000, 4.000000, 5.000000, 9.000000, 10.000000, 11.000000, 8.000000, 7.000000, 6.000000] C 0x19e2464, 0x19e2468, 0x19e246c Depth 7 on dim 1: [1, 3) med: 2 27141016 27141024 27141032 [0, 1, 2, 3, 4, 5, 9, 10, 11, 8, 7, 6] [0.000000, 1.000000, 2.000000, 3.000000, 4.000000, 5.000000, 9.000000, 10.000000, 11.000000, 8.000000, 7.000000, 6.000000] indices[0] = 0 indices[1] = 1 indices[2] = 2 indices[3] = 3 indices[4] = 4 indices[5] = 5 indices[6] = 9 indices[7] = 10 indices[8] = 11 indices[9] = 8 indices[10] = 7 indices[11] = 6 X[indices[0]]= 0.000000 0.000000 X[indices[1]]= 1.000000 1.000000 X[indices[2]]= 2.000000 2.000000 X[indices[3]]= 3.000000 3.000000 X[indices[4]]= 4.000000 4.000000 X[indices[5]]= 5.000000 5.000000 X[indices[6]]= 9.000000 9.000000 X[indices[7]]= 10.000000 10.000000 X[indices[8]]= 11.000000 11.000000 X[indices[9]]= 8.000000 8.000000 X[indices[10]]= 7.000000 7.000000 X[indices[11]]= 6.000000 6.000000 ```
Showing
Please register or sign in to comment