Public Types | Public Member Functions | Private Attributes | Friends | List of all members
ecl::Polynomial< N > Class Template Reference

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

#include <polynomial.hpp>

Public Types

typedef Array< double, N+1 > Coefficients
 The coefficient container storage type. More...
 

Public Member Functions

Coefficientscoefficients ()
 Handle to the coefficient array, use to initialise the polynomial. More...
 
const Coefficientscoefficients () const
 Non-modifiable handle to the coefficient array. More...
 
double dderivative (const double &x) const
 Access the second derivative directly. More...
 
Polynomial< N-1 > derivative () const
 Generates the derivative polynomial. More...
 
double derivative (const double &x) const
 Access the derivative directly. More...
 
double operator() (const double &x) const
 Access the value of the polynomial at a certain point. More...
 
 Polynomial ()
 Default constructor. More...
 
template<typename Derived >
 Polynomial (const BluePrint< Derived > &blueprint)
 Blueprint constructor. More...
 
void shift_horizontal (const double &shift)
 Horizontal shift transform. More...
 
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. More...
 

Detailed Description

template<unsigned int N>
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 50 of file polynomial.hpp.

Member Typedef Documentation

◆ Coefficients

template<unsigned int N>
typedef Array<double,N+1> ecl::Polynomial< N >::Coefficients

The coefficient container storage type.

Definition at line 123 of file polynomial.hpp.

Constructor & Destructor Documentation

◆ Polynomial() [1/2]

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 135 of file polynomial.hpp.

◆ Polynomial() [2/2]

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 162 of file polynomial.hpp.

◆ ~Polynomial()

template<unsigned int N>
virtual ecl::Polynomial< N >::~Polynomial ( )
inlinevirtual

Definition at line 165 of file polynomial.hpp.

Member Function Documentation

◆ coefficients() [1/2]

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 241 of file polynomial.hpp.

◆ coefficients() [2/2]

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 247 of file polynomial.hpp.

◆ dderivative()

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 443 of file polynomial.hpp.

◆ derivative() [1/2]

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 197 of file polynomial.hpp.

◆ derivative() [2/2]

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 433 of file polynomial.hpp.

◆ operator()()

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 422 of file polynomial.hpp.

◆ shift_horizontal()

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 402 of file polynomial.hpp.

Friends And Related Function Documentation

◆ operator<<

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 457 of file polynomial.hpp.

Member Data Documentation

◆ coeff

template<unsigned int N>
Coefficients ecl::Polynomial< N >::coeff
private

Definition at line 275 of file polynomial.hpp.


The documentation for this class was generated from the following file:
ecl::CubicPolynomial
Polynomial< 3 > CubicPolynomial
Mathematical term for 3rd order polynomials.
Definition: polynomial.hpp:395


ecl_geometry
Author(s): Daniel Stonier
autogenerated on Sun Aug 2 2020 03:12:16