Mercurial > hg > octave-nkf
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 +++ b/scripts/sparse/spdiags.m @@ -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)