CombiFunction.h

Classes

CombiFunction -- Form a linear combination of function objects. (full description)
CombiFunction_PS -- Partial specialization of CombiFunction for AutoDiff (full description)

template <class T> class CombiFunction : public CombiParam<T>

Interface

Public Members
CombiFunction() : CombiParam<T>()
CombiFunction(const CombiFunction<T> &other) : other<T>(other)
CombiFunction(const CombiFunction<T> &other, Bool) : other<T>(other, True)
template <class W> CombiFunction(const CombiFunction<W> &other) : CombiParam<T>(other)
template <class W> CombiFunction(const CombiFunction<W> &other, Bool) : CombiParam<T>(other, True)
CombiFunction<T> &operator=(const CombiFunction<T> &other)
virtual ~CombiFunction()
virtual T eval(typename Function<T>::FunctionArg x) const
virtual Function<T> *clone() const
virtual Function<typename FunctionTraits<T>::DiffType> *cloneAD() const
virtual Function<typename FunctionTraits<T>::BaseType> *cloneNonAD() const

Description

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25
Programs:
Tests:

Prerequisite

Synopsis

Given N function objects, the class describes a linear combination of the form:
    f(x) = a(0)*f(0)(x) + a(1)*f(1)(x) + ... + a(N-1)*f(N-1)(x)
    
where a = {a(n)} are parameters. If the combi function is used in a functional fitting process (see LinearFit) these parameters canm be solved for. In all aspects they behave as FunctionParam values.

Member functions are added with the addFunction() method.

Tip Check CompoundFunction class for a combination of functions behaving as one object.

Example

In the following example a second order polynomial is built from 3 separate polynomials.
    Polynomial<Double> constant(0); 
    Polynomial<Double> linear(1); 
    Polynomial<Double> square(2);
    
    constant.setCoefficient(0, 1.0);   // 1
    linear.setCoefficient(1, 1.0);     // x
    square[2] = 1.0;     // x^2
    
    CombiFunction<Double> combination;
    
    // form function, e0 + e1*x + e2*x^2
    combination.addFunction(constant);
    combination.addFunction(linear);
    combination.addFunction(square);
    

Template Type Argument Requirements (T)

Thrown Exceptions

Motivation

This class was created to allow specialization of the evaluation in a simple way.

To Do

Member Description

CombiFunction() : CombiParam<T>()

The default constructor -- no functions, no parameters, nothing, the function operator returns a 0.

CombiFunction(const CombiFunction<T> &other) : other<T>(other)
CombiFunction(const CombiFunction<T> &other, Bool) : other<T>(other, True)
template <class W> CombiFunction(const CombiFunction<W> &other) : CombiParam<T>(other)
template <class W> CombiFunction(const CombiFunction<W> &other, Bool) : CombiParam<T>(other, True)

Make this object a (deep) copy of other.

CombiFunction<T> &operator=(const CombiFunction<T> &other)

Make this object a (deep) copy of other.

virtual ~CombiFunction()

Destructor

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

Evaluate the function at x.

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 CombiFunction_PS<AutoDiff<T> > :public CombiParam<AutoDiff<T> >

Interface

CombiFunction_PS() : CombiParam<AutoDiff<T> >()
CombiFunction_PS(const CombiFunction_PS<AutoDiff<T> > &other) : other<AutoDiff<T> >(other)
template <class W> CombiFunction_PS(const CombiFunction_PS<W> &other) : CombiParam<other<T> >(other)
CombiFunction_PS<AutoDiff<T> > & operator=(const CombiFunction_PS<AutoDiff<T> > &other)
virtual ~CombiFunction_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 CombiFunction_PS is only for cxx2html documentation problems. Use CombiFunction in your code.

Member Description

CombiFunction_PS() : CombiParam<AutoDiff<T> >()

The default constructor -- no functions, no parameters, nothing, the function operator returns a 0.

CombiFunction_PS(const CombiFunction_PS<AutoDiff<T> > &other) : other<AutoDiff<T> >(other)
template <class W> CombiFunction_PS(const CombiFunction_PS<W> &other) : CombiParam<other<T> >(other)

Make this object a (deep) copy of other.

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

Make this object a (deep) copy of other.

virtual ~CombiFunction_PS()

Destructor

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

Evaluate the function 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 the pointer.