comparison libinterp/corefcn/bsxfun.cc @ 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 c9788d7f6e65
children b86b86ad4b23
comparison
equal deleted inserted replaced
30912:ec5b57af230a 30913:a4ed2fed7dfa
813 %! mask = true (4,4); 813 %! mask = true (4,4);
814 %! mask(:,1:2) = false; 814 %! mask(:,1:2) = false;
815 %! r = bsxfun (@times, im, mask); 815 %! r = bsxfun (@times, im, mask);
816 %! assert (r(:,:,1), repmat (single ([0, 0, 1+i, 1+i]), [4, 1])); 816 %! assert (r(:,:,1), repmat (single ([0, 0, 1+i, 1+i]), [4, 1]));
817 817
818 ## automatic broadcasting with inplace times operator
819 %!test <*38466>
820 %! a = ones (2, 2, 2);
821 %! b = 2 * ones (2, 1);
822 %! a .*= b;
823 %! assert (a, 2 * ones (2, 2, 2));
824
825 %!test <*38466>
826 %! a = ones (2, 2, 2);
827 %! b = 2 * ones (1, 2);
828 %! a .*= b;
829 %! assert (a, 2 * ones (2, 2, 2));
830
831 %!test <*38466>
832 %! a = ones (2, 2, 2);
833 %! b = 2 * ones (2, 2);
834 %! a .*= b;
835 %! assert (a, 2 * ones (2, 2, 2));
836
837 %!test <*38466>
838 %! a = ones (2, 2, 2);
839 %! b = 2 * ones (1, 1, 2);
840 %! a .*= b;
841 %! assert (a, 2 * ones (2, 2, 2));
842
843 %!assert (ones (2,2,2) .* ones (1,2), ones (2,2,2));
844
818 */ 845 */
819 846
820 OCTAVE_NAMESPACE_END 847 OCTAVE_NAMESPACE_END