When CompoundFunction is evaluated, the result is the sum of
all the individual function values.
Note that any Function object (including another Compound object) can be
part of a compound object.
Give name of function
Return the number of functions in the sum.
Prerequisite
Synopsis
This class takes an arbitrary number of Function objects, and generates
a new, single function object. The parameters of the compound object
are the union of all the parameters in the input objects.
Example
Suppose for some reason we wanted the sum of x^2 plus a gaussian.
We could form it as follows:
Polynomial<Float> x2(2);
x[2] = 1.0; // x^2
Gaussian1D<Float> gauss(1.0, 0.0, 1.0); // e^{-x^2}
CompoundParam<Float> sum; // sum == 0.0
sum.addFunction(x2); // sum == x^2
sum.addFunction(gauss); // sum == x^2+e^{-x^2}
sum(2.0); // == 4 + e^-4
CompoundParam[0] = 2.0; // sum ==2x^2+e^{-x^2}
sum(2.0); // == 8 + e^-4
// Set the height of the gaussian
sum[parameterOffset[1] + Gaussian1D<Float>::HEIGHT] = 2.5;
Template Type Argument Requirements (T)
Thrown Exceptions
Motivation
This class was created to allow a non-linear least squares fitter to fit a
(potentially) arbitrary number of functions (typically gaussians).
To Do
Member Description
CompoundParam()
The default constructor -- no functions, no parameters, nothing, the
function operator returns a 0.
CompoundParam(const CompoundParam<T> &other)
Make this object a (deep) copy of other.
CompoundParam(const CompoundParam<T> &other, Bool) : other<T>(other), ndim_p(other.ndim_p), functionPtr_p(other.functionPtr_p.nelements()), paroff_p(other.paroff_p.nelements()), funpar_p(other.funpar_p.nelements()), locpar_p(other.locpar_p.nelements())
template <class W> CompoundParam(const CompoundParam<W> &other) : Function<T>(other), ndim_p(other.ndim()), functionPtr_p(other.nFunctions()), paroff_p(other.nFunctions()), funpar_p(other.nparameters()), locpar_p(other.nparameters())
template <class W> CompoundParam(const CompoundParam<W> &other, Bool) : Function<T>(other), ndim_p(other.ndim()), functionPtr_p(other.nFunctions()), paroff_p(other.nFunctions()), funpar_p(other.nparameters()), locpar_p(other.nparameters())
CompoundParam<T> &operator=(const CompoundParam<T> &other)
virtual ~CompoundParam()
virtual const String &name() const
uInt addFunction(const Function<T> &newFunction)
Add a function to the sum. All functions must have the same
ndim() as the first one. Returns the (zero relative) number
of the function just added.
uInt nFunctions() const
const Function<T> &function(uInt which) const
Return a reference to a specific Function.
const uInt parameterOffset(uInt which) const
Get the offset in function parameterlist for function which
const uInt parameterFunction(uInt which) const
Get the function number belonging to parameter list element which
const uInt parameterLocation(uInt which) const
Return locpar
virtual uInt ndim() const
Returns the dimension of functions in the linear combination