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

Parameters for a compiled string function object. More...

#include <CompiledParam.h>

Inheritance diagram for casa::CompiledParam< T >:
casa::Function< T > casa::Functional< FunctionTraits< T >::ArgType, T > casa::Functional< Vector< FunctionTraits< T >::ArgType >, T > casa::CompiledFunction< T >

List of all members.

Public Member Functions

 CompiledParam ()
 The default constructor -- no functions, no parameters, nothing, the function operator returns a 0.
 CompiledParam (const CompiledParam< T > &other)
 Make this object a (deep) copy of other.
template<class W >
 CompiledParam (const CompiledParam< W > &other)
CompiledParam< T > & operator= (const CompiledParam< T > &other)
 Make this object a (deep) copy of other.
virtual ~CompiledParam ()
 Destructor.
virtual const Stringname () const
 Give name of function.
Bool setFunction (const String &newFunction)
 Set a function.
const StringerrorMessage () const
 Return the error message of the compilation.
const FuncExpressionfunction () const
 Return the expression.
virtual uInt ndim () const
 Returns the dimension of function.
const StringgetText () const
 Returns the text of the function string.
const FuncExpressiongetFunctionPtr () const
 Returns the function pointer (for debugging)

Protected Attributes

uInt ndim_p
 Number of dimensions of underlying function.
String msg_p
 Possible error message.
String text_p
 Input text string.
FuncExpressionfunctionPtr_p
 Pointer to function.

Detailed Description

template<class T>
class casa::CompiledParam< T >

Parameters for a compiled string function object.

Intended use:

Internal

Review Status

Test programs:
tFuncExpression

Prerequisite

Synopsis

Given a string describing an expression (see FuncExpression class for details of the expression), the CompiledFunctionclass wraps this expression as a Function (see Function class) which can be used in all places where functions can be used (e.g. see Fitting ).

This class takes care of the CompiledFunction parameter interface (see FunctionParam class for details).

Example

In the following example a Gaussian profile with three parameters (height, center and halfwidth) is specified and its value and derivatives with respect to the parameters are calculated at x=2.

    // the Gaussian
    CompiledFunction<Double> prof("p0*exp(-((x-p1)/p2)^2)");
    prof[0] = 2;                                // the height
    prof[1] = 1.5;                      // the center
    prof[2] = 1;                                // the width
    Vector<Double> x(3);
    X[0] = 1.9; x[1] = 2.0; x[2] = 2.1;
    cout << "Gaussian at x=" << x << ": " << prof(x) << endl;
    // and an automatic derivative one:
    CompiledFunction<AutoDiff<Double> > profad("p0*exp(-((x-p1)/p2)^2)");
    cout << "Gaussian at x=" << x << ": " << profad(x) << endl;

will produce the output:

Template Type Argument Requirements (T)

Motivation

This class was created to allow specialization of the function evaluation in a simple way.

To Do

Definition at line 106 of file CompiledParam.h.


Constructor & Destructor Documentation

template<class T>
casa::CompiledParam< T >::CompiledParam ( )

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

template<class T>
casa::CompiledParam< T >::CompiledParam ( const CompiledParam< T > &  other)

Make this object a (deep) copy of other.

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

Definition at line 116 of file CompiledParam.h.

template<class T>
virtual casa::CompiledParam< T >::~CompiledParam ( ) [virtual]

Destructor.


Member Function Documentation

template<class T>
const String& casa::CompiledParam< T >::errorMessage ( ) const [inline]

Return the error message of the compilation.

Definition at line 138 of file CompiledParam.h.

References casa::CompiledParam< T >::msg_p.

template<class T>
const FuncExpression& casa::CompiledParam< T >::function ( ) const

Return the expression.

template<class T>
const FuncExpression* casa::CompiledParam< T >::getFunctionPtr ( ) const [inline]

Returns the function pointer (for debugging)

Definition at line 150 of file CompiledParam.h.

References casa::CompiledParam< T >::functionPtr_p.

template<class T>
const String& casa::CompiledParam< T >::getText ( ) const [inline]

Returns the text of the function string.

Definition at line 147 of file CompiledParam.h.

References casa::CompiledParam< T >::text_p.

template<class T>
virtual const String& casa::CompiledParam< T >::name ( ) const [inline, virtual]

Give name of function.

Reimplemented from casa::Function< T >.

Definition at line 130 of file CompiledParam.h.

template<class T>
virtual uInt casa::CompiledParam< T >::ndim ( ) const [inline, virtual]

Returns the dimension of function.

Implements casa::Function< T >.

Definition at line 144 of file CompiledParam.h.

References casa::CompiledParam< T >::ndim_p.

template<class T>
CompiledParam<T>& casa::CompiledParam< T >::operator= ( const CompiledParam< T > &  other)

Make this object a (deep) copy of other.

template<class T>
Bool casa::CompiledParam< T >::setFunction ( const String newFunction)

Set a function.

The return will be False (and an error message will be set) if a compilation error occurs


Member Data Documentation

template<class T>
FuncExpression* casa::CompiledParam< T >::functionPtr_p [protected]

Pointer to function.

Definition at line 163 of file CompiledParam.h.

Referenced by casa::CompiledParam< T >::getFunctionPtr().

template<class T>
String casa::CompiledParam< T >::msg_p [protected]

Possible error message.

Definition at line 158 of file CompiledParam.h.

Referenced by casa::CompiledParam< T >::errorMessage().

template<class T>
uInt casa::CompiledParam< T >::ndim_p [protected]

Number of dimensions of underlying function.

Definition at line 156 of file CompiledParam.h.

Referenced by casa::CompiledParam< T >::ndim().

template<class T>
String casa::CompiledParam< T >::text_p [protected]

Input text string.

Definition at line 160 of file CompiledParam.h.

Referenced by casa::CompiledParam< T >::getText().


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