casa
$Rev:20696$
|
Sum of a collection of Functions which behaves as one Function object. More...
#include <CompoundFunction.h>
Public Member Functions | |
CompoundFunction () | |
The default constructor -- no functions, no parameters, nothing, the function operator returns a 0. | |
CompoundFunction (const CompoundFunction< T > &other) | |
Make this object a (deep) copy of other. | |
CompoundFunction (const CompoundFunction< T > &other, Bool) | |
template<class W > | |
CompoundFunction (const CompoundFunction< W > &other) | |
template<class W > | |
CompoundFunction (const CompoundFunction< W > &other, Bool) | |
CompoundFunction< T > & | operator= (const CompoundFunction< T > &other) |
Make this object a (deep) copy of other. | |
virtual | ~CompoundFunction () |
Destructor. | |
virtual T | eval (typename Function< T >::FunctionArg x) const |
Evaluate the function at x . | |
CompoundFunction< T > & | consolidate () |
Consolidate the parameter settings. | |
virtual Function< T > * | clone () const |
Return a copy of this object from the heap. | |
virtual Function< typename FunctionTraits< T >::DiffType > * | cloneAD () const |
virtual Function< typename FunctionTraits< T >::BaseType > * | cloneNonAD () const |
Private Member Functions | |
void | fromParam_p () const |
void | toParam_p () |
Make the general block from local parameters. |
Sum of a collection of Functions which behaves as one Function object.
Public interface
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.
When CompoundFunction is evaluated, the result is the sum of all the individual function values.
Member functions are added with the addFunction()
method.
In general the interaction with the function parameters should be through the overall function parameters (i.e. through the parameters of the CompoundFunction
). If for any reason you want to set the parameters of an individual function (see e.g. the example in the Fit2D ), call consolidate()
before abd after the actual setting.
Tip: Check CombiFunction class for a simple linear combination of function objects
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
This class was created to allow a non-linear least squares fitter to fit a (potentially) arbitrary number of functions (typically Gaussians).
Definition at line 114 of file CompoundFunction.h.
casa::CompoundFunction< T >::CompoundFunction | ( | ) | [inline] |
The default constructor -- no functions, no parameters, nothing, the function operator returns a 0.
Definition at line 120 of file CompoundFunction.h.
casa::CompoundFunction< T >::CompoundFunction | ( | const CompoundFunction< T > & | other | ) | [inline] |
Make this object a (deep) copy of other.
If parameters have been set without an intervening calculation, a consolidate()
could be necessary on other first.
Definition at line 125 of file CompoundFunction.h.
casa::CompoundFunction< T >::CompoundFunction | ( | const CompoundFunction< T > & | other, |
Bool | |||
) | [inline] |
Definition at line 127 of file CompoundFunction.h.
casa::CompoundFunction< T >::CompoundFunction | ( | const CompoundFunction< W > & | other | ) | [inline] |
Definition at line 130 of file CompoundFunction.h.
casa::CompoundFunction< T >::CompoundFunction | ( | const CompoundFunction< W > & | other, |
Bool | |||
) | [inline] |
Definition at line 133 of file CompoundFunction.h.
virtual casa::CompoundFunction< T >::~CompoundFunction | ( | ) | [inline, virtual] |
Destructor.
Definition at line 142 of file CompoundFunction.h.
virtual Function<T>* casa::CompoundFunction< T >::clone | ( | ) | const [inline, virtual] |
Return a copy of this object from the heap.
The caller is responsible for deleting the pointer.
Implements casa::Function< T >.
Definition at line 158 of file CompoundFunction.h.
virtual Function<typename FunctionTraits<T>::DiffType>* casa::CompoundFunction< T >::cloneAD | ( | ) | const [inline, virtual] |
Reimplemented from casa::Function< T >.
Definition at line 160 of file CompoundFunction.h.
virtual Function<typename FunctionTraits<T>::BaseType>* casa::CompoundFunction< T >::cloneNonAD | ( | ) | const [inline, virtual] |
Reimplemented from casa::Function< T >.
Definition at line 162 of file CompoundFunction.h.
CompoundFunction<T>& casa::CompoundFunction< T >::consolidate | ( | ) | [inline] |
Consolidate the parameter settings.
This could be necessary if parameters have been set, and a copy constructor called. This is necessary before and after the setting of local parameters; i.e. the parameters of the individual functions.
Definition at line 153 of file CompoundFunction.h.
virtual T casa::CompoundFunction< T >::eval | ( | typename Function< T >::FunctionArg | x | ) | const [virtual] |
Evaluate the function at x
.
void casa::CompoundFunction< T >::fromParam_p | ( | ) | const [private] |
Copy the local parameters from general block
Referenced by casa::CompoundFunction< AutoDiff< Double > >::clone(), casa::CompoundFunction< AutoDiff< Double > >::consolidate(), and casa::CompoundFunction< AutoDiff< Double > >::operator=().
CompoundFunction<T>& casa::CompoundFunction< T >::operator= | ( | const CompoundFunction< T > & | other | ) | [inline] |
Make this object a (deep) copy of other.
Definition at line 137 of file CompoundFunction.h.
Referenced by casa::CompoundFunction< AutoDiff< Double > >::operator=().
void casa::CompoundFunction< T >::toParam_p | ( | ) | [private] |
Make the general block from local parameters.
Referenced by casa::CompoundFunction< AutoDiff< Double > >::consolidate().