changeset 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 4715ce9f911d
children a12d7f53c2ab
files scripts/ChangeLog scripts/sparse/spdiags.m
diffstat 2 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Thu Mar 31 10:09:34 2011 -0700
+++ b/scripts/ChangeLog	Thu Mar 31 10:19:59 2011 -0700
@@ -1,3 +1,7 @@
+2011-03-31  Marco Caliari  <marco.caliari@univr.it>
+
+	* sparse/spdiags.m: Treat empty vector (1x0 or 0x1) the same as diag().
+
 2011-03-31  Rik  <octave@nomad.inbox5.com>
 
 	* statistics/base/cor.m: Increase tolerance of %!tests using random
--- 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)