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 const scalar disc =
p*
p*
p/27 + q*q/4;
93 const bool oneReal = disc == 0 &&
p == 0;
94 const bool twoReal = disc == 0 &&
p != 0;
95 const bool threeReal = disc < 0;
98 static const scalar sqrt3 =
sqrt(3.0);
122 const scalar wCbRe = - q/2, wCbIm =
sqrt(- disc);
123 const scalar wAbs =
cbrt(
hypot(wCbRe, wCbIm));
124 const scalar wArg =
atan2(wCbIm, wCbRe)/3;
125 const scalar wRe = wAbs*
cos(wArg), wIm = wAbs*
sin(wArg);
128 x = - wRe -
mag(wIm)*sqrt3 -
b/3;
137 const scalar wCb = - q/2 -
sign(q)*
sqrt(disc);
138 const scalar w =
cbrt(wCb);
139 const scalar t = w -
p/(3*w);
146 const scalar xRe = - t/2 -
b/3, xIm = sqrt3/2*(w +
p/3/w);
147 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
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)
dimensionedScalar atan2(const dimensionedScalar &x, const dimensionedScalar &y)
dimensionedScalar sqrt(const dimensionedScalar &ds)
dimensionedScalar hypot(const dimensionedScalar &x, const dimensionedScalar &y)
dimensioned< scalar > mag(const dimensioned< Type > &)
dimensionedScalar cbrt(const dimensionedScalar &ds)
dimensionedScalar cos(const dimensionedScalar &ds)