MLPACK  1.0.11
fastmks_stat.hpp
Go to the documentation of this file.
1 
22 #ifndef __MLPACK_METHODS_FASTMKS_FASTMKS_STAT_HPP
23 #define __MLPACK_METHODS_FASTMKS_FASTMKS_STAT_HPP
24 
25 #include <mlpack/core.hpp>
27 
28 namespace mlpack {
29 namespace fastmks {
30 
36 {
37  public:
42  bound(-DBL_MAX),
43  selfKernel(0.0),
44  lastKernel(0.0),
45  lastKernelNode(NULL)
46  { }
47 
55  template<typename TreeType>
56  FastMKSStat(const TreeType& node) :
57  bound(-DBL_MAX),
58  lastKernel(0.0),
59  lastKernelNode(NULL)
60  {
61  // Do we have to calculate the centroid?
63  {
64  // If this type of tree has self-children, then maybe the evaluation is
65  // already done. These statistics are built bottom-up, so the child stat
66  // should already be done.
68  (node.NumChildren() > 0) &&
69  (node.Point(0) == node.Child(0).Point(0)))
70  {
71  selfKernel = node.Child(0).Stat().SelfKernel();
72  }
73  else
74  {
75  selfKernel = sqrt(node.Metric().Kernel().Evaluate(
76  node.Dataset().unsafe_col(node.Point(0)),
77  node.Dataset().unsafe_col(node.Point(0))));
78  }
79  }
80  else
81  {
82  // Calculate the centroid.
83  arma::vec centroid;
84  node.Centroid(centroid);
85 
86  selfKernel = sqrt(node.Metric().Kernel().Evaluate(centroid, centroid));
87  }
88  }
89 
91  double SelfKernel() const { return selfKernel; }
93  double& SelfKernel() { return selfKernel; }
94 
96  double Bound() const { return bound; }
98  double& Bound() { return bound; }
99 
101  double LastKernel() const { return lastKernel; }
103  double& LastKernel() { return lastKernel; }
104 
106  void* LastKernelNode() const { return lastKernelNode; }
109  void*& LastKernelNode() { return lastKernelNode; }
110 
111  private:
113  double bound;
114 
116  double selfKernel;
117 
119  double lastKernel;
120 
124 };
125 
126 }; // namespace fastmks
127 }; // namespace mlpack
128 
129 #endif
void * lastKernelNode
The node corresponding to the last kernel evaluation.
double lastKernel
The last kernel evaluation.
double LastKernel() const
Get the last kernel evaluation.
double & LastKernel()
Modify the last kernel evaluation.
FastMKSStat(const TreeType &node)
Initialize this statistic for the given tree node.
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: load.hpp:31
double & Bound()
Modify the bound.
double selfKernel
The self-kernel evaluation: sqrt(K(centroid, centroid)).
double bound
The bound for pruning.
double & SelfKernel()
Modify the self-kernel.
FastMKSStat()
Default initialization.
double Bound() const
Get the bound.
double SelfKernel() const
Get the self-kernel.
void *& LastKernelNode()
Modify the address of the node corresponding to the last distance evaluation.
The TreeTraits class provides compile-time information on the characteristics of a given tree type...
Definition: tree_traits.hpp:88
The statistic used in trees with FastMKS.
void * LastKernelNode() const
Get the address of the node corresponding to the last distance evaluation.