aboutsummaryrefslogtreecommitdiff
path: root/tests/aux/test_trainfactor.m
diff options
context:
space:
mode:
authorGertjan van den Burg <burg@ese.eur.nl>2016-12-05 19:21:59 +0100
committerGertjan van den Burg <burg@ese.eur.nl>2016-12-05 19:21:59 +0100
commit3713989f5ea8747c2afca4d35e5f2da746f25b24 (patch)
tree902398c9d05c122612bcc76fdd7bc82f04800b6f /tests/aux/test_trainfactor.m
parentfurther unit tests for kernel module (diff)
downloadgensvm-3713989f5ea8747c2afca4d35e5f2da746f25b24.tar.gz
gensvm-3713989f5ea8747c2afca4d35e5f2da746f25b24.zip
add octave testfiles to git
Diffstat (limited to 'tests/aux/test_trainfactor.m')
-rw-r--r--tests/aux/test_trainfactor.m34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/aux/test_trainfactor.m b/tests/aux/test_trainfactor.m
new file mode 100644
index 0000000..581a074
--- /dev/null
+++ b/tests/aux/test_trainfactor.m
@@ -0,0 +1,34 @@
+clc;
+more off; # Octave
+rand('state', 123456);
+
+n = 10;
+m = 5;
+K = 3;
+r = 7;
+
+P = rand(n, r);
+Sigma = rand(r, 1);
+
+for ii=1:n
+ for jj=1:r
+ fprintf("matrix_set(P, r, %i, %i, %.16f);\n", ii-1, jj-1, P(ii, jj));
+ end
+end
+
+fprintf('\n');
+for ii=1:r
+ fprintf("Sigma[%i] = %.16f;\n", ii-1, Sigma(ii));
+end
+
+Z = [ones(n, 1), P*diag(Sigma)];
+
+for ii=1:n
+ for jj=1:r+1
+ fprintf("mu_assert(fabs(matrix_get(Z, r+1, %i, %i) -\n%.16f) < eps,\n\"Incorrect Z at %i, %i\");\n", ii-1, jj-1, Z(ii, jj), ii-1, jj-1);
+ end
+end
+
+
+
+ \ No newline at end of file