Ejemplo n.º 1
0
 def _df_tree(self, delta):
     print 'constructing tree1'
     tree_inner = KD_tree(self._points_inner.value)
     print 'constructing tree2'
     tree_outer = KD_tree(self._points_outer.value)
     self._cmp_pts_kern()
     vox_pts = np.zeros((self._voxels._value.size,4))
     vox_pts = self._vpoints.value
     vox_pts.shape = (vox_pts.shape[0]*vox_pts.shape[1]*vox_pts.shape[2], 4)
     print 'getting nn from tree1'
     nn_dat_inner = tree_inner.get_nn(vox_pts)
     print 'getting nn from tree2'
     nn_dat_outer = tree_outer.get_nn(vox_pts)
     self._dist_inner.value = nn_dat_inner[1]
     self._dist_outer.value = nn_dat_outer[1]
     self._cmp_df_kern()
Ejemplo n.º 2
0
@author: Hagen
"""


import numpy as np
from numcl.data_structures import KD_tree
import timeit
import math

n = 1000

points = np.random.rand(n,4)
points2 = np.random.rand(n,4) 
         
tree = KD_tree(points)
#"""

t0 = timeit.default_timer()
neighs = []
dists = []
for q in points2:
    dist = 99999999;
    nid = -1
    n = 0
    for p in points:
        d = (p[0]-q[0])*(p[0]-q[0]) + (p[1]-q[1])*(p[1]-q[1]) + (p[2]-q[2])*(p[2]-q[2])
        if d < dist:
            dist = d
            nid = n
        n += 1;