67 void ANNkd_split::print(
71 child[
ANN_HI]->print(level+1, out);
73 for (
int i = 0; i < level; i++)
75 out <<
"Split cd=" << cut_dim <<
" cv=" << cut_val;
76 out <<
" lbnd=" << cd_bnds[
ANN_LO];
77 out <<
" hbnd=" << cd_bnds[
ANN_HI];
79 child[
ANN_LO]->print(level+1, out);
82 void ANNkd_leaf::print(
88 for (
int i = 0; i < level; i++)
92 out <<
"Leaf (trivial)\n";
95 out <<
"Leaf n=" << n_pts <<
" <";
96 for (
int j = 0; j < n_pts; j++) {
98 if (j < n_pts-1) out <<
",";
108 out <<
"ANN Version " << ANNversion <<
"\n";
111 for (
int i = 0; i <
n_pts; i++) {
112 out <<
"\t" << i <<
": ";
118 out <<
" Null tree.\n";
131 #define MAX(a,b) ((a) > (b) ? (a) : (b))
147 void ANNkd_leaf::getStats(
157 st.
sum_ar += float(ar < ANN_AR_TOOBIG ? ar : ANN_AR_TOOBIG);
160 void ANNkd_split::getStats(
168 bnd_box.
hi[cut_dim] = cut_val;
170 child[
ANN_LO]->getStats(dim, ch_stats, bnd_box);
172 bnd_box.
hi[cut_dim] = hv;
175 bnd_box.
lo[cut_dim] = cut_val;
177 child[
ANN_HI]->getStats(dim, ch_stats, bnd_box);
179 bnd_box.
lo[cut_dim] = lv;
198 root->getStats(dim, st, bnd_box);
260 for (
int i = 0; i < n; i++) {
321 ANNkd_splitter splitter)
327 return new ANNkd_leaf(n, pidx);
336 (*splitter)(pa, pidx, bnd_box, n,
dim, cd, cv, n_lo);
344 dim, bsp, bnd_box, splitter);
349 pa, pidx + n_lo, n-n_lo,
350 dim, bsp, bnd_box, splitter);
354 ANNkd_split *ptr =
new ANNkd_split(cd, cv, lv, hv, lo, hi);
void SkeletonTree(int n, int dd, int bs, ANNpointArray pa=NULL, ANNidxArray pi=NULL)
void annPrintPt(ANNpoint pt, int dim, std::ostream &out)
void annEnclRect(ANNpointArray pa, ANNidxArray pidx, int n, int dim, ANNorthRect &bnds)
void sl_midpt_split(ANNpointArray pa, ANNidxArray pidx, const ANNorthRect &bnds, int n, int dim, int &cut_dim, ANNcoord &cut_val, int &n_lo)
void sl_fair_split(ANNpointArray pa, ANNidxArray pidx, const ANNorthRect &bnds, int n, int dim, int &cut_dim, ANNcoord &cut_val, int &n_lo)
DLL_API void annDeallocPt(ANNpoint &p)
virtual void Print(ANNbool with_pts, std::ostream &out)
virtual void getStats(ANNkdStats &st)
ANNkd_ptr rkd_tree(ANNpointArray pa, ANNidxArray pidx, int n, int dim, int bsp, ANNorthRect &bnd_box, ANNkd_splitter splitter)
double annAspectRatio(int dim, const ANNorthRect &bnd_box)
void kd_split(ANNpointArray pa, ANNidxArray pidx, const ANNorthRect &bnds, int n, int dim, int &cut_dim, ANNcoord &cut_val, int &n_lo)
ANNkd_tree(int n=0, int dd=0, int bs=1)
void fair_split(ANNpointArray pa, ANNidxArray pidx, const ANNorthRect &bnds, int n, int dim, int &cut_dim, ANNcoord &cut_val, int &n_lo)
void reset(int d=0, int n=0, int bs=0)
DLL_API ANNpoint annCopyPt(int dim, ANNpoint source)
const double ANN_AR_TOOBIG
void annError(const char *msg, ANNerr level)
void merge(const ANNkdStats &st)
void midpt_split(ANNpointArray pa, ANNidxArray pidx, const ANNorthRect &bnds, int n, int dim, int &cut_dim, ANNcoord &cut_val, int &n_lo)