MRPT  2.0.4
poly_roots.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #pragma once
11 
12 #include <cstdlib>
13 
14 namespace mrpt::math
15 {
16 /** @addtogroup polynomial_roots Find polynomial roots (`#include
17  * <mrpt/math/poly_roots.h>`)
18  * \ingroup mrpt_math_grp
19  * @{ */
20 
21 /** Solves cubic equation `x^3 + a*x^2 + b*x + c = 0`. Returns the number of
22  * real roots `N`<=3.
23  * The roots are returned in the first entries of `x`, i.e. `x[0]` if N=1,
24  * `x[0]` and `x[1]` if N=2, etc.
25  * \param x array of size 3
26  * \note Based on `poly34.h`, by Khashin S.I.
27  * http://math.ivanovo.ac.ru/dalgebra/Khashin/index.html - khash2 (at) gmail.com
28  */
29 int solve_poly3(double* x, double a, double b, double c) noexcept;
30 
31 /** Solves quartic equation `x^4 + a*x^3 + b*x^2 + c*x + d = 0` by Dekart-Euler
32  * method.
33  * Returns the number of real roots `N`<=4:
34  * - return 4: 4 real roots x[0], x[1], x[2], x[3], possible multiple roots
35  * - return 2: 2 real roots x[0], x[1] and complex x[2]+-i*x[3],
36  * - return 0: two pair of complex roots: x[0]+-i*x[1], x[2]+-i*x[3],
37  *
38  * The roots are returned in the first entries of `x`, i.e. `x[0]` if N=1,
39  * `x[0]` and `x[1]` if N=2, etc.
40  * \param x array of size 4
41  * \note Based on `poly34.h`, by Khashin S.I.
42  * http://math.ivanovo.ac.ru/dalgebra/Khashin/index.html - khash2 (at) gmail.com
43  */
44 int solve_poly4(double* x, double a, double b, double c, double d) noexcept;
45 
46 /** Solves equation `x^5 + a*x^4 + b*x^3 + c*x^2 + d*x + e = 0`.
47  * Returns the number of real roots `N`<=5.
48  * The roots are returned in the first entries of `x`, i.e. `x[0]` if N=1,
49  * `x[0]` and `x[1]` if N=2, etc.
50  * \param x array of size 5
51  * \note Based on `poly34.h`, by Khashin S.I.
52  * http://math.ivanovo.ac.ru/dalgebra/Khashin/index.html - khash2 (at) gmail.com
53  */
54 int solve_poly5(
55  double* x, double a, double b, double c, double d, double e) noexcept;
56 
57 /** Solve equation x^4 + b*x^2 + d = 0 */
58 int solve_poly4Bi(double* x, double b, double d) noexcept;
59 /** Solve equation x^4 + b*x^2 + c*x + d = 0 */
60 int solve_poly4De(double* x, double b, double c, double d) noexcept;
61 
62 /** Solves equation `a*x^2 + b*x + c = 0`.
63  * Returns the number of real roots: either 0 or 2; or 1 if a=0 (in this case
64  * the root is in r1).
65  * r1, r2 are the roots. (r1<=r2)
66  * \note Based on `poly34.h`, by Khashin S.I.
67  * http://math.ivanovo.ac.ru/dalgebra/Khashin/index.html - khash2 (at) gmail.com
68  */
69 int solve_poly2(double a, double b, double c, double& r1, double& r2) noexcept;
70 
71 /** @} */
72 
73 } // namespace mrpt::math
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.
Definition: poly_roots.cpp:381
This base provides a set of functions for maths stuff.
int solve_poly4De(double *x, double b, double c, double d) noexcept
Solve equation x^4 + b*x^2 + c*x + d = 0.
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. ...
Definition: poly_roots.cpp:247
int solve_poly4Bi(double *x, double b, double d) noexcept
Solve equation x^4 + b*x^2 + d = 0.
int solve_poly3(double *x, double a, double b, double c) noexcept
Solves cubic equation x^3 + a*x^2 + b*x + c = 0.
Definition: poly_roots.cpp:29
int solve_poly2(double a, double b, double c, double &r1, double &r2) noexcept
Solves equation a*x^2 + b*x + c = 0.
Definition: poly_roots.cpp:394



Page generated by Doxygen 1.8.14 for MRPT 2.0.4 Git: 7b5ddf9de Fri May 29 14:02:56 2020 +0200 at vie may 29 14:15:09 CEST 2020