casacore
|
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. More... | |
CompoundFunction (const CompoundFunction< T > &other) | |
Make this object a (deep) copy of other. More... | |
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. More... | |
virtual | ~CompoundFunction () |
Destructor. More... | |
virtual T | eval (typename Function< T >::FunctionArg x) const |
Evaluate the function at x . More... | |
CompoundFunction< T > & | consolidate () |
Consolidate the parameter settings. More... | |
virtual Function< T > * | clone () const |
Return a copy of this object from the heap. More... | |
virtual Function< typename FunctionTraits< T >::DiffType > * | cloneAD () const |
virtual Function< typename FunctionTraits< T >::BaseType > * | cloneNonAD () const |
Public Member Functions inherited from casacore::CompoundParam< T > | |
CompoundParam () | |
The default constructor – no functions, no parameters, nothing, the function operator returns a 0. More... | |
CompoundParam (const CompoundParam< T > &other) | |
Make this object a (deep) copy of other. More... | |
CompoundParam (const CompoundParam< T > &other, Bool) | |
template<class W > | |
CompoundParam (const CompoundParam< W > &other) | |
template<class W > | |
CompoundParam (const CompoundParam< W > &other, Bool) | |
CompoundParam< T > & | operator= (const CompoundParam< T > &other) |
virtual | ~CompoundParam () |
virtual const String & | name () const |
Give name of function. More... | |
uInt | addFunction (const Function< T > &newFunction) |
Add a function to the sum. More... | |
uInt | nFunctions () const |
Return the number of functions in the sum. More... | |
const Function< T > & | function (uInt which) const |
Return a reference to a specific Function. More... | |
uInt | parameterOffset (uInt which) const |
Get the offset in function parameterlist for function which. More... | |
uInt | parameterFunction (uInt which) const |
Get the function number belonging to parameter list element which. More... | |
uInt | parameterLocation (uInt which) const |
Return locpar. More... | |
virtual uInt | ndim () const |
Returns the dimension of functions in the linear combination. More... | |
Public Member Functions inherited from casacore::Function< T > | |
Function () | |
Constructors. More... | |
Function (const uInt n) | |
Function (const Vector< T > &in) | |
Function (const FunctionParam< T > &other) | |
Function (const Function< W, X > &other) | |
virtual | ~Function () |
Destructor. More... | |
uInt | nparameters () const |
Returns the number of parameters. More... | |
virtual U | eval (FunctionArg x) const =0 |
Evaluate the function object. More... | |
T & | operator[] (const uInt n) |
Manipulate the nth parameter (0-based) with no index check. More... | |
const T & | operator[] (const uInt n) const |
virtual U | operator() () const |
Evaluate this function object at x or at x, y . More... | |
virtual U | operator() (const ArgType &x) const |
virtual U | operator() (const Vector< ArgType > &x) const |
virtual U | operator() (FunctionArg x) const |
virtual U | operator() (const ArgType &x, const ArgType &y) const |
virtual U | operator() (const ArgType &x, const ArgType &y, const ArgType &z) const |
Bool & | mask (const uInt n) |
Manipulate the mask associated with the nth parameter (e.g. More... | |
const Bool & | mask (const uInt n) const |
const FunctionParam< T > & | parameters () const |
Return the parameter interface. More... | |
FunctionParam< T > & | parameters () |
const Vector< ArgType > & | argp () const |
Get arg_p and parset_p . More... | |
Bool | parsetp () const |
void | lockParam () |
Compiler cannot always find the correct 'const' version of parameter access. More... | |
void | unlockParam () |
virtual void | setMode (const RecordInterface &mode) |
get/set the function mode. More... | |
virtual void | getMode (RecordInterface &mode) const |
virtual Bool | hasMode () const |
return True if the implementing function supports a mode. More... | |
ostream & | print (ostream &os) const |
Print the function (i.e. More... | |
Public Member Functions inherited from casacore::Functional< FunctionTraits< T >::ArgType, U > | |
virtual | ~Functional () |
Destructor. More... | |
virtual U | operator() (const FunctionTraits< T >::ArgType &x) const =0 |
Map a Domain x into a Range y value. More... | |
Public Member Functions inherited from casacore::Functional< Vector< FunctionTraits< T >::ArgType >, U > | |
virtual | ~Functional () |
Destructor. More... | |
virtual U | operator() (const Vector< FunctionTraits< T >::ArgType > &x) const =0 |
Map a Domain x into a Range y value. More... | |
Private Member Functions | |
void | fromParam_p () const |
Copy the local parameters from general block. More... | |
void | toParam_p () |
Make the general block from local parameters. More... | |
Additional Inherited Members | |
Public Types inherited from casacore::Function< T > | |
typedef FunctionTraits< T > ::ArgType | ArgType |
typedef const ArgType * | FunctionArg |
Protected Attributes inherited from casacore::CompoundParam< T > | |
PtrBlock< Function< T > * > | functionPtr_p |
Pointer to each added function. More... | |
Block< uInt > | paroff_p |
Index of offset for each function to its parameters in general list. More... | |
Block< uInt > | funpar_p |
Index of function belonging to parameter. More... | |
Block< uInt > | locpar_p |
Index of local parameter. More... | |
Protected Attributes inherited from casacore::Function< T > | |
FunctionParam< T > | param_p |
The parameters and masks. More... | |
Vector< ArgType > | arg_p |
Aid for non-contiguous argument storage. More... | |
Bool | parset_p |
Indicate parameter written. More... | |
Bool | locked_p |
Indicate that parameters are expected to be locked from changing. More... | |
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:
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.
|
inline |
The default constructor – no functions, no parameters, nothing, the function operator returns a 0.
Definition at line 120 of file CompoundFunction.h.
|
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.
|
inline |
Definition at line 127 of file CompoundFunction.h.
|
inline |
Definition at line 130 of file CompoundFunction.h.
|
inline |
Definition at line 133 of file CompoundFunction.h.
|
inlinevirtual |
Destructor.
Definition at line 142 of file CompoundFunction.h.
|
inlinevirtual |
Return a copy of this object from the heap.
The caller is responsible for deleting the pointer.
Implements casacore::Function< T >.
Definition at line 158 of file CompoundFunction.h.
|
inlinevirtual |
Reimplemented from casacore::Function< T >.
Definition at line 160 of file CompoundFunction.h.
|
inlinevirtual |
Reimplemented from casacore::Function< T >.
Definition at line 162 of file CompoundFunction.h.
|
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 |
Evaluate the function at x
.
|
private |
Copy the local parameters from general block.
Referenced by casacore::CompoundFunction< casacore::AutoDiff< Double > >::clone(), casacore::CompoundFunction< casacore::AutoDiff< Double > >::consolidate(), and casacore::CompoundFunction< casacore::AutoDiff< Double > >::operator=().
|
inline |
Make this object a (deep) copy of other.
Definition at line 137 of file CompoundFunction.h.
|
private |
Make the general block from local parameters.
Referenced by casacore::CompoundFunction< casacore::AutoDiff< Double > >::consolidate().