Mercurial > hg > octave-terminal
changeset 15434:e1f59fd57756
repmat() should interpret empties as implying unit.
Bug # 37390.
* scripts/general/repmat.m: If the inputs specifying the number to
replications is empty, interpret the empty as unity. Add tests.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Fri, 21 Sep 2012 21:13:33 -0400 |
parents | 283cada76dd6 |
children | 13ffb3130b2f |
files | scripts/general/repmat.m |
diffstat | 1 files changed, 12 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/general/repmat.m +++ b/scripts/general/repmat.m @@ -40,11 +40,20 @@ endif if (nargin == 3) - if (! (isscalar (m) && isscalar (n))) + if (! (numel (m) < 2 && numel (n) < 2)) error ("repmat: with 3 arguments M and N must be scalar"); endif + if (isempty (m)) + m = 1; + endif + if (isempty (n)) + n = 1; + endif idx = [m, n]; else + if (isempty (m)) + m = 1; + endif if (isscalar (m)) idx = [m, m]; n = m; @@ -101,10 +110,11 @@ endfunction - # Test various methods of providing size parameters %!shared x %! x = [1 2;3 4]; +%!assert (repmat (x, 1, []), repmat (x, 1)) +%!assert (repmat (x, [], 3), repmat (x, [1, 3])) %!assert (repmat (x, [1 1]), repmat (x, 1)) %!assert (repmat (x, [3 3]), repmat (x, 3)) %!assert (repmat (x, [1 1]), repmat (x, 1, 1))