FuncExpression.h
Classes
- FuncExpression -- An expression executable as function (full description)
- Global Functions -- Output function (full description)
- Global Functions -- Execute function (full description)
Interface
- Public Members
- FuncExpression()
- explicit FuncExpression(const String &prog)
- FuncExpression(const FuncExpression &other)
- FuncExpression &operator=(const FuncExpression &other)
- ~FuncExpression()
- Bool create(const String &prog)
- const String &errorMessage()
- const vector<FuncExprData::ExprOperator> &getCode() const
- uInt getNpar() const
- uInt getNdim() const
- const vector<FuncExprData::ExprOperator> &getCode()
- const vector<Double> &getConst()
- Bool exec(Double &res) const
- void print(ostream &os) const
- Private Members
- Bool compStmt(MUString &prg)
- Bool compExpr(MUString &prg)
- Bool compTerm(MUString &prg)
- Bool setOp(FuncExprData::ExprOperator &oper)
- Bool setVal(const Double &val)
- Bool setCode(const FuncExprData::ExprOperator &oper)
- void initState()
Review Status
- Date Reviewed:
- yyyy/mm/dd
Prerequisite
Synopsis
This class acts as an interface between a program given as a string (e.g.
from a command line interface) and a
Function class. The grammar of the language
use to express the function is given below. The FuncEXpression
can be used in all places where Functions can be used (like in the
linear and non-linear Fitting classes.
An expression is created by either supplying a String to a
constructor, or be setting a String.
Example
Motivation
To tie the Glish language to non-linear fitting procedures
Thrown Exceptions
- AipsError if an illegal program passed in constructor
To Do
Member Description
Construct an empty executable expression
explicit FuncExpression(const String &prog)
Construct an executable expression from the given string
FuncExpression(const FuncExpression &other)
Make this object a (deep) copy of other.
FuncExpression &operator=(const FuncExpression &other)
Make this object a (deep) copy of other.
Destructor
Create an executable program
Get the current error message
const vector<FuncExprData::ExprOperator> &getCode() const
Get the executable program
Get the number of parameters in executable program
Get the number of dimensions of executable program
const vector<FuncExprData::ExprOperator> &getCode()
Get reference to the compiled program
const vector<Double> &getConst()
Get reference to compiled constants
Bool exec(Double &res) const
Execute the program
void print(ostream &os) const
Print the stack information (mainly for debugging)
Compile a statement (in prg, which will be adjusted)
Compile an expression (in prg, which will be adjusted)
Compile a term (in prg, which will be adjusted)
Save an operation on compilation RP stack.
Bool setVal(const Double &val)
Save a value on constant stack.
Save an executable code
Initialise the state
Interface
- ostream &operator<<(ostream &os, const FuncExpression &ed)
Member Description
ostream &operator<<(ostream &os, const FuncExpression &ed)
Show the program
Interface
- T FuncExecute(const Vector<T> &x, const Vector<T> &par)
Member Description
T FuncExecute(const Vector<T> &x, const Vector<T> &par)
Execute the program