36
36
37
37
namespace colmap {
38
38
39
- // All polynomials are assumed to be the form:
40
- //
41
- // sum_{i=0}^N polynomial(i) x^{N-i}.
42
- //
43
- // and are given by a vector of coefficients of size N + 1.
44
- //
45
- // The implementation is based on COLMAP's old polynomial functionality and is
46
- // inspired by Ceres-Solver's/Theia's implementation to support complex
47
- // polynomials. The companion matrix implementation is based on NumPy.
48
-
49
- // Evaluate the polynomial for the given coefficients at x using the Horner
50
- // scheme. This function is templated such that the polynomial may be evaluated
51
- // at real and/or imaginary points.
52
- template <typename T>
53
- T EvaluatePolynomial (const Eigen::VectorXd &coeffs, const T &x);
54
-
55
- // Find the root of polynomials of the form: a * x + b = 0.
56
- // The real and/or imaginary variable may be NULL if the output is not needed.
57
- bool FindLinearPolynomialRoots (const Eigen::VectorXd &coeffs,
58
- Eigen::VectorXd *real, Eigen::VectorXd *imag);
59
-
60
- // Find the roots of polynomials of the form: a * x^2 + b * x + c = 0.
61
- // The real and/or imaginary variable may be NULL if the output is not needed.
62
- bool FindQuadraticPolynomialRoots (const Eigen::VectorXd &coeffs,
63
- Eigen::VectorXd *real, Eigen::VectorXd *imag);
64
-
65
- // Find the roots of a polynomial using the Durand-Kerner method, based on:
66
- //
67
- // https://en.wikipedia.org/wiki/Durand%E2%80%93Kerner_method
68
- //
69
- // The Durand-Kerner is comparatively fast but often unstable/inaccurate.
70
- // The real and/or imaginary variable may be NULL if the output is not needed.
71
- bool FindPolynomialRootsDurandKerner (const Eigen::VectorXd &coeffs,
72
- Eigen::VectorXd *real,
73
- Eigen::VectorXd *imag);
74
-
75
39
// Find the roots of a polynomial using the companion matrix method, based on:
76
40
//
77
41
// R. A. Horn & C. R. Johnson, Matrix Analysis. Cambridge,
@@ -83,19 +47,6 @@ bool FindPolynomialRootsCompanionMatrix(const Eigen::VectorXd &coeffs,
83
47
Eigen::VectorXd *real,
84
48
Eigen::VectorXd *imag);
85
49
86
- // //////////////////////////////////////////////////////////////////////////////
87
- // Implementation
88
- // //////////////////////////////////////////////////////////////////////////////
89
-
90
- template <typename T>
91
- T EvaluatePolynomial (const Eigen::VectorXd &coeffs, const T &x) {
92
- T value = 0.0 ;
93
- for (Eigen::VectorXd::Index i = 0 ; i < coeffs.size (); ++i) {
94
- value = value * x + coeffs (i);
95
- }
96
- return value;
97
- }
98
-
99
50
} // namespace colmap
100
51
101
52
#endif // COLMAP_SRC_BASE_POLYNOMIAL_H_
0 commit comments