72 const scalar
a = this->
a();
73 const scalar
b = this->
b();
74 const scalar
c = this->
c();
75 const scalar
d = this->
d();
83 const scalar
p = c*a - b*b/3;
84 const scalar q = b*b*b*scalar(2)/27 - b*c*a/3 + d*a*
a;
85 const scalar disc = p*p*p/27 + q*q/4;
88 const bool oneReal = disc == 0 && p == 0;
89 const bool twoReal = disc == 0 && p != 0;
90 const bool threeReal = disc < 0;
93 static const scalar sqrt3 =
sqrt(3.0);
106 x = - 2*
cbrt(q/2) - b/3;
117 const scalar wCbRe = - q/2, wCbIm =
sqrt(- disc);
118 const scalar wAbs =
cbrt(
hypot(wCbRe, wCbIm));
119 const scalar wArg =
atan2(wCbIm, wCbRe)/3;
120 const scalar wRe = wAbs*
cos(wArg), wIm = wAbs*
sin(wArg);
123 x = - wRe -
mag(wIm)*sqrt3 - b/3;
132 const scalar wCb = - q/2 -
sign(q)*
sqrt(disc);
133 const scalar w =
cbrt(wCb);
134 const scalar t = w - p/(3*w);
141 const scalar xRe = - t/2 - b/3, xIm = sqrt3/2*(w + p/3/w);
142 x = - a*a*d/(xRe*xRe + xIm*xIm);
dimensionedScalar sign(const dimensionedScalar &ds)
Roots< 2 > roots() const
Get the roots.
dimensionedScalar sqrt(const dimensionedScalar &ds)
Templated storage for the roots of polynomial equations, plus flags to indicate the nature of the roo...
dimensionedScalar cos(const dimensionedScalar &ds)
dimensionedScalar cbrt(const dimensionedScalar &ds)
dimensionedScalar sin(const dimensionedScalar &ds)
dimensionedScalar atan2(const dimensionedScalar &x, const dimensionedScalar &y)
Quadratic equation of the form a*x^2 + b*x + c = 0.
Linear equation of the form a*x + b = 0.
Roots< 3 > roots() const
Get the roots.
Roots< 1 > roots() const
Get the roots.
dimensioned< scalar > mag(const dimensioned< Type > &)
dimensionedScalar hypot(const dimensionedScalar &x, const dimensionedScalar &y)
void type(const direction i, const rootType t)
Set the type of the i-th root.