Merge pull request #5605 from hoangviet1985:fix_bug_5599
commit
0f288d1082
3 changed files with 130 additions and 2 deletions
@ -0,0 +1,38 @@ |
|||||||
|
/*
|
||||||
|
* solves equations x^4 - x^2 = 0, and x^2 - 2x + 1 = 0 |
||||||
|
*/ |
||||||
|
|
||||||
|
#include "opencv2/core/core.hpp" |
||||||
|
#include <iostream> |
||||||
|
|
||||||
|
|
||||||
|
int main(void) |
||||||
|
{ |
||||||
|
cv::Mat coefs = (cv::Mat_<float>(1,5) << 0, 0, -1, 0, 1 ); |
||||||
|
std::cout << "x^4 - x^2 = 0\n\n" << "Coefficients: " << coefs << "\n" << std::endl; |
||||||
|
cv::Mat r; |
||||||
|
|
||||||
|
double prec; |
||||||
|
prec = cv::solvePoly(coefs, r); |
||||||
|
std::cout << "Preciseness = " << prec << std::endl; |
||||||
|
std::cout << "roots after 1000 iterations:\n" << r << "\n" << std::endl; |
||||||
|
|
||||||
|
prec = cv::solvePoly(coefs, r, 9999); |
||||||
|
std::cout << "Preciseness = " << prec << std::endl; |
||||||
|
std::cout << "roots after 9999 iterations:\n" << r << "\n" << std::endl; |
||||||
|
|
||||||
|
std::cout << "\n---------------------------------------\n" << std::endl; |
||||||
|
|
||||||
|
coefs = (cv::Mat_<float>(1,3) << 1, -2, 1 ); |
||||||
|
std::cout << "x^2 - 2x + 1 = 0\n\n" << "Coefficients: " << coefs << "\n" << std::endl; |
||||||
|
|
||||||
|
prec = cv::solvePoly(coefs, r); |
||||||
|
std::cout << "Preciseness = " << prec << std::endl; |
||||||
|
std::cout << "roots after 1000 iterations:\n" << r << "\n" << std::endl; |
||||||
|
|
||||||
|
prec = cv::solvePoly(coefs, r, 9999); |
||||||
|
std::cout << "Preciseness = " << prec << std::endl; |
||||||
|
std::cout << "roots after 9999 iterations:\n" << r << "\n" << std::endl; |
||||||
|
|
||||||
|
return 0; |
||||||
|
} |
Loading…
Reference in new issue