diff scripts/sparse/svds.m @ 16722:c8bbab6b9e7a

Avoid converting sparse matrix to full format in svds. * script/sparse/svds.m: fix a bug where the matrix passed as sparse in input would be unnecessarily converted to full storage for computing the maximum magnitude of its nonzeros.
author Carlo de Falco <cdf@users.sourceforge.net>
date Wed, 05 Jun 2013 13:49:47 +0200
parents 610e02bf9579
children 6992c1bb4773
line wrap: on
line diff
--- a/scripts/sparse/svds.m
+++ b/scripts/sparse/svds.m
@@ -137,7 +137,11 @@
   endif
 
   [m, n] = size (A);
-  max_a = max (abs (A(:)));
+  max_a = max (abs (nonzeros (A)));
+  if (isempty (max_a))
+    max_a = 0;
+  endif
+
   if (max_a == 0)
     s = zeros (k, 1);  # special case of zero matrix
   else