12 #ifndef MLPACK_METHODS_RANGE_SEARCH_RS_MODEL_IMPL_HPP 13 #define MLPACK_METHODS_RANGE_SEARCH_RS_MODEL_IMPL_HPP 23 template<
template<
typename TreeMetricType,
24 typename TreeStatType,
25 typename TreeMatType>
class TreeType>
29 rs.Train(std::move(referenceSet));
32 template<
template<
typename TreeMetricType,
33 typename TreeStatType,
34 typename TreeMatType>
class TreeType>
35 void
RSWrapper<TreeType>::Search(arma::mat&& querySet,
36 const math::Range& range,
37 std::vector<std::vector<size_t>>& neighbors,
38 std::vector<std::vector<double>>& distances,
41 rs.
Search(std::move(querySet), range, neighbors, distances);
44 template<
template<
typename TreeMetricType,
45 typename TreeStatType,
46 typename TreeMatType>
class TreeType>
47 void
RSWrapper<TreeType>::Search(const math::Range& range,
48 std::vector<std::vector<size_t>>& neighbors,
49 std::vector<std::vector<double>>& distances)
51 rs.
Search(range, neighbors, distances);
54 template<
template<
typename TreeMetricType,
55 typename TreeStatType,
56 typename TreeMatType>
class TreeType>
58 const size_t leafSize)
62 rs.Train(std::move(referenceSet));
66 std::vector<size_t> oldFromNewReferences;
67 typename decltype(rs)::Tree* tree =
68 new typename decltype(rs)::Tree(std::move(referenceSet),
75 rs.oldFromNewReferences = std::move(oldFromNewReferences);
79 template<
template<
typename TreeMetricType,
80 typename TreeStatType,
81 typename TreeMatType>
class TreeType>
84 const math::Range& range,
85 std::vector<std::vector<size_t>>& neighbors,
86 std::vector<std::vector<double>>& distances,
87 const size_t leafSize)
89 if (!rs.Naive() && !rs.SingleMode())
93 Log::Info <<
"Building query tree..." << std::endl;
94 std::vector<size_t> oldFromNewQueries;
95 typename decltype(rs)::Tree queryTree(std::move(querySet),
101 std::vector<std::vector<size_t>> neighborsOut;
102 std::vector<std::vector<double>> distancesOut;
103 rs.Search(&queryTree, range, neighborsOut, distancesOut);
106 neighbors.resize(queryTree.Dataset().n_cols);
107 distances.resize(queryTree.Dataset().n_cols);
108 for (
size_t i = 0; i < queryTree.Dataset().n_cols; ++i)
110 neighbors[oldFromNewQueries[i]] = neighborsOut[i];
111 distances[oldFromNewQueries[i]] = distancesOut[i];
116 rs.Search(std::move(querySet), range, neighbors, distances);
121 template<
typename Archive>
124 ar(CEREAL_NVP(treeType));
125 ar(CEREAL_NVP(randomBasis));
129 if (cereal::is_loading<Archive>())
130 InitializeModel(
false,
false);
139 ar(CEREAL_NVP(typedSearch));
146 ar(CEREAL_NVP(typedSearch));
154 ar(CEREAL_NVP(typedSearch));
162 ar(CEREAL_NVP(typedSearch));
170 ar(CEREAL_NVP(typedSearch));
177 ar(CEREAL_NVP(typedSearch));
185 ar(CEREAL_NVP(typedSearch));
193 ar(CEREAL_NVP(typedSearch));
197 case R_PLUS_PLUS_TREE:
201 ar(CEREAL_NVP(typedSearch));
209 ar(CEREAL_NVP(typedSearch));
217 ar(CEREAL_NVP(typedSearch));
225 ar(CEREAL_NVP(typedSearch));
232 ar(CEREAL_NVP(typedSearch));
239 ar(CEREAL_NVP(typedSearch));
RSWrapper is a wrapper class for most RangeSearch types.
Definition: rs_model.hpp:86
static void Start(const std::string &name)
Start the given timer.
Definition: timers.cpp:28
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
Forward declaration.
Definition: range_search.hpp:28
void serialize(Archive &ar, const uint32_t)
Serialize the range search model.
Definition: rs_model_impl.hpp:122
virtual void Search(arma::mat &&querySet, const math::Range &range, std::vector< std::vector< size_t >> &neighbors, std::vector< std::vector< double >> &distances, const size_t)
Perform bichromatic range search (i.e.
Definition: rs_model_impl.hpp:35
Definition: hmm_train_main.cpp:300
static void Stop(const std::string &name)
Stop the given timer.
Definition: timers.cpp:36
static MLPACK_EXPORT util::PrefixedOutStream Info
Prints informational messages if –verbose is specified, prefixed with [INFO ].
Definition: log.hpp:84