Mercurial > octave
changeset 21346:afc3108f13fe
maint: Merge away extra head on default.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 25 Feb 2016 11:16:12 -0500 |
parents | 12280fef2741 (diff) 32651c9a1235 (current diff) |
children | 2f9de06a526e |
files | |
diffstat | 2 files changed, 13 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/bsxfun.cc Thu Feb 25 08:16:27 2016 -0500 +++ b/libinterp/corefcn/bsxfun.cc Thu Feb 25 11:16:12 2016 -0500 @@ -805,5 +805,15 @@ %! endfor %! endfor %! endfor -%! + +## Automatic broadcasting with zero length dimensions (bug #47085) +%!assert ([1 2 3] .+ zeros (0, 3), zeros (0, 3)) +%!assert (rand (3, 3, 1) .+ rand (3, 3, 0), zeros (3, 3, 0)) + +## In-place broadcasting with zero length dimensions (bug #47085) +%!test +%! a = zeros (0, 3); +%! a .+= [1 2 3]; +%! assert (a, zeros (0, 3)) + */
--- a/liboctave/numeric/bsxfun.h Thu Feb 25 08:16:27 2016 -0500 +++ b/liboctave/numeric/bsxfun.h Thu Feb 25 11:16:12 2016 -0500 @@ -43,7 +43,7 @@ octave_idx_type xk = dx(i); octave_idx_type yk = dy(i); // Check the three conditions for valid bsxfun dims - if (! ((xk == yk) || (xk == 1 && yk > 1) || (xk > 1 && yk == 1))) + if (! ((xk == yk) || (xk == 1 && yk != 1) || (xk != 1 && yk == 1))) return false; } @@ -73,7 +73,7 @@ octave_idx_type xk = dx(i); // Only two valid canditions to check; can't stretch rk - if (! ((rk == xk) || (rk > 1 && xk == 1))) + if (! ((rk == xk) || (rk != 1 && xk == 1))) return false; }