def __init__(self, pa, dim=2, leaf_size=32, radius_scale=2.0, use_double=False, c_type='float'): super(PointTree, self).__init__(pa.get_number_of_particles(), 2 ** dim, leaf_size) assert (1 <= dim <= 3) self.max_depth = None self.dim = dim self.powdim = 2 ** self.dim self.xvars = ('x', 'y', 'z')[:dim] self.c_type = c_type self.c_type_src = 'double' if use_double else 'float' if use_double and c_type == 'float': # Extend the search radius a little to account for rounding errors radius_scale = radius_scale * (1 + 2e-7) # y and z coordinates need to be present for 1D and z for 2D # This is because the NNPS implementation below assumes them to be # just set to 0. self.pa = ParticleArrayWrapper(pa, self.c_type_src, self.c_type, ('x', 'y', 'z', 'h')) self.radius_scale = radius_scale self.use_double = use_double self.helper = get_helper('tree/point_tree.mako', self.c_type) self.xmin = None self.xmax = None self.hmin = None self.make_vec = make_vec_dict[c_type][self.dim] self.ctx = get_context()
def __init__(self, n, k=8, leaf_size=32): self.ctx = get_context() self.queue = get_queue() self.sorted = False self.main_helper = get_helper(os.path.join('tree', 'tree.mako')) self.initialized = False self.preamble = "" self.leaf_size = leaf_size self.k = k self.n = n self.sorted = False self.depth = 0 self.index_function_args = [] self.index_function_arg_ctypes = [] self.index_function_arg_dtypes = [] self.index_function_consts = [] self.index_function_const_ctypes = [] self.index_code = "" self.set_index_function_info()