Polynomials

# Introduction

This group includes various structures and tools for polynomials.

Include the following at the top of any translation unit that uses geometry functions or classes.

#include <ecl/geometry.hpp>
// The classes
// Typedefs to Polynomial<>

You will also need to link to -lecl_geometry.

# Usage

## Polynomial

Polynomials are embedded in the usual c++ wrapper. Coefficient storage is based on the array class in ecl_containers, so comma initialisation can be used to configure the polynomial appropriately.

// 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

There is also a method for shifting the polynomial on the horizontal axis (later, if there is a need a vertical shift will be added).

## Typedefs

Rather than specifying the degree of the polynomial with a template argument, a few more convenient typedefs are available:

typedef Polynomial<1> LinearFunction;
typedef Polynomial<3> CubicPolynomial;
typedef Polynomial<5> QuinticPolynomial;

## BluePrints

There are also some blueprints for generating polynomials that interpolate between two end points. These can be accessed via static methods that are inherited by the polynomial's class. For example:

LinearFunction linear = LinearFunction::Interpolation(0.0,0.0,1.0,2.0); // x_i, y_i, x_f, y_f
LinearFunction linear = LinearFunction::PointSlopeForm(1.0,2.0,2.0); // x_f, y_f, slope
cubic = CubicPolynomial::DerivativeInterpolation(2.0,0.0,0.0,3.0,1.0,0.0); // x_i, y_i, y'_i, x_f, y_f, y'_f
cubic = CubicPolynomial::SecondDerivativeInterpolation(2.0,0.0,0.0,3.0,1.0,0.0); // x_i, y_i, y''_i, x_f, y_f, y''_f
QuinticPolynomial quintic = QuinticPolynomial::Interpolation(0.0,0.0,0.0,0.0,1.0,2.0,1.0,0.0); // x_i, y_i, y'_i, y''_i, x_f, y_f, y'_f, y''_f
• ecl::CubicPolynomial::DerivativeInterpolation

## Pascal's Triangle

Pascal's triangle is used to calculate the coefficients for polynomial expansion. The class here accepts a template parameter N and calculates all the coefficients up to order N (i.e. for polynomial expansion up to (x+y)^N).

You can stream the output directly if you just need to view them or you can use an stl style iterator to traverse the rows diagonally. Simply call the usual begin function with an integer argument representing the diagonal you're interested in. The first iterator will traverse from the top of the triangle to the bottom right. As you increase the index the diagonals shift down and to the left.

There may be a future addition to allow horizontal row representations. Also note, specialised (low N) versions of these exist that directly set coefficients so as to avoid expensive calculations.

PascalsTriangle<5> pascals_triangle;
cout << pascals_triangle << endl;
cout << "Row iteration : ";
PascalsTriangle<5>::const_iterator row_iter;
for (row_iter = pascals_triangle.begin(2); row_iter != pascals_triangle.end(2); ++row_iter) {
cout << *row_iter << " ";
}
cout << endl;

# Polynomial Functions

There also exist various functions that operate on polynomials. These currently include:

They can also be called from the function classes themselves if it is preferred, e.g.

double maximum = ecl::Maximum<CubicPolynomial>()(0.0, 0.2, p);

OR

double maximum = ecl::CubicPolynomial::Maximum(0.0, 0.2, p);

# ChangeLog

ecl::PascalsTriangle
Holds the coefficients for pascal's triangle up to row N.
Definition: pascals_triangle.hpp:63
ecl::LinearFunction
Polynomial< 1 > LinearFunction
Mathematical term for 1st order polynomials.
Definition: polynomial.hpp:393
Mathematical term for 2nd order polynomials.
Definition: polynomial.hpp:394
ecl::Minimum
Primary template functor for the minimum of a continuous function.
Definition: function_math.hpp:86
ecl::Maximum< CubicPolynomial >
Mathematical maximum on a compact interval for cubic polynomials.
Definition: polynomial.hpp:1020
ecl::Maximum
Primary template functor for the maximum of a continuous function.
Definition: function_math.hpp:66
geometry.hpp
Mathematical tools for geometry.
ecl::Polynomial
Representation of a polynomial function of n-th degree.
Definition: polynomial.hpp:50
ecl::QuinticPolynomial
Polynomial< 5 > QuinticPolynomial
Mathematical term for 5th order polynomials.
Definition: polynomial.hpp:396
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