casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Private Member Functions
casa::CompoundFunction< T > Class Template Reference

Sum of a collection of Functions which behaves as one Function object. More...

#include <CompoundFunction.h>

Inheritance diagram for casa::CompoundFunction< T >:
casa::CompoundParam< T > casa::Function< T > casa::Functional< FunctionTraits< T >::ArgType, T > casa::Functional< Vector< FunctionTraits< T >::ArgType >, T >

List of all members.

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.

Detailed Description

template<class T>
class casa::CompoundFunction< T >

Sum of a collection of Functions which behaves as one Function object.

Intended use:

Public interface

Review Status

Reviewed By:
tcornwel
Date Reviewed:
1996/02/22
Test programs:
tCompoundFunction

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.

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

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

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

Definition at line 114 of file CompoundFunction.h.


Constructor & Destructor Documentation

template<class T>
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.

template<class T>
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.

template<class T>
casa::CompoundFunction< T >::CompoundFunction ( const CompoundFunction< T > &  other,
Bool   
) [inline]

Definition at line 127 of file CompoundFunction.h.

template<class T>
template<class W >
casa::CompoundFunction< T >::CompoundFunction ( const CompoundFunction< W > &  other) [inline]

Definition at line 130 of file CompoundFunction.h.

template<class T>
template<class W >
casa::CompoundFunction< T >::CompoundFunction ( const CompoundFunction< W > &  other,
Bool   
) [inline]

Definition at line 133 of file CompoundFunction.h.

template<class T>
virtual casa::CompoundFunction< T >::~CompoundFunction ( ) [inline, virtual]

Destructor.

Definition at line 142 of file CompoundFunction.h.


Member Function Documentation

template<class T>
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.

template<class T>
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.

template<class T>
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.

template<class T>
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.

template<class T>
virtual T casa::CompoundFunction< T >::eval ( typename Function< T >::FunctionArg  x) const [virtual]

Evaluate the function at x.

template<class T>
void casa::CompoundFunction< T >::fromParam_p ( ) const [private]
template<class T>
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=().

template<class T>
void casa::CompoundFunction< T >::toParam_p ( ) [private]

Make the general block from local parameters.

Referenced by casa::CompoundFunction< AutoDiff< Double > >::consolidate().


The documentation for this class was generated from the following file: