[mlpack-svn] r15909 - mlpack/trunk/src/mlpack/tests
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Wed Oct 2 22:05:37 EDT 2013
Author: rcurtin
Date: Wed Oct 2 22:05:36 2013
New Revision: 15909
Log:
Add test for DiagonalConstraint.
Modified:
mlpack/trunk/src/mlpack/tests/gmm_test.cpp
Modified: mlpack/trunk/src/mlpack/tests/gmm_test.cpp
==============================================================================
--- mlpack/trunk/src/mlpack/tests/gmm_test.cpp (original)
+++ mlpack/trunk/src/mlpack/tests/gmm_test.cpp Wed Oct 2 22:05:36 2013
@@ -11,6 +11,7 @@
#include <mlpack/methods/gmm/no_constraint.hpp>
#include <mlpack/methods/gmm/positive_definite_constraint.hpp>
+#include <mlpack/methods/gmm/diagonal_constraint.hpp>
#include <boost/test/unit_test.hpp>
#include "old_boost_test_definitions.hpp"
@@ -657,4 +658,22 @@
}
}
+BOOST_AUTO_TEST_CASE(DiagonalConstraintTest)
+{
+ // Make sure matrices are made to be positive definite.
+ for (size_t i = 0; i < 30; ++i)
+ {
+ const size_t elem = 5 + math::RandInt(50);
+ arma::mat cov(elem, elem);
+ cov.randu();
+
+ DiagonalConstraint::ApplyConstraint(cov);
+
+ for (size_t j = 0; j < elem; ++j)
+ for (size_t k = 0; k < elem; ++k)
+ if (j != k)
+ BOOST_REQUIRE_SMALL(cov(j, k), 1e-50);
+ }
+}
+
BOOST_AUTO_TEST_SUITE_END();
More information about the mlpack-svn
mailing list