Go to the documentation of this file.
74 const scalar
a = this->
a();
75 const scalar
b = this->
b();
76 const scalar
c = this->
c();
77 const scalar
d = this->
d();
85 const scalar
p =
c*
a -
b*
b/3;
86 const scalar q =
b*
b*
b*scalar(2)/27 -
b*
c*
a/3 +
d*
a*
a;
87 const scalar disc =
p*
p*
p/27 + q*q/4;
90 const bool oneReal = disc == 0 &&
p == 0;
91 const bool twoReal = disc == 0 &&
p != 0;
92 const bool threeReal = disc < 0;
95 static const scalar sqrt3 =
sqrt(3.0);
119 const scalar wCbRe = - q/2, wCbIm =
sqrt(- disc);
120 const scalar wAbs =
cbrt(
hypot(wCbRe, wCbIm));
121 const scalar wArg =
atan2(wCbIm, wCbRe)/3;
122 const scalar wRe = wAbs*
cos(wArg), wIm = wAbs*
sin(wArg);
125 x = - wRe -
mag(wIm)*sqrt3 -
b/3;
134 const scalar wCb = - q/2 -
sign(q)*
sqrt(disc);
135 const scalar w =
cbrt(wCb);
136 const scalar t = w -
p/(3*w);
143 const scalar xRe = - t/2 -
b/3, xIm = sqrt3/2*(w +
p/3/w);
144 x = -
a*
a*
d/(xRe*xRe + xIm*xIm);
void type(const direction i, const roots::type t)
Set the type of the i-th root.
dimensionedScalar sin(const dimensionedScalar &ds)
dimensionedScalar atan2(const dimensionedScalar &x, const dimensionedScalar &y)
Roots< 3 > roots() const
Get the roots.
dimensionedScalar sign(const dimensionedScalar &ds)
Linear equation of the form a*x + b = 0.
dimensionedScalar hypot(const dimensionedScalar &x, const dimensionedScalar &y)
Roots< 1 > roots() const
Get the roots.
dimensionedScalar sqrt(const dimensionedScalar &ds)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Templated storage for the roots of polynomial equations, plus flags to indicate the nature of the roo...
dimensionedScalar cbrt(const dimensionedScalar &ds)
Quadratic equation of the form a*x^2 + b*x + c = 0.
dimensionedScalar cos(const dimensionedScalar &ds)