diff --git a/modules/core/src/mathfuncs.cpp b/modules/core/src/mathfuncs.cpp index 08649780b..2c980a7cc 100644 --- a/modules/core/src/mathfuncs.cpp +++ b/modules/core/src/mathfuncs.cpp @@ -2544,15 +2544,15 @@ double cv::solvePoly( InputArray _coeffs0, OutputArray _roots0, int maxIters ) } if( num_same_root % 2 != 0){ - Mat cube_coefs(4, 1, CV_32FC1); - Mat cube_roots(3, 1, CV_32FC2); - cube_coefs.at(3) = -(std::pow(old_num_re, 3)); - cube_coefs.at(2) = -(15*std::pow(old_num_re, 2) + 27*std::pow(old_num_im, 2)); - cube_coefs.at(1) = -48*old_num_re; - cube_coefs.at(0) = 64; + Mat cube_coefs(4, 1, CV_64FC1); + Mat cube_roots(3, 1, CV_64FC2); + cube_coefs.at(3) = -(std::pow(old_num_re, 3)); + cube_coefs.at(2) = -(15*std::pow(old_num_re, 2) + 27*std::pow(old_num_im, 2)); + cube_coefs.at(1) = -48*old_num_re; + cube_coefs.at(0) = 64; cv::solveCubic(cube_coefs, cube_roots); - num.re = cv::cubeRoot(cube_roots.at(0)); + num.re = cv::cubeRoot(cube_roots.at(0)); num.im = std::sqrt(std::pow(num.re, 2) / 3 - old_num_re / (3*num.re)); } } diff --git a/modules/core/test/test_math.cpp b/modules/core/test/test_math.cpp index c07af500d..8490d696c 100644 --- a/modules/core/test/test_math.cpp +++ b/modules/core/test/test_math.cpp @@ -2351,7 +2351,7 @@ void Core_SolvePolyTest::run( int ) template static void checkRoot(Mat& r, T re, T im) { - for (size_t i = 0; i < r.total(); i++) + for (int i = 0; i < r.cols*r.rows; i++) { Vec v = *(Vec*)r.ptr(i); if (fabs(re - v[0]) < 1e-6 && fabs(im - v[1]) < 1e-6)