Loading...
Searching...
No Matches
casacore::CompoundParam< T > Class Template Reference
Functionals_module_internal_classes

More...

`#include <CompoundParam.h>`

## Public Member Functions

| 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)
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.
uInt | addFunction (const Function< T > &newFunction)
| Add a function to the sum.
uInt | nFunctions () const
| Return the number of functions in the sum.
const Function< T > & | function (uInt which) const
| Return a reference to a specific Function.
uInt | parameterOffset (uInt which) const
| Get the offset in function parameterlist for function which.
uInt | parameterFunction (uInt which) const
| Get the function number belonging to parameter list element which.
uInt | parameterLocation (uInt which) const
| Return locpar.
virtual uInt | ndim () const
| Returns the dimension of functions in the linear combination.
Public Member Functions inherited from casacore::Function< T, U >
| Function ()
| Constructors.
| Function (const uInt n)
| Function (const Vector< T > &in)
| Function (const FunctionParam< T > &other)
template<class W, class X>
| Function (const Function< W, X > &other)
virtual | ~Function ()
| Destructor.
uInt | nparameters () const
| Returns the number of parameters.
virtual U | eval (FunctionArg x) const =0
| Evaluate the function object.
T & | operator[] (const uInt n)
| Manipulate the nth parameter (0-based) with no index check.
const T & | operator[] (const uInt n) const
virtual U | operator() () const
| Evaluate this function object at xor at x, y.
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.
const Bool & | mask (const uInt n) const
const FunctionParam< T > & | parameters () const
| Return the parameter interface.
FunctionParam< T > & | parameters ()
const Vector< ArgType > & | argp () const
| Get arg_p and parset_p.
Bool | parsetp () const
void | lockParam ()
| Compiler cannot always find the correct 'const' version of parameter access.
void | unlockParam ()
virtual void | setMode (const RecordInterface &mode)
| get/set the function mode.
virtual void | getMode (RecordInterface &mode) const
virtual Bool | hasMode () const
| return True if the implementing function supports a mode.
ostream & | print (ostream &os) const
| Print the function (i.e.
virtual Function< T, U > * | clone () const =0
| 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
Public Member Functions inherited from casacore::Functional< FunctionTraits< T >::ArgType, T >
virtual | ~Functional ()
| Destructor.
virtual T | operator() (const FunctionTraits< T >::ArgType &x) const=0
| Map a Domain x into a Range y value.
Public Member Functions inherited from casacore::Functional< Vector< FunctionTraits< T >::ArgType >, T >
virtual | ~Functional ()
| Destructor.
virtual T | operator() (const Vector< FunctionTraits< T >::ArgType > &x) const=0
| Map a Domain x into a Range y value.

## Protected Attributes

PtrBlock< Function< T > * > | functionPtr_p
| Pointer to each added function.
Block< uInt > | paroff_p
| Index of offset for each function to its parameters in general list.
Block< uInt > | funpar_p
| Index of function belonging to parameter.
Block< uInt > | locpar_p
| Index of local parameter.
Protected Attributes inherited from casacore::Function< T, U >
FunctionParam< T > | param_p
| The parameters and masks.
Vector< ArgType > | arg_p
| Aid for non-contiguous argument storage.
Bool | parset_p
| Indicate parameter written.
Bool | locked_p
| Indicate that parameters are expected to be locked from changing.

## Private Attributes

uInt | ndim_p
| Number of dimensions of underlying functions.

## Additional Inherited Members

Public Types inherited from casacore::Function< T, U >
typedef FunctionTraits< T >::ArgType | ArgType
typedef const ArgType * | FunctionArg

## Detailed Description

template<class T>
class casacore::CompoundParam< T >

Parameters for sum of parameterized Functions

### Intended use:

Internal

### Review Status

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

### Prerequisite

- Function

### 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.

Note that any Function object (including another Compound object) can be part of a compound object.

### 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;
casacore::CompoundParam::parameterOffset
uInt parameterOffset(uInt which) const
Get the offset in function parameterlist for function which.
Definition CompoundParam.h:182
casacore::CompoundParam::CompoundParam
CompoundParam()
The default constructor – no functions, no parameters, nothing, the function operator returns a 0.
casacore::Gaussian1DParam::HEIGHT
@ HEIGHT
Definition Gaussian1DParam.h:129
casacore::Gaussian1D
Definition Gaussian1D.h:133
casacore::Polynomial
Polynomial()
Definition Polynomial.h:94
casacore::sum
LatticeExprNode sum(const LatticeExprNode &expr)

### Template Type Argument Requirements (T)

- T should have standard numerical operators and exp() function. Current implementation only tested for real types.
- To obtain derivatives, the derivatives should be defined.

### Thrown Exceptions

- AipsError if dimensions of functions added different

### 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

- Nothing I know of

Definition at line 98 of file CompoundParam.h.

## Constructor & Destructor Documentation

## CompoundParam() [1/5]

template<class T>

casacore::CompoundParam< T >::CompoundParam | ( |  | ) |

The default constructor – no functions, no parameters, nothing, the function operator returns a 0.

Referenced by casacore::CompoundFunction< T >::CompoundFunction(), casacore::CompoundFunction< T >::CompoundFunction(), casacore::CompoundFunction< T >::CompoundFunction(), casacore::CompoundFunction< T >::CompoundFunction(), casacore::CompoundFunction< T >::CompoundFunction(), CompoundParam(), CompoundParam(), CompoundParam(), CompoundParam(), operator=(), and casacore::CompoundFunction< T >::toParam_p().

## CompoundParam() [2/5]

template<class T>

casacore::CompoundParam< T >::CompoundParam | ( | const CompoundParam< T > & | other | ) |

Make this object a (deep) copy of other.

References CompoundParam().

## CompoundParam() [3/5]

template<class T>

casacore::CompoundParam< T >::CompoundParam | ( | const CompoundParam< T > & | other,
|  | Bool | )

inline

Definition at line 108 of file CompoundParam.h.

References CompoundParam(), casacore::Function< T, U >::Function(), functionPtr_p, funpar_p, locpar_p, ndim_p, casacore::nelements(), and paroff_p.

## CompoundParam() [4/5]

template<class T>
template<class W>

casacore::CompoundParam< T >::CompoundParam | ( | const CompoundParam< W > & | other | ) |

inline

Definition at line 124 of file CompoundParam.h.

References CompoundParam(), casacore::Function< T, U >::Function(), function(), functionPtr_p, funpar_p, locpar_p, ndim(), ndim_p, nFunctions(), casacore::Function< T, U >::nparameters(), parameterFunction(), parameterLocation(), parameterOffset(), and paroff_p.

## CompoundParam() [5/5]

template<class T>
template<class W>

casacore::CompoundParam< T >::CompoundParam | ( | const CompoundParam< W > & | other,
|  | Bool | )

inline

Definition at line 140 of file CompoundParam.h.

References CompoundParam(), casacore::Function< T, U >::Function(), function(), functionPtr_p, funpar_p, locpar_p, ndim(), ndim_p, nFunctions(), casacore::Function< T, U >::nparameters(), parameterFunction(), parameterLocation(), parameterOffset(), and paroff_p.

## ~CompoundParam()

template<class T>

virtual casacore::CompoundParam< T >::~CompoundParam | ( |  | ) |

virtual

## Member Function Documentation

## addFunction()

template<class T>

uInt casacore::CompoundParam< T >::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.

References casacore::Function< T, U >::Function().

## function()

template<class T>

const Function< T > & casacore::CompoundParam< T >::function | ( | uInt | which | ) | const

inline

Return a reference to a specific Function.

Definition at line 177 of file CompoundParam.h.

References DebugAssert, casacore::Function< T, U >::Function(), functionPtr_p, and nFunctions().

Referenced by CompoundParam(), CompoundParam(), and casacore::CompoundFunction< T >::toParam_p().

## name()

template<class T>

virtual const String & casacore::CompoundParam< T >::name | ( |  | ) | const

inline virtual

Give name of function.

Reimplemented from casacore::Function< T, U >.

Definition at line 164 of file CompoundParam.h.

## ndim()

template<class T>

virtual uInt casacore::CompoundParam< T >::ndim | ( |  | ) | const

inline virtual

Returns the dimension of functions in the linear combination.

Implements casacore::Function< T, U >.

Definition at line 195 of file CompoundParam.h.

References ndim_p.

Referenced by CompoundParam(), and CompoundParam().

## nFunctions()

template<class T>

uInt casacore::CompoundParam< T >::nFunctions | ( |  | ) | const

inline

Return the number of functions in the sum.

Definition at line 173 of file CompoundParam.h.

References functionPtr_p.

Referenced by CompoundParam(), CompoundParam(), function(), parameterOffset(), and casacore::CompoundFunction< T >::toParam_p().

## operator=()

template<class T>

CompoundParam< T > & casacore::CompoundParam< T >::operator= | ( | const CompoundParam< T > & | other | ) |

References CompoundParam().

Referenced by casacore::CompoundFunction< T >::operator=().

## parameterFunction()

template<class T>

uInt casacore::CompoundParam< T >::parameterFunction | ( | uInt | which | ) | const

inline

Get the function number belonging to parameter list element which.

Definition at line 185 of file CompoundParam.h.

References DebugAssert, funpar_p, and casacore::Function< T, U >::nparameters().

Referenced by CompoundParam(), and CompoundParam().

## parameterLocation()

template<class T>

uInt casacore::CompoundParam< T >::parameterLocation | ( | uInt | which | ) | const

inline

Return locpar.

Definition at line 190 of file CompoundParam.h.

References DebugAssert, locpar_p, and casacore::Function< T, U >::nparameters().

Referenced by CompoundParam(), and CompoundParam().

## parameterOffset()

template<class T>

uInt casacore::CompoundParam< T >::parameterOffset | ( | uInt | which | ) | const

inline

Get the offset in function parameterlist for function which.

Definition at line 182 of file CompoundParam.h.

References DebugAssert, nFunctions(), and paroff_p.

Referenced by CompoundParam(), and CompoundParam().

## Member Data Documentation

## functionPtr_p

template<class T>

PtrBlock<Function<T> *> casacore::CompoundParam< T >::functionPtr_p

protected

Pointer to each added function.

Definition at line 205 of file CompoundParam.h.

Referenced by CompoundParam(), CompoundParam(), CompoundParam(), function(), nFunctions(), and casacore::CompoundFunction< T >::toParam_p().

## funpar_p

template<class T>

Block<uInt> casacore::CompoundParam< T >::funpar_p

protected

Index of function belonging to parameter.

Definition at line 209 of file CompoundParam.h.

Referenced by CompoundParam(), CompoundParam(), CompoundParam(), parameterFunction(), and casacore::CompoundFunction< T >::toParam_p().

## locpar_p

template<class T>

Block<uInt> casacore::CompoundParam< T >::locpar_p

protected

Index of local parameter.

Definition at line 211 of file CompoundParam.h.

Referenced by CompoundParam(), CompoundParam(), CompoundParam(), parameterLocation(), and casacore::CompoundFunction< T >::toParam_p().

## ndim_p

template<class T>

uInt casacore::CompoundParam< T >::ndim_p

private

Number of dimensions of underlying functions.

Definition at line 200 of file CompoundParam.h.

Referenced by CompoundParam(), CompoundParam(), CompoundParam(), and ndim().

## paroff_p

template<class T>

Block<uInt> casacore::CompoundParam< T >::paroff_p

protected

Index of offset for each function to its parameters in general list.

Definition at line 207 of file CompoundParam.h.

Referenced by CompoundParam(), CompoundParam(), CompoundParam(), parameterOffset(), and casacore::CompoundFunction< T >::toParam_p().

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

- scimath/Functionals/CompoundParam.h