diff libinterp/corefcn/bsxfun.cc @ 21345:12280fef2741

automatic broadcasting: correctly handle dimensions of length zero (bug #47085) * liboctave/numeric/bsxfun.h: fix identification of correct dimensions for valid broadcasting. Dimensions of length zero should be considered so use "=! 1" instead of "> 1". * libinterp/corefcn/bsxfun.cc: add tests.
author Carnë Draug <carandraug@octave.org>
date Thu, 25 Feb 2016 13:48:41 +0000
parents a4faec57f4c8
children a1aa52bff079
line wrap: on
line diff
--- a/libinterp/corefcn/bsxfun.cc	Wed Feb 24 21:47:10 2016 -0800
+++ b/libinterp/corefcn/bsxfun.cc	Thu Feb 25 13:48:41 2016 +0000
@@ -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))
+
 */