- the "steady_state" function is implemented with the "bytecode" option
git-svn-id: https://www.dynare.org/svn/dynare/trunk@2952 ac1d8469-bf42-47a9-8791-bf33cf982152issue#70
parent
e337789b54
commit
0c7fea9e5f
|
@ -41,13 +41,13 @@ const char FEND=17;
|
|||
const char FOK=18;
|
||||
const char FENDEQU=19;
|
||||
const char FLDSV=20;
|
||||
const char FSTPSV=21;
|
||||
const char FLDSU=22;
|
||||
const char FSTPSU=23;
|
||||
const char FLDST=24;
|
||||
const char FSTPST=25;
|
||||
const char FDIMST=26;
|
||||
|
||||
const char FLDVS=21;
|
||||
const char FSTPSV=22;
|
||||
const char FLDSU=23;
|
||||
const char FSTPSU=24;
|
||||
const char FLDST=25;
|
||||
const char FSTPST=26;
|
||||
const char FDIMST=27;
|
||||
|
||||
|
||||
enum BlockType
|
||||
|
|
|
@ -60,7 +60,7 @@ DynamicModel::compileDerivative(ofstream &code_file, int eq, int symb_id, int la
|
|||
//first_derivatives_type::const_iterator it = first_derivatives.find(make_pair(eq, getDerivID(symb_id, lag)));
|
||||
first_derivatives_type::const_iterator it = first_derivatives.find(make_pair(eq, getDerivID(symbol_table.getID(eEndogenous, symb_id), lag)));
|
||||
if (it != first_derivatives.end())
|
||||
(it->second)->compile(code_file, false, temporary_terms, map_idx, true);
|
||||
(it->second)->compile(code_file, false, temporary_terms, map_idx, true, false);
|
||||
else
|
||||
code_file.write(&FLDZ, sizeof(FLDZ));
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ DynamicModel::compileChainRuleDerivative(ofstream &code_file, int eqr, int varr,
|
|||
{
|
||||
map<pair<int, pair<int, int> >, NodeID>::const_iterator it = first_chain_rule_derivatives.find(make_pair(eqr, make_pair(varr, lag)));
|
||||
if (it != first_chain_rule_derivatives.end())
|
||||
(it->second)->compile(code_file, false, temporary_terms, map_idx, true);
|
||||
(it->second)->compile(code_file, false, temporary_terms, map_idx, true, false);
|
||||
else
|
||||
code_file.write(&FLDZ, sizeof(FLDZ));
|
||||
}
|
||||
|
@ -934,7 +934,7 @@ DynamicModel::writeModelEquationsCodeOrdered(const string file_name, const Model
|
|||
for (temporary_terms_type::const_iterator it = ModelBlock->Block_List[j].Temporary_Terms_in_Equation[i]->begin();
|
||||
it != ModelBlock->Block_List[j].Temporary_Terms_in_Equation[i]->end(); it++)
|
||||
{
|
||||
(*it)->compile(code_file, false, tt2, map_idx, true);
|
||||
(*it)->compile(code_file, false, tt2, map_idx, true, false);
|
||||
code_file.write(&FSTPT, sizeof(FSTPT));
|
||||
map_idx_type::const_iterator ii=map_idx.find((*it)->idx);
|
||||
v=(int)ii->second;
|
||||
|
@ -967,16 +967,16 @@ evaluation:
|
|||
eq_node = equations[ModelBlock->Block_List[j].Equation[i]];
|
||||
lhs = eq_node->get_arg1();
|
||||
rhs = eq_node->get_arg2();
|
||||
rhs->compile(code_file, false, temporary_terms, map_idx, true);
|
||||
lhs->compile(code_file, true, temporary_terms, map_idx, true);
|
||||
rhs->compile(code_file, false, temporary_terms, map_idx, true, false);
|
||||
lhs->compile(code_file, true, temporary_terms, map_idx, true, false);
|
||||
}
|
||||
else if (ModelBlock->Block_List[j].Equation_Type[i] == E_EVALUATE_S)
|
||||
{
|
||||
eq_node = (BinaryOpNode*)ModelBlock->Block_List[j].Equation_Normalized[i];
|
||||
lhs = eq_node->get_arg1();
|
||||
rhs = eq_node->get_arg2();
|
||||
rhs->compile(code_file, false, temporary_terms, map_idx, true);
|
||||
lhs->compile(code_file, true, temporary_terms, map_idx, true);
|
||||
rhs->compile(code_file, false, temporary_terms, map_idx, true, false);
|
||||
lhs->compile(code_file, true, temporary_terms, map_idx, true, false);
|
||||
}
|
||||
break;
|
||||
case SOLVE_BACKWARD_COMPLETE:
|
||||
|
@ -994,8 +994,8 @@ end:
|
|||
eq_node = equations[ModelBlock->Block_List[j].Equation[i]];
|
||||
lhs = eq_node->get_arg1();
|
||||
rhs = eq_node->get_arg2();
|
||||
lhs->compile(code_file, false, temporary_terms, map_idx, true);
|
||||
rhs->compile(code_file, false, temporary_terms, map_idx, true);
|
||||
lhs->compile(code_file, false, temporary_terms, map_idx, true, false);
|
||||
rhs->compile(code_file, false, temporary_terms, map_idx, true, false);
|
||||
code_file.write(&FBINARY, sizeof(FBINARY));
|
||||
int v=oMinus;
|
||||
code_file.write(reinterpret_cast<char *>(&v),sizeof(v));
|
||||
|
|
119
ExprNode.cc
119
ExprNode.cc
|
@ -191,7 +191,7 @@ NumConstNode::eval(const eval_context_type &eval_context) const throw (EvalExcep
|
|||
}
|
||||
|
||||
void
|
||||
NumConstNode::compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx, bool dynamic) const
|
||||
NumConstNode::compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx, bool dynamic, bool steady_dynamic) const
|
||||
{
|
||||
CompileCode.write(&FLDC, sizeof(FLDC));
|
||||
double vard = datatree.num_constants.getDouble(id);
|
||||
|
@ -379,9 +379,9 @@ VariableNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
|
|||
case oMatlabOutsideModel:
|
||||
output << "oo_.steady_state(" << tsid + 1 << ")";
|
||||
break;
|
||||
case oMatlabDynamicSteadyStateOperator:
|
||||
output << "oo_.steady_state(" << tsid + 1 << ")";
|
||||
break;
|
||||
case oMatlabDynamicSteadyStateOperator:
|
||||
output << "oo_.steady_state(" << tsid + 1 << ")";
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
|
@ -416,9 +416,9 @@ VariableNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
|
|||
assert(lag == 0);
|
||||
output << "oo_.exo_steady_state(" << i << ")";
|
||||
break;
|
||||
case oMatlabDynamicSteadyStateOperator:
|
||||
output << "oo_.exo_steady_state(" << i << ")";
|
||||
break;
|
||||
case oMatlabDynamicSteadyStateOperator:
|
||||
output << "oo_.exo_steady_state(" << i << ")";
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
|
@ -478,20 +478,34 @@ VariableNode::eval(const eval_context_type &eval_context) const throw (EvalExcep
|
|||
}
|
||||
|
||||
void
|
||||
VariableNode::compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx, bool dynamic) const
|
||||
VariableNode::compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx, bool dynamic, bool steady_dynamic) const
|
||||
{
|
||||
int i, lagl;
|
||||
if (!lhs_rhs)
|
||||
{
|
||||
if(dynamic)
|
||||
CompileCode.write(&FLDV, sizeof(FLDV));
|
||||
{
|
||||
if(steady_dynamic) // steady state values in a dynamic model
|
||||
CompileCode.write(&FLDVS, sizeof(FLDVS));
|
||||
else
|
||||
CompileCode.write(&FLDV, sizeof(FLDV));
|
||||
}
|
||||
else
|
||||
CompileCode.write(&FLDSV, sizeof(FLDSV));
|
||||
}
|
||||
else
|
||||
{
|
||||
if(dynamic)
|
||||
CompileCode.write(&FSTPV, sizeof(FSTPV));
|
||||
{
|
||||
if(steady_dynamic) // steady state values in a dynamic model
|
||||
{
|
||||
/*CompileCode.write(&FLDVS, sizeof(FLDVS));*/
|
||||
cerr << "Impossible case: steady_state in rhs of equation" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
else
|
||||
CompileCode.write(&FSTPV, sizeof(FSTPV));
|
||||
}
|
||||
else
|
||||
CompileCode.write(&FSTPSV, sizeof(FSTPSV));
|
||||
}
|
||||
|
@ -509,7 +523,7 @@ VariableNode::compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_
|
|||
//cout << "Endogenous=" << symb_id << "\n";
|
||||
i = tsid;//symb_id;
|
||||
CompileCode.write(reinterpret_cast<char *>(&i), sizeof(i));
|
||||
if(dynamic)
|
||||
if(dynamic && !steady_dynamic)
|
||||
{
|
||||
lagl=lag;
|
||||
CompileCode.write(reinterpret_cast<char *>(&lagl), sizeof(lagl));
|
||||
|
@ -519,7 +533,7 @@ VariableNode::compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_
|
|||
//cout << "Exogenous=" << tsid << "\n";
|
||||
i = tsid;
|
||||
CompileCode.write(reinterpret_cast<char *>(&i), sizeof(i));
|
||||
if(dynamic)
|
||||
if(dynamic && !steady_dynamic)
|
||||
{
|
||||
lagl=lag;
|
||||
CompileCode.write(reinterpret_cast<char *>(&lagl), sizeof(lagl));
|
||||
|
@ -529,7 +543,7 @@ VariableNode::compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_
|
|||
i = tsid + datatree.symbol_table.exo_nbr();
|
||||
//cout << "ExogenousDet=" << i << "\n";
|
||||
CompileCode.write(reinterpret_cast<char *>(&i), sizeof(i));
|
||||
if(dynamic)
|
||||
if(dynamic && !steady_dynamic)
|
||||
{
|
||||
lagl=lag;
|
||||
CompileCode.write(reinterpret_cast<char *>(&lagl), sizeof(lagl));
|
||||
|
@ -538,7 +552,7 @@ VariableNode::compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_
|
|||
case eModelLocalVariable:
|
||||
case eModFileLocalVariable:
|
||||
//cout << "eModelLocalVariable=" << symb_id << "\n";
|
||||
datatree.local_variables_table[symb_id]->compile(CompileCode, lhs_rhs, temporary_terms, map_idx, dynamic);
|
||||
datatree.local_variables_table[symb_id]->compile(CompileCode, lhs_rhs, temporary_terms, map_idx, dynamic, steady_dynamic);
|
||||
break;
|
||||
case eUnknownFunction:
|
||||
cerr << "Impossible case: eUnknownFuncion" << endl;
|
||||
|
@ -886,7 +900,7 @@ UnaryOpNode::collectTemporary_terms(const temporary_terms_type &temporary_terms,
|
|||
void
|
||||
UnaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
|
||||
const temporary_terms_type &temporary_terms) const
|
||||
{
|
||||
{
|
||||
// If node is a temporary term
|
||||
temporary_terms_type::const_iterator it = temporary_terms.find(const_cast<UnaryOpNode *>(this));
|
||||
if (it != temporary_terms.end())
|
||||
|
@ -958,28 +972,28 @@ UnaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
|
|||
case oSqrt:
|
||||
output << "sqrt";
|
||||
break;
|
||||
case oSteadyState:
|
||||
ExprNodeOutputType new_output_type;
|
||||
case oSteadyState:
|
||||
ExprNodeOutputType new_output_type;
|
||||
switch(output_type)
|
||||
{
|
||||
case oMatlabDynamicModel:
|
||||
new_output_type = oMatlabDynamicSteadyStateOperator;
|
||||
break;
|
||||
case oLatexDynamicModel:
|
||||
new_output_type = oLatexDynamicSteadyStateOperator;
|
||||
break;
|
||||
case oCDynamicModel:
|
||||
cerr << "Steady State Operator not implemented for oCDynamicModel." << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
case oMatlabDynamicModelSparse:
|
||||
cerr << "Steady State Operator not implemented for oMatlabDynamicModelSparse." << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
default:
|
||||
new_output_type = output_type;
|
||||
break;
|
||||
}
|
||||
arg->writeOutput(output, new_output_type, temporary_terms);
|
||||
return;
|
||||
{
|
||||
case oMatlabDynamicModel:
|
||||
new_output_type = oMatlabDynamicSteadyStateOperator;
|
||||
break;
|
||||
case oLatexDynamicModel:
|
||||
new_output_type = oLatexDynamicSteadyStateOperator;
|
||||
break;
|
||||
case oCDynamicModel:
|
||||
cerr << "Steady State Operator not implemented for oCDynamicModel." << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
case oMatlabDynamicModelSparse:
|
||||
cerr << "Steady State Operator not implemented for oMatlabDynamicModelSparse." << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
default:
|
||||
new_output_type = output_type;
|
||||
break;
|
||||
}
|
||||
arg->writeOutput(output, new_output_type, temporary_terms);
|
||||
return;
|
||||
}
|
||||
|
||||
bool close_parenthesis = false;
|
||||
|
@ -988,7 +1002,7 @@ UnaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
|
|||
- current opcode is not uminus, or
|
||||
- current opcode is uminus and argument has lowest precedence
|
||||
*/
|
||||
if (op_code != oUminus
|
||||
if (op_code != oUminus
|
||||
|| (op_code == oUminus
|
||||
&& arg->precedence(output_type, temporary_terms) < precedence(output_type, temporary_terms)))
|
||||
{
|
||||
|
@ -1062,7 +1076,7 @@ UnaryOpNode::eval(const eval_context_type &eval_context) const throw (EvalExcept
|
|||
}
|
||||
|
||||
void
|
||||
UnaryOpNode::compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx, bool dynamic) const
|
||||
UnaryOpNode::compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx, bool dynamic, bool steady_dynamic) const
|
||||
{
|
||||
temporary_terms_type::const_iterator it = temporary_terms.find(const_cast<UnaryOpNode *>(this));
|
||||
if (it != temporary_terms.end())
|
||||
|
@ -1075,10 +1089,15 @@ UnaryOpNode::compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_t
|
|||
CompileCode.write(reinterpret_cast<char *>(&var), sizeof(var));
|
||||
return;
|
||||
}
|
||||
arg->compile(CompileCode, lhs_rhs, temporary_terms, map_idx, dynamic);
|
||||
CompileCode.write(&FUNARY, sizeof(FUNARY));
|
||||
UnaryOpcode op_codel=op_code;
|
||||
CompileCode.write(reinterpret_cast<char *>(&op_codel), sizeof(op_codel));
|
||||
if (op_code == oSteadyState)
|
||||
arg->compile(CompileCode, lhs_rhs, temporary_terms, map_idx, dynamic, true);
|
||||
else
|
||||
{
|
||||
arg->compile(CompileCode, lhs_rhs, temporary_terms, map_idx, dynamic, steady_dynamic);
|
||||
CompileCode.write(&FUNARY, sizeof(FUNARY));
|
||||
UnaryOpcode op_codel=op_code;
|
||||
CompileCode.write(reinterpret_cast<char *>(&op_codel), sizeof(op_codel));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1557,7 +1576,7 @@ BinaryOpNode::eval(const eval_context_type &eval_context) const throw (EvalExcep
|
|||
}
|
||||
|
||||
void
|
||||
BinaryOpNode::compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx, bool dynamic) const
|
||||
BinaryOpNode::compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx, bool dynamic, bool steady_dynamic) const
|
||||
{
|
||||
// If current node is a temporary term
|
||||
temporary_terms_type::const_iterator it = temporary_terms.find(const_cast<BinaryOpNode *>(this));
|
||||
|
@ -1571,8 +1590,8 @@ BinaryOpNode::compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_
|
|||
CompileCode.write(reinterpret_cast<char *>(&var), sizeof(var));
|
||||
return;
|
||||
}
|
||||
arg1->compile(CompileCode, lhs_rhs, temporary_terms, map_idx, dynamic);
|
||||
arg2->compile(CompileCode, lhs_rhs, temporary_terms, map_idx, dynamic);
|
||||
arg1->compile(CompileCode, lhs_rhs, temporary_terms, map_idx, dynamic, steady_dynamic);
|
||||
arg2->compile(CompileCode, lhs_rhs, temporary_terms, map_idx, dynamic, steady_dynamic);
|
||||
CompileCode.write(&FBINARY, sizeof(FBINARY));
|
||||
BinaryOpcode op_codel=op_code;
|
||||
CompileCode.write(reinterpret_cast<char *>(&op_codel),sizeof(op_codel));
|
||||
|
@ -2291,7 +2310,7 @@ TrinaryOpNode::eval(const eval_context_type &eval_context) const throw (EvalExce
|
|||
}
|
||||
|
||||
void
|
||||
TrinaryOpNode::compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx, bool dynamic) const
|
||||
TrinaryOpNode::compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx, bool dynamic, bool steady_dynamic) const
|
||||
{
|
||||
// If current node is a temporary term
|
||||
temporary_terms_type::const_iterator it = temporary_terms.find(const_cast<TrinaryOpNode *>(this));
|
||||
|
@ -2305,9 +2324,9 @@ TrinaryOpNode::compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms
|
|||
CompileCode.write(reinterpret_cast<char *>(&var), sizeof(var));
|
||||
return;
|
||||
}
|
||||
arg1->compile(CompileCode, lhs_rhs, temporary_terms, map_idx, dynamic);
|
||||
arg2->compile(CompileCode, lhs_rhs, temporary_terms, map_idx, dynamic);
|
||||
arg3->compile(CompileCode, lhs_rhs, temporary_terms, map_idx, dynamic);
|
||||
arg1->compile(CompileCode, lhs_rhs, temporary_terms, map_idx, dynamic, steady_dynamic);
|
||||
arg2->compile(CompileCode, lhs_rhs, temporary_terms, map_idx, dynamic, steady_dynamic);
|
||||
arg3->compile(CompileCode, lhs_rhs, temporary_terms, map_idx, dynamic, steady_dynamic);
|
||||
CompileCode.write(&FBINARY, sizeof(FBINARY));
|
||||
TrinaryOpcode op_codel=op_code;
|
||||
CompileCode.write(reinterpret_cast<char *>(&op_codel),sizeof(op_codel));
|
||||
|
@ -2497,7 +2516,7 @@ UnknownFunctionNode::eval(const eval_context_type &eval_context) const throw (Ev
|
|||
}
|
||||
|
||||
void
|
||||
UnknownFunctionNode::compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx, bool dynamic) const
|
||||
UnknownFunctionNode::compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx, bool dynamic, bool steady_dynamic) const
|
||||
{
|
||||
cerr << "UnknownFunctionNode::compile: operation impossible!" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
|
|
16
ExprNode.hh
16
ExprNode.hh
|
@ -76,7 +76,7 @@ enum ExprNodeOutputType
|
|||
|
||||
#define IS_LATEX(output_type) ((output_type) == oLatexStaticModel \
|
||||
|| (output_type) == oLatexDynamicModel \
|
||||
|| (output_type) == oLatexDynamicSteadyStateOperator)
|
||||
|| (output_type) == oLatexDynamicSteadyStateOperator)
|
||||
|
||||
/* Equal to 1 for Matlab langage, or to 0 for C language. Not defined for LaTeX.
|
||||
In Matlab, array indexes begin at 1, while they begin at 0 in C */
|
||||
|
@ -207,7 +207,7 @@ public:
|
|||
};
|
||||
|
||||
virtual double eval(const eval_context_type &eval_context) const throw (EvalException) = 0;
|
||||
virtual void compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx, bool dynamic) const = 0;
|
||||
virtual void compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx, bool dynamic, bool steady_dynamic) const = 0;
|
||||
//! Creates a static version of this node
|
||||
/*!
|
||||
This method duplicates the current node by creating a similar node from which all leads/lags have been stripped,
|
||||
|
@ -241,7 +241,7 @@ public:
|
|||
virtual void collectVariables(SymbolType type_arg, set<pair<int, int> > &result) const;
|
||||
virtual void collectTemporary_terms(const temporary_terms_type &temporary_terms, Model_Block *ModelBlock, int Curr_Block) const;
|
||||
virtual double eval(const eval_context_type &eval_context) const throw (EvalException);
|
||||
virtual void compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx, bool dynamic) const;
|
||||
virtual void compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx, bool dynamic, bool steady_dynamic) const;
|
||||
virtual NodeID toStatic(DataTree &static_datatree) const;
|
||||
virtual pair<int, NodeID> normalizeEquation(int symb_id_endo, vector<pair<int, pair<NodeID, NodeID> > > &List_of_Op_RHS) const;
|
||||
virtual NodeID getChainRuleDerivative(int deriv_id, const map<int, NodeID> &recursive_variables);
|
||||
|
@ -271,7 +271,7 @@ public:
|
|||
map_idx_type &map_idx) const;
|
||||
virtual void collectTemporary_terms(const temporary_terms_type &temporary_terms, Model_Block *ModelBlock, int Curr_Block) const;
|
||||
virtual double eval(const eval_context_type &eval_context) const throw (EvalException);
|
||||
virtual void compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx, bool dynamic) const;
|
||||
virtual void compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx, bool dynamic, bool steady_dynamic) const;
|
||||
virtual NodeID toStatic(DataTree &static_datatree) const;
|
||||
int get_symb_id() const { return symb_id; };
|
||||
virtual pair<int, NodeID> normalizeEquation(int symb_id_endo, vector<pair<int, pair<NodeID, NodeID> > > &List_of_Op_RHS) const;
|
||||
|
@ -303,7 +303,7 @@ public:
|
|||
virtual void collectTemporary_terms(const temporary_terms_type &temporary_terms, Model_Block *ModelBlock, int Curr_Block) const;
|
||||
static double eval_opcode(UnaryOpcode op_code, double v) throw (EvalException);
|
||||
virtual double eval(const eval_context_type &eval_context) const throw (EvalException);
|
||||
virtual void compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx, bool dynamic) const;
|
||||
virtual void compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx, bool dynamic, bool steady_dynamic) const;
|
||||
//! Returns operand
|
||||
NodeID get_arg() const { return(arg); };
|
||||
//! Returns op code
|
||||
|
@ -340,7 +340,7 @@ public:
|
|||
virtual void collectTemporary_terms(const temporary_terms_type &temporary_terms, Model_Block *ModelBlock, int Curr_Block) const;
|
||||
static double eval_opcode(double v1, BinaryOpcode op_code, double v2) throw (EvalException);
|
||||
virtual double eval(const eval_context_type &eval_context) const throw (EvalException);
|
||||
virtual void compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx, bool dynamic) const;
|
||||
virtual void compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx, bool dynamic, bool steady_dynamic) const;
|
||||
virtual NodeID Compute_RHS(NodeID arg1, NodeID arg2, int op, int op_type) const;
|
||||
//! Returns first operand
|
||||
NodeID get_arg1() const { return(arg1); };
|
||||
|
@ -381,7 +381,7 @@ public:
|
|||
virtual void collectTemporary_terms(const temporary_terms_type &temporary_terms, Model_Block *ModelBlock, int Curr_Block) const;
|
||||
static double eval_opcode(double v1, TrinaryOpcode op_code, double v2, double v3) throw (EvalException);
|
||||
virtual double eval(const eval_context_type &eval_context) const throw (EvalException);
|
||||
virtual void compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx, bool dynamic) const;
|
||||
virtual void compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx, bool dynamic, bool steady_dynamic) const;
|
||||
virtual NodeID toStatic(DataTree &static_datatree) const;
|
||||
virtual pair<int, NodeID> normalizeEquation(int symb_id_endo, vector<pair<int, pair<NodeID, NodeID> > > &List_of_Op_RHS) const;
|
||||
virtual NodeID getChainRuleDerivative(int deriv_id, const map<int, NodeID> &recursive_variables);
|
||||
|
@ -409,7 +409,7 @@ public:
|
|||
virtual void collectVariables(SymbolType type_arg, set<pair<int, int> > &result) const;
|
||||
virtual void collectTemporary_terms(const temporary_terms_type &temporary_terms, Model_Block *ModelBlock, int Curr_Block) const;
|
||||
virtual double eval(const eval_context_type &eval_context) const throw (EvalException);
|
||||
virtual void compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx, bool dynamic) const;
|
||||
virtual void compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx, bool dynamic, bool steady_dynamic) const;
|
||||
virtual NodeID toStatic(DataTree &static_datatree) const;
|
||||
virtual pair<int, NodeID> normalizeEquation(int symb_id_endo, vector<pair<int, pair<NodeID, NodeID> > > &List_of_Op_RHS) const;
|
||||
virtual NodeID getChainRuleDerivative(int deriv_id, const map<int, NodeID> &recursive_variables);
|
||||
|
|
|
@ -60,7 +60,7 @@ StaticDllModel::compileDerivative(ofstream &code_file, int eq, int symb_id, int
|
|||
//first_derivatives_type::const_iterator it = first_derivatives.find(make_pair(eq, getDerivID(symb_id, lag)));
|
||||
first_derivatives_type::const_iterator it = first_derivatives.find(make_pair(eq, getDerivID(symbol_table.getID(eEndogenous, symb_id), lag)));
|
||||
if (it != first_derivatives.end())
|
||||
(it->second)->compile(code_file, false, temporary_terms, map_idx, false);
|
||||
(it->second)->compile(code_file, false, temporary_terms, map_idx, false, false);
|
||||
else
|
||||
code_file.write(&FLDZ, sizeof(FLDZ));
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ StaticDllModel::compileChainRuleDerivative(ofstream &code_file, int eqr, int var
|
|||
{
|
||||
map<pair<int, pair<int, int> >, NodeID>::const_iterator it = first_chain_rule_derivatives.find(make_pair(eqr, make_pair(varr, lag)));
|
||||
if (it != first_chain_rule_derivatives.end())
|
||||
(it->second)->compile(code_file, false, temporary_terms, map_idx, false);
|
||||
(it->second)->compile(code_file, false, temporary_terms, map_idx, false, false);
|
||||
else
|
||||
code_file.write(&FLDZ, sizeof(FLDZ));
|
||||
}
|
||||
|
@ -435,7 +435,7 @@ StaticDllModel::writeModelEquationsCodeOrdered(const string file_name, const Mod
|
|||
for (temporary_terms_type::const_iterator it = ModelBlock->Block_List[j].Temporary_Terms_in_Equation[i]->begin();
|
||||
it != ModelBlock->Block_List[j].Temporary_Terms_in_Equation[i]->end(); it++)
|
||||
{
|
||||
(*it)->compile(code_file, false, tt2, map_idx, false);
|
||||
(*it)->compile(code_file, false, tt2, map_idx, false, false);
|
||||
code_file.write(&FSTPST, sizeof(FSTPST));
|
||||
map_idx_type::const_iterator ii=map_idx.find((*it)->idx);
|
||||
v=(int)ii->second;
|
||||
|
@ -453,16 +453,16 @@ evaluation:
|
|||
eq_node = equations[ModelBlock->Block_List[j].Equation[i]];
|
||||
lhs = eq_node->get_arg1();
|
||||
rhs = eq_node->get_arg2();
|
||||
rhs->compile(code_file, false, temporary_terms, map_idx, false);
|
||||
lhs->compile(code_file, true, temporary_terms, map_idx, false);
|
||||
rhs->compile(code_file, false, temporary_terms, map_idx, false, false);
|
||||
lhs->compile(code_file, true, temporary_terms, map_idx, false, false);
|
||||
}
|
||||
else if (ModelBlock->Block_List[j].Equation_Type[i] == E_EVALUATE_S)
|
||||
{
|
||||
eq_node = (BinaryOpNode*)ModelBlock->Block_List[j].Equation_Normalized[i];
|
||||
lhs = eq_node->get_arg1();
|
||||
rhs = eq_node->get_arg2();
|
||||
rhs->compile(code_file, false, temporary_terms, map_idx, false);
|
||||
lhs->compile(code_file, true, temporary_terms, map_idx, false);
|
||||
rhs->compile(code_file, false, temporary_terms, map_idx, false, false);
|
||||
lhs->compile(code_file, true, temporary_terms, map_idx, false, false);
|
||||
}
|
||||
break;
|
||||
case SOLVE_BACKWARD_COMPLETE:
|
||||
|
@ -478,8 +478,8 @@ end:
|
|||
eq_node = equations[ModelBlock->Block_List[j].Equation[i]];
|
||||
lhs = eq_node->get_arg1();
|
||||
rhs = eq_node->get_arg2();
|
||||
lhs->compile(code_file, false, temporary_terms, map_idx, false);
|
||||
rhs->compile(code_file, false, temporary_terms, map_idx, false);
|
||||
lhs->compile(code_file, false, temporary_terms, map_idx, false, false);
|
||||
rhs->compile(code_file, false, temporary_terms, map_idx, false, false);
|
||||
code_file.write(&FBINARY, sizeof(FBINARY));
|
||||
int v=oMinus;
|
||||
code_file.write(reinterpret_cast<char *>(&v),sizeof(v));
|
||||
|
|
Loading…
Reference in New Issue