diff scripts/sparse/spdiags.m @ 12558:1f0243949b77

spdiags.m: Treat empty vector (1x0 or 0x1) the same as diag().
author Marco Caliari <marco.caliari@univr.it>
date Thu, 31 Mar 2011 10:19:59 -0700
parents c792872f8942
children 72c96de7a403
line wrap: on
line diff
--- a/scripts/sparse/spdiags.m	Thu Mar 31 10:09:34 2011 -0700
+++ b/scripts/sparse/spdiags.m	Thu Mar 31 10:19:59 2011 -0700
@@ -79,10 +79,16 @@
     ## Create new matrix of size mxn using v,c
     [j, i, v] = find (v);
     offset = max (min (c(:), n-m), 0);
-    j = j(:) + offset(i);
+    j = j + offset(i);
     i = j-c(:)(i);
     idx = i > 0 & i <= m & j > 0 & j <= n;
     A = sparse (i(idx), j(idx), v(idx), m, n);
   endif
 
 endfunction
+
+%!test
+%assert(spdiags(zeros(1,0),1,1,1),0)
+
+%!test
+%assert(spdiags(zeros(0,1),1,1,1),0)