ecl::Polynomial< N > Class Template Reference

Representation of a polynomial function of n-th degree. More...

`#include <polynomial.hpp>`

Inheritance diagram for ecl::Polynomial< N >:

## Public Types | |

typedef Array< double, N+1 > | Coefficients |

The coefficient container storage type. | |

## Public Member Functions | |

Coefficients & | coefficients () |

Handle to the coefficient array, use to initialise the polynomial. | |

const Coefficients & | coefficients () const |

Non-modifiable handle to the coefficient array. | |

double | dderivative (const double &x) const |

Access the second derivative directly. | |

Polynomial< N-1 > | derivative () const |

Generates the derivative polynomial. | |

double | derivative (const double &x) const |

Access the derivative directly. | |

double | operator() (const double &x) const |

Access the value of the polynomial at a certain point. | |

Polynomial () | |

Default constructor. | |

template<typename Derived > | |

Polynomial (const BluePrint< Derived > &blueprint) | |

Blueprint constructor. | |

void | shift_horizontal (const double &shift) |

Horizontal shift transform. | |

virtual | ~Polynomial () |

## Private Attributes | |

Coefficients | coeff |

## Friends | |

template<typename OutputStream , unsigned int Degree> | |

OutputStream & | operator<< (OutputStream &ostream, const Polynomial< Degree > &polynomial) |

Streaming output insertion operator for polynomials. |

class ecl::Polynomial< N >

Representation of a polynomial function of n-th degree.

Representation of a polynomial function of n-th order. Use the template parameter to specify the degree of the polynomial. The representation is defined by an array of coefficients which are given in the form a_0 -> a_n where p(x) = a_0 + a_1 x + ....

**Comma Initialisation:**

The polynomial uses a an ecl array (ecl_containers) for storage, so comma initialisation is possible.

// Comma Initialisation Polynomial<5> p; p.coefficients() = 1,2,3,4,5,6; cout << p << endl; // 1.00 + 2.00x + 3.00x^2 + 4.00x^3 + 5.00x^4 + 6.00x^5

**Blueprint Initialisation:**

Lightweight blueprints can also be used to initialise/assign the polynomial:

CubicPolynomial cubic = CubicPolynomial::Interpolation(2.0,0.0,0.0,3.0,1.0,0.0);

**Utility Functions:**

**Template Parameters:**-
N : the degree of the polynomial (i.e. a_0 + ... + a_i x^i + ... + a_N x^N)

**See also:**- Math::Polynomials.

Definition at line 110 of file polynomial.hpp.

template<unsigned int N>

typedef Array<double,N+1> ecl::Polynomial< N >::Coefficients |

The coefficient container storage type.

Definition at line 115 of file polynomial.hpp.

template<unsigned int N>

ecl::Polynomial< N >::Polynomial | ( | ) | ` [inline]` |

Default constructor.

This does not initialise the polynomial, use with the coefficients() accessor with comma initialisation operator to conveniently set the coefficients.

Definition at line 127 of file polynomial.hpp.

template<unsigned int N>

template<typename Derived >

ecl::Polynomial< N >::Polynomial | ( | const BluePrint< Derived > & | blueprint | ) | ` [inline]` |

Blueprint constructor.

Constructor that allows automatic generation from an existing blueprint. This can be used simply in the following manner for any static element belonging to the BluePrintFactory.

CubicPolynomial cubic = CubicPolynomial::Interpolation(2.0,0.0,0.0,3.0,1.0,0.0);

Since this is not explicit, it will also allow assignment.

```
CubicPolynomial cubic; // Alternatively Polynomial<3>
cubic = CubicPolynomial::Interpolation(2.0,0.0,0.0,3.0,1.0,0.0);
```

