Mercurial > hg > octave-lyh
diff scripts/special-matrix/hankel.m @ 5731:c7d5a534afa5
[project @ 2006-04-03 19:33:26 by jwe]
author | jwe |
---|---|
date | Mon, 03 Apr 2006 19:33:27 +0000 |
parents | 2618a0750ae6 |
children | 34f96dd5441b |
line wrap: on
line diff
--- a/scripts/special-matrix/hankel.m +++ b/scripts/special-matrix/hankel.m @@ -51,7 +51,7 @@ function retval = hankel (c, r) if (nargin == 1) - r = zeros (size (c)); + r = resize (resize (c, 0), size(c)); elseif (nargin != 2) usage ("hankel (c, r)"); endif @@ -84,7 +84,7 @@ ## This should probably be done with the colon operator... - retval = zeros (nr, nc); + retval = resize (resize (c, 0), nr, nc); for i = 1:min (nr, nc) retval (1:nr-i+1, i) = c (i:nr); @@ -100,3 +100,9 @@ endfor endfunction + +%!assert(hankel(1:3),[1,2,3;2,3,0;3,0,0]) +%!assert(hankel(1),[1]); +%!assert(hankel(1:3,3:6),[1,2,3,4;2,3,4,5;3,4,5,6]); +%!assert(hankel(1:3,3:4),[1,2;2,3;3,4]); +%!assert(hankel(1:3,4:6),[1,2,3;2,3,5;3,5,6]);