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.
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.
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<T> &operator=(const CompoundParam<T> &other)
virtual ~CompoundParam()
uInt addFunction(const Function<T> &newFunction)
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
virtual uInt ndim() const
Returns the dimension of functions in the linear combination