Polynomial.h

Classes

Polynomial -- A one dimensional polynomial class (full description)
Polynomial_PS -- Partial specialization of Polynomial for AutoDiff (full description)

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

Interface

Public Members
Polynomial() : PolynomialParam<T>()
explicit Polynomial(uInt order) : order<T>(order)
Polynomial(const Polynomial<T> &other) : other<T>(other)
template <class W> Polynomial(const Polynomial<W> &other) : PolynomialParam<T>(other)
Polynomial<T> &operator=(const Polynomial<T> &other)
virtual ~Polynomial()
virtual T eval(typename Function1D<T>::FunctionArg x) const
Polynomial<T> derivative() const
virtual Function<T> *clone() const
virtual Function<typename FunctionTraits<T>::DiffType> *cloneAD() const
virtual Function<typename FunctionTraits<T>::BaseType> *cloneNonAD() const

Description

Prerequisite

Synopsis

A Polynomial contains a set of coefficients; its fundamental operations is evaluating itself at some "x". The number of coefficients is the order of the polynomial plus one, so is the number of available parameters.

Tip The present implementation merely stores the coefficients in a Block. In the unlikely case that we need to deal with polynomials with many zero coefficients, a more efficient representation would be possible.

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

Polynomial() : PolynomialParam<T>()

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

explicit Polynomial(uInt order) : order<T>(order)

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

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

Copy constructor/assignment (deep copy)

virtual ~Polynomial()

Destructor

virtual T eval(typename Function1D<T>::FunctionArg x) const

Evaluate the polynomial at x.

Polynomial<T> derivative() const

Return the polynomial which is the derivative of this one. e.g., 2+4x+5x^2 --> 0+4+10x .

virtual Function<T> *clone() const
virtual Function<typename FunctionTraits<T>::DiffType> *cloneAD() const
virtual Function<typename FunctionTraits<T>::BaseType> *cloneNonAD() const

Return a copy of this object from the heap. The caller is responsible for deleting the pointer.


template <class T> class Polynomial_PS<AutoDiff<T> > : public PolynomialParam<AutoDiff<T> >

Interface

Polynomial_PS() : PolynomialParam<AutoDiff<T> >()
explicit Polynomial_PS(uInt order) : order<PolynomialParam<T> >(order)
Polynomial_PS(const Polynomial_PS<AutoDiff<T> > &other) : other<AutoDiff<T> >(other)
template <class W> Polynomial_PS(const Polynomial_PS<W> &other) : PolynomialParam<other<T> >(other)
Polynomial_PS<AutoDiff<T> > & operator=(const Polynomial_PS<AutoDiff<T> > &other)
virtual ~Polynomial_PS()
virtual AutoDiff<T> eval(typename Function<AutoDiff<T> >::FunctionArg x) const
virtual Function<AutoDiff<T> > *clone() const
virtual Function<typename FunctionTraits<Traits<T> >::DiffType> *cloneAD() const
virtual Function<typename FunctionTraits<Traits<T> >::BaseType> *cloneNonAD() const

Description

Synopsis

Warning The name Polynomial_PS is only for cxx2html documentation problems. Use Polynomial in your code.

Member Description

Polynomial_PS() : PolynomialParam<AutoDiff<T> >()
explicit Polynomial_PS(uInt order) : order<PolynomialParam<T> >(order)

Constructs one dimensional Polynomials.

Polynomial_PS(const Polynomial_PS<AutoDiff<T> > &other) : other<AutoDiff<T> >(other)
template <class W> Polynomial_PS(const Polynomial_PS<W> &other) : PolynomialParam<other<T> >(other)

Copy constructor (deep copy)

Polynomial_PS<AutoDiff<T> > & operator=(const Polynomial_PS<AutoDiff<T> > &other)

Copy assignment (deep copy)

virtual ~Polynomial_PS()

Destructor

virtual AutoDiff<T> eval(typename Function<AutoDiff<T> >::FunctionArg x) const

Evaluate the polynomial and its derivatives at x wrt to the coefficients.

virtual Function<AutoDiff<T> > *clone() const
virtual Function<typename FunctionTraits<Traits<T> >::DiffType> *cloneAD() const
virtual Function<typename FunctionTraits<Traits<T> >::BaseType> *cloneNonAD() const

Return a copy of this object from the heap. The caller is responsible for deleting this pointer.