From 9c80bead819622e76966fe80b75bf422bc78cdcc Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sat, 4 May 2013 22:52:06 -0400 Subject: [PATCH] Check for error flag in rank_k_approximation(). --- rank_k_approximation.m | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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 -- 2.44.2