mlpack  master
neighbor_search_stat.hpp
Go to the documentation of this file.
1 
13 #ifndef MLPACK_METHODS_NEIGHBOR_SEARCH_NEIGHBOR_SEARCH_STAT_HPP
14 #define MLPACK_METHODS_NEIGHBOR_SEARCH_NEIGHBOR_SEARCH_STAT_HPP
15 
16 #include <mlpack/prereqs.hpp>
17 
18 namespace mlpack {
19 namespace neighbor {
20 
25 template<typename SortPolicy>
27 {
28  private:
31  double firstBound;
36  double secondBound;
39  double auxBound;
41  double lastDistance;
42 
43  public:
49  firstBound(SortPolicy::WorstDistance()),
50  secondBound(SortPolicy::WorstDistance()),
51  auxBound(SortPolicy::WorstDistance()),
52  lastDistance(0.0) { }
53 
58  template<typename TreeType>
59  NeighborSearchStat(TreeType& /* node */) :
60  firstBound(SortPolicy::WorstDistance()),
61  secondBound(SortPolicy::WorstDistance()),
62  auxBound(SortPolicy::WorstDistance()),
63  lastDistance(0.0) { }
64 
68  void Reset()
69  {
70  firstBound = SortPolicy::WorstDistance();
71  secondBound = SortPolicy::WorstDistance();
72  auxBound = SortPolicy::WorstDistance();
73  lastDistance = 0.0;
74  }
75 
77  double FirstBound() const { return firstBound; }
79  double& FirstBound() { return firstBound; }
81  double SecondBound() const { return secondBound; }
83  double& SecondBound() { return secondBound; }
85  double AuxBound() const { return auxBound; }
87  double& AuxBound() { return auxBound; }
89  double LastDistance() const { return lastDistance; }
91  double& LastDistance() { return lastDistance; }
92 
94  template<typename Archive>
95  void Serialize(Archive& ar, const unsigned int /* version */)
96  {
97  using data::CreateNVP;
98 
99  ar & CreateNVP(firstBound, "firstBound");
100  ar & CreateNVP(secondBound, "secondBound");
101  ar & CreateNVP(auxBound, "auxBound");
102  ar & CreateNVP(lastDistance, "lastDistance");
103  }
104 };
105 
106 } // namespace neighbor
107 } // namespace mlpack
108 
109 #endif
void Reset()
Reset statistic parameters to initial values.
NeighborSearchStat(TreeType &)
Initialization for a fully initialized node.
double secondBound
The second bound on the node&#39;s neighbor distances (B_2).
double & AuxBound()
Modify the aux bound.
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: binarize.hpp:18
double lastDistance
The last distance evaluation.
Extra data for each node in the tree.
The core includes that mlpack expects; standard C++ includes and Armadillo.
FirstShim< T > CreateNVP(T &t, const std::string &name, typename std::enable_if_t< HasSerialize< T >::value > *=0)
Call this function to produce a name-value pair; this is similar to BOOST_SERIALIZATION_NVP(), but should be used for types that have a Serialize() function (or contain a type that has a Serialize() function) instead of a serialize() function.
double FirstBound() const
Get the first bound.
NeighborSearchStat()
Initialize the statistic with the worst possible distance according to our sorting policy...
double firstBound
The first bound on the node&#39;s neighbor distances (B_1).
double & FirstBound()
Modify the first bound.
double LastDistance() const
Get the last distance calculation.
double & SecondBound()
Modify the second bound.
double auxBound
The aux bound on the node&#39;s neighbor distances (B_aux).
void Serialize(Archive &ar, const unsigned int)
Serialize the statistic to/from an archive.
double SecondBound() const
Get the second bound.
double AuxBound() const
Get the aux bound.
double & LastDistance()
Modify the last distance calculation.