diff --git a/fastlib/branches/fastlib-stl/mlpack/allnn/allnn.h b/fastlib/branches/fastlib-stl/mlpack/allnn/allnn.h index 8ccdffb008..aa7a66220b 100644 --- a/fastlib/branches/fastlib-stl/mlpack/allnn/allnn.h +++ b/fastlib/branches/fastlib-stl/mlpack/allnn/allnn.h @@ -154,12 +154,12 @@ class AllNN { * Candidate nearest neighbor distances, modified during * compuatation. Later, true nearest neighbor distances. */ - Vector neighbor_distances_; + arma::vec neighbor_distances_; /** * Candidate nearest neighbor indicies, modified during * compuatation. Later, true nearest neighbor indices. */ - GenVector neighbor_indices_; + arma::Col neighbor_indices_; /** Number of node-pairs pruned by the dual-tree algorithm. */ index_t number_of_prunes_; @@ -204,7 +204,6 @@ class AllNN { if (reference_tree_ != query_tree_) { delete reference_tree_; } - } ////////// Helper Functions //////////////////////////////////////// @@ -469,11 +468,11 @@ class AllNN { fx_timer_stop(module_, "tree_building"); /* Ready the list of nearest neighbor candidates to be filled. */ - neighbor_indices_.Init(queries_->n_cols); + neighbor_indices_.set_size(queries_->n_cols); /* Ready the vector of upper bound nn distances for use. */ - neighbor_distances_.Init(queries_->n_cols); - neighbor_distances_.SetAll(DBL_MAX); + neighbor_distances_.set_size(queries_->n_cols); + neighbor_distances_.fill(DBL_MAX); number_of_prunes_ = 0; @@ -490,8 +489,6 @@ class AllNN { if (reference_tree_ != query_tree_) { delete reference_tree_; } - neighbor_distances_.Destruct(); - neighbor_indices_.Destruct(); } @@ -528,11 +525,11 @@ class AllNN { leaf_size_, old_from_new_references_); /* Ready the list of nearest neighbor candidates to be filled. */ - neighbor_indices_.Init(queries_->n_cols); + neighbor_indices_.set_size(queries_->n_cols); /* Ready the vector of upper bound nn distances for use. */ - neighbor_distances_.Init(queries_->n_cols); - neighbor_distances_.SetAll(DBL_MAX); + neighbor_distances_.set_size(queries_->n_cols); + neighbor_distances_.fill(DBL_MAX); number_of_prunes_ = 0; @@ -606,11 +603,11 @@ class AllNN { DEBUG_ASSERT(initialized_ == true); - results.set_size(neighbor_indices_.length()); - distances.set_size(neighbor_distances_.length()); + results.set_size(neighbor_indices_.n_elem); + distances.set_size(neighbor_distances_.n_elem); /* Map the indices back from how they have been permuted. */ - for (index_t i = 0; i < neighbor_indices_.length(); i++) { + for (index_t i = 0; i < neighbor_indices_.n_elem; i++) { results[old_from_new_queries_[i]] = old_from_new_references_[neighbor_indices_[i]]; distances[old_from_new_references_[i]] = neighbor_distances_[i]; diff --git a/fastlib/branches/fastlib-stl/mlpack/allnn/allnn_test.cc b/fastlib/branches/fastlib-stl/mlpack/allnn/allnn_test.cc index eeac9139a0..b8c615b767 100644 --- a/fastlib/branches/fastlib-stl/mlpack/allnn/allnn_test.cc +++ b/fastlib/branches/fastlib-stl/mlpack/allnn/allnn_test.cc @@ -31,7 +31,7 @@ class TestAllNN { public: TestAllNN(fx_module *module) { - module_=module; + module_ = module; } void Init() { allnn_ = new AllNN(); diff --git a/fastlib/branches/fastlib-stl/mlpack/allnn/main.cc b/fastlib/branches/fastlib-stl/mlpack/allnn/main.cc index c1daa620e1..8ef1dd8a22 100644 --- a/fastlib/branches/fastlib-stl/mlpack/allnn/main.cc +++ b/fastlib/branches/fastlib-stl/mlpack/allnn/main.cc @@ -25,19 +25,17 @@ int main (int argc, char *argv[]) { fx_module *fx_root=fx_init(argc, argv, NULL); AllNN allnn; - Matrix data_for_tree; - arma::mat tmp_data; + arma::mat data_for_tree; std::string filename=fx_param_str_req(fx_root, "file"); NOTIFY("Loading file..."); - data::Load(filename.c_str(), tmp_data); - arma_compat::armaToMatrix(tmp_data, data_for_tree); + data::Load(filename.c_str(), data_for_tree); NOTIFY("File loaded..."); - allnn.Init(data_for_tree, fx_root); - //GenVector resulting_neighbors_tree; - //GenVector resulting_distances_tree; + allnn.Init(&data_for_tree, fx_root); + + arma::vec output; NOTIFY("Computing Neighbors..."); - allnn.ComputeNeighbors(NULL, NULL); + allnn.ComputeNeighbors(output); NOTIFY("Neighbors Computed..."); fx_done(fx_root); }