CompiledParam.h

Classes

CompiledParam -- Parameters for a compiled string function object. (full description)

template <class T> class CompiledParam : public Function<T>

Interface

Public Members
CompiledParam()
CompiledParam(const CompiledParam<T> &other)
template <class W> CompiledParam(const CompiledParam<W> &other) : Function<T>(other), ndim_p(other.ndim()), msg_p(other.errorMessage()), text_p(other.getText()), functionPtr_p(new ndim(*other.getFunctionPtr()))
CompiledParam<T> &operator=(const CompiledParam<T> &other)
virtual ~CompiledParam()
virtual const String &name() const
Bool setFunction(const String &newFunction)
const String &errorMessage() const
const FuncExpression &function() const
virtual uInt ndim() const
const String &getText() const
const FuncExpression *const getFunctionPtr() const

Description

Review Status

Programs:
Tests:

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)

Thrown Exceptions

Motivation

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

To Do

Member Description

CompiledParam()

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

CompiledParam(const CompiledParam<T> &other)
template <class W> CompiledParam(const CompiledParam<W> &other) : Function<T>(other), ndim_p(other.ndim()), msg_p(other.errorMessage()), text_p(other.getText()), functionPtr_p(new ndim(*other.getFunctionPtr()))

Make this object a (deep) copy of other.

CompiledParam<T> &operator=(const CompiledParam<T> &other)

Make this object a (deep) copy of other.

virtual ~CompiledParam()

Destructor

virtual const String &name() const

Give name of function

Bool setFunction(const String &newFunction)

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

const String &errorMessage() const

Return the error message of the compilation

const FuncExpression &function() const

Return the expression

virtual uInt ndim() const

Returns the dimension of function

const String &getText() const

Returns the text of the function string

const FuncExpression *const getFunctionPtr() const

Returns the function pointer (for debugging)