X-Git-Url: http://gitweb.michael.orlitzky.com/?p=octave.git;a=blobdiff_plain;f=rank_k_approximation.m;h=444325902e646e3c37a5ad6d7931745cc7d94e64;hp=9883084d479b1cb71d290ceb17281e82b1d56101;hb=9c80bead819622e76966fe80b75bf422bc78cdcc;hpb=4684857f18bb97f9b6ed8b4bf4622fd1d82dfcb5 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