From 850a8577b24d60e1765e085d5a97093befc6381b Mon Sep 17 00:00:00 2001 From: Vitaly Tuzov Date: Thu, 12 Jul 2018 19:19:51 +0300 Subject: [PATCH] Fixed unreachable code warnings for Matx::solve() --- modules/core/include/opencv2/core/operations.hpp | 12 ++++++++---- modules/core/test/test_math.cpp | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/modules/core/include/opencv2/core/operations.hpp b/modules/core/include/opencv2/core/operations.hpp index 3570d06fd7..eb240e0af3 100644 --- a/modules/core/include/opencv2/core/operations.hpp +++ b/modules/core/include/opencv2/core/operations.hpp @@ -65,7 +65,6 @@ template struct Matx_FastInvOp { bool operator()(const Matx<_Tp, m, n>&, Matx<_Tp, n, m>&, int) const { - CV_Assert(false); return false; } }; @@ -132,7 +131,6 @@ template struct Matx_FastSolveOp bool operator()(const Matx<_Tp, m, l>&, const Matx<_Tp, m, n>&, Matx<_Tp, l, n>&, int) const { - CV_Assert(false); return false; } }; @@ -213,8 +211,11 @@ Matx<_Tp, n, m> Matx<_Tp, m, n>::inv(int method, bool *p_is_ok /*= NULL*/) const { Matx<_Tp, n, m> b; bool ok; - if( m == n && (method == DECOMP_LU || method == DECOMP_CHOLESKY) ) + if (method == DECOMP_LU || method == DECOMP_CHOLESKY) + { + CV_Assert(m == n); ok = cv::internal::Matx_FastInvOp<_Tp, m, n>()(*this, b, method); + } else { Mat A(*this, false), B(b, false); @@ -229,8 +230,11 @@ Matx<_Tp, n, l> Matx<_Tp, m, n>::solve(const Matx<_Tp, m, l>& rhs, int method) c { Matx<_Tp, n, l> x; bool ok; - if( m == n && (method == DECOMP_LU || method == DECOMP_CHOLESKY) ) + if (method == DECOMP_LU || method == DECOMP_CHOLESKY) + { + CV_Assert(m == n); ok = cv::internal::Matx_FastSolveOp<_Tp, m, n, l>()(*this, rhs, x, method); + } else { Mat A(*this, false), B(rhs, false), X(x, false); diff --git a/modules/core/test/test_math.cpp b/modules/core/test/test_math.cpp index 2adc8dca52..8fc49bf8fd 100644 --- a/modules/core/test/test_math.cpp +++ b/modules/core/test/test_math.cpp @@ -3139,7 +3139,7 @@ TEST(Core_Solve, regression_11888) cv::Vec b(4, 5, 7); cv::Matx xQR = A.solve(b, DECOMP_QR); cv::Matx xSVD = A.solve(b, DECOMP_SVD); - EXPECT_LE(cvtest::norm(xQR, xSVD, CV_RELATIVE_L2), FLT_EPSILON); + EXPECT_LE(cvtest::norm(xQR, xSVD, CV_RELATIVE_L2), 0.001); cv::Matx iA = A.inv(DECOMP_SVD); EXPECT_LE(cvtest::norm(A*iA, Matx::eye(), CV_RELATIVE_L2), 0.6); }