Robotics Library  0.7.0
Public Member Functions | Static Public Member Functions | Protected Attributes | Friends | List of all members
rl::math::Polynomial< T > Class Template Reference

A vector-valued polynomial function from Real -> T. More...

#include <Polynomial.h>

Inheritance diagram for rl::math::Polynomial< T >:
Inheritance graph
[legend]

Public Member Functions

 Polynomial (const ::std::size_t &degree)
 
virtual ~Polynomial ()
 
Polynomialclone () const
 
T & coefficient (const ::std::size_t &i)
 
const T & coefficient (const ::std::size_t &i) const
 
::std::size_t degree () const
 
Polynomial derivative () const
 
getAbsoluteMaximum () const
 Returns the array of the maximum function values of each dimension within the definition range, not regarding the sign of the function values. More...
 
Polynomial integral () const
 
operator() (const Real &x, const ::std::size_t &derivative=0) const
 Evaluates the function or a derivative thereof for a given value x. More...
 
Polynomial operator+ (const Polynomial &rhs) const
 
Polynomialoperator+= (const T &rhs)
 
Polynomialoperator+= (const Polynomial &rhs)
 
Polynomial operator- () const
 
Polynomial operator- (const Polynomial &rhs) const
 
Polynomialoperator-= (const T &rhs)
 
Polynomialoperator-= (const Polynomial &rhs)
 
Polynomialoperator*= (const Real &rhs)
 
Polynomialoperator/= (const Real &rhs)
 
static ::std::vector< RealrealRoots (const ::std::vector< Real > &c)
 Calculates the real roots (or, zeros) for given polynomial coefficients. More...
 
Polynomial scaledX (const Real &factor) const
 Stretches the x-axis of a polynomial by a given factor. More...
 
Polynomial translatedX (const Real &translation) const
 Translates a polynomial along the x-axis by a given parameter translation. More...
 
- Public Member Functions inherited from rl::math::Function< T >
 Function ()
 
virtual ~Function ()
 
Real duration () const
 
Reallower ()
 
const Reallower () const
 
Realupper ()
 
const Realupper () const
 

Static Public Member Functions

static Polynomial CubicFirst (const T &y0, const T &y1, const T &yd0, const T &yd1, const Real &x1=1)
 
static Polynomial CubicSecond (const T &y0, const T &y1, const T &ydd0, const T &ydd1, const Real &x1=1)
 
static Polynomial Linear (const T &y0, const T &y1, const Real &x1=1)
 
static Polynomial Quadratic (const T &y0, const T &y1, const T &yd0, const Real &x1=1)
 
static Polynomial QuarticFirstSecond (const T &y0, const T &y1, const T &yd0, const T &yd1, const T &ydd0, const Real &x1=1)
 
static Polynomial QuinticFirstSecond (const T &y0, const T &y1, const T &yd0, const T &yd1, const T &ydd0, const T &ydd1, const Real &x1=1)
 
static Polynomial SepticFirstSecondThird (const T &y0, const T &y1, const T &yd0, const T &yd1, const T &ydd0, const T &ydd1, const T &yddd0, const T &yddd1, const Real &x1=1)
 
static Polynomial SexticFirstSecondThird (const T &y0, const T &y1, const T &yd0, const T &yd1, const T &ydd0, const T &ydd1, const T &yddd0, const Real &x1=1)
 

Protected Attributes

::std::vector< T > c
 
- Protected Attributes inherited from rl::math::Function< T >
Real x0
 
Real x1
 

Friends

Polynomial operator+ (const T &lhs, const Polynomial &rhs)
 
Polynomial operator+ (const Polynomial &lhs, const T &rhs)
 
Polynomial operator- (const T &lhs, const Polynomial &rhs)
 
Polynomial operator- (const Polynomial &lhs, const T &rhs)
 
Polynomial operator* (const Real &lhs, const Polynomial &rhs)
 
Polynomial operator* (const Polynomial &lhs, const Real &rhs)
 
Polynomial operator/ (const Real &lhs, const Polynomial &rhs)
 
Polynomial operator/ (const Polynomial &lhs, const Real &rhs)
 

Detailed Description

template<typename T>
class rl::math::Polynomial< T >

A vector-valued polynomial function from Real -> T.

