From 99d0cbd6b8800a7804f62651166a5e2f8e441a8b Mon Sep 17 00:00:00 2001 From: Ryan Curtin Date: Wed, 2 Jun 2010 21:24:04 +0000 Subject: [PATCH] Finish transition of tree to arma::vec and related classes, and remove some methods that were commented out and unnecessary --- .../fastlib-armadillo/fastlib/tree/kdtree.h | 79 ------------------- .../fastlib/tree/kdtree_impl.h | 17 +--- 2 files changed, 3 insertions(+), 93 deletions(-) diff --git a/fastlib/branches/fastlib-armadillo/fastlib/tree/kdtree.h b/fastlib/branches/fastlib-armadillo/fastlib/tree/kdtree.h index c3f30cf8f9..f5be78fcf8 100644 --- a/fastlib/branches/fastlib-armadillo/fastlib/tree/kdtree.h +++ b/fastlib/branches/fastlib-armadillo/fastlib/tree/kdtree.h @@ -59,65 +59,6 @@ * Regular pointer-style trees (as opposed to THOR trees). */ namespace tree { - /** - * Creates a KD tree from data, splitting on the midpoint. - * - * @experimental - * - * This requires you to pass in two unitialized ArrayLists (or Vectors) which - * will contain index mappings so you can account for the re-ordering of the - * matrix. (By unitialized I mean don't call Init on it) - * - * @param matrix data where each column is a point, WHICH WILL BE RE-ORDERED - * @param split_dimensions ordering of the dimensions that we should split on; - * the first element in this vector will be the first element we split - * on, and so on - * @param leaf_size the maximum points in a leaf - * @param old_from_new pointer to an unitialized arraylist; it will map - * new indices to original - * @param new_from_old pointer to an unitialized arraylist; it will map - * original indexes to new indices - */ -/* - template - TKdTree *MakeKdTreeMidpointSelective(arma::Mat& matrix, - const arma::Col& split_dimensions, - index_t leaf_size, - ArrayList& old_from_new - ArrayList& new_from_old) { - TKdTree *node = new TKdTree(); - index_t *old_from_new_ptr; - - if (old_from_new) { - old_from_new->Init(matrix.n_cols); - - for (index_t i = 0; i < matrix.n_cols; i++) { - (*old_from_new)[i] = i; - } - - old_from_new_ptr = old_from_new->begin(); - } else { - old_from_new_ptr = NULL; - } - - node->Init(0, matrix.n_cols); - node->bound().SetSize(split_dimensions.length()); - tree_kdtree_private::SelectFindBoundFromMatrix(matrix, split_dimensions, - 0, matrix.n_cols, &node->bound()); - - tree_kdtree_private::SelectSplitKdTreeMidpoint(matrix, split_dimensions, - node, leaf_size, old_from_new_ptr); - - if (new_from_old) { - new_from_old->Init(matrix.n_cols); - for (index_t i = 0; i < matrix.n_cols; i++) { - (*new_from_old)[(*old_from_new)[i]] = i; - } - } - return node; - } -*/ - /** * Creates a KD tree from data, splitting on the midpoint. * @@ -231,26 +172,6 @@ namespace tree { return node; } -/* - template - TKdTree *MakeKdTreeMidpoint(arma::Mat& matrix, - index_t leaf_size, - ArrayList *old_from_new = NULL, - ArrayList *new_from_old = NULL) { - // create vector of dimensions that we will split on - // by default we'll just split the first dimension first, and so on - Vector split_dimensions; - split_dimensions.Init(matrix.n_rows); - for(int i = 0; i < matrix.n_rows; i++) - split_dimensions[i] = i; - - TKdTree *result; - result = MakeKdTreeMidpointSelective(matrix, split_dimensions, - leaf_size, old_from_new, new_from_old); - return result; - } -*/ - template TKdTree *MakeKdTreeMidpoint(arma::Mat& matrix, index_t leaf_size, diff --git a/fastlib/branches/fastlib-armadillo/fastlib/tree/kdtree_impl.h b/fastlib/branches/fastlib-armadillo/fastlib/tree/kdtree_impl.h index 7b29943198..26ba55a72f 100644 --- a/fastlib/branches/fastlib-armadillo/fastlib/tree/kdtree_impl.h +++ b/fastlib/branches/fastlib-armadillo/fastlib/tree/kdtree_impl.h @@ -37,15 +37,6 @@ #include "../base/arma_compat.h" namespace tree_kdtree_private { - template - void MakeBoundVector(const GenVector& point, - const Vector& bound_dimensions, - GenVector* bound_vector) { - int i; - for (i = 0; i < bound_dimensions.length(); i++) - (*bound_vector)[i] = point[(int) bound_dimensions[i]]; - } - void MakeBoundVector(const arma::vec& point, const arma::uvec& bound_dimensions, arma::vec& bound_vector); @@ -73,12 +64,10 @@ namespace tree_kdtree_private { index_t first, index_t count, TBound *bounds) { - Vector split_dimensions; - split_dimensions.Init(matrix.n_rows); - int i; - for (i = 0; i < matrix.n_rows; i++){ + arma::uvec split_dimensions(matrix.n_rows); + for(int i = 0; i < matrix.n_rows; i++) split_dimensions[i] = i; - } + SelectFindBoundFromMatrix(matrix, split_dimensions, first, count, bounds); }