CompiledParam.h
Classes
- CompiledParam -- Parameters for a compiled string function object. (full description)
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
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)
- T should have standard numerical operators and functions.
- To obtain derivatives, the derivatives should be defined.
Thrown Exceptions
Motivation
This class was created to allow specialization of the function evaluation in
a simple way.
To Do
Member Description
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.
Destructor
virtual const String &name() const
Give name of function
Set a function. The return will be False (and an error message will be
set) if a compilation error occurs
Return the error message of the compilation
Return the expression
virtual uInt ndim() const
Returns the dimension of function
Returns the text of the function string
Returns the function pointer (for debugging)