queso-0.53.0
Macros | Functions | Variables
kd_tree.cpp File Reference
#include "kd_tree.h"
#include "kd_split.h"
#include "kd_util.h"
#include <ANN/ANNperf.h>
Include dependency graph for kd_tree.cpp:

Go to the source code of this file.

Macros

#define MAX(a, b)   ((a) > (b) ? (a) : (b))
 

Functions

void annClose ()
 
ANNkd_ptr rkd_tree (ANNpointArray pa, ANNidxArray pidx, int n, int dim, int bsp, ANNorthRect &bnd_box, ANNkd_splitter splitter)
 

Variables

static int IDX_TRIVIAL [] = {0}
 
ANNkd_leafKD_TRIVIAL = NULL
 
const double ANN_AR_TOOBIG = 1000
 

Macro Definition Documentation

#define MAX (   a,
 
)    ((a) > (b) ? (a) : (b))

Definition at line 131 of file kd_tree.cpp.

Referenced by ANNkdStats::merge().

Function Documentation

void annClose ( )

Definition at line 221 of file kd_tree.cpp.

References KD_TRIVIAL.

Referenced by main().

222 {
223  if (KD_TRIVIAL != NULL) {
224  delete KD_TRIVIAL;
225  KD_TRIVIAL = NULL;
226  }
227 }
ANNkd_leaf * KD_TRIVIAL
Definition: kd_tree.cpp:50
ANNkd_ptr rkd_tree ( ANNpointArray  pa,
ANNidxArray  pidx,
int  n,
int  dim,
int  bsp,
ANNorthRect bnd_box,
ANNkd_splitter  splitter 
)

Definition at line 314 of file kd_tree.cpp.

References dim, KD_TRIVIAL, and rkd_tree().

Referenced by ANNkd_tree::ANNkd_tree(), and rkd_tree().

322 {
323  if (n <= bsp) { // n small, make a leaf node
324  if (n == 0) // empty leaf node
325  return KD_TRIVIAL; // return (canonical) empty leaf
326  else // construct the node and return
327  return new ANNkd_leaf(n, pidx);
328  }
329  else { // n large, make a splitting node
330  int cd; // cutting dimension
331  ANNcoord cv; // cutting value
332  int n_lo; // number on low side of cut
333  ANNkd_node *lo, *hi; // low and high children
334 
335  // invoke splitting procedure
336  (*splitter)(pa, pidx, bnd_box, n, dim, cd, cv, n_lo);
337 
338  ANNcoord lv = bnd_box.lo[cd]; // save bounds for cutting dimension
339  ANNcoord hv = bnd_box.hi[cd];
340 
341  bnd_box.hi[cd] = cv; // modify bounds for left subtree
342  lo = rkd_tree( // build left subtree
343  pa, pidx, n_lo, // ...from pidx[0..n_lo-1]
344  dim, bsp, bnd_box, splitter);
345  bnd_box.hi[cd] = hv; // restore bounds
346 
347  bnd_box.lo[cd] = cv; // modify bounds for right subtree
348  hi = rkd_tree( // build right subtree
349  pa, pidx + n_lo, n-n_lo,// ...from pidx[n_lo..n-1]
350  dim, bsp, bnd_box, splitter);
351  bnd_box.lo[cd] = lv; // restore bounds
352 
353  // create the splitting node
354  ANNkd_split *ptr = new ANNkd_split(cd, cv, lv, hv, lo, hi);
355 
356  return ptr; // return pointer to this node
357  }
358 }
ANNkd_ptr rkd_tree(ANNpointArray pa, ANNidxArray pidx, int n, int dim, int bsp, ANNorthRect &bnd_box, ANNkd_splitter splitter)
Definition: kd_tree.cpp:314
double ANNcoord
Definition: ANN.h:158
ANNkd_leaf * KD_TRIVIAL
Definition: kd_tree.cpp:50
int dim
Definition: ann2fig.cpp:81

Variable Documentation

const double ANN_AR_TOOBIG = 1000

Definition at line 145 of file kd_tree.cpp.

Referenced by ANNkd_leaf::getStats().

int IDX_TRIVIAL[] = {0}
static

Definition at line 49 of file kd_tree.cpp.

Referenced by ANNkd_tree::SkeletonTree().

ANNkd_leaf* KD_TRIVIAL = NULL

Generated on Thu Jun 11 2015 13:52:33 for queso-0.53.0 by  doxygen 1.8.5