Check for error flag in rank_k_approximation().
authorMichael Orlitzky <michael@orlitzky.com>
Sun, 5 May 2013 02:52:06 +0000 (22:52 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Sun, 5 May 2013 02:52:06 +0000 (22:52 -0400)
rank_k_approximation.m

index 9883084d479b1cb71d290ceb17281e82b1d56101..444325902e646e3c37a5ad6d7931745cc7d94e64 100644 (file)
@@ -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