This will emit a compile time failure if the template argument does not conform to the blueprints concept (refer to ecl_concepts' documentation).

**Parameters:**-
blueprint : the blue print to use to generate this instance.

**See also:**- ecl::BluePrintFactory<LinearFunction>, ecl::BluePrintFactory<CubicPolynomial>, ecl::BluePrintFactory<QuinticPolynomial>.

Definition at line 154 of file polynomial.hpp.

template<unsigned int N>

virtual ecl::Polynomial< N >::~Polynomial | ( | ) | ` [inline, virtual]` |

Definition at line 157 of file polynomial.hpp.

template<unsigned int N>

Coefficients& ecl::Polynomial< N >::coefficients | ( | ) | ` [inline]` |

Handle to the coefficient array, use to initialise the polynomial.

This returns a handle to the coefficient array. Use this with the comma initialiser to conveniently set the polynomial.

```
Polynomial<5> p;
p.coefficients() = 1,2,3,4,5,6;
cout << p << endl; // 1.00 + 2.00x + 3.00x^2 + 4.00x^3 + 5.00x^4 + 6.00x^5
```

**Returns:**- Coefficients& : reference to the co-efficient array.

Definition at line 233 of file polynomial.hpp.

template<unsigned int N>

const Coefficients& ecl::Polynomial< N >::coefficients | ( | ) | const` [inline]` |

Non-modifiable handle to the coefficient array.

**Returns:**- const Coefficients& : non-modifiable reference to the co-efficient array.

Definition at line 239 of file polynomial.hpp.

template<unsigned int N>

double ecl::Polynomial< N >::dderivative | ( | const double & | x | ) | const |

Access the second derivative directly.

Access the values of the second derivative directly.

**Parameters:**-
x : the point at which you wish to calculate the value for.

**Returns:**- double : the value of the second derivative at x.

Definition at line 437 of file polynomial.hpp.

template<unsigned int N>

Polynomial<N-1> ecl::Polynomial< N >::derivative | ( | ) | const` [inline]` |

Generates the derivative polynomial.

Calculates and returns a copy of the derivative polynomial.

**Returns:**- Polynomial<N-1> : the derivative polynomial.

Definition at line 189 of file polynomial.hpp.

template<unsigned int N>

double ecl::Polynomial< N >::derivative | ( | const double & | x | ) | const |

Access the derivative directly.

Access the values of the derivative directly.

**Parameters:**-
x : the point at which you wish to calculate the value for.

**Returns:**- double : the value of the derivative at x.

Definition at line 427 of file polynomial.hpp.

template<unsigned int N>

double ecl::Polynomial< N >::operator() | ( | const double & | x | ) | const |

Access the value of the polynomial at a certain point.

Access the value of the polynomial at a certain point.

**Parameters:**-
x : the point at which you wish to calculate the value for.

**Returns:**- double : the value of the polynomial at x.

Definition at line 416 of file polynomial.hpp.

template<unsigned int N>

void ecl::Polynomial< N >::shift_horizontal | ( | const double & | shift | ) |

Horizontal shift transform.

Shifts the polynomial along the x axis by the specified offset. A negative offset will shift the polynomial to the left, while a positive offset will shit the polynomial to the right.

Polynomial<2> quadratic; // x^2 quadratic.shift(2); // x^2 -> (x-2)^2 (graph shifted right by 2)

**Parameters:**-
shift : the amount of x-shift (-ve -> left, +ve -> right).

Definition at line 396 of file polynomial.hpp.

template<unsigned int N>

template<typename OutputStream , unsigned int Degree>

OutputStream& operator<< | ( | OutputStream & | ostream, |

const Polynomial< Degree > & | polynomial |
||

) | ` [friend]` |

Streaming output insertion operator for polynomials.

Streaming output insertion operator for polynomials.

**Template Parameters:**-
OutputStream : the type of stream being used. Degree : the order of the polynomial being inserted.

**Parameters:**-
ostream : the output stream being used. polynomial : the polynomial

**Returns:**- OutputStream : the output stream.

Definition at line 451 of file polynomial.hpp.

template<unsigned int N>

Coefficients ecl::Polynomial< N >::coeff` [private]` |

Definition at line 267 of file polynomial.hpp.

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