tfel
Loading...
Searching...
No Matches
tfel::math::CubicRoots Struct Reference

#include </home/runner/work/tfel/tfel/include/TFEL/Math/General/CubicRoots.hxx>

Static Public Member Functions

template<typename T>
static TFEL_HOST_DEVICE T cbrt (const T x) noexcept
template<typename T>
requires ((tfel::typetraits::IsReal<T>::cond) && (tfel::typetraits::IsFundamentalNumericType<T>::cond))
static TFEL_HOST_DEVICE unsigned short find_roots (T &x1, T &x2, T &x3, const T a3, const T a2, const T a1, const T a0)
template<typename T>
requires ((tfel::typetraits::IsReal<T>::cond) && (tfel::typetraits::IsFundamentalNumericType<T>::cond))
static TFEL_HOST_DEVICE unsigned short exe (T &x1, T &x2, T &x3, const T a3, const T a2, const T a1, const T a0, const bool b=false)

Static Protected Member Functions

template<typename T>
static TFEL_HOST_DEVICE void improve (T &vp, const T a3, const T a2, const T a1, const T a0)

Detailed Description

struct gathering tools function to compute the roots of a cubic polynomial

Member Function Documentation

◆ cbrt()

template<typename T>
TFEL_HOST_DEVICE T tfel::math::CubicRoots::cbrt ( const T x)
inlinestaticnoexcept
Returns
the cubic root of a real number
Parameters
[in]x: value

◆ exe()

template<typename T>
requires ((tfel::typetraits::IsReal<T>::cond) && (tfel::typetraits::IsFundamentalNumericType<T>::cond))
TFEL_HOST_DEVICE unsigned short tfel::math::CubicRoots::exe ( T & x1,
T & x2,
T & x3,
const T a3,
const T a2,
const T a1,
const T a0,
const bool b = false )
inlinestatic
Returns
the number of real roots.
Parameters
[out]x1: first root
[out]x2: second root
[out]x3: third root
[in]a3: coefficient of the polynom
[in]a2: coefficient of the polynom
[in]a1: coefficient of the polynom
[in]a0: coefficient of the polynom
[in]b: if true, use a newton raphson algorithm to refine the roots found

◆ find_roots()

template<typename T>
requires ((tfel::typetraits::IsReal<T>::cond) && (tfel::typetraits::IsFundamentalNumericType<T>::cond))
TFEL_HOST_DEVICE unsigned short tfel::math::CubicRoots::find_roots ( T & x1,
T & x2,
T & x3,
const T a3,
const T a2,
const T a1,
const T a0 )
inlinestatic

find the real roots of a cubic polynomial by Cardan's method

Returns
the number of real roots. a3 X^{3}+a2 X^{2}+a1 X^{1}+a0 = 0
Parameters
[out]x1: first root
[out]x2: second root
[out]x3: third root
[in]a3: coefficient of the polynom
[in]a2: coefficient of the polynom
[in]a1: coefficient of the polynom
[in]a0: coefficient of the polynom
Note
due to numerical errors, this function may find only one real root when three are expected (for example, when searching the eigen values of a symmetric tensor). If only one real root is found:
  • x1 contains this real root
  • x2 and x3 contain the real part of the two other roots

The documentation for this struct was generated from the following file: