72 const scalar
a = this->
a();
73 const scalar
b = this->
b();
74 const scalar
c = this->
c();
75 const scalar
d = this->
d();
88 const scalar
p =
c*
a -
b*
b/3;
89 const scalar q =
b*
b*
b*scalar(2)/27 -
b*
c*
a/3 +
d*
a*
a;
90 scalar disc =
p*
p*
p/27 + q*q/4;
100 const bool oneReal = disc == 0 &&
p == 0;
101 const bool twoReal = disc == 0 &&
p != 0;
102 const bool threeReal = disc < 0;
105 static const scalar sqrt3 =
sqrt(3.0);
129 const scalar wCbRe = - q/2, wCbIm =
sqrt(- disc);
130 const scalar wAbs =
cbrt(
hypot(wCbRe, wCbIm));
131 const scalar wArg =
atan2(wCbIm, wCbRe)/3;
132 const scalar wRe = wAbs*
cos(wArg), wIm = wAbs*
sin(wArg);
135 x = - wRe -
mag(wIm)*sqrt3 -
b/3;
144 const scalar wCb = - q/2 -
sign(q)*
sqrt(disc);
145 const scalar w =
cbrt(wCb);
146 const scalar t = w -
p/(3*w);
153 const scalar xRe = - t/2 -
b/3, xIm = sqrt3/2*(w +
p/3/w);
154 x = -
a*
a*
d/(xRe*xRe + xIm*xIm);
Templated storage for the roots of polynomial equations, plus flags to indicate the nature of the roo...
void type(const direction i, const rootType t)
Set the type of the i-th root.
Roots< 3 > roots(const bool real=false) const
Get the roots.
Linear equation of the form a*x + b = 0.
Roots< 1 > roots() const
Get the roots.
Quadratic equation of the form a*x^2 + b*x + c = 0.
dimensionedScalar sign(const dimensionedScalar &ds)
dimensionedScalar sin(const dimensionedScalar &ds)
void mag(LagrangianPatchField< scalar > &f, const LagrangianPatchField< Type > &f1)
dimensionedScalar atan2(const dimensionedScalar &x, const dimensionedScalar &y)
dimensionedScalar hypot(const dimensionedScalar &x, const dimensionedScalar &y)
void cbrt(LagrangianPatchField< scalar > &f, const LagrangianPatchField< scalar > &f1)
void sqrt(LagrangianPatchField< scalar > &f, const LagrangianPatchField< scalar > &f1)
dimensionedScalar cos(const dimensionedScalar &ds)