Go to the documentation of this file.
21 #define TwoPi 6.28318530717958648
22 const double eps = 1e-14;
32 double q = (
a2 - 3 *
b) / 9;
33 double r = (
a * (2 *
a2 - 9 *
b) + 27 *
c) / 54;
35 double q3 =
q *
q *
q;
39 double t =
r / sqrt(q3);
45 x[0] =
q * cos(
t / 3) -
a;
52 A = -pow(std::abs(
r) + sqrt(r2 - q3), 1. / 3);
54 B = A == 0 ? 0 :
q / A;
58 x[1] = -0.5 * (A + B) -
a;
59 x[2] = 0.5 * sqrt(3.) * (A - B);
60 if (std::abs(
x[2]) <
eps)
71 double x,
double y,
double&
a,
double&
b)
73 double r = sqrt(
x *
x +
y *
y);
90 a = sqrt(0.5 * (
x +
r));
96 double*
x,
double b,
double d)
98 double D =
b *
b - 4 * d;
102 double x1 = (-
b + sD) / 2;
103 double x2 = (-
b - sD) / 2;
106 double sx1 = sqrt(x1);
107 double sx2 = sqrt(x2);
116 double sx1 = sqrt(-x1);
117 double sx2 = sqrt(-x2);
125 double sx1 = sqrt(x1);
126 double sx2 = sqrt(-x2);
135 double sD2 = 0.5 * sqrt(-D);
160 double*
x,
double b,
double c,
164 if (std::abs(
c) < 1e-14 * (std::abs(
b) + std::abs(d)))
168 x, 2 *
b,
b *
b - 4 * d, -
c *
c);
176 double sz1 = sqrt(
x[0]);
177 double sz2 = sqrt(
x[1]);
178 double sz3 = sqrt(
x[2]);
182 x[0] = (-sz1 - sz2 - sz3) / 2;
183 x[1] = (-sz1 + sz2 + sz3) / 2;
184 x[2] = (+sz1 - sz2 + sz3) / 2;
185 x[3] = (+sz1 + sz2 - sz3) / 2;
189 x[0] = (-sz1 - sz2 + sz3) / 2;
190 x[1] = (-sz1 + sz2 - sz3) / 2;
191 x[2] = (+sz1 - sz2 - sz3) / 2;
192 x[3] = (+sz1 + sz2 + sz3) / 2;
197 double sz1 = sqrt(-
x[0]);
198 double sz2 = sqrt(-
x[1]);
199 double sz3 = sqrt(
x[2]);
204 x[1] = (sz1 - sz2) / 2;
206 x[3] = (-sz1 - sz2) / 2;
211 x[1] = (-sz1 + sz2) / 2;
213 x[3] = (sz1 + sz2) / 2;
219 double sz1 = sqrt(
x[0]);
224 x[0] = -sz1 / 2 - szr;
225 x[1] = -sz1 / 2 + szr;
231 x[0] = sz1 / 2 - szr;
232 x[1] = sz1 / 2 + szr;
241 double x,
double a,
double b,
double c,
244 double fxs = ((4 *
x + 3 *
a) *
x + 2 *
b) *
x +
c;
245 if (fxs == 0)
return 1e99;
246 double fx = (((
x +
a) *
x +
b) *
x +
c) *
x + d;
255 double*
x,
double a,
double b,
double c,
double d) noexcept
258 double d1 = d + 0.25 *
a * (0.25 *
b *
a - 3. / 64 *
a *
a *
a -
c);
259 double c1 =
c + 0.5 *
a * (0.25 *
a *
a -
b);
260 double b1 =
b - 0.375 *
a *
a;
294 #define F5(t) (((((t + a) * t + b) * t + c) * t + d) * t + e)
297 double a,
double b,
double c,
double d,
301 if (std::abs(e) <
eps)
return 0;
303 double brd = std::abs(
a);
304 if (std::abs(
b) > brd) brd = std::abs(
b);
305 if (std::abs(
c) > brd) brd = std::abs(
c);
306 if (std::abs(d) > brd) brd = std::abs(d);
307 if (std::abs(e) > brd) brd = std::abs(e);
332 if (std::abs(f0) <
eps)
return x0;
333 if (std::abs(f1) <
eps)
return x1;
337 for (cnt = 0; cnt < 5; cnt++)
341 if (std::abs(f2) <
eps)
return x2;
361 if (x2 <= x0 || x2 >= x1) x2 = (x0 + x1) / 2;
363 if (std::abs(f2) <
eps)
return x2;
375 (((5 * x2 + 4 *
a) * x2 + 3 *
b) * x2 + 2 *
c) * x2 + d;
376 if (std::abs(f2s) <
eps)
383 }
while (std::abs(dx) >
eps);
389 double*
x,
double a,
double b,
double c,
double d,
402 double a,
double b,
double c,
double& r1,
double& r2) noexcept
404 if (std::abs(
a) <
eps)
407 if (std::abs(
b) <
eps)
return 0;
414 double Di =
b *
b - 4 *
a *
c;
421 r1 = (-
b + Di) / (2 *
a);
422 r2 = (-
b - Di) / (2 *
a);
425 if (r2 < r1)
SWAP(r1, r2);
GLdouble GLdouble GLdouble GLdouble q
int SolveP4Bi(double *x, double b, double d)
int solve_poly3(double *x, double a, double b, double c) noexcept
Solves cubic equation x^3 + a*x^2 + b*x + c = 0.
GLdouble GLdouble GLdouble r
double N4Step(double x, double a, double b, double c, double d)
static void dblSort3(double &a, double &b, double &c)
int solve_poly5(double *x, double a, double b, double c, double d, double e) noexcept
Solves equation x^5 + a*x^4 + b*x^3 + c*x^2 + d*x + e = 0.
int solve_poly2(double a, double b, double c, double &r1, double &r2) noexcept
Solves equation a*x^2 + b*x + c = 0.
void CSqrt(double x, double y, double &a, double &b)
int SolveP4De(double *x, double b, double c, double d)
int solve_poly4(double *x, double a, double b, double c, double d) noexcept
Solves quartic equation x^4 + a*x^3 + b*x^2 + c*x + d = 0 by Dekart-Euler method.
static double SolveP5_1(double a, double b, double c, double d, double e)
GLubyte GLubyte GLubyte a
Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at mié 12 jul 2023 10:03:34 CEST | |