This class provides several functions to solve equations with different degree using floating point values with the precission specified by type T.
More...
#include <Equation.h>
|
| static bool | solveLinear (const T a, const T b, T &x) |
| | Solves a linear eqation with the form:
|
| |
| static bool | solveQuadratic (const T a, const T b, const T c, T &x1, T &x2) |
| | Solves an quadratic equation with the form:
|
| |
| static unsigned int | solveCubic (const T a, const T b, const T c, const T d, T &x1, T &x2, T &x3, const bool refine=true) |
| | Solves a cubic equation with the from:
|
| |
| static unsigned int | solveQuartic (const T a, const T b, const T c, const T d, const T e, T *x, const bool refine=true) |
| | Solves a quartic equation with the form:
|
| |
| static unsigned int | optimizeCubic (const T a, const T b, const T c, const T d, T &x, const unsigned int maxIterations=10u, const T updateFactor=T(1.0)) |
| | Optimizes a root of a cubic equation using Newton-Raphson iterations.
|
| |
| static unsigned int | optimizeQuartic (const T a, const T b, const T c, const T d, const T e, T &x, const unsigned int maxIterations=10u, const T updateFactor=T(1.0)) |
| | Optimizes a root of a quartic equation using Newton-Raphson iterations.
|
| |
template<typename T>
class Ocean::EquationT< T >
This class provides several functions to solve equations with different degree using floating point values with the precission specified by type T.
- Template Parameters
-
| T | Type of passed floating point values |
- See also
- Equation, EquationF, EquationD.
◆ optimizeCubic()
template<typename T >
| unsigned int Ocean::EquationT< T >::optimizeCubic |
( |
const T |
a, |
|
|
const T |
b, |
|
|
const T |
c, |
|
|
const T |
d, |
|
|
T & |
x, |
|
|
const unsigned int |
maxIterations = 10u, |
|
|
const T |
updateFactor = T(1.0) |
|
) |
| |
|
static |
Optimizes a root of a cubic equation using Newton-Raphson iterations.
The function optimizes a known x for the following equation:
ax^3 + bx^2 + cx + d = 0
- Parameters
-
| a | A parameter, with range (-infinity, infinity) \ {0}, (must not be 0) |
| b | B parameter, with range (-infinity, infinity) |
| c | C parameter, with range (-infinity, infinity) |
| d | D parameter, with range (-infinity, infinity) |
| x | The known root to optimize, with range (-infinity, infinity) |
| maxIterations | The maximum number of Newton-Raphson iterations, with range [1, infinity) |
| updateFactor | The update factor for the Newton-Raphson iterations, with range (0, 2] |
- Returns
- The number of applied iterations, with range [0, maxIterations], 0 if the root could not be optimized
◆ optimizeQuartic()
template<typename T >
| unsigned int Ocean::EquationT< T >::optimizeQuartic |
( |
const T |
a, |
|
|
const T |
b, |
|
|
const T |
c, |
|
|
const T |
d, |
|
|
const T |
e, |
|
|
T & |
x, |
|
|
const unsigned int |
maxIterations = 10u, |
|
|
const T |
updateFactor = T(1.0) |
|
) |
| |
|
static |
Optimizes a root of a quartic equation using Newton-Raphson iterations.
The function optimizes a known x for the following equation:
ax^4 + bx^3 + cx^2 + dx + e = 0
- Parameters
-
| a | A parameter, with range (-infinity, infinity) \ {0}, (must not be 0) |
| b | B parameter, with range (-infinity, infinity) |
| c | C parameter, with range (-infinity, infinity) |
| d | D parameter, with range (-infinity, infinity) |
| e | E parameter, with range (-infinity, infinity) |
| x | The known root to optimize, with range (-infinity, infinity) |
| maxIterations | The maximum number of Newton-Raphson iterations, with range [1, infinity) |
| updateFactor | The update factor for the Newton-Raphson iterations, with range (0, 2] |
- Returns
- The number of applied iterations, with range [0, maxIterations], 0 if the root could not be optimized
◆ solveCubic()
template<typename T >
| unsigned int Ocean::EquationT< T >::solveCubic |
( |
const T |
a, |
|
|
const T |
b, |
|
|
const T |
c, |
|
|
const T |
d, |
|
|
T & |
x1, |
|
|
T & |
x2, |
|
|
T & |
x3, |
|
|
const bool |
refine = true |
|
) |
| |
|
static |
Solves a cubic equation with the from:
ax^3 + bx^2 + cx + d = 0
- Parameters
-
| a | A parameter, with range (-infinity, infinity) \ {0}, (must not be 0) |
| b | B parameter, with range (-infinity, infinity) |
| c | C parameter, with range (-infinity, infinity) |
| d | D parameter, with range (-infinity, infinity) |
| x1 | First resulting solution, with range (-infinity, infinity) |
| x2 | Second resulting solution, with range (-infinity, infinity) |
| x3 | Third resulting solution, with range (-infinity, infinity) |
| refine | True, to refine the calculated solutions with an iterative algorithm; False, to use the roots as calculated |
- Returns
- The number of solutions, with range [0, 3]
◆ solveLinear()
Solves a linear eqation with the form:
ax + b = 0
- Parameters
-
| a | A parameter, with range (-infinity, infinity) \ {0}, (must not be 0) |
| b | B parameter, with range (-infinity, infinity) |
| x | Resulting solution |
- Returns
- True, if succeeded
◆ solveQuadratic()
template<typename T >
| bool Ocean::EquationT< T >::solveQuadratic |
( |
const T |
a, |
|
|
const T |
b, |
|
|
const T |
c, |
|
|
T & |
x1, |
|
|
T & |
x2 |
|
) |
| |
|
static |
Solves an quadratic equation with the form:
ax^2 + bx + c = 0
- Parameters
-
| a | A parameter, with range (-infinity, infinity) \ {0}, (must not be 0) |
| b | B parameter, with range (-infinity, infinity) |
| c | C parameter, with range (-infinity, infinity) |
| x1 | First resulting solution, with range (-infinity, infinity) |
| x2 | Second resulting solution, with range (-infinity, infinity) |
- Returns
- True, if succeeded
◆ solveQuartic()
template<typename T >
| unsigned int Ocean::EquationT< T >::solveQuartic |
( |
const T |
a, |
|
|
const T |
b, |
|
|
const T |
c, |
|
|
const T |
d, |
|
|
const T |
e, |
|
|
T * |
x, |
|
|
const bool |
refine = true |
|
) |
| |
|
static |
Solves a quartic equation with the form:
ax^4 + bx^3 + cx^2 + dx + e = 0
- Parameters
-
| a | A parameter, with range (-infinity, infinity) \ {0}, (must not be 0) |
| b | B parameter, with range (-infinity, infinity) |
| c | C parameter, with range (-infinity, infinity) |
| d | D parameter, with range (-infinity, infinity) |
| e | E parameter, with range (-infinity, infinity) |
| x | Array with at least four scalar values receiving the (at most) four solutions |
| refine | True, to refine the calculated solutions with an iterative algorithm; False, to use the roots as calculated |
- Returns
- The number of solutions, with range [0, 4]
y^4 + alpha * y^2 + beta * y + gamma = 0
The documentation for this class was generated from the following file: