mlpack  1.0.12
fastmks_stat.hpp
Go to the documentation of this file.
1 
14 #ifndef __MLPACK_METHODS_FASTMKS_FASTMKS_STAT_HPP
15 #define __MLPACK_METHODS_FASTMKS_FASTMKS_STAT_HPP
16 
17 #include <mlpack/core.hpp>
19 
20 namespace mlpack {
21 namespace fastmks {
22 
28 {
29  public:
34  bound(-DBL_MAX),
35  selfKernel(0.0),
36  lastKernel(0.0),
37  lastKernelNode(NULL)
38  { }
39 
47  template<typename TreeType>
48  FastMKSStat(const TreeType& node) :
49  bound(-DBL_MAX),
50  lastKernel(0.0),
51  lastKernelNode(NULL)
52  {
53  // Do we have to calculate the centroid?
55  {
56  // If this type of tree has self-children, then maybe the evaluation is
57  // already done. These statistics are built bottom-up, so the child stat
58  // should already be done.
60  (node.NumChildren() > 0) &&
61  (node.Point(0) == node.Child(0).Point(0)))
62  {
63  selfKernel = node.Child(0).Stat().SelfKernel();
64  }
65  else
66  {
67  selfKernel = sqrt(node.Metric().Kernel().Evaluate(
68  node.Dataset().unsafe_col(node.Point(0)),
69  node.Dataset().unsafe_col(node.Point(0))));
70  }
71  }
72  else
73  {
74  // Calculate the centroid.
75  arma::vec centroid;
76  node.Centroid(centroid);
77 
78  selfKernel = sqrt(node.Metric().Kernel().Evaluate(centroid, centroid));
79  }
80  }
81 
83  double SelfKernel() const { return selfKernel; }
85  double& SelfKernel() { return selfKernel; }
86 
88  double Bound() const { return bound; }
90  double& Bound() { return bound; }
91 
93  double LastKernel() const { return lastKernel; }
95  double& LastKernel() { return lastKernel; }
96 
98  void* LastKernelNode() const { return lastKernelNode; }
101  void*& LastKernelNode() { return lastKernelNode; }
102 
103  private:
105  double bound;
106 
108  double selfKernel;
109 
111  double lastKernel;
112 
116 };
117 
118 }; // namespace fastmks
119 }; // namespace mlpack
120 
121 #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:23
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:80
The statistic used in trees with FastMKS.
void * LastKernelNode() const
Get the address of the node corresponding to the last distance evaluation.