13 #ifndef MLPACK_METHODS_RANGE_SEARCH_RANGE_SEARCH_HPP 14 #define MLPACK_METHODS_RANGE_SEARCH_RANGE_SEARCH_HPP 25 template<
template<
typename TreeMetricType,
26 typename TreeStatType,
27 typename TreeMatType>
class TreeType>
41 typename MatType = arma::mat,
42 template<
typename TreeMetricType,
43 typename TreeStatType,
49 typedef TreeType<MetricType, RangeSearchStat, MatType>
Tree;
68 const bool naive =
false,
69 const bool singleMode =
false,
70 const MetricType metric = MetricType());
95 const bool singleMode =
false,
96 const MetricType metric = MetricType());
109 const bool singleMode =
false,
110 const MetricType metric = MetricType());
158 void Train(MatType referenceSet);
163 void Train(Tree* referenceTree);
192 void Search(
const MatType& querySet,
194 std::vector<std::vector<size_t>>& neighbors,
195 std::vector<std::vector<double>>& distances);
233 void Search(Tree* queryTree,
235 std::vector<std::vector<size_t>>& neighbors,
236 std::vector<std::vector<double>>& distances);
268 std::vector<std::vector<size_t>>& neighbors,
269 std::vector<std::vector<double>>& distances);
277 bool Naive()
const {
return naive; }
287 template<
typename Archive>
288 void serialize(Archive& ar,
const uint32_t version);
298 std::vector<size_t> oldFromNewReferences;
303 const MatType* referenceSet;
329 #include "range_search_impl.hpp" The RangeSearch class is a template class for performing range searches.
size_t BaseCases() const
Get the number of base cases during the last search.
bool & Naive()
Modify whether naive search is being used.
Tree * ReferenceTree()
Return the reference tree (or NULL if in naive mode).
Linear algebra utility functions, generally performed on matrices or vectors.
bool Naive() const
Get whether naive search is being used.
The core includes that mlpack expects; standard C++ includes and Armadillo.
RangeSearch & operator=(const RangeSearch &other)
Deep copy the given RangeSearch model.
A binary space partitioning tree, such as a KD-tree or a ball tree.
void serialize(Archive &ar, const uint32_t version)
Serialize the model.
void Train(MatType referenceSet)
Set the reference set to a new reference set, and build a tree if necessary.
bool & SingleMode()
Modify whether single-tree search is being used.
~RangeSearch()
Destroy the RangeSearch object.
TreeType< MetricType, RangeSearchStat, MatType > Tree
Convenience typedef.
void Search(const MatType &querySet, const math::Range &range, std::vector< std::vector< size_t >> &neighbors, std::vector< std::vector< double >> &distances)
Search for all reference points in the given range for each point in the query set, returning the results in the neighbors and distances objects.
bool SingleMode() const
Get whether single-tree search is being used.
RangeSearch(MatType referenceSet, const bool naive=false, const bool singleMode=false, const MetricType metric=MetricType())
Initialize the RangeSearch object with a given reference dataset (this is the dataset which is search...
const MatType & ReferenceSet() const
Return the reference set.
LMetric< 2, true > EuclideanDistance
The Euclidean (L2) distance.
size_t Scores() const
Get the number of scores during the last search.