# HG changeset patch # User David Bateman # Date 1337560265 -7200 # Node ID 1e77f60786922ce74c5697b7c659fa24b25048c5 # Parent 4f458e882516324b1cd724ffd5ace8110ec71871 spdiags.m: correctly treat row vector arguments diff -r 4f458e882516 -r 1e77f6078692 scripts/sparse/spdiags.m --- a/scripts/sparse/spdiags.m Mon May 21 00:40:44 2012 +0200 +++ b/scripts/sparse/spdiags.m Mon May 21 02:31:05 2012 +0200 @@ -79,8 +79,8 @@ ## 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); - i = j-c(:)(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 @@ -90,4 +90,4 @@ %!assert (spdiags (zeros (1,0),1,1,1), sparse (0)) %!assert (spdiags (zeros (0,1),1,1,1), sparse (0)) - +%!assert (spdiags ([0.5 -1 0.5], 0:2, 1, 1), sparse(0.5))