[mlpack-git] master: Move mlpack_allkrann to mlpack_krann, preserving backwards compatibility. (a0b31ab)
gitdub at mlpack.org
gitdub at mlpack.org
Thu Jun 16 10:58:00 EDT 2016
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/a8b5be966f2b874d31c9e2a65583a3a874ff36d7...a0b31abe5ff69117645c664dbeac1476dd5e48f7
>---------------------------------------------------------------
commit a0b31abe5ff69117645c664dbeac1476dd5e48f7
Author: Ryan Curtin <ryan at ratml.org>
Date: Thu Jun 16 10:52:52 2016 -0400
Move mlpack_allkrann to mlpack_krann, preserving backwards compatibility.
>---------------------------------------------------------------
a0b31abe5ff69117645c664dbeac1476dd5e48f7
CMakeLists.txt | 2 +-
HISTORY.md | 6 +--
src/mlpack/core.hpp | 2 +-
src/mlpack/methods/rann/CMakeLists.txt | 20 ++++++++--
.../rann/{allkrann_main.cpp => krann_main.cpp} | 4 +-
src/mlpack/methods/rann/ra_typedef.hpp | 43 +++++++++++++++++-----
src/mlpack/tests/CMakeLists.txt | 2 +-
...krann_search_test.cpp => krann_search_test.cpp} | 10 ++---
8 files changed, 62 insertions(+), 27 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e0525e1..b5ce3bc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -365,7 +365,7 @@ if (UNIX)
mlpack_adaboost
mlpack_kfn
mlpack_knn
- mlpack_allkrann
+ mlpack_krann
mlpack_cf
mlpack_decision_stump
mlpack_det
diff --git a/HISTORY.md b/HISTORY.md
index 56ba8bd..a129f00 100644
--- a/HISTORY.md
+++ b/HISTORY.md
@@ -25,9 +25,9 @@
and MLPACK_VERSION_PATCH. The old names will remain in place until
mlpack 3.0.0.
- * Renamed mlpack_allknn and mlpack_allkfn to mlpack_knn and mlpack_kfn. The
- mlpack_allknn and mlpack_allkfn programs will remain as copies until mlpack
- 3.0.0.
+ * Renamed mlpack_allknn, mlpack_allkfn, and mlpack_allkrann to mlpack_knn,
+ mlpack_kfn, and mlpack_krann. The mlpack_allknn, mlpack_allkfn, and
+ mlpack_allkrann programs will remain as copies until mlpack 3.0.0.
* Add --random_initialization option to mlpack_hmm_train, for use when no
labels are provided.
diff --git a/src/mlpack/core.hpp b/src/mlpack/core.hpp
index c0cbeea..6f5c181 100644
--- a/src/mlpack/core.hpp
+++ b/src/mlpack/core.hpp
@@ -51,7 +51,6 @@
* A full list of executables is given below:
*
* - mlpack_adaboost
- * - mlpack_allkrann
* - mlpack_cf
* - mlpack_decision_stump
* - mlpack_det
@@ -69,6 +68,7 @@
* - mlpack_kfn
* - mlpack_kmeans
* - mlpack_knn
+ * - mlpack_krann
* - mlpack_lars
* - mlpack_linear_regression
* - mlpack_local_coordinate_coding
diff --git a/src/mlpack/methods/rann/CMakeLists.txt b/src/mlpack/methods/rann/CMakeLists.txt
index 2effb36..906c4e6 100644
--- a/src/mlpack/methods/rann/CMakeLists.txt
+++ b/src/mlpack/methods/rann/CMakeLists.txt
@@ -30,10 +30,22 @@ set(DIR_SRCS)
foreach(file ${SOURCES})
set(DIR_SRCS ${DIR_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/${file})
endforeach()
-# append sources (with directory name) to list of all mlpack sources (used at the parent scope)
+# Append sources (with directory name) to list of all mlpack sources (used at the parent scope)
set(MLPACK_SRCS ${MLPACK_SRCS} ${DIR_SRCS} PARENT_SCOPE)
+# The code to compute the rank-approximate neighbor for the given query and
+# reference sets.
+add_cli_executable(krann)
+
+if (BUILD_CLI_EXECUTABLES)
+ # Compatibility: retain mlpack_allkrann until mlpack 3.0.0.
+ get_property(krann_loc TARGET mlpack_krann PROPERTY LOCATION)
+ get_filename_component(krann_ext ${krann_loc} EXT)
+
+ add_custom_command(TARGET mlpack_krann POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E copy
+ $<TARGET_FILE:mlpack_krann>
+ $<TARGET_FILE_DIR:mlpack_krann>/mlpack_allkrann${kfn_ext}
+ )
+endif ()
-# The code to compute the rank-approximate neighbor
-# for the given query and reference sets
-add_cli_executable(allkrann)
diff --git a/src/mlpack/methods/rann/allkrann_main.cpp b/src/mlpack/methods/rann/krann_main.cpp
similarity index 98%
rename from src/mlpack/methods/rann/allkrann_main.cpp
rename to src/mlpack/methods/rann/krann_main.cpp
index 2eb2b8b..5fede84 100644
--- a/src/mlpack/methods/rann/allkrann_main.cpp
+++ b/src/mlpack/methods/rann/krann_main.cpp
@@ -2,7 +2,7 @@
* @file allkrann_main.cpp
* @author Parikshit Ram
*
- * Implementation of the AllkRANN executable. Allows some number of standard
+ * Implementation of the kRANN executable. Allows some number of standard
* options.
*/
#include <mlpack/core.hpp>
@@ -18,7 +18,7 @@ using namespace mlpack::tree;
using namespace mlpack::metric;
// Information about the program itself.
-PROGRAM_INFO("All K-Rank-Approximate-Nearest-Neighbors",
+PROGRAM_INFO("K-Rank-Approximate-Nearest-Neighbors (kRANN)",
"This program will calculate the k rank-approximate-nearest-neighbors of a "
"set of points. You may specify a separate set of reference points and "
"query points, or just a reference set which will be used as both the "
diff --git a/src/mlpack/methods/rann/ra_typedef.hpp b/src/mlpack/methods/rann/ra_typedef.hpp
index 41d7e29..553dd04 100644
--- a/src/mlpack/methods/rann/ra_typedef.hpp
+++ b/src/mlpack/methods/rann/ra_typedef.hpp
@@ -20,32 +20,55 @@ namespace mlpack {
namespace neighbor {
/**
- * The AllkRANN class is the all-k-rank-approximate-nearest-neighbors method.
- * It returns squared L2 distances (squared Euclidean distances) for each of the
- * k rank-approximate nearest-neighbors. Squared distances are used because
- * they are slightly faster than non-squared distances (they have one fewer call
- * to sqrt()).
+ * The KRANN class is the k-rank-approximate-nearest-neighbors method. It
+ * returns L2 distances for each of the k rank-approximate nearest-neighbors.
*
* The approximation is controlled with two parameters (see allkrann_main.cpp)
* which can be specified at search time. So the tree building is done only once
* while the search can be performed multiple times with different approximation
* levels.
*/
+typedef RASearch<> KRANN;
+
+/**
+ * The KRAFN class is the k-rank-approximate-farthest-neighbors method. It
+ * returns L2 distances for each of the k rank-approximate farthest-neighbors.
+ *
+ * The approximation is controlled with two parameters (see allkrann_main.cpp)
+ * which can be specified at search time. So the tree building is done only once
+ * while the search can be performed multiple times with different approximation
+ * levels.
+ */
+typedef RASearch<FurthestNeighborSort> KRAFN;
+
+/**
+ * @deprecated
+ * The AllkRANN class is the all-k-rank-approximate-nearest-neighbors method. It
+ * returns L2 distances for each of the k rank-approximate nearest-neighbors.
+ *
+ * The approximation is controlled with two parameters (see allkrann_main.cpp)
+ * which can be specified at search time. So the tree building is done only once
+ * while the search can be performed multiple times with different approximation
+ * levels.
+ *
+ * This typedef will be removed in mlpack 3.0.0; use the KRANN typedef instead.
+ */
typedef RASearch<> AllkRANN;
/**
+ * @deprecated
* The AllkRAFN class is the all-k-rank-approximate-farthest-neighbors method.
- * It returns squared L2 distances (squared Euclidean distances) for each of the
- * k rank-approximate farthest-neighbors. Squared distances are used because
- * they are slightly faster than non-squared distances (they have one fewer
- * call to sqrt()).
+ * It returns L2 distances for each of the k rank-approximate
+ * farthest-neighbors.
*
* The approximation is controlled with two parameters (see allkrann_main.cpp)
* which can be specified at search time. So the tree building is done only once
* while the search can be performed multiple times with different approximation
* levels.
+ *
+ * This typedef will be removed in mlpack 3.0.0; use the KRANN typedef instead.
*/
-typedef RASearch<FurthestNeighborSort> AllkRAFN;
+typedef RASearch<> AllkRAFN;
} // namespace neighbor
} // namespace mlpack
diff --git a/src/mlpack/tests/CMakeLists.txt b/src/mlpack/tests/CMakeLists.txt
index 8b36a94..4a3d406 100644
--- a/src/mlpack/tests/CMakeLists.txt
+++ b/src/mlpack/tests/CMakeLists.txt
@@ -5,7 +5,6 @@ add_executable(mlpack_test
adaboost_test.cpp
adam_test.cpp
ada_delta_test.cpp
- allkrann_search_test.cpp
arma_extend_test.cpp
aug_lagrangian_test.cpp
cf_test.cpp
@@ -30,6 +29,7 @@ add_executable(mlpack_test
kfn_test.cpp
kmeans_test.cpp
knn_test.cpp
+ krann_search_test.cpp
lars_test.cpp
lbfgs_test.cpp
lin_alg_test.cpp
diff --git a/src/mlpack/tests/allkrann_search_test.cpp b/src/mlpack/tests/krann_search_test.cpp
similarity index 99%
rename from src/mlpack/tests/allkrann_search_test.cpp
rename to src/mlpack/tests/krann_search_test.cpp
index 757811a..37e9b35 100644
--- a/src/mlpack/tests/allkrann_search_test.cpp
+++ b/src/mlpack/tests/krann_search_test.cpp
@@ -22,9 +22,9 @@ using namespace mlpack::tree;
using namespace mlpack::metric;
using namespace mlpack::bound;
-BOOST_AUTO_TEST_SUITE(AllkRANNTest);
+BOOST_AUTO_TEST_SUITE(KRANNTest);
-// Test the correctness and guarantees of AllkRANN when in naive mode.
+// Test the correctness and guarantees of KRANN when in naive mode.
BOOST_AUTO_TEST_CASE(NaiveGuaranteeTest)
{
arma::Mat<size_t> neighbors;
@@ -562,8 +562,8 @@ BOOST_AUTO_TEST_CASE(MoveConstructorTest)
arma::mat dataset = arma::randu<arma::mat>(3, 200);
arma::mat copy(dataset);
- AllkRANN moveknn(std::move(copy));
- AllkRANN knn(dataset);
+ KRANN moveknn(std::move(copy));
+ KRANN knn(dataset);
BOOST_REQUIRE_EQUAL(copy.n_elem, 0);
BOOST_REQUIRE_EQUAL(moveknn.ReferenceSet().n_rows, 3);
@@ -590,7 +590,7 @@ BOOST_AUTO_TEST_CASE(MoveTrainTest)
arma::mat dataset = arma::randu<arma::mat>(3, 200);
// Do it in tree mode, and in naive mode.
- AllkRANN knn;
+ KRANN knn;
knn.Train(std::move(dataset));
arma::mat distances;
More information about the mlpack-git
mailing list