20 #ifndef MIRTK_PolynomialSolvers_H 21 #define MIRTK_PolynomialSolvers_H 23 #include "mirtk/Assert.h" 27 namespace boost {
namespace math {
namespace tools {
28 template <
class T>
class polynomial;
59 int SolveCubicEquation(
double x[3],
double a,
double b,
double c);
82 inline int SolveCubicEquation(
double x[3],
double a,
double b,
double c,
double d)
84 mirtkAssert(a != 0.,
"cubic coefficient is non-zero");
85 return SolveCubicEquation(x, b / a, c / a, d / a);
107 inline int SolveCubicEquation(
double x[3],
const boost::math::tools::polynomial<T> &p)
109 mirtkAssert(p.degree() == 3,
"polynomial degree must be 3");
110 mirtkAssert(
double(p[3]) != 0.,
"cubic coefficient is non-zero");
111 return SolveCubicEquation(x, p[3], p[2], p[1], p[0]);
130 double MinimumOf4thDegreePolynomial(
double a,
double b,
double c);
145 inline double MinimumOf4thDegreePolynomial(
double a,
double b,
double c,
double)
147 return MinimumOf4thDegreePolynomial(a, b, c);
164 inline double MinimumOf4thDegreePolynomial(
double a,
double b,
double c,
double d,
double)
166 mirtkAssert(a != 0.,
"quartic coefficient is non-zero");
167 return MinimumOf4thDegreePolynomial(b / a, c / a, d / a);
181 inline double MinimumOf4thDegreePolynomial(
const boost::math::tools::polynomial<T> &p)
183 mirtkAssert(p.degree() == 4,
"polynomial degree must be 4");
184 return MinimumOf4thDegreePolynomial(p[4], p[3], p[2], p[1], p[0]);
190 #endif // MIRTK_PolynomialSolvers_H