Mercurial > hg > octave-terminal
changeset 8508:dee629f14bfa
repmat.m: handle negative dimensions properly
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 13 Jan 2009 17:33:44 -0500 |
parents | cadc73247d65 |
children | 841f8e3370c6 |
files | scripts/ChangeLog scripts/general/repmat.m |
diffstat | 2 files changed, 12 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,5 +1,7 @@ 2009-01-13 John W. Eaton <jwe@octave.org> + * general/repmat.m: Handle negative row or column dimension. + * elfun/lcm.m, general/accumarray.m, general/bicubic.m, general/cellidx.m, general/cplxpair.m, general/dblquad.m, general/gradient.m, general/interp1.m , general/pol2cart.m,
--- a/scripts/general/repmat.m +++ b/scripts/general/repmat.m @@ -51,6 +51,12 @@ error ("repmat: invalid dimensional argument"); endif endif + + if (all (idx < 0)) + error ("repmat: invalid dimensions"); + else + idx = max (idx, 0); + endif if (numel (a) == 1) ## optimize the scalar fill case. @@ -121,3 +127,7 @@ # Test that sparsity is kept %!assert(sparse(4,4), repmat(sparse(2,2),[2 2])); + +%!assert (size (repmat (".", -1, 1)), [0, 1]); +%!assert (size (repmat (".", 1, -1)), [1, 0]); +%!error (size (repmat (".", -1, -1)));