A Polynomial is indefinitely often differentiable and can be evaluated efficiently.

Constructor & Destructor Documentation

◆ Polynomial()

template<typename T>
rl::math::Polynomial< T >::Polynomial ( const ::std::size_t &  degree)
inline

◆ ~Polynomial()

template<typename T>
virtual rl::math::Polynomial< T >::~Polynomial ( )
inlinevirtual

Member Function Documentation

◆ clone()

template<typename T>
Polynomial* rl::math::Polynomial< T >::clone ( ) const
inlinevirtual

◆ coefficient() [1/2]

template<typename T>
T& rl::math::Polynomial< T >::coefficient ( const ::std::size_t &  i)
inline

◆ coefficient() [2/2]

template<typename T>
const T& rl::math::Polynomial< T >::coefficient ( const ::std::size_t &  i) const
inline

◆ CubicFirst()

template<typename T>
static Polynomial rl::math::Polynomial< T >::CubicFirst ( const T &  y0,
const T &  y1,
const T &  yd0,
const T &  yd1,
const Real x1 = 1 
)
inlinestatic

◆ CubicSecond()

template<typename T>
static Polynomial rl::math::Polynomial< T >::CubicSecond ( const T &  y0,
const T &  y1,
const T &  ydd0,
const T &  ydd1,
const Real x1 = 1 
)
inlinestatic

◆ degree()

template<typename T>
::std::size_t rl::math::Polynomial< T >::degree ( ) const
inline

◆ derivative()

template<typename T>
Polynomial rl::math::Polynomial< T >::derivative ( ) const
inline

◆ getAbsoluteMaximum()

template<typename T>
T rl::math::Polynomial< T >::getAbsoluteMaximum ( ) const
inline

Returns the array of the maximum function values of each dimension within the definition range, not regarding the sign of the function values.

For polynomials higher than cubics, Eigen::PolynomialSolver is required and calculations become iterative, without guaranteeing convergence. A common use case is to verify speed limits with the comparison (trajectory.derivate().getAbsoluteMaximum() < maximumSpeed).all()

◆ integral()

template<typename T>
Polynomial rl::math::Polynomial< T >::integral ( ) const
inline

◆ Linear()

template<typename T>
static Polynomial rl::math::Polynomial< T >::Linear ( const T &  y0,
const T &  y1,
const Real x1 = 1 
)
inlinestatic

◆ operator()()

template<typename T>
T rl::math::Polynomial< T >::operator() ( const Real x,
const ::std::size_t &  derivative = 0 
) const
inlinevirtual

Evaluates the function or a derivative thereof for a given value x.

Some functions are only defined in the interval [lower(), upper()], and fail to evaluate outside of [lower() - FUNCTION_BOUNDARY, upper() + FUNCTION_BOUNDARY]. In Debug mode, this is signaled by failing asserts. In Release mode, the function is evaluated if algebraically possible, or will return an empty ArrayX otherwise. Some functions are not indefinitely often differentiable, and will return a NaN array for all higher orders.

Parameters
[in]xInput value of the function or derivative
[in]derivativeOrder of the derivative to be evaluated

Implements rl::math::Function< T >.

◆ operator*=()

template<typename T>
Polynomial& rl::math::Polynomial< T >::operator*= ( const Real rhs)
inline

◆ operator+()

template<typename T>
Polynomial rl::math::Polynomial< T >::operator+ ( const Polynomial< T > &  rhs) const
inline

◆ operator+=() [1/2]

template<typename T>
Polynomial& rl::math::Polynomial< T >::operator+= ( const T &  rhs)
inline

◆ operator+=() [2/2]

template<typename T>
Polynomial& rl::math::Polynomial< T >::operator+= ( const Polynomial< T > &  rhs)
inline

◆ operator-() [1/2]

template<typename T>
Polynomial rl::math::Polynomial< T >::operator- ( ) const
inline

◆ operator-() [2/2]

template<typename T>
Polynomial rl::math::Polynomial< T >::operator- ( const Polynomial< T > &  rhs) const
inline

◆ operator-=() [1/2]

template<typename T>
Polynomial& rl::math::Polynomial< T >::operator-= ( const T &  rhs)
inline

◆ operator-=() [2/2]

