solvePoly() does not work as intended (Bug #1765)


Added by Baris Demiroz almost 13 years ago. Updated almost 13 years ago.


Status:Done Start date:2012-04-05
Priority:Normal Due date:
Assignee:Andrey Kamaev % Done:

0%

Category:core
Target version:2.4.0
Affected version: Operating System:
Difficulty: HW Platform:
Pull request:

Description

I have tested the simplest case for a quadratic equation could not generate meaningful results. The equation is 2(x-3)(x+5)=0, in other representation it is 2x^2+4x-30=0
Clearly the roots are x=3 and x=-5

Here is the code to demonstrate the case:

 1// Coefficients of 2(x-3)(x+5) = 0
 2Mat coefs = (Mat_<float>(1,3) << -30.0f, 4.0f, 2.0f);
 3std::cout << "Coefs: " << coefs << std::endl;
 4Mat r;
 5
 6solvePoly(coefs, r);
 7std::cout << "roots after 300 iterations: " << r << std::endl;
 8
 9solvePoly(coefs, r, 9999);
10std::cout << "roots after 9999 iterations: " << r << std::endl;

The output is:

Coefs: [-30, 4, 2]
roots after 300 iterations: [-48.41674, -190.29749; 1.1712749, 1.5136811]
roots after 9999 iterations: [255.0712, 1078.2856; 1.1929021, 1.6043143]


Associated revisions

Revision dcadc4f8
Added by Andrey Kamaev almost 13 years ago

#1765 Fixed solvePoly for polynomials having coeffs[n] != 1

Revision 26f5d2d6
Added by Andrey Pavlenko about 11 years ago

Merge pull request #1765 from ilya-lavrenov:cv_remap

History

Updated by Baris Demiroz almost 13 years ago

I am aware of the Issue #1060 (http://code.opencv.org/issues/1060) and I tried reversing the coefficients, the result is:

Coefs: [2, 4, -30]
roots after 300 iterations: [-1.#IND, 1.#INF; -1.#IND, -1.#IND]
roots after 9999 iterations: [-1.#IND, 1.#INF; -1.#IND, -1.#IND]

Updated by Andrey Kamaev almost 13 years ago

  • Description changed from I have tested the simplest case for a quadratic equation could not generate m... to I have tested the simplest case for a quadratic equation could not generate m... More
  • Category set to core

Updated by Andrey Kamaev almost 13 years ago

Thanks for report!
The bug is fixed in 2.4 branch.

  • Status changed from Open to Done
  • Target version set to 2.4.0
  • Assignee set to Andrey Kamaev

Also available in: Atom PDF