X-Git-Url: http://gitweb.michael.orlitzky.com/?p=octave.git;a=blobdiff_plain;f=tests%2Frank_k_approximation_tests.m;fp=tests%2Frank_k_approximation_tests.m;h=82887526fe789ff483d2dd25a6ecc05c296daecf;hp=0000000000000000000000000000000000000000;hb=79deafc20bc4cb3704f7f2cfcf845ed09d31eee3;hpb=6208d54caedc1bab6bb794a8ad3dd8e72c28d342 diff --git a/tests/rank_k_approximation_tests.m b/tests/rank_k_approximation_tests.m new file mode 100644 index 0000000..8288752 --- /dev/null +++ b/tests/rank_k_approximation_tests.m @@ -0,0 +1,20 @@ +U = [4/5, 3/5, 0 ; ... + 0 , 4/5, 3/5; ... + 3/5, 0 , 4/5 ]; + +S = [ 1, 0, 0; + 0, 2, 0; + 0, 0, 3 ]; + +V = [ 0, 1, 0; + 1, 0, 0; + 0, 0, 1 ]; + +A = U*S*V'; + +expected = A; +actual = rank_k_approximation(A, 3); + +unit_test_equals("Full rank approximation of a matrix is itself", ... + expected, ... + actual);