From 53cae8db56c9637ffaec514e19a1c7dfcbfca824 Mon Sep 17 00:00:00 2001 From: Ryan Curtin Date: Thu, 24 Jun 2010 00:13:01 +0000 Subject: [PATCH] Fix main executable to stop using Matrix or Vector or ArrayList entirely. --- .../fastlib-stl/mlpack/allkfn/main.cc | 32 ++++++++----------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/fastlib/branches/fastlib-stl/mlpack/allkfn/main.cc b/fastlib/branches/fastlib-stl/mlpack/allkfn/main.cc index 9e744f40a9..bd67e25bcd 100644 --- a/fastlib/branches/fastlib-stl/mlpack/allkfn/main.cc +++ b/fastlib/branches/fastlib-stl/mlpack/allkfn/main.cc @@ -28,36 +28,32 @@ int main(int argc, char *argv[]) { fx_module *module = fx_init(argc, argv, NULL); std::string result_file = fx_param_str(module, "result_file", "result.txt"); std::string reference_file = fx_param_str_req(module, "reference_file"); - Matrix reference_data; - arma::mat tmp_ref; - ArrayList neighbors; - ArrayList distances; - if (data::Load(reference_file.c_str(), tmp_ref)==SUCCESS_FAIL) { + arma::mat reference_data; + arma::Col neighbors; + arma::vec distances; + if (data::Load(reference_file.c_str(), reference_data)==SUCCESS_FAIL) { FATAL("Reference file %s not found", reference_file.c_str()); } - arma_compat::armaToMatrix(tmp_ref, reference_data); NOTIFY("Loaded reference data from file %s", reference_file.c_str()); AllkFN allkfn; if (fx_param_exists(module, "query_file")) { - std::string query_file=fx_param_str_req(module, "query_file"); - Matrix query_data; - arma::mat tmp_query; - if (data::Load(query_file.c_str(), tmp_query)==SUCCESS_FAIL) { + std::string query_file = fx_param_str_req(module, "query_file"); + arma::mat query_data; + if (data::Load(query_file.c_str(), query_data)==SUCCESS_FAIL) { FATAL("Query file %s not found", query_file.c_str()); } - arma_compat::armaToMatrix(tmp_query, query_data); NOTIFY("Query data loaded from %s", query_file.c_str()); NOTIFY("Building query and reference tree"); - allkfn.Init(query_data, reference_data, module); + allkfn.Init(&query_data, &reference_data, module); } else { NOTIFY("Building reference tree"); - allkfn.Init(reference_data, module); + allkfn.Init(&reference_data, module); } NOTIFY("Tree(s) built"); - index_t kfns=fx_param_int_req(module, "kfns"); + index_t kfns = fx_param_int_req(module, "kfns"); NOTIFY("Computing %"LI"d furthest neighbors", kfns); - allkfn.ComputeNeighbors(&neighbors, &distances); + allkfn.ComputeNeighbors(neighbors, distances); NOTIFY("Neighbors computed"); NOTIFY("Exporting results"); FILE *fp=fopen(result_file.c_str(), "w"); @@ -65,9 +61,9 @@ int main(int argc, char *argv[]) { FATAL("Error while opening %s...%s", result_file.c_str(), strerror(errno)); } - for(index_t i=0 ; i < neighbors.size()/kfns ; i++) { - for(index_t j=0; j