Polynomial of degree at most N (N >= 0). More...
#include <roboptim/trajectory/polynomial.hh>
Public Types | |
typedef Function::interval_t | interval_t |
typedef std::vector< value_type > | roots_t |
Type of the vector of roots. More... | |
typedef Eigen::Matrix < value_type, N+1, 1 > | coefs_t |
Fixed-size coefficient vector (N+1 if N is the polynomial degree). More... | |
typedef std::vector< value_type > | values_t |
Type of the critical points. More... | |
typedef std::pair< value_type, value_type > | max_t |
Type of a maximum query: (t_max, P(t_max)) More... | |
typedef std::pair< value_type, value_type > | min_t |
Type of a minimum query: (t_min, P(t_min)) More... | |
typedef ::roboptim::Polynomial < Function::traits_t > | polynomialFunction_t |
Polynomial function. More... | |
Public Member Functions | |
ROBOPTIM_FUNCTION_FWD_TYPEDEFS_ (Function) | |
BOOST_STATIC_ASSERT (N >=0) | |
Polynomial degree >= 0. More... | |
Polynomial () | |
Default constructor: return a null polynomial. More... | |
Polynomial (value_type t0, const_vector_ref coefs) | |
Construct of a polynomial from its center and its coefficients. More... | |
Polynomial (value_type t0,...) | |
Variadic constructor. More... | |
template<int M> | |
Polynomial (const Polynomial< M > &p) | |
Copy constructor of polynomials of different orders. More... | |
Polynomial< N > | translate (value_type t1) const |
Return a new polynomial translated from (t-t₀) to (t-t₁). More... | |
void | translateInPlace (value_type t1) |
Translate the polynomial (in place) from (t-t₀) to (t-t₁). More... | |
template<int K> | |
Polynomial< N-K > | derivative () const |
Compute the derivative polynomial of a given order. More... | |
value_type | derivative (value_type t, size_type order=1) const |
Evaluate the derivative of a given order. More... | |
template<int M> | |
Polynomial< N+M > | operator* (const Polynomial< M > &poly) const |
Multiply polynomials of different orders. More... | |
Polynomial< N > | operator+ (const Polynomial< N > &poly) const |
Addition of polynomials. More... | |
Polynomial< N > | operator- (const Polynomial< N > &poly) const |
Subtraction of polynomials. More... | |
Polynomial< N > | operator* (value_type lambda) const |
Scalar multiplication of a polynomial. More... | |
void | operator+= (const Polynomial< N > &poly) |
Addition of polynomials. More... | |
value_type | operator() (value_type t) const |
Evaluate the polynomial with Horner's method. More... | |
const coefs_t & | coefs () const |
Const getter to coefs. More... | |
coefs_t & | coefs () |
Getter to coefs. More... | |
value_type | t0 () const |
Const getter to t0. More... | |
value_type & | t0 () |
Reference to t0. More... | |
value_type | operator[] (int i) const |
Get the i-th polynomial coefficient. More... | |
roots_t | realRoots (value_type epsilon=1e-6) const |
Return the real roots of the polynomial. More... | |
values_t | critPoints (const interval_t &interval) const |
Compute the critical values of the polynomial on an interval. More... | |
min_t | min (const interval_t &interval, bool acceptConstant=true) const |
Compute the minimum of the polynomial on an interval. More... | |
max_t | max (const interval_t &interval, bool acceptConstant=true) const |
Compute the maximum of the polynomial on an interval. More... | |
bool | isNull (value_type epsilon=Function::epsilon()) const |
Return whether the polynomial is null. More... | |
bool | isConstant (value_type epsilon=Function::epsilon()) const |
Return whether the polynomial is constant. More... | |
bool | isLinear (value_type epsilon=Function::epsilon()) const |
Return whether the polynomial is linear. More... | |
int | trueOrder (value_type epsilon=Function::epsilon()) const |
Return the "true" order of the polynomial. More... | |
polynomialFunction_t | asFunction () const |
Get the equivalent Polynomial function. More... | |
virtual std::ostream & | print (std::ostream &o) const |
Print the polynomial. More... | |
Static Public Member Functions | |
static int | order () |
Return the order of such a polynomial. More... | |
Protected Types | |
enum | special_polynomials { all_zero_coefficients = 0, monomial_coefficients = 1 } |
Enum for special polynomials. More... | |
Protected Member Functions | |
value_type | impl_derivative (value_type t, size_type order, size_type start_coef=0) const |
template<int K> | |
Polynomial< N-K > | impl_derivative () const |
Implementation of the compile-time derivative. More... | |
coefs_t | impl_translate (value_type t1) const |
Polynomial (value_type t0, special_polynomials key) | |
Special constructor for Monomial<N> and some operators. More... | |
Static Protected Attributes | |
static const int | order_ = N |
order of the polynomial. More... | |
Polynomial of degree at most N (N >= 0).
\[ P (t) = \sum_{i=0}^{N} a_i (t-t_0)^i \]
typedef Eigen::Matrix<value_type, N+1, 1> roboptim::trajectory::Polynomial< N >::coefs_t |
Fixed-size coefficient vector (N+1 if N is the polynomial degree).
typedef Function::interval_t roboptim::trajectory::Polynomial< N >::interval_t |
typedef std::pair<value_type, value_type> roboptim::trajectory::Polynomial< N >::max_t |
Type of a maximum query: (t_max, P(t_max))
typedef std::pair<value_type, value_type> roboptim::trajectory::Polynomial< N >::min_t |
Type of a minimum query: (t_min, P(t_min))
typedef ::roboptim::Polynomial<Function::traits_t> roboptim::trajectory::Polynomial< N >::polynomialFunction_t |
Polynomial function.
typedef std::vector<value_type> roboptim::trajectory::Polynomial< N >::roots_t |
Type of the vector of roots.
typedef std::vector<value_type> roboptim::trajectory::Polynomial< N >::values_t |
Type of the critical points.
|
protected |
Enum for special polynomials.
Enumerator | |
---|---|
all_zero_coefficients |
Null polynomial: 0. |
monomial_coefficients |
Monomial polynomial: (t-t₀) |
roboptim::trajectory::Polynomial< N >::Polynomial | ( | ) |
Default constructor: return a null polynomial.
roboptim::trajectory::Polynomial< N >::Polynomial | ( | value_type | t0, |
const_vector_ref | coefs | ||
) |
Construct of a polynomial from its center and its coefficients.
t0 | polynomial of (t-t₀). |
coefs | polynomial coefficients. |
References roboptim::trajectory::Polynomial< N >::coefs().
roboptim::trajectory::Polynomial< N >::Polynomial | ( | value_type | t0, |
... | |||
) |
Variadic constructor.
Note: this is a legacy constructor used to keep Polynomial3's API.
t0 | polynomial of (t-t₀). |
... | variadic arguments containing [a₀,a₁,...,a_N] |
roboptim::trajectory::Polynomial< N >::Polynomial | ( | const Polynomial< M > & | p | ) |
Copy constructor of polynomials of different orders.
M | degree of the copied polynomial. |
p | copied polynomial. |
References roboptim::trajectory::Polynomial< N >::coefs().
|
protected |
Special constructor for Monomial<N> and some operators.
t0 | |
key | one of all_zero_coefficients, monomial_coefficients. |
References roboptim::trajectory::Polynomial< N >::all_zero_coefficients, and roboptim::trajectory::Polynomial< N >::monomial_coefficients.
Polynomial< N >::polynomialFunction_t roboptim::trajectory::Polynomial< N >::asFunction | ( | ) | const |
Get the equivalent Polynomial function.
This can be used for all the methods that expect a RobOptim function (e.g. plotting).
roboptim::trajectory::Polynomial< N >::BOOST_STATIC_ASSERT | ( | N >= | 0 | ) |
Polynomial degree >= 0.
const Polynomial< N >::coefs_t & roboptim::trajectory::Polynomial< N >::coefs | ( | ) | const |
Const getter to coefs.
Referenced by roboptim::trajectory::Polynomial< N >::operator*(), and roboptim::trajectory::Polynomial< N >::Polynomial().
Polynomial< N >::coefs_t & roboptim::trajectory::Polynomial< N >::coefs | ( | ) |
Getter to coefs.
Polynomial< N >::values_t roboptim::trajectory::Polynomial< N >::critPoints | ( | const interval_t & | interval | ) | const |
Compute the critical values of the polynomial on an interval.
interval | time interval. |
std::runtime_error | invalid polynomial. This is the case for constant polynomials since there is an infinity of critical points. This can be tested before calling min(). |
Polynomial< N-K > roboptim::trajectory::Polynomial< N >::derivative | ( | ) | const |
Compute the derivative polynomial of a given order.
K | derivative order. |
Referenced by roboptim::trajectory::BSpline< N >::basisFunctions(), roboptim::trajectory::BSpline< N >::impl_derivative(), roboptim::trajectory::CubicBSpline::impl_derivative(), roboptim::trajectory::ConstrainedBSpline< N >::variationDerivWrtParam(), and roboptim::trajectory::BSpline< N >::variationDerivWrtParam().
Polynomial< N >::value_type roboptim::trajectory::Polynomial< N >::derivative | ( | value_type | t, |
size_type | order = 1 |
||
) | const |
Evaluate the derivative of a given order.
t | time of the evaluation. |
order | order of the derivative. |
|
protected |
|
protected |
Implementation of the compile-time derivative.
K | order of the derivation. |
|
protected |
bool roboptim::trajectory::Polynomial< N >::isConstant | ( | value_type | epsilon = Function::epsilon () | ) | const |
Return whether the polynomial is constant.
epsilon | epsilon used. |
bool roboptim::trajectory::Polynomial< N >::isLinear | ( | value_type | epsilon = Function::epsilon () | ) | const |
Return whether the polynomial is linear.
epsilon | epsilon used. |
bool roboptim::trajectory::Polynomial< N >::isNull | ( | value_type | epsilon = Function::epsilon () | ) | const |
Return whether the polynomial is null.
epsilon | epsilon used. |
Polynomial< N >::max_t roboptim::trajectory::Polynomial< N >::max | ( | const interval_t & | interval, |
bool | acceptConstant = true |
||
) | const |
Compute the maximum of the polynomial on an interval.
interval | time interval. |
acceptConstant | boolean allowing constant polynomials. |
std::runtime_error | invalid polynomial. This is the case for constant polynomials if acceptConstant is set to false, since there is an infinity of critical points. |
Polynomial< N >::min_t roboptim::trajectory::Polynomial< N >::min | ( | const interval_t & | interval, |
bool | acceptConstant = true |
||
) | const |
Compute the minimum of the polynomial on an interval.
interval | time interval. |
acceptConstant | boolean allowing constant polynomials. |
std::runtime_error | invalid polynomial. This is the case for constant polynomials if acceptConstant is set to false, since there is an infinity of critical points. |
Polynomial< N >::value_type roboptim::trajectory::Polynomial< N >::operator() | ( | value_type | t | ) | const |
Evaluate the polynomial with Horner's method.
t | point of evaluation. |
Polynomial< N+M > roboptim::trajectory::Polynomial< N >::operator* | ( | const Polynomial< M > & | poly | ) | const |
Multiply polynomials of different orders.
M | order of the polynomial. |
poly | polynomial to multiply. |
References roboptim::trajectory::Polynomial< N >::coefs(), and roboptim::trajectory::Polynomial< N >::translate().
Polynomial< N > roboptim::trajectory::Polynomial< N >::operator* | ( | value_type | lambda | ) | const |
Scalar multiplication of a polynomial.
lambda | scalar. |
Polynomial< N > roboptim::trajectory::Polynomial< N >::operator+ | ( | const Polynomial< N > & | poly | ) | const |
Addition of polynomials.
poly | polynomial to add. |
References roboptim::trajectory::Polynomial< N >::translate().
void roboptim::trajectory::Polynomial< N >::operator+= | ( | const Polynomial< N > & | poly | ) |
Addition of polynomials.
poly | polynomial to add. |
References roboptim::trajectory::Polynomial< N >::translate().
Polynomial< N > roboptim::trajectory::Polynomial< N >::operator- | ( | const Polynomial< N > & | poly | ) | const |
Subtraction of polynomials.
poly | polynomial to subtract. |
References roboptim::trajectory::Polynomial< N >::translate().
Polynomial< N >::value_type roboptim::trajectory::Polynomial< N >::operator[] | ( | int | i | ) | const |
Get the i-th polynomial coefficient.
i | number of the coefficient to get. |
|
inlinestatic |
Return the order of such a polynomial.
References roboptim::trajectory::Polynomial< N >::order_.
|
virtual |
Print the polynomial.
o | output stream. |
Polynomial< N >::roots_t roboptim::trajectory::Polynomial< N >::realRoots | ( | value_type | epsilon = 1e-6 | ) | const |
Return the real roots of the polynomial.
epsilon | epsilon used for testing constant polynomials. |
std::runtime_error | invalid polynomial (e.g. null/constant). |
roboptim::trajectory::Polynomial< N >::ROBOPTIM_FUNCTION_FWD_TYPEDEFS_ | ( | Function | ) |
Polynomial< N >::value_type roboptim::trajectory::Polynomial< N >::t0 | ( | ) | const |
Const getter to t0.
Polynomial< N >::value_type & roboptim::trajectory::Polynomial< N >::t0 | ( | ) |
Reference to t0.
Polynomial< N > roboptim::trajectory::Polynomial< N >::translate | ( | value_type | t1 | ) | const |
Return a new polynomial translated from (t-t₀) to (t-t₁).
t1 | new center. |
Referenced by roboptim::trajectory::Polynomial< N >::operator*(), roboptim::trajectory::Polynomial< N >::operator+(), roboptim::trajectory::Polynomial< N >::operator+=(), and roboptim::trajectory::Polynomial< N >::operator-().
void roboptim::trajectory::Polynomial< N >::translateInPlace | ( | value_type | t1 | ) |
Translate the polynomial (in place) from (t-t₀) to (t-t₁).
t1 | new center. |
int roboptim::trajectory::Polynomial< N >::trueOrder | ( | value_type | epsilon = Function::epsilon () | ) | const |
Return the "true" order of the polynomial.
Leading coefficients may be null, which c
|
staticprotected |
order of the polynomial.
Referenced by roboptim::trajectory::Polynomial< N >::order().