Ocean
Loading...
Searching...
No Matches
Ocean::EquationT< T > Class Template Reference

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 Public Member Functions

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.
 

Detailed Description

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
TType of passed floating point values
See also
Equation, EquationF, EquationD.

Member Function Documentation

◆ 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
aA parameter, with range (-infinity, infinity) \ {0}, (must not be 0)
bB parameter, with range (-infinity, infinity)
cC parameter, with range (-infinity, infinity)
dD parameter, with range (-infinity, infinity)
xThe known root to optimize, with range (-infinity, infinity)
maxIterationsThe maximum number of Newton-Raphson iterations, with range [1, infinity)
updateFactorThe 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
aA parameter, with range (-infinity, infinity) \ {0}, (must not be 0)
bB parameter, with range (-infinity, infinity)
cC parameter, with range (-infinity, infinity)
dD parameter, with range (-infinity, infinity)
eE parameter, with range (-infinity, infinity)
xThe known root to optimize, with range (-infinity, infinity)
maxIterationsThe maximum number of Newton-Raphson iterations, with range [1, infinity)
updateFactorThe 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
aA parameter, with range (-infinity, infinity) \ {0}, (must not be 0)
bB parameter, with range (-infinity, infinity)
cC parameter, with range (-infinity, infinity)
dD parameter, with range (-infinity, infinity)
x1First resulting solution, with range (-infinity, infinity)
x2Second resulting solution, with range (-infinity, infinity)
x3Third resulting solution, with range (-infinity, infinity)
refineTrue, 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()

template<typename T >
bool Ocean::EquationT< T >::solveLinear ( const T  a,
const T  b,
T &  x 
)
static

Solves a linear eqation with the form:

ax + b = 0
Parameters
aA parameter, with range (-infinity, infinity) \ {0}, (must not be 0)
bB parameter, with range (-infinity, infinity)
xResulting 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
aA parameter, with range (-infinity, infinity) \ {0}, (must not be 0)
bB parameter, with range (-infinity, infinity)
cC parameter, with range (-infinity, infinity)
x1First resulting solution, with range (-infinity, infinity)
x2Second 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
aA parameter, with range (-infinity, infinity) \ {0}, (must not be 0)
bB parameter, with range (-infinity, infinity)
cC parameter, with range (-infinity, infinity)
dD parameter, with range (-infinity, infinity)
eE parameter, with range (-infinity, infinity)
xArray with at least four scalar values receiving the (at most) four solutions
refineTrue, 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: