34 std::vector<double>
val;
55 std::set<SeExpr2::DExpression *> ret;
57 std::set<SeExpr2::DExpression *> workList = gv->
users;
58 while (workList.size()) {
69 std::set<SeExpr2::DExpression *> ret;
71 std::set<SeExpr2::DExpression *> workList;
72 workList.insert(
expr);
73 while (workList.size()) {
83std::set<SeExpr2::DExpression *> tmpOperandExprs;
84std::set<SeExpr2::GlobalVal *> tmpOperandVars;
115 if ((*I)->name() ==
name) {
117 (*I)->val->users.insert(
const_cast<DExpression *
>(
this));
122 if ((*I)->varName ==
name) {
124 (*I)->users.insert(
const_cast<DExpression *
>(
this));
152 std::pair<std::set<GlobalVal *>::iterator,
bool>
ret;
156 else if (
seTy.isString())
165 std::pair<std::set<DExpression *>::iterator,
bool>
ret;
185 assert(
thisvar &&
"set value to variable with incompatible types.");
195 assert(
thisvar &&
"set value to variable with incompatible types.");
201 assert(
thisvar &&
"set value to variable with incompatible types.");
208 for (std::set<DExpression *>::iterator
I =
ret.begin(),
E =
ret.end();
I !=
E; ++
I) (*I)->eval();
213 assert(
thisvar &&
"set value to variable with incompatible types.");
218 for (std::set<DExpression *>::iterator
I =
ret.begin(),
E =
ret.end();
I !=
E; ++
I) (*I)->eval();
224 ret &= (*I)->isValid();
235 std::vector<DExpression *>::iterator
it;
237 std::vector<DExpression *>
ret1(all.size());
241 std::vector<DExpression *>
ret2(
ret1.size());
248 return std::make_pair(
eh,
ret2);
253 for (std::vector<DExpression *>::iterator
I =
eeh.second.begin(),
E =
eeh.second.end();
I !=
E; ++
I) (*I)->eval();
264 for (std::vector<DExpression *>::iterator
I =
eeh.second.begin(),
E =
eeh.second.end();
I !=
E; ++
I) (*I)->eval();
std::set< DExpression * > operandExprs
ExprVarRef * resolveVar(const std::string &name) const
const std::string & name() const
DExpression(const std::string &varName, Expressions &context, const std::string &e, const ExprType &type=ExprType().FP(3), EvaluationStrategy be=defaultEvaluationStrategy)
std::set< GlobalVal * > operandVars
bool isFP() const
Direct is predicate checks.
abstract class for implementing variable references
virtual ExprType type() const
returns (current) type
EvaluationStrategy
Types of evaluation strategies that are available.
const char * evalStr(VarBlock *varBlock=nullptr) const
void addError(const std::string &error, const int startPos, const int endPos) const
const double * evalFP(VarBlock *varBlock=nullptr) const
ExprType _desiredReturnType
void prepIfNeeded() const
VariableSetHandle getLoopVarSetHandle(VariableHandle vh)
const std::vector< double > & evalFP(ExprEvalHandle eeh)
void setLoopVariable(VariableSetHandle handle, double *values, unsigned dim)
std::set< GlobalVal * > AllExternalVars
ExprEvalHandle getExprEvalHandle(ExprHandle eh)
ExprHandle addExpression(const std::string &varName, ExprType seTy, const std::string &expr)
std::set< DExpression * > exprEvaled
const char * evalStr(ExprEvalHandle eeh)
std::set< DExpression * > exprToEval
void setVariable(VariableHandle handle, double *values, unsigned dim)
std::set< DExpression * > AllExprs
VariableHandle addExternalVariable(const std::string &variableName, ExprType seTy)
GlobalVal(const std::string &varName, const SeExpr2::ExprType &et)
std::set< DExpression * > users
you may not use this file except in compliance with the License and the following modification to it
std::set< GlobalVal * >::iterator VariableSetHandle
std::set< GlobalVal * >::iterator VariableHandle
std::pair< ExprHandle, std::vector< DExpression * > > ExprEvalHandle
std::set< DExpression * >::iterator ExprHandle
void eval(const char **result)
std::vector< double > val
GlobalFP(const std::string &varName, int dim)
void eval(double *result)
returns this variable's value by setting result
void eval(const char **result)
void eval(double *result)
returns this variable's value by setting result
GlobalStr(const std::string &varName)
</pre >< h3 > Binding our variable reference</h3 > If we now tried to use the variable would still not be found by our expressions To make it bindable we need to override the resolveVar() function as follows</pre >< h3 > Variable setting</h3 > Next we need to make a way of setting the variable As the controlling code will use the expression it will repeatedly alternate between setting the independent variables that are used and calling evaluate(). What it has to do depends very much on the application. In this case we only need to set the independent variable x as</pre >< h2 > Evaluating expressions</h2 > Evaluating an expression is pretty easy But before we can do that we need to make an instance< pre > GrapherExpr expr("x+x^2")
If a scalar is used in a vector context
< b ></b >< br >< b ></b ></td >< td > vector constructor< br > vector component access n must be