diff --git a/modules/core/src/arithm.cpp b/modules/core/src/arithm.cpp index a11b64b442..0517a5fae6 100644 --- a/modules/core/src/arithm.cpp +++ b/modules/core/src/arithm.cpp @@ -1272,8 +1272,8 @@ static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst, bool haveScalar = false, swapped12 = false; int depth2 = src2.depth(); if( src1.size != src2.size || src1.channels() != src2.channels() || - ((kind1 == _InputArray::MATX || kind2 == _InputArray::MATX) && - src1.cols == 1 && src2.rows == 4) ) + (kind1 == _InputArray::MATX && (src1.size() == Size(1,4) || src1.size() == Size(1,1))) || + (kind2 == _InputArray::MATX && (src2.size() == Size(1,4) || src2.size() == Size(1,1))) ) { if( checkScalar(src1, src2.type(), kind1, kind2) ) { diff --git a/modules/core/test/test_arithm.cpp b/modules/core/test/test_arithm.cpp index 664fa0204a..f16c801713 100644 --- a/modules/core/test/test_arithm.cpp +++ b/modules/core/test/test_arithm.cpp @@ -1564,3 +1564,19 @@ TEST(Core_round, CvRound) ASSERT_EQ(-2, cvRound(-2.5)); ASSERT_EQ(-4, cvRound(-3.5)); } + + +typedef testing::TestWithParam Mul1; + +TEST_P(Mul1, One) +{ + Size size = GetParam(); + cv::Mat src(size, CV_32FC1, cv::Scalar::all(2)), dst, + ref_dst(size, CV_32FC1, cv::Scalar::all(6)); + + cv::multiply(3, src, dst); + + ASSERT_EQ(0, cv::norm(dst, ref_dst, cv::NORM_INF)); +} + +INSTANTIATE_TEST_CASE_P(Arithm, Mul1, testing::Values(Size(2, 2), Size(1, 1)));