Preprocessor:
* in DataTree, new functions for testing if some opcode (unary, binary or trinary) is used somewhere in the tree * removed DataTree::containsSteadyState(), rather use a call to the new utility functiontime-shift
parent
3475341ac9
commit
eba049899e
|
@ -490,11 +490,33 @@ DataTree::getDynJacobianCol(int deriv_id) const throw (UnknownDerivIDException)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
DataTree::containsSteadyStateOperator() const
|
DataTree::isUnaryOpUsed(UnaryOpcode opcode) const
|
||||||
{
|
{
|
||||||
for (unary_op_node_map_type::const_iterator it = unary_op_node_map.begin();
|
for (unary_op_node_map_type::const_iterator it = unary_op_node_map.begin();
|
||||||
it != unary_op_node_map.end(); it++)
|
it != unary_op_node_map.end(); it++)
|
||||||
if (it->first.second == oSteadyState)
|
if (it->first.second == opcode)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
DataTree::isBinaryOpUsed(BinaryOpcode opcode) const
|
||||||
|
{
|
||||||
|
for (binary_op_node_map_type::const_iterator it = binary_op_node_map.begin();
|
||||||
|
it != binary_op_node_map.end(); it++)
|
||||||
|
if (it->first.second == opcode)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
DataTree::isTrinaryOpUsed(TrinaryOpcode opcode) const
|
||||||
|
{
|
||||||
|
for (trinary_op_node_map_type::const_iterator it = trinary_op_node_map.begin();
|
||||||
|
it != trinary_op_node_map.end(); it++)
|
||||||
|
if (it->first.second == opcode)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -67,9 +67,6 @@ protected:
|
||||||
//! Internal implementation of AddVariable(), without the check on the lag
|
//! Internal implementation of AddVariable(), without the check on the lag
|
||||||
VariableNode *AddVariableInternal(int symb_id, int lag);
|
VariableNode *AddVariableInternal(int symb_id, int lag);
|
||||||
|
|
||||||
//! Is there a steady state operator in the tree?
|
|
||||||
bool containsSteadyStateOperator() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef list<NodeID> node_list_type;
|
typedef list<NodeID> node_list_type;
|
||||||
//! The list of nodes
|
//! The list of nodes
|
||||||
|
@ -183,6 +180,12 @@ public:
|
||||||
NodeID AddUnknownFunction(const string &function_name, const vector<NodeID> &arguments);
|
NodeID AddUnknownFunction(const string &function_name, const vector<NodeID> &arguments);
|
||||||
//! Checks if a given symbol is used somewhere in the data tree
|
//! Checks if a given symbol is used somewhere in the data tree
|
||||||
bool isSymbolUsed(int symb_id) const;
|
bool isSymbolUsed(int symb_id) const;
|
||||||
|
//! Checks if a given unary op is used somewhere in the data tree
|
||||||
|
bool isUnaryOpUsed(UnaryOpcode opcode) const;
|
||||||
|
//! Checks if a given binary op is used somewhere in the data tree
|
||||||
|
bool isBinaryOpUsed(BinaryOpcode opcode) const;
|
||||||
|
//! Checks if a given trinary op is used somewhere in the data tree
|
||||||
|
bool isTrinaryOpUsed(TrinaryOpcode opcode) const;
|
||||||
//! Thrown when trying to access an unknown variable by deriv_id
|
//! Thrown when trying to access an unknown variable by deriv_id
|
||||||
class UnknownDerivIDException
|
class UnknownDerivIDException
|
||||||
{
|
{
|
||||||
|
|
|
@ -1136,7 +1136,7 @@ DynamicModel::writeDynamicMFile(const string &dynamic_basename) const
|
||||||
<< "% Warning : this file is generated automatically by Dynare" << endl
|
<< "% Warning : this file is generated automatically by Dynare" << endl
|
||||||
<< "% from model file (.mod)" << endl << endl;
|
<< "% from model file (.mod)" << endl << endl;
|
||||||
|
|
||||||
if (containsSteadyStateOperator())
|
if (isUnaryOpUsed(oSteadyState))
|
||||||
mDynamicModelFile << "global oo_;" << endl << endl;
|
mDynamicModelFile << "global oo_;" << endl << endl;
|
||||||
|
|
||||||
writeDynamicModel(mDynamicModelFile, false);
|
writeDynamicModel(mDynamicModelFile, false);
|
||||||
|
|
Loading…
Reference in New Issue