[mlpack-git] mlpack-2.x: Move mlpack_allkrann to mlpack_krann, preserving backwards compatibility. (f9bef96)
gitdub at mlpack.org
gitdub at mlpack.org
Thu Jun 16 10:52:52 EDT 2016
Repository : https://github.com/mlpack/mlpack
On branch : mlpack-2.x
Link : https://github.com/mlpack/mlpack/compare/909d69e4bff15bb4db0b3d05739f6963123e346a...92a7f9a1849cd89c0861b3e4b08cf32f33936daa
>---------------------------------------------------------------
commit f9bef96efc34af8e04a52fb9baacfc75efeaf656
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.
>---------------------------------------------------------------
f9bef96efc34af8e04a52fb9baacfc75efeaf656
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 f264d8d..321cb63 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 fbe9246..473fcd2 100644
--- a/HISTORY.md
+++ b/HISTORY.md
@@ -27,9 +27,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 e8ba7ad..37f9cde 100644
--- a/src/mlpack/core.hpp
+++ b/src/mlpack/core.hpp
@@ -66,7 +66,6 @@
* A full list of executables is given below:
*
* - mlpack_adaboost
- * - mlpack_allkrann
* - mlpack_cf
* - mlpack_decision_stump
* - mlpack_det
@@ -84,6 +83,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 40c05cf..600ccb2 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.
*
* This file is part of mlpack 2.0.2.
@@ -33,7 +33,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 a3d7fd7..a0a42ef 100644
--- a/src/mlpack/methods/rann/ra_typedef.hpp
+++ b/src/mlpack/methods/rann/ra_typedef.hpp
@@ -35,32 +35,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 1b97640..257152c 100644
--- a/src/mlpack/tests/CMakeLists.txt
+++ b/src/mlpack/tests/CMakeLists.txt
@@ -2,7 +2,6 @@
add_executable(mlpack_test
mlpack_test.cpp
adaboost_test.cpp
- allkrann_search_test.cpp
arma_extend_test.cpp
aug_lagrangian_test.cpp
cf_test.cpp
@@ -23,6 +22,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 ebaad37..7aee87c 100644
--- a/src/mlpack/tests/allkrann_search_test.cpp
+++ b/src/mlpack/tests/krann_search_test.cpp
@@ -37,9 +37,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;
@@ -577,8 +577,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);
@@ -605,7 +605,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