RobWorkProject  24.5.15-
PolynomialND< Coef, Scalar > Class Template Reference

Representation of a polynomial that can have non-scalar coefficients (polynomial matrix). More...

#include <PolynomialND.hpp>

Inherited by Polynomial< std::complex< double > >.

## Public Member Functions

PolynomialND (std::size_t order)
Create polynomial with uninitialized coefficients. More...

PolynomialND (const std::vector< Coef > &coefficients)
Create polynomial from vector. More...

PolynomialND (const PolynomialND< Coef, Scalar > &p)
Create polynomial from other polynomial. More...

virtual ~PolynomialND ()
Destructor.

std::size_t order () const
Get the order of the polynomial (the highest power). More...

void increaseOrder (std::size_t increase, const Coef &value)
Increase the order of this polynomial. More...

void increaseOrder (std::size_t increase=1)
Increase the order of this polynomial. More...

Coef evaluate (const Scalar &x) const
Evaluate the polynomial using Horner's Method. More...

std::vector< Coef > evaluateDerivatives (const Scalar &x, std::size_t n=1) const
Evaluate the first n derivatives of the polynomial using Horner's Method. More...

PolynomialND< Coef, Scalar > deflate (const Scalar &x) const
Perform deflation of polynomial. More...

PolynomialND< Coef, Scalar > derivative (std::size_t n=1) const
Get the derivative polynomial. More...

const PolynomialND< Coef, Scalar > operator- () const
Negate coefficients. More...

bool operator== (const PolynomialND< Coef, Scalar > &b) const
Check if polynomials are equal. More...

Coefficient access operators.

Operators used to access coefficients.

const Coef & operator() (std::size_t i) const
Get specific coefficient. More...

Coef & operator() (size_t i)
Get specific coefficient. More...

const Coef & operator[] (size_t i) const
Get specific coefficient. More...

Coef & operator[] (size_t i)
Get specific coefficient. More...

Arithmetic operators between polynomials.

Operators used to do arithmetic between two polynomials.

const PolynomialND< Coef, Scalar > operator- (const PolynomialND< Coef, Scalar > &b) const
Polynomial subtraction. More...

PolynomialND< Coef, Scalar > & operator-= (const PolynomialND< Coef, Scalar > &b)
Polynomial subtraction. More...

const PolynomialND< Coef, Scalar > operator+ (const PolynomialND< Coef, Scalar > &b) const
Polynomial addition. More...

PolynomialND< Coef, Scalar > & operator+= (const PolynomialND< Coef, Scalar > &b)
Polynomial addition. More...

template<typename OutCoef , typename Coef2 = Coef>
PolynomialND< OutCoef, Scalar > multiply (const PolynomialND< Coef2, Scalar > &b) const
Polynomial multiplication. More...

template<typename OutCoef , typename Coef2 = Coef>
PolynomialND< OutCoef, Scalar > multiply (const Coef2 &b) const
Multiply with a coefficient. More...

void operator= (const PolynomialND< Coef, Scalar > &b)
Assignment. More...

## Protected Attributes

std::vector< Coef > _coef
The coefficient vector.

## Friends

std::ostream & operator<< (std::ostream &out, const PolynomialND< Coef, Scalar > &p)
Printing polynomial to stream. More...

## Arithmetic operators between polynomial and scalars.

Operators used to do arithmetic with scalars.

const PolynomialND< Coef, Scalar > operator* (Scalar s) const
Scalar multiplication. More...

const PolynomialND< Coef, Scalar > operator/ (Scalar s) const
Scalar division. More...

PolynomialND< Coef, Scalar > & operator*= (Scalar s)
Scalar multiplication. More...

PolynomialND< Coef, Scalar > & operator/= (Scalar s)
Scalar division. More...

const PolynomialND< Coef, Scalar > operator* (Scalar s, const PolynomialND< Coef, Scalar > &p)
Scalar multiplication. More...

## Detailed Description

### template<typename Coef, typename Scalar = double> class rw::math::PolynomialND< Coef, Scalar >

Representation of a polynomial that can have non-scalar coefficients (polynomial matrix).

Representation of a polynomial of the following form:

$$f(x) = C_n x^n + C_(n-1) x^(n-1) + C_2 x^2 + C_1 x + C_0$$

The polynomial is represented as a list of coefficients ordered from lowest-order term to highest-order term, $${c_0,c_1,...,c_n}$$.

## ◆ PolynomialND() [1/3]

 PolynomialND ( std::size_t order )
inlineexplicit

Create polynomial with uninitialized coefficients.

Parameters
 order [in] the order of the polynomial.

## ◆ PolynomialND() [2/3]

 PolynomialND ( const std::vector< Coef > & coefficients )
inline

Create polynomial from vector.

Parameters
 coefficients [in] the coefficients ordered from lowest-order term to highest-order term.

## ◆ PolynomialND() [3/3]

 PolynomialND ( const PolynomialND< Coef, Scalar > & p )
inline

Create polynomial from other polynomial.

Parameters
 p [in] the polynomial to copy.

## ◆ deflate()

 PolynomialND deflate ( const Scalar & x ) const
inline

Perform deflation of polynomial.

Parameters
 x [in] a root of the polynomial.
Returns
a new polynomial of same order minus one.
Note
There is no check that the given root is in fact a root of the polynomial.

## ◆ derivative()

 PolynomialND derivative ( std::size_t n = 1 ) const
inline

Get the derivative polynomial.

Parameters
 n [in] gives the n'th derivative (default is n=1).
Returns
a new polynomial of same order minus one.
Note
To evaluate derivatives use the evaluate derivative method which is more precise.

## ◆ evaluate()

 Coef evaluate ( const Scalar & x ) const
inline

