[mlpack] 259/324: * added tests for PlainSVD

Barak A. Pearlmutter barak+git at cs.nuim.ie
Sun Aug 17 08:22:16 UTC 2014


This is an automated email from the git hooks/post-receive script.

bap pushed a commit to branch svn-trunk
in repository mlpack.

commit 9f564cf4673ee2882e6ed017689bd25934468057
Author: sumedhghaisas <sumedhghaisas at 9d5b8971-822b-0410-80eb-d18c1038ef23>
Date:   Mon Aug 4 21:56:29 2014 +0000

    * added tests for PlainSVD
    
    
    git-svn-id: http://svn.cc.gatech.edu/fastlab/mlpack/trunk@16940 9d5b8971-822b-0410-80eb-d18c1038ef23
---
 src/mlpack/tests/CMakeLists.txt     |  1 +
 src/mlpack/tests/plain_svd_test.cpp | 44 +++++++++++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+)

diff --git a/src/mlpack/tests/CMakeLists.txt b/src/mlpack/tests/CMakeLists.txt
index 6257181..d177223 100644
--- a/src/mlpack/tests/CMakeLists.txt
+++ b/src/mlpack/tests/CMakeLists.txt
@@ -55,6 +55,7 @@ add_executable(mlpack_test
   svd_batch_test.cpp
   svd_incremental_test.cpp
   nystroem_method_test.cpp
+  plain_svd_test.cpp
 )
 # Link dependencies of test executable.
 target_link_libraries(mlpack_test
diff --git a/src/mlpack/tests/plain_svd_test.cpp b/src/mlpack/tests/plain_svd_test.cpp
new file mode 100644
index 0000000..b6577e3
--- /dev/null
+++ b/src/mlpack/tests/plain_svd_test.cpp
@@ -0,0 +1,44 @@
+#include <mlpack/core.hpp>
+#include <mlpack/methods/cf/plain_svd.hpp>
+
+#include <boost/test/unit_test.hpp>
+#include "old_boost_test_definitions.hpp"
+
+BOOST_AUTO_TEST_SUITE(PlainSVDTest);
+
+using namespace std;
+using namespace mlpack;
+using namespace mlpack::svd;
+using namespace arma;
+
+/**
+ * Test PlainSVD for normal factorization
+ */
+BOOST_AUTO_TEST_CASE(PlainSVDNormalFactorizationTest)
+{
+  mlpack::math::RandomSeed(10);
+  mat test = randu<mat>(5,4);
+
+  PlainSVD svd;
+  arma::mat W, H, sigma;
+  double result = svd.Apply(test, W, sigma, H);
+  
+  BOOST_REQUIRE_LT(result, 1e-15);
+}
+
+/**
+ * Test PlainSVD as wrapper for CF.
+ */
+BOOST_AUTO_TEST_CASE(PlainSVDCFWrapperTest)
+{
+  mlpack::math::RandomSeed(10);
+  mat test = randu<mat>(5,4);
+  
+  PlainSVD svd;
+  mat W, H;
+  double result = svd.Apply(test, 3, W, H);
+  
+  BOOST_REQUIRE_LT(result, 0.1);
+}
+
+BOOST_AUTO_TEST_SUITE_END();

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/mlpack.git



More information about the debian-science-commits mailing list