template<typename T>
Polynomial& rl::math::Polynomial< T >::operator-= ( const Polynomial< T > &  rhs)
inline

◆ operator/=()

template<typename T>
Polynomial& rl::math::Polynomial< T >::operator/= ( const Real rhs)
inline

◆ Quadratic()

template<typename T>
static Polynomial rl::math::Polynomial< T >::Quadratic ( const T &  y0,
const T &  y1,
const T &  yd0,
const Real x1 = 1 
)
inlinestatic

◆ QuarticFirstSecond()

template<typename T>
static Polynomial rl::math::Polynomial< T >::QuarticFirstSecond ( const T &  y0,
const T &  y1,
const T &  yd0,
const T &  yd1,
const T &  ydd0,
const Real x1 = 1 
)
inlinestatic

◆ QuinticFirstSecond()

template<typename T>
static Polynomial rl::math::Polynomial< T >::QuinticFirstSecond ( const T &  y0,
const T &  y1,
const T &  yd0,
const T &  yd1,
const T &  ydd0,
const T &  ydd1,
const Real x1 = 1 
)
inlinestatic

◆ realRoots()

template<typename T>
static ::std::vector<Real> rl::math::Polynomial< T >::realRoots ( const ::std::vector< Real > &  c)
inline

Calculates the real roots (or, zeros) for given polynomial coefficients.

For degrees higher than 3, Eigen::PolynomialSolver is required and calculations become iterative, without guaranteeing convergence.

◆ scaledX()

template<typename T>
Polynomial rl::math::Polynomial< T >::scaledX ( const Real factor) const
inline

Stretches the x-axis of a polynomial by a given factor.

The returned, scaled polynomial p' of a given polynomial p fulfills p'(x * factor) = p(x), and p'.duration() = factor * p.duration(). This is done by recalculating the underlying polynomial coefficients.

◆ SepticFirstSecondThird()

template<typename T>
static Polynomial rl::math::Polynomial< T >::SepticFirstSecondThird ( const T &  y0,
const T &  y1,
const T &  yd0,
const T &  yd1,
const T &  ydd0,
const T &  ydd1,
const T &  yddd0,
const T &  yddd1,
const Real x1 = 1 
)
inlinestatic

◆ SexticFirstSecondThird()

template<typename T>
static Polynomial rl::math::Polynomial< T >::SexticFirstSecondThird ( const T &  y0,
const T &  y1,
const T &  yd0,
const T &  yd1,
const T &  ydd0,
const T &  ydd1,
const T &  yddd0,
const Real x1 = 1 
)
inlinestatic

◆ translatedX()

template<typename T>
Polynomial rl::math::Polynomial< T >::translatedX ( const Real translation) const
inline

Translates a polynomial along the x-axis by a given parameter translation.

The returned polynomial p' for a given polynomial p fulfills p'(x - translation) = p(x) This is done by recalculating the underlying polynomial coefficients.

Friends And Related Function Documentation

◆ operator* [1/2]

template<typename T>
Polynomial operator* ( const Real lhs,
const Polynomial< T > &  rhs 
)
friend

◆ operator* [2/2]

template<typename T>
Polynomial operator* ( const Polynomial< T > &  lhs,
const Real rhs 
)
friend

◆ operator+ [1/2]

template<typename T>
Polynomial operator+ ( const T &  lhs,
const Polynomial< T > &  rhs 
)
friend

◆ operator+ [2/2]

template<typename T>
Polynomial operator+ ( const Polynomial< T > &  lhs,
const T &  rhs 
)
friend

◆ operator- [1/2]

template<typename T>
Polynomial operator- ( const T &  lhs,
const Polynomial< T > &  rhs 
)
friend

◆ operator- [2/2]

template<typename T>
Polynomial operator- ( const Polynomial< T > &  lhs,
const T &  rhs 
)
friend

◆ operator/ [1/2]

template<typename T>
Polynomial operator/ ( const Real lhs,
const Polynomial< T > &  rhs 
)
friend

◆ operator/ [2/2]

template<typename T>
Polynomial operator/ ( const Polynomial< T > &  lhs,
const Real rhs 
)
friend

Member Data Documentation

◆ c

template<typename T>
::std::vector<T> rl::math::Polynomial< T >::c
protected

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