PolynomialParam.h

Classes

PolynomialParam -- Parameter handling for one-dimensional polynomials (full description)

template<class T> class PolynomialParam: public Function1D<T>

Interface

Public Members
PolynomialParam()
explicit PolynomialParam(uInt order)
PolynomialParam(const PolynomialParam<T> &other)
template <class W> PolynomialParam(const PolynomialParam<W> &other) : Function1D<T>(other)
PolynomialParam<T> &operator=(const PolynomialParam<T> &other)
~PolynomialParam()
Bool operator==(const PolynomialParam<T> &other) const
Bool operator!=(const PolynomialParam<T> &other) const
virtual const String &name() const
uInt order() const
T coefficient(uInt which) const
const Vector<T> &coefficients() const
void setCoefficient(uInt which, const T value)
void setCoefficients(const Vector<T> &coefficients)

Description

Prerequisite

Etymology

A 1-dimensional Polynomial's parameters.

Synopsis

A Polynomial is described by a set of coefficients; its fundamental operation is evaluating itself at some "x". The number of coefficients is the order of the polynomial plus one.

Since the Polynomial is a Function, the derivatives can be obtained as well.

The parameter interface (see FunctionParam class), is used to provide an interface to the Fitting classes.

This class is in general used implicitly by the Polynomial class only.

Example

  Polynomial<Float> pf(3);  // Third order polynomial - coeffs 0 by default
  pf.setCoefficient(1, 1.0);
  pf[2] = 2.0;
  pf.setCoefficient(3, 3.0);  // 3x^3 + 2x^2 + x
  pf(2); // == 34

Template Type Argument Requirements (T)

Thrown Exceptions

To Do

Member Description

PolynomialParam()

Constructs a zero'th order polynomial, with a coeficcient of 0.0.

explicit PolynomialParam(uInt order)

Makes a polynomial of the given order, with all coeficcients set to zero.

PolynomialParam(const PolynomialParam<T> &other)
template <class W> PolynomialParam(const PolynomialParam<W> &other) : Function1D<T>(other)
PolynomialParam<T> &operator=(const PolynomialParam<T> &other)

Make this a copy of other (deep copy).

~PolynomialParam()

Destructor

Bool operator==(const PolynomialParam<T> &other) const
Bool operator!=(const PolynomialParam<T> &other) const

Comparisons. Polynomials are equal if they are the same order

virtual const String &name() const

Give name of function

uInt order() const

What is the order of the polynomial, i.e. maximum exponent of "x".

T coefficient(uInt which) const

What is the which'th coefficient of the polynomial. For an nth degree polynomial, which varies between zero and n.

const Vector<T> &coefficients() const

Return all the coefficients as a vector.

void setCoefficient(uInt which, const T value)

Set the which'th coefficient to value.

void setCoefficients(const Vector<T> &coefficients)

Set all the coefficients at once, throw away all existing coefficients.