[mlpack-svn] r13957 - mlpack/trunk/src/mlpack/tests

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Thu Nov 29 19:10:13 EST 2012


Author: rcurtin
Date: 2012-11-29 19:10:12 -0500 (Thu, 29 Nov 2012)
New Revision: 13957

Modified:
   mlpack/trunk/src/mlpack/tests/tree_test.cpp
Log:
Add a test for the furthest descendant distance.


Modified: mlpack/trunk/src/mlpack/tests/tree_test.cpp
===================================================================
--- mlpack/trunk/src/mlpack/tests/tree_test.cpp	2012-11-30 00:09:59 UTC (rev 13956)
+++ mlpack/trunk/src/mlpack/tests/tree_test.cpp	2012-11-30 00:10:12 UTC (rev 13957)
@@ -1490,6 +1490,21 @@
   BOOST_REQUIRE(rootNode.Right()->Right()->Count() == 1);
 }
 
+// Ensure FurthestDescendantDistance() works.
+BOOST_AUTO_TEST_CASE(FurthestDescendantDistanceTest)
+{
+  arma::mat dataset = "1; 3"; // One point.
+  BinarySpaceTree<HRectBound<2> > rootNode(dataset, 1);
+
+  BOOST_REQUIRE_SMALL(rootNode.FurthestDescendantDistance(), 1e-5);
+
+  dataset = "1 -1; 1 -1"; // Square of size [2, 2].
+
+  // Both points are contained in the one node.
+  BinarySpaceTree<HRectBound<2> > twoPoint(dataset);
+  BOOST_REQUIRE_CLOSE(twoPoint.FurthestDescendantDistance(), 2, 1e-5);
+}
+
 // Forward declaration of methods we need for the next test.
 template<typename TreeType, typename MatType>
 bool CheckPointBounds(TreeType* node, const MatType& data);




More information about the mlpack-svn mailing list