# HG changeset patch # User Markus Mützel # Date 1649433000 -7200 # Node ID a4ed2fed7dfac181cd93a5d49c3f8903f62e3b82 # Parent ec5b57af230a20a11e55075acc06b6683da91b35 Add tests for automatic broadcasting with inplace times operator ".*=" (bug #38466). * libinterp/corefcn/bsxfun.cc: Add tests for automatic broadcasting with inplace times operator ".*=" with rhs of different shapes. diff -r ec5b57af230a -r a4ed2fed7dfa libinterp/corefcn/bsxfun.cc --- a/libinterp/corefcn/bsxfun.cc Wed Apr 06 21:47:52 2022 -0700 +++ b/libinterp/corefcn/bsxfun.cc Fri Apr 08 17:50:00 2022 +0200 @@ -815,6 +815,33 @@ %! r = bsxfun (@times, im, mask); %! assert (r(:,:,1), repmat (single ([0, 0, 1+i, 1+i]), [4, 1])); +## automatic broadcasting with inplace times operator +%!test <*38466> +%! a = ones (2, 2, 2); +%! b = 2 * ones (2, 1); +%! a .*= b; +%! assert (a, 2 * ones (2, 2, 2)); + +%!test <*38466> +%! a = ones (2, 2, 2); +%! b = 2 * ones (1, 2); +%! a .*= b; +%! assert (a, 2 * ones (2, 2, 2)); + +%!test <*38466> +%! a = ones (2, 2, 2); +%! b = 2 * ones (2, 2); +%! a .*= b; +%! assert (a, 2 * ones (2, 2, 2)); + +%!test <*38466> +%! a = ones (2, 2, 2); +%! b = 2 * ones (1, 1, 2); +%! a .*= b; +%! assert (a, 2 * ones (2, 2, 2)); + +%!assert (ones (2,2,2) .* ones (1,2), ones (2,2,2)); + */ OCTAVE_NAMESPACE_END