Mercurial > octave
changeset 30913:a4ed2fed7dfa
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.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Fri, 08 Apr 2022 17:50:00 +0200 |
parents | ec5b57af230a |
children | b86b86ad4b23 |
files | libinterp/corefcn/bsxfun.cc |
diffstat | 1 files changed, 27 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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