41 void ANNbd_shrink::print(
45 child[
ANN_OUT]->print(level+1, out);
48 for (
int i = 0; i < level; i++)
51 for (
int j = 0; j < n_bnds; j++) {
54 for (
int i = 0; i < level+2; i++) out <<
" ";
56 out <<
" ([" << bnds[j].cd <<
"]"
57 << (bnds[j].sd > 0 ?
">=" :
"< ")
62 child[
ANN_IN]->print(level+1, out);
71 void ANNbd_shrink::getStats(
86 child[
ANN_IN]->getStats(dim, ch_stats, inner_box);
90 child[
ANN_OUT]->getStats(dim, ch_stats, bnd_box);
113 ANNkd_splitter splitter,
194 for (i = 0; i <
dim; i++) {
196 if (length > max_length) {
202 for (i = 0; i <
dim; i++) {
206 if (gap_hi < max_length*BD_GAP_THRESH)
207 inner_box.
hi[i] = bnd_box.
hi[i];
212 if (gap_lo < max_length*BD_GAP_THRESH)
213 inner_box.
lo[i] = bnd_box.
lo[i];
217 if (shrink_ct >= BD_CT_THRESH)
242 ANNkd_splitter splitter,
246 int n_goal = (int) (n*BD_FRACTION);
251 while (n_sub > n_goal) {
256 (*splitter)(pa, pidx, inner_box, n_sub,
dim, cd, cv, n_lo);
259 if (n_lo >= n_sub/2) {
260 inner_box.hi[cd] = cv;
264 inner_box.lo[cd] = cv;
269 if (n_splits > dim*BD_MAX_SPLIT_FAC)
285 ANNkd_splitter splitter,
342 ANNkd_splitter splitter,
353 return new ANNkd_leaf(n, pidx);
363 if (decomp ==
SPLIT) {
368 (*splitter)(pa, pidx, bnd_box, n,
dim, cd, cv, n_lo);
376 dim, bsp, bnd_box, splitter, shrink);
381 pa, pidx + n_lo, n-n_lo,
382 dim, bsp, bnd_box, splitter, shrink);
385 return new ANNkd_split(cd, cv, lv, hv, lo, hi);
400 pa, pidx, n_in, dim, bsp, inner_box, splitter, shrink);
402 pa, pidx+n_in, n - n_in, dim, bsp, bnd_box, splitter, shrink);
415 return new ANNbd_shrink(n_bnds, bnds, in, out);
void annBoxSplit(ANNpointArray pa, ANNidxArray pidx, int n, int dim, ANNorthRect &box, int &n_in)
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)
void annBox2Bnds(const ANNorthRect &inner_box, const ANNorthRect &bnd_box, int dim, int &n_bnds, ANNorthHSArray &bnds)
ANNbd_tree(int n, int dd, int bs=1)
const float BD_GAP_THRESH
void kd_split(ANNpointArray pa, ANNidxArray pidx, const ANNorthRect &bnds, int n, int dim, int &cut_dim, ANNcoord &cut_val, int &n_lo)
ANNdecomp selectDecomp(ANNpointArray pa, ANNidxArray pidx, int n, int dim, const ANNorthRect &bnd_box, ANNkd_splitter splitter, ANNshrinkRule shrink, ANNorthRect &inner_box)
ANNkd_ptr rbd_tree(ANNpointArray pa, ANNidxArray pidx, int n, int dim, int bsp, ANNorthRect &bnd_box, ANNkd_splitter splitter, ANNshrinkRule shrink)
const float BD_MAX_SPLIT_FAC
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)
ANNdecomp tryCentroidShrink(ANNpointArray pa, ANNidxArray pidx, int n, int dim, const ANNorthRect &bnd_box, ANNkd_splitter splitter, ANNorthRect &inner_box)
ANNdecomp trySimpleShrink(ANNpointArray pa, ANNidxArray pidx, int n, int dim, const ANNorthRect &bnd_box, ANNorthRect &inner_box)
DLL_API ANNpoint annCopyPt(int dim, ANNpoint source)
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)
void annBnds2Box(const ANNorthRect &bnd_box, int dim, int n_bnds, ANNorthHSArray bnds, ANNorthRect &inner_box)
void annAssignRect(int dim, ANNorthRect &dest, const ANNorthRect &source)