Preprocessor: various minor changes, including

* moved some declarations from ExprNode.hh to BlockTriangular.hh to which they conceptually belong
* replaced non standard boolean operators (and, or, not) by standard ones (&&, ||, !)


git-svn-id: https://www.dynare.org/svn/dynare/trunk@2812 ac1d8469-bf42-47a9-8791-bf33cf982152
issue#70
sebastien 2009-07-06 10:36:36 +00:00
parent a8c2baa936
commit 9595358690
8 changed files with 96 additions and 113 deletions

View File

@ -42,6 +42,49 @@ typedef vector<pair<EquationType, NodeID > > t_etype;
//! Vector describing variables: max_lag in the block, max_lead in the block
typedef vector<pair< int, int> > t_vtype;
typedef set<int> temporary_terms_inuse_type;
//! For one lead/lag of one block, stores mapping of information between original model and block-decomposed model
struct IM_compact
{
int size, u_init, u_finish, nb_endo, nb_other_endo, size_exo, size_other_endo;
int *u, *us, *Var, *Equ, *Var_Index, *Equ_Index, *Exogenous, *Exogenous_Index, *Equ_X, *Equ_X_Index;
int *u_other_endo, *Var_other_endo, *Equ_other_endo, *Var_Index_other_endo, *Equ_Index_other_endo;
};
//! One block of the model
struct Block
{
int Size, Sized, nb_exo, nb_exo_det, nb_other_endo, Nb_Recursives;
BlockType Type;
BlockSimulationType Simulation_Type;
int Max_Lead, Max_Lag, Nb_Lead_Lag_Endo;
int Max_Lag_Endo, Max_Lead_Endo;
int Max_Lag_Other_Endo, Max_Lead_Other_Endo;
int Max_Lag_Exo, Max_Lead_Exo;
bool is_linear;
int *Equation, *Own_Derivative;
EquationType *Equation_Type;
NodeID *Equation_Normalized;
int *Variable, *Other_Endogenous, *Exogenous;
temporary_terms_type **Temporary_Terms_in_Equation;
//temporary_terms_type *Temporary_terms;
temporary_terms_inuse_type *Temporary_InUse;
IM_compact *IM_lead_lag;
int Code_Start, Code_Length;
};
//! The set of all blocks of the model
struct Model_Block
{
int Size, Periods;
Block* Block_List;
//int *in_Block_Equ, *in_Block_Var, *in_Equ_of_Block, *in_Var_of_Block;
};
//! Creates the incidence matrix, computes prologue & epilogue, normalizes the model and computes the block decomposition
class BlockTriangular
{

View File

@ -17,11 +17,11 @@
* along with Dynare. If not, see <http://www.gnu.org/licenses/>.
*/
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include "DynamicModel.hh"
// For mkdir() and chdir()

View File

@ -22,6 +22,8 @@
using namespace std;
#include <fstream>
#include "StaticModel.hh"
#include "BlockTriangular.hh"

View File

@ -26,6 +26,7 @@
#include "ExprNode.hh"
#include "DataTree.hh"
#include "BlockTriangular.hh"
ExprNode::ExprNode(DataTree &datatree_arg) : datatree(datatree_arg)
{
@ -94,13 +95,6 @@ ExprNode::computeTemporaryTerms(map<NodeID, int> &reference_count,
// Nothing to do for a terminal node
}
void
ExprNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
const temporary_terms_type &temporary_terms) const
{
//writeOutput(output, oMatlabOutsideModel, temporary_terms_type());
}
void
ExprNode::writeOutput(ostream &output)
@ -108,11 +102,6 @@ ExprNode::writeOutput(ostream &output)
writeOutput(output, oMatlabOutsideModel, temporary_terms_type());
}
pair<bool, NodeID>
ExprNode::normalizeLinearInEndoEquation(int var_endo, NodeID Derivative) const
{
return(make_pair(true, (NodeID)NULL));
}
NumConstNode::NumConstNode(DataTree &datatree_arg, int id_arg) :
ExprNode(datatree_arg),
@ -160,7 +149,7 @@ NumConstNode::eval(const eval_context_type &eval_context) const throw (EvalExcep
}
void
NumConstNode::compile(ofstream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx) const
NumConstNode::compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx) const
{
CompileCode.write(&FLDC, sizeof(FLDC));
double vard = datatree.num_constants.getDouble(id);
@ -448,7 +437,7 @@ VariableNode::eval(const eval_context_type &eval_context) const throw (EvalExcep
}
void
VariableNode::compile(ofstream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx) const
VariableNode::compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx) const
{
int i, lagl;
#ifdef DEBUGC
@ -543,7 +532,7 @@ VariableNode::normalizeLinearInEndoEquation(int var_endo, NodeID Derivative) con
{
if (type ==eEndogenous)
{
if (datatree.symbol_table.getTypeSpecificID(symb_id)==var_endo and lag==0)
if (datatree.symbol_table.getTypeSpecificID(symb_id)==var_endo && lag==0)
return(make_pair(true, (NodeID)NULL));
else
return(make_pair(false, datatree.AddVariableInternal(datatree.symbol_table.getName(symb_id), lag)));
@ -557,19 +546,6 @@ VariableNode::normalizeLinearInEndoEquation(int var_endo, NodeID Derivative) con
}
}
template<class InputIterator, class T>
pair<InputIterator, int> find_r ( InputIterator first, InputIterator last, const T& value )
{
int i=0;
for (; first!=last; first++)
{
if ( *first==value ) break;
i++;
}
return make_pair(first, i);
}
NodeID
VariableNode::getChainRuleDerivative(int deriv_id_arg, const map<int, NodeID> &recursive_variables)
{
@ -1003,7 +979,7 @@ UnaryOpNode::eval(const eval_context_type &eval_context) const throw (EvalExcept
}
void
UnaryOpNode::compile(ofstream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx) const
UnaryOpNode::compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx) const
{
temporary_terms_type::const_iterator it = temporary_terms.find(const_cast<UnaryOpNode *>(this));
if (it != temporary_terms.end())
@ -1037,7 +1013,7 @@ UnaryOpNode::normalizeLinearInEndoEquation(int var_endo, NodeID Derivative) cons
pair<bool, NodeID> res = arg->normalizeLinearInEndoEquation(var_endo, Derivative);
bool is_endogenous_present = res.first;
NodeID New_NodeID = res.second;
if (not is_endogenous_present)
if (!is_endogenous_present)
{
switch (op_code)
{
@ -1447,7 +1423,7 @@ BinaryOpNode::eval(const eval_context_type &eval_context) const throw (EvalExcep
}
void
BinaryOpNode::compile(ofstream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx) const
BinaryOpNode::compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx) const
{
// If current node is a temporary term
temporary_terms_type::const_iterator it = temporary_terms.find(const_cast<BinaryOpNode *>(this));
@ -1667,63 +1643,63 @@ BinaryOpNode::normalizeLinearInEndoEquation(int var_endo, NodeID Derivative) con
switch (op_code)
{
case oPlus:
if (not is_endogenous_present_1 and not is_endogenous_present_2)
if (!is_endogenous_present_1 && !is_endogenous_present_2)
return(make_pair(false, /*tmp_*/datatree.AddPlus(NodeID_1, NodeID_2)));
else if (is_endogenous_present_1 and is_endogenous_present_2)
else if (is_endogenous_present_1 && is_endogenous_present_2)
return(make_pair(true, (NodeID)NULL));
else if (not is_endogenous_present_1 and is_endogenous_present_2)
else if (!is_endogenous_present_1 && is_endogenous_present_2)
return(make_pair(false, NodeID_1));
else if (is_endogenous_present_1 and not is_endogenous_present_2)
else if (is_endogenous_present_1 && !is_endogenous_present_2)
return(make_pair(false, NodeID_2));
break;
case oMinus:
if (not is_endogenous_present_1 and not is_endogenous_present_2)
if (!is_endogenous_present_1 && !is_endogenous_present_2)
return(make_pair(false, /*tmp_*/datatree.AddMinus(NodeID_1, NodeID_2)));
else if (is_endogenous_present_1 and is_endogenous_present_2)
else if (is_endogenous_present_1 && is_endogenous_present_2)
return(make_pair(true, (NodeID)NULL));
else if (not is_endogenous_present_1 and is_endogenous_present_2)
else if (!is_endogenous_present_1 && is_endogenous_present_2)
return(make_pair(false, NodeID_1));
else if (is_endogenous_present_1 and not is_endogenous_present_2)
else if (is_endogenous_present_1 && !is_endogenous_present_2)
return(make_pair(false, /*tmp_*/datatree.AddUMinus(NodeID_2)));
break;
case oTimes:
if (not is_endogenous_present_1 and not is_endogenous_present_2)
if (!is_endogenous_present_1 && !is_endogenous_present_2)
return(make_pair(false, /*tmp_*/datatree.AddTimes(NodeID_1, NodeID_2)));
else
return(make_pair(true, (NodeID)NULL));
break;
case oDivide:
if (not is_endogenous_present_1 and not is_endogenous_present_2)
if (!is_endogenous_present_1 && !is_endogenous_present_2)
return(make_pair(false, datatree.AddDivide(NodeID_1, NodeID_2)));
else
return(make_pair(true, (NodeID)NULL));
break;
case oPower:
if (not is_endogenous_present_1 and not is_endogenous_present_2)
if (!is_endogenous_present_1 && !is_endogenous_present_2)
return(make_pair(false, datatree.AddPower(NodeID_1, NodeID_2)));
else
return(make_pair(true, (NodeID)NULL));
break;
case oEqual:
if (not is_endogenous_present_1 and not is_endogenous_present_2)
if (!is_endogenous_present_1 && !is_endogenous_present_2)
{
if (Derivative!=datatree.One)
return( make_pair(false, datatree.AddEqual(datatree.AddVariable(datatree.symbol_table.getName(datatree.symbol_table.getID(eEndogenous, var_endo)), 0), datatree.AddDivide(datatree.AddMinus(NodeID_2, NodeID_1), Derivative))) );
else
return( make_pair(false, datatree.AddEqual(datatree.AddVariable(datatree.symbol_table.getName(datatree.symbol_table.getID(eEndogenous, var_endo)), 0), datatree.AddMinus(NodeID_2, NodeID_1))) );
}
else if (is_endogenous_present_1 and is_endogenous_present_2)
else if (is_endogenous_present_1 && is_endogenous_present_2)
{
return(make_pair(false, datatree.AddEqual(datatree.AddVariable(datatree.symbol_table.getName(datatree.symbol_table.getID(eEndogenous, var_endo)), 0), datatree.Zero)));
}
else if (not is_endogenous_present_1 and is_endogenous_present_2)
else if (!is_endogenous_present_1 && is_endogenous_present_2)
{
if (Derivative!=datatree.One)
return(make_pair(false, datatree.AddEqual(datatree.AddVariable(datatree.symbol_table.getName(datatree.symbol_table.getID(eEndogenous, var_endo)), 0), datatree.AddDivide(datatree.AddUMinus(NodeID_1), Derivative))));
else
return(make_pair(false, datatree.AddEqual(datatree.AddVariable(datatree.symbol_table.getName(datatree.symbol_table.getID(eEndogenous, var_endo)), 0), datatree.AddUMinus(NodeID_1))));
}
else if (is_endogenous_present_1 and not is_endogenous_present_2)
else if (is_endogenous_present_1 && !is_endogenous_present_2)
{
if (Derivative!=datatree.One)
return(make_pair(false, datatree.AddEqual(datatree.AddVariable(datatree.symbol_table.getName(datatree.symbol_table.getID(eEndogenous, var_endo)), 0), datatree.AddDivide(NodeID_2, Derivative))));
@ -1732,49 +1708,49 @@ BinaryOpNode::normalizeLinearInEndoEquation(int var_endo, NodeID Derivative) con
}
break;
case oMax:
if (not is_endogenous_present_1 and not is_endogenous_present_2)
if (!is_endogenous_present_1 && !is_endogenous_present_2)
return(make_pair(false, datatree.AddMax(NodeID_1, NodeID_2)));
else
return(make_pair(true, (NodeID)NULL));
break;
case oMin:
if (not is_endogenous_present_1 and not is_endogenous_present_2)
if (!is_endogenous_present_1 && !is_endogenous_present_2)
return(make_pair(false, datatree.AddMin(NodeID_1, NodeID_2)));
else
return(make_pair(true, (NodeID)NULL));
break;
case oLess:
if (not is_endogenous_present_1 and not is_endogenous_present_2)
if (!is_endogenous_present_1 && !is_endogenous_present_2)
return(make_pair(false, /*tmp_*/datatree.AddLess(NodeID_1, NodeID_2)));
else
return(make_pair(true, (NodeID)NULL));
break;
case oGreater:
if (not is_endogenous_present_1 and not is_endogenous_present_2)
if (!is_endogenous_present_1 && !is_endogenous_present_2)
return(make_pair(false, /*tmp_*/datatree.AddGreater(NodeID_1, NodeID_2)));
else
return(make_pair(true, (NodeID)NULL));
break;
case oLessEqual:
if (not is_endogenous_present_1 and not is_endogenous_present_2)
if (!is_endogenous_present_1 && !is_endogenous_present_2)
return(make_pair(false, /*tmp_*/datatree.AddLessEqual(NodeID_1, NodeID_2)));
else
return(make_pair(true, (NodeID)NULL));
break;
case oGreaterEqual:
if (not is_endogenous_present_1 and not is_endogenous_present_2)
if (!is_endogenous_present_1 && !is_endogenous_present_2)
return(make_pair(false, /*tmp_*/datatree.AddGreaterEqual(NodeID_1, NodeID_2)));
else
return(make_pair(true, (NodeID)NULL));
break;
case oEqualEqual:
if (not is_endogenous_present_1 and not is_endogenous_present_2)
if (!is_endogenous_present_1 && !is_endogenous_present_2)
return(make_pair(false, /*tmp_*/datatree.AddEqualEqual(NodeID_1, NodeID_2)));
else
return(make_pair(true, (NodeID)NULL));
break;
case oDifferent:
if (not is_endogenous_present_1 and not is_endogenous_present_2)
if (!is_endogenous_present_1 && !is_endogenous_present_2)
return(make_pair(false, /*tmp_*/datatree.AddDifferent(NodeID_1, NodeID_2)));
else
return(make_pair(true, (NodeID)NULL));
@ -2042,7 +2018,7 @@ TrinaryOpNode::eval(const eval_context_type &eval_context) const throw (EvalExce
}
void
TrinaryOpNode::compile(ofstream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx) const
TrinaryOpNode::compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx) const
{
// If current node is a temporary term
temporary_terms_type::const_iterator it = temporary_terms.find(const_cast<TrinaryOpNode *>(this));
@ -2133,7 +2109,7 @@ TrinaryOpNode::normalizeLinearInEndoEquation(int var_endo, NodeID Derivative) co
res = arg3->normalizeLinearInEndoEquation(var_endo, Derivative);
bool is_endogenous_present_3 = res.first;
NodeID NodeID_3 = res.second;
if (not is_endogenous_present_1 and not is_endogenous_present_2 and not is_endogenous_present_3)
if (!is_endogenous_present_1 && !is_endogenous_present_2 && !is_endogenous_present_3)
return(make_pair(false, /*tmp_*/datatree.AddNormcdf(NodeID_1, NodeID_2, NodeID_3)));
else
return(make_pair(true, (NodeID)NULL));
@ -2261,7 +2237,7 @@ UnknownFunctionNode::eval(const eval_context_type &eval_context) const throw (Ev
}
void
UnknownFunctionNode::compile(ofstream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx) const
UnknownFunctionNode::compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx) const
{
cerr << "UnknownFunctionNode::compile: operation impossible!" << endl;
exit(EXIT_FAILURE);
@ -2277,10 +2253,10 @@ UnknownFunctionNode::normalizeLinearInEndoEquation(int var_endo, NodeID Derivati
it != arguments.end(); it++)
{
V_arguments.push_back((*it)->normalizeLinearInEndoEquation(var_endo, Derivative));
present = present or V_arguments[V_arguments.size()-1].first;
present = present || V_arguments[V_arguments.size()-1].first;
V_NodeID.push_back(V_arguments[V_arguments.size()-1].second);
}
if (not present)
if (!present)
return(make_pair(false, datatree.AddUnknownFunction(datatree.symbol_table.getName(symb_id), V_NodeID)));
else
return(make_pair(true, (NodeID)NULL));

View File

@ -25,8 +25,7 @@ using namespace std;
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <fstream>
#include <ostream>
#include "SymbolTable.hh"
#include "CodeInterpreter.hh"
@ -44,7 +43,6 @@ struct ExprNodeLess;
typedef set<NodeID, ExprNodeLess> temporary_terms_type;
typedef map<int,int> map_idx_type;
typedef set<int> temporary_terms_inuse_type;
//! Type for evaluation contexts
/*! The key is a symbol id. Lags are assumed to be null */
@ -152,7 +150,7 @@ public:
virtual void computeTemporaryTerms(map<NodeID, int> &reference_count, temporary_terms_type &temporary_terms, bool is_matlab) const;
//! Writes output of node, using a Txxx notation for nodes in temporary_terms
virtual void writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_type &temporary_terms) const /*= 0*/;
virtual void writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_type &temporary_terms) const = 0;
//! Writes output of node (with no temporary terms and with "outside model" output type)
void writeOutput(ostream &output);
@ -186,7 +184,7 @@ public:
};
virtual double eval(const eval_context_type &eval_context) const throw (EvalException) = 0;
virtual void compile(ofstream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx) const = 0;
virtual void compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx) 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,
@ -194,7 +192,7 @@ public:
*/
virtual NodeID toStatic(DataTree &static_datatree) const = 0;
//! Try to normalize an equation linear in its endogenous variable
virtual pair<bool, NodeID> normalizeLinearInEndoEquation(int symb_id_endo, NodeID Derivative) const;
virtual pair<bool, NodeID> normalizeLinearInEndoEquation(int symb_id_endo, NodeID Derivative) const = 0;
};
//! Object used to compare two nodes (using their indexes)
@ -221,7 +219,7 @@ public:
virtual void collectExogenous(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(ofstream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx) const;
virtual void compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx) const;
virtual NodeID toStatic(DataTree &static_datatree) const;
virtual pair<bool, NodeID> normalizeLinearInEndoEquation(int symb_id_endo, NodeID Derivative) const;
virtual NodeID getChainRuleDerivative(int deriv_id, const map<int, NodeID> &recursive_variables);
@ -240,7 +238,7 @@ private:
virtual NodeID computeDerivative(int deriv_id_arg);
public:
VariableNode(DataTree &datatree_arg, int symb_id_arg, int lag_arg, int deriv_id_arg);
virtual void writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_type &temporary_terms = temporary_terms_type()) const;
virtual void writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_type &temporary_terms) const;
virtual void collectEndogenous(set<pair<int, int> > &result) const;
virtual void collectExogenous(set<pair<int, int> > &result) const;
virtual void computeTemporaryTerms(map<NodeID, int> &reference_count,
@ -252,7 +250,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(ofstream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx) const;
virtual void compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx) const;
virtual NodeID toStatic(DataTree &static_datatree) const;
int get_symb_id() const { return symb_id; };
virtual pair<bool, NodeID> normalizeLinearInEndoEquation(int symb_id_endo, NodeID Derivative) const;
@ -285,7 +283,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(ofstream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx) const;
virtual void compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx) const;
//! Returns operand
NodeID get_arg() const { return(arg); };
//! Returns op code
@ -323,7 +321,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(ofstream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx) const;
virtual void compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx) const;
//! Returns first operand
NodeID get_arg1() const { return(arg1); };
//! Returns second operand
@ -364,7 +362,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(ofstream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx) const;
virtual void compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx) const;
virtual NodeID toStatic(DataTree &static_datatree) const;
virtual pair<bool, NodeID> normalizeLinearInEndoEquation(int symb_id_endo, NodeID Derivative) const;
virtual NodeID getChainRuleDerivative(int deriv_id, const map<int, NodeID> &recursive_variables);
@ -393,50 +391,10 @@ public:
virtual void collectExogenous(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(ofstream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx) const;
virtual void compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_type &temporary_terms, map_idx_type &map_idx) const;
virtual NodeID toStatic(DataTree &static_datatree) const;
virtual pair<bool, NodeID> normalizeLinearInEndoEquation(int symb_id_endo, NodeID Derivative) const;
virtual NodeID getChainRuleDerivative(int deriv_id, const map<int, NodeID> &recursive_variables);
};
//! For one lead/lag of one block, stores mapping of information between original model and block-decomposed model
struct IM_compact
{
int size, u_init, u_finish, nb_endo, nb_other_endo, size_exo, size_other_endo;
int *u, *us, *Var, *Equ, *Var_Index, *Equ_Index, *Exogenous, *Exogenous_Index, *Equ_X, *Equ_X_Index;
int *u_other_endo, *Var_other_endo, *Equ_other_endo, *Var_Index_other_endo, *Equ_Index_other_endo;
};
//! One block of the model
struct Block
{
int Size, Sized, nb_exo, nb_exo_det, nb_other_endo, Nb_Recursives;
BlockType Type;
BlockSimulationType Simulation_Type;
int Max_Lead, Max_Lag, Nb_Lead_Lag_Endo;
int Max_Lag_Endo, Max_Lead_Endo;
int Max_Lag_Other_Endo, Max_Lead_Other_Endo;
int Max_Lag_Exo, Max_Lead_Exo;
bool is_linear;
int *Equation, *Own_Derivative;
EquationType *Equation_Type;
NodeID *Equation_Normalized;
int *Variable, *Other_Endogenous, *Exogenous;
temporary_terms_type **Temporary_Terms_in_Equation;
//temporary_terms_type *Temporary_terms;
temporary_terms_inuse_type *Temporary_InUse;
IM_compact *IM_lead_lag;
int Code_Start, Code_Length;
};
//! The set of all blocks of the model
struct Model_Block
{
int Size, Periods;
Block* Block_List;
//int *in_Block_Equ, *in_Block_Var, *in_Equ_of_Block, *in_Var_of_Block;
};
#endif

View File

@ -17,6 +17,7 @@
* along with Dynare. If not, see <http://www.gnu.org/licenses/>.
*/
#include <iostream>
#include <cstdlib>
#include <cstring>

View File

@ -20,6 +20,7 @@
#include <cstdlib>
#include <cassert>
#include <iostream>
#include <fstream>
#include "ModelTree.hh"

View File

@ -17,6 +17,8 @@
* along with Dynare. If not, see <http://www.gnu.org/licenses/>.
*/
#include <iostream>
#include <fstream>
#include <cstdlib>
#include "NumericalInitialization.hh"