X-Git-Url: http://gitweb.michael.orlitzky.com/?p=octave.git;a=blobdiff_plain;f=rank_k_approximation.m;h=444325902e646e3c37a5ad6d7931745cc7d94e64;hp=9883084d479b1cb71d290ceb17281e82b1d56101;hb=fb5be501fba46b17fec32d786aac2ad3f6f9ee0a;hpb=b39f6d3f6aaaebe891c09a8923547f25c2d43b84 diff --git a/rank_k_approximation.m b/rank_k_approximation.m index 9883084..4443259 100644 --- a/rank_k_approximation.m +++ b/rank_k_approximation.m @@ -23,6 +23,11 @@ function Ak = rank_k_approximation(A,k) return; end - [U, S, V] = svds(A, k); - Ak = U*S*V'; + [U, S, V, flag] = svds(A, k); + + if (flag == 0) + Ak = U*S*V'; + else + error('Could not compute the rank-k approximation.'); + end end