Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
ed006526
Commit
ed006526
authored
Nov 02, 2015
by
Viet Dinh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update fixing bug #5599
parent
03e7b717
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
10 deletions
+42
-10
mathfuncs.cpp
modules/core/src/mathfuncs.cpp
+3
-10
polynominal_equations.cpp
samples/cpp/polynominal_equations.cpp
+39
-0
No files found.
modules/core/src/mathfuncs.cpp
View file @
ed006526
...
...
@@ -2530,21 +2530,14 @@ double cv::solvePoly( InputArray _coeffs0, OutputArray _roots0, int maxIters )
double
old_num_im
=
num
.
im
;
num
.
re
=
old_num_re
*
old_num_re
+
old_num_im
*
old_num_im
;
Mat
num_re_arr
=
(
Mat_
<
double
>
(
1
,
1
)
<<
num
.
re
);
cv
::
sqrt
(
num_re_arr
,
num_re_arr
);
num
.
re
=
num_re_arr
.
at
<
double
>
(
0
,
0
);
num
.
re
=
std
::
sqrt
(
num
.
re
);
num
.
re
+=
old_num_re
;
num
.
im
=
num
.
re
-
old_num_re
;
num
.
re
/=
2
;
num_re_arr
.
at
<
double
>
(
0
,
0
)
=
num
.
re
;
cv
::
sqrt
(
num_re_arr
,
num_re_arr
);
num
.
re
=
num_re_arr
.
at
<
double
>
(
0
,
0
);
num
.
re
=
std
::
sqrt
(
num
.
re
);
Mat
num_im_arr
=
(
Mat_
<
double
>
(
1
,
1
)
<<
num
.
im
);
num
.
im
/=
2
;
num_im_arr
.
at
<
double
>
(
0
,
0
)
=
num
.
re
;
cv
::
sqrt
(
num_im_arr
,
num_im_arr
);
num
.
im
=
num_im_arr
.
at
<
double
>
(
0
,
0
);
num
.
im
=
std
::
sqrt
(
num
.
im
);
if
(
old_num_re
<
0
)
num
.
im
=
-
num
.
im
;
}
}
...
...
samples/cpp/polynominal_equations.cpp
0 → 100644
View file @
ed006526
/*
* 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
;
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment