[mlpack-svn] r15764 - mlpack/trunk/src/mlpack/methods/fastmks

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Wed Sep 11 22:55:40 EDT 2013


Author: rcurtin
Date: Wed Sep 11 22:55:40 2013
New Revision: 15764

Log:
Add lastKernel and lastKernelNode for pre-emptive child pruning.


Modified:
   mlpack/trunk/src/mlpack/methods/fastmks/fastmks_stat.hpp

Modified: mlpack/trunk/src/mlpack/methods/fastmks/fastmks_stat.hpp
==============================================================================
--- mlpack/trunk/src/mlpack/methods/fastmks/fastmks_stat.hpp	(original)
+++ mlpack/trunk/src/mlpack/methods/fastmks/fastmks_stat.hpp	Wed Sep 11 22:55:40 2013
@@ -23,7 +23,12 @@
   /**
    * Default initialization.
    */
-  FastMKSStat() : bound(-DBL_MAX), selfKernel(0.0) { }
+  FastMKSStat() :
+      bound(-DBL_MAX),
+      selfKernel(0.0),
+      lastKernel(0.0),
+      lastKernelNode(NULL)
+  { }
 
   /**
    * Initialize this statistic for the given tree node.  The TreeType's metric
@@ -34,7 +39,9 @@
    */
   template<typename TreeType>
   FastMKSStat(const TreeType& node) :
-      bound(-DBL_MAX)
+      bound(-DBL_MAX),
+      lastKernel(0.0),
+      lastKernelNode(NULL)
   {
     // Do we have to calculate the centroid?
     if (tree::TreeTraits<TreeType>::FirstPointIsCentroid)
@@ -75,12 +82,30 @@
   //! Modify the bound.
   double& Bound() { return bound; }
 
+  //! Get the last kernel evaluation.
+  double LastKernel() const { return lastKernel; }
+  //! Modify the last kernel evaluation.
+  double& LastKernel() { return lastKernel; }
+
+  //! Get the address of the node corresponding to the last distance evaluation.
+  void* LastKernelNode() const { return lastKernelNode; }
+  //! Modify the address of the node corresponding to the last distance
+  //! evaluation.
+  void*& LastKernelNode() { return lastKernelNode; }
+
  private:
   //! The bound for pruning.
   double bound;
 
   //! The self-kernel evaluation: sqrt(K(centroid, centroid)).
   double selfKernel;
+
+  //! The last kernel evaluation.
+  double lastKernel;
+
+  //! The node corresponding to the last kernel evaluation.  This has to be void
+  //! otherwise we get recursive template arguments.
+  void* lastKernelNode;
 };
 
 }; // namespace fastmks



More information about the mlpack-svn mailing list