Evaluate the polynomial using Horner's Method.

Parameters
 x [in] the input parameter.
Returns
the value $$f(x)$$.

## ◆ evaluateDerivatives()

 std::vector evaluateDerivatives ( const Scalar & x, std::size_t n = 1 ) const
inline

Evaluate the first n derivatives of the polynomial using Horner's Method.

Parameters
 x [in] the input parameter. n [in] the number of derivatives to find (default is the first derivative only)
Returns
a vector of values $${f(x),\dot{f}(x),\ddot{f}(x),\cdots}$$.

## ◆ increaseOrder() [1/2]

 void increaseOrder ( std::size_t increase, const Coef & value )
inline

Increase the order of this polynomial.

Parameters
 increase [in] how much to increase the order (default is 1). value [in] initialize new coefficients to this value.

## ◆ increaseOrder() [2/2]

 void increaseOrder ( std::size_t increase = 1 )
inline

Increase the order of this polynomial.

Parameters
 increase [in] how much to increase the order (default is 1).
See also
increaseOrder(std::size_t,const Coef&) for a version that initializes the new coefficients to a certain value.

## ◆ multiply() [1/2]

 PolynomialND multiply ( const Coef2 & b ) const
inline

Multiply with a coefficient.

Each coefficient is post-multiplied with the given coefficient.

Parameters
 b [in] coefficient to multiply with. Post-multiplication is used - the dimensions must match.
Returns
new polynomial after multiplication.

## ◆ multiply() [2/2]

 PolynomialND multiply ( const PolynomialND< Coef2, Scalar > & b ) const
inline

Polynomial multiplication.

A convolution of the coefficients is used. Notice that more efficient algorithms exist for polynomials with scalar coefficients.

Parameters
 b [in] polynomial to multiply. Post-multiplication is used - the dimensions must match.
Returns
new polynomial after multiplication.

## ◆ operator()() [1/2]

 Coef& operator() ( size_t i )
inline

Get specific coefficient.

Parameters
 i [in] the power of the term to get coefficient for.
Returns
the coefficient.

## ◆ operator()() [2/2]

 const Coef& operator() ( std::size_t i ) const
inline

Get specific coefficient.

Parameters
 i [in] the power of the term to get coefficient for.
Returns
the coefficient.

## ◆ operator*()

 const PolynomialND operator* ( Scalar s ) const
inline

Scalar multiplication.

Parameters
 s [in] scalar to multiply with.
Returns
new polynomial after multiplication.

## ◆ operator*=()

 PolynomialND& operator*= ( Scalar s )
inline

Scalar multiplication.

Parameters
 s [in] the scalar to multiply with.
Returns
reference to same polynomial with changed coefficients.

## ◆ operator+()

 const PolynomialND operator+ ( const PolynomialND< Coef, Scalar > & b ) const
inline

Polynomial addition.

Parameters
 b [in] polynomial to add.
Returns
new polynomial after addition.

## ◆ operator+=()

 PolynomialND& operator+= ( const PolynomialND< Coef, Scalar > & b )
inline

Polynomial addition.

Parameters
 b [in] polynomial to add.
Returns
same polynomial with different coefficients after addition.

## ◆ operator-() [1/2]

 const PolynomialND operator- ( ) const
inline

Negate coefficients.

Returns
new polynomial with coefficients negated.

## ◆ operator-() [2/2]

 const PolynomialND operator- ( const PolynomialND< Coef, Scalar > & b ) const
inline

Polynomial subtraction.

Parameters
 b [in] polynomial of to subtract.
Returns
new polynomial after subtraction.

## ◆ operator-=()

 PolynomialND& operator-= ( const PolynomialND< Coef, Scalar > & b )
inline

Polynomial subtraction.

Parameters
 b [in] polynomial to subtract.
Returns
same polynomial with different coefficients after subtraction.

## ◆ operator/()

 const PolynomialND operator/ ( Scalar s ) const
inline

Scalar division.

Parameters
 s [in] scalar to divide with.
Returns
new polynomial after division.

## ◆ operator/=()

 PolynomialND& operator/= ( Scalar s )
inline

Scalar division.

Parameters
 s [in] the scalar to divide with.
Returns
reference to same polynomial with changed coefficients.

## ◆ operator=()

 void operator= ( const PolynomialND< Coef, Scalar > & b )
inline

Assignment.

Parameters
 b [in] the polynomial to take coefficients from.

## ◆ operator==()

 bool operator== ( const PolynomialND< Coef, Scalar > & b ) const
inline

Check if polynomials are equal.

Parameters
 b [in] the polynomial to compare with.
Returns
true if equal, false if not.

## ◆ operator[]() [1/2]

 Coef& operator[] ( size_t i )
inline

Get specific coefficient.

Parameters
 i [in] the power of the term to get coefficient for.
Returns
the coefficient.

## ◆ operator[]() [2/2]

 const Coef& operator[] ( size_t i ) const
inline

Get specific coefficient.

Parameters
 i [in] the power of the term to get coefficient for.
Returns
the coefficient.

## ◆ order()

 std::size_t order ( ) const
inline

Get the order of the polynomial (the highest power).

Returns
the order.

## ◆ operator*

 const PolynomialND operator* ( Scalar s, const PolynomialND< Coef, Scalar > & p )
friend

Scalar multiplication.

Parameters
 s [in] scalar to multiply with. p [in] polynomial to multiply with.
Returns
new polynomial after multiplication.

## ◆ operator<<

 std::ostream& operator<< ( std::ostream & out, const PolynomialND< Coef, Scalar > & p )
friend

Printing polynomial to stream.

Parameters
 out [in/out] the stream to write to. p [in] the polynomail to print.
Returns
the same ostream as out parameter.

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