void ANNbd_shrink::getStats( // get subtree statistics int dim, // dimension of space ANNkdStats &st, // stats (modified) ANNorthRect &bnd_box) // bounding box { ANNkdStats ch_stats; // stats for children ANNorthRect inner_box(dim); // inner box of shrink annBnds2Box(bnd_box, // enclosing box dim, // dimension n_bnds, // number of bounds bnds, // bounds array inner_box); // inner box (modified) // get stats for inner child ch_stats.reset(); // reset child[ANN_IN]->getStats(dim, ch_stats, inner_box); st.merge(ch_stats); // merge them // get stats for outer child ch_stats.reset(); // reset child[ANN_OUT]->getStats(dim, ch_stats, bnd_box); st.merge(ch_stats); // merge them st.depth++; // increment depth st.n_shr++; // increment number of shrinks }
void ANNkd_tree::getStats( // get tree statistics ANNkdStats &st) // stats (modified) { st.reset(dim, n_pts, bkt_size); // reset stats // create bounding box ANNorthRect bnd_box(dim, bnd_box_lo, bnd_box_hi); if (root != NULL) { // if nonempty tree root->getStats(dim, st, bnd_box); // get statistics st.avg_ar = st.sum_ar / st.n_lf; // average leaf asp ratio } }
void ANNkd_leaf::getStats( // get subtree statistics int dim, // dimension of space ANNkdStats &st, // stats (modified) ANNorthRect &bnd_box) // bounding box { st.reset(); if (this == KD_TRIVIAL) st.n_tl = 1; // trivial leaf? else st.n_lf = 1; // else increment leaf count double ar = annAspectRatio(dim, bnd_box); // aspect ratio of leaf st.sum_ar += (ar < 100 ? ar : 100); // increment (set outlier=100) }
void ANNkd_leaf::getStats( // get subtree statistics int dim, // dimension of space ANNkdStats &st, // stats (modified) ANNorthRect &bnd_box) // bounding box { st.reset(); st.n_lf = 1; // count this leaf if (this == KD_TRIVIAL) st.n_tl = 1; // count trivial leaf double ar = annAspectRatio(dim, bnd_box); // aspect ratio of leaf // incr sum (ignore outliers) st.sum_ar += float(ar < ANN_AR_TOOBIG ? ar : ANN_AR_TOOBIG); }
void ANNkd_split::getStats( // get subtree statistics int dim, // dimension of space ANNkdStats &st, // stats (modified) ANNorthRect &bnd_box) // bounding box { ANNkdStats ch_stats; // stats for children // get stats for low child ANNcoord hv = bnd_box.hi[cut_dim]; // save box bounds bnd_box.hi[cut_dim] = cut_val; // upper bound for low child ch_stats.reset(); // reset child[ANN_LO]->getStats(dim, ch_stats, bnd_box); st.merge(ch_stats); // merge them bnd_box.hi[cut_dim] = hv; // restore bound // get stats for high child ANNcoord lv = bnd_box.lo[cut_dim]; // save box bounds bnd_box.lo[cut_dim] = cut_val; // lower bound for high child ch_stats.reset(); // reset child[ANN_HI]->getStats(dim, ch_stats, bnd_box); st.merge(ch_stats); // merge them bnd_box.lo[cut_dim] = lv; // restore bound st.depth++; // increment depth st.n_spl++; // increment number of splits }