Mercurial > octave-antonio
diff scripts/general/repmat.m @ 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 | eb63fbe60fab |
line wrap: on
line diff
--- a/scripts/general/repmat.m Tue Jan 13 14:08:36 2009 -0500 +++ b/scripts/general/repmat.m Tue Jan 13 17:33:44 2009 -0500 @@ -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)));