Add rank_k_approximation() and its tests.
[octave.git] / tests / rank_k_approximation_tests.m
1 U = [4/5, 3/5, 0 ; ...
2 0 , 4/5, 3/5; ...
3 3/5, 0 , 4/5 ];
4
5 S = [ 1, 0, 0;
6 0, 2, 0;
7 0, 0, 3 ];
8
9 V = [ 0, 1, 0;
10 1, 0, 0;
11 0, 0, 1 ];
12
13 A = U*S*V';
14
15 expected = A;
16 actual = rank_k_approximation(A, 3);
17
18 unit_test_equals("Full rank approximation of a matrix is itself", ...
19 expected, ...
20 actual);