Mercurial > hg > octave-nkf
changeset 14666:1e77f6078692
spdiags.m: correctly treat row vector arguments
author | David Bateman <dbateman@free.fr> |
---|---|
date | Mon, 21 May 2012 02:31:05 +0200 |
parents | 4f458e882516 |
children | d95e719ef108 |
files | scripts/sparse/spdiags.m |
diffstat | 1 files changed, 3 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/sparse/spdiags.m +++ b/scripts/sparse/spdiags.m @@ -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))