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. | |
typedef Eigen::Matrix < value_type, N+1, 1 > | coefs_t |
Fixed-size coefficient vector (N+1 if N is the polynomial degree). | |
typedef std::pair< value_type, value_type > | min_t |
Type of a minimum query: (t_min, P(t_min)) | |
typedef ::roboptim::Polynomial < Function::traits_t > | polynomialFunction_t |
Polynomial function. | |
Public Member Functions | |
ROBOPTIM_FUNCTION_FWD_TYPEDEFS_ (Function) | |
BOOST_STATIC_ASSERT (N >=0) | |
Polynomial degree >= 0. | |
Polynomial () | |
Default constructor: return a null polynomial. | |
Polynomial (value_type t0, const_vector_ref coefs) | |
Construct of a polynomial from its center and its coefficients. | |
Polynomial (value_type t0,...) | |
Variadic constructor. | |
template<int M> | |
Polynomial (const Polynomial< M > &p) | |
Copy constructor of polynomials of different orders. | |
Polynomial< N > | translate (value_type t1) const |
Return a new polynomial translated from (t-t₀) to (t-t₁). | |
void | translateInPlace (value_type t1) |
Translate the polynomial (in place) from (t-t₀) to (t-t₁). | |
template<int K> | |
Polynomial< N-K > | derivative () const |
Compute the derivative polynomial of a given order. | |
value_type | derivative (value_type t, size_type order=1) const |
Evaluate the derivative of a given order. | |
template<int M> | |
Polynomial< N+M > | operator* (const Polynomial< M > &poly) const |
Multiply polynomials of different orders. | |
Polynomial< N > | operator+ (const Polynomial< N > &poly) const |
Addition of polynomials. | |
Polynomial< N > | operator- (const Polynomial< N > &poly) const |
Subtraction of polynomials. | |
Polynomial< N > | operator* (value_type lambda) const |
Scalar multiplication of a polynomial. | |
value_type | operator() (value_type t) const |
Evaluate the polynomial with Horner's method. | |
const coefs_t & | coefs () const |
Const getter to coefs. | |
coefs_t & | coefs () |
Getter to coefs. | |
value_type | t0 () const |
Const getter to t0. | |
value_type & | t0 () |
Reference to t0. | |
value_type | operator[] (int i) const |
Get the i-th polynomial coefficient. | |
roots_t | realRoots (value_type epsilon=1e-6) const |
Return the real roots of the polynomial. | |
min_t | min (const interval_t &interval) const |
Compute the minimum of the polynomial on an interval. | |
bool | isNull (value_type epsilon=Function::epsilon()) const |
Return whether the polynomial is null. | |
bool | isConstant (value_type epsilon=Function::epsilon()) const |
Return whether the polynomial is constant. | |
bool | isLinear (value_type epsilon=Function::epsilon()) const |
Return whether the polynomial is linear. | |
int | trueOrder (value_type epsilon=Function::epsilon()) const |
Return the "true" order of the polynomial. | |
polynomialFunction_t | asFunction () const |
Get the equivalent Polynomial function. | |
virtual std::ostream & | print (std::ostream &o) const |
Print the polynomial. | |
Static Public Member Functions | |
static int | order () |
Return the order of such a polynomial. | |
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. | |
coefs_t | impl_translate (value_type t1) const |
Polynomial (value_type t0, special_polynomials key) | |
Special constructor for Monomial<N> and some operators. | |
Static Protected Attributes | |
static const int | order_ = N |
order of the polynomial. |
Polynomial of degree at most N (N >= 0).
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 >::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.
enum roboptim::trajectory::Polynomial::special_polynomials [protected] |
Enum for special polynomials.
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().
roboptim::trajectory::Polynomial< N >::Polynomial | ( | value_type | t0, |
special_polynomials | key | ||
) | [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::BSpline< N >::cox_de_boor(), 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-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::CubicBSpline::variationDerivWrtParam(), 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. |
Polynomial< N >::value_type roboptim::trajectory::Polynomial< N >::impl_derivative | ( | value_type | t, |
size_type | order, | ||
size_type | start_coef = 0 |
||
) | const [protected] |
Polynomial< N-K > roboptim::trajectory::Polynomial< N >::impl_derivative | ( | ) | const [protected] |
Implementation of the compile-time derivative.
K | order of the derivation. |
Polynomial< N >::coefs_t roboptim::trajectory::Polynomial< N >::impl_translate | ( | value_type | t1 | ) | const [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 >::min_t roboptim::trajectory::Polynomial< N >::min | ( | const interval_t & | interval | ) | const |
Compute the minimum 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 >::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().
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. |
static int roboptim::trajectory::Polynomial< N >::order | ( | ) | [inline, static] |
Return the order of such a polynomial.
References roboptim::trajectory::Polynomial< N >::order_.
std::ostream & roboptim::trajectory::Polynomial< N >::print | ( | std::ostream & | o | ) | const [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+(), 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
const int roboptim::trajectory::Polynomial< N >::order_ = N [static, protected] |
order of the polynomial.
Referenced by roboptim::trajectory::Polynomial< N >::order().