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. | |
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. |
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:
N | : the degree of the polynomial (i.e. a_0 + ... + a_i x^i + ... + a_N x^N) |
Definition at line 81 of file polynomial.hpp.
typedef Array<double,N+1> ecl::Polynomial< N >::Coefficients |
The coefficient container storage type.
Definition at line 86 of file polynomial.hpp.
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 98 of file polynomial.hpp.
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).
blueprint | : the blue print to use to generate this instance. |
Definition at line 125 of file polynomial.hpp.
virtual ecl::Polynomial< N >::~Polynomial | ( | ) | [inline, virtual] |
Definition at line 128 of file polynomial.hpp.
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
Definition at line 204 of file polynomial.hpp.
const Coefficients& ecl::Polynomial< N >::coefficients | ( | ) | const [inline] |
Non-modifiable handle to the coefficient array.
Definition at line 210 of file polynomial.hpp.
double ecl::Polynomial< N >::dderivative | ( | const double & | x | ) | const |
Access the second derivative directly.
Access the values of the second derivative directly.
x | : the point at which you wish to calculate the value for. |
Definition at line 408 of file polynomial.hpp.
Polynomial<N-1> ecl::Polynomial< N >::derivative | ( | ) | const [inline] |
Generates the derivative polynomial.
Calculates and returns a copy of the derivative polynomial.
Definition at line 160 of file polynomial.hpp.
double ecl::Polynomial< N >::derivative | ( | const double & | x | ) | const |
Access the derivative directly.
Access the values of the derivative directly.
x | : the point at which you wish to calculate the value for. |
Definition at line 398 of file polynomial.hpp.
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.
x | : the point at which you wish to calculate the value for. |
Definition at line 387 of file polynomial.hpp.
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)
shift | : the amount of x-shift (-ve -> left, +ve -> right). |
Definition at line 367 of file polynomial.hpp.
OutputStream& operator<< | ( | OutputStream & | ostream, |
const Polynomial< Degree > & | polynomial | ||
) | [friend] |
Streaming output insertion operator for polynomials.
Streaming output insertion operator for polynomials.
OutputStream | : the type of stream being used. |
Degree | : the order of the polynomial being inserted. |
ostream | : the output stream being used. |
polynomial | : the polynomial |
Definition at line 422 of file polynomial.hpp.
Coefficients ecl::Polynomial< N >::coeff [private] |
Definition at line 238 of file polynomial.hpp.