FuncExpression.h

Classes

FuncExpression -- An expression executable as function (full description)
Global Functions -- Output function (full description)
Global Functions -- Execute function (full description)

class FuncExpression

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()

Description

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

To Do

Member Description

FuncExpression()

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.

~FuncExpression()

Destructor

Bool create(const String &prog)

Create an executable program

const String &errorMessage()

Get the current error message

const vector<FuncExprData::ExprOperator> &getCode() const

Get the executable program

uInt getNpar() const

Get the number of parameters in executable program

uInt getNdim() const

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)

Bool compStmt(MUString &prg)

Compile a statement (in prg, which will be adjusted)

Bool compExpr(MUString &prg)

Compile an expression (in prg, which will be adjusted)

Bool compTerm(MUString &prg)

Compile a term (in prg, which will be adjusted)

Bool setOp(FuncExprData::ExprOperator &oper)

Save an operation on compilation RP stack.

Bool setVal(const Double &val)

Save a value on constant stack.

Bool setCode(const FuncExprData::ExprOperator &oper)

Save an executable code

void initState()

Initialise the state

Output function (source)

Interface

ostream &operator<<(ostream &os, const FuncExpression &ed)

Description

Member Description

ostream &operator<<(ostream &os, const FuncExpression &ed)

Show the program

Execute function (source)

Interface

T FuncExecute(const Vector<T> &x, const Vector<T> &par)

Description

Member Description

T FuncExecute(const Vector<T> &x, const Vector<T> &par)

Execute the program