preprocessor: initialize xref structure and use indices. closes #1125

time-shift
Houtan Bastani 2016-02-23 14:32:48 +01:00
parent 710e8ef3a5
commit 458cfc4fc6
2 changed files with 18 additions and 9 deletions

View File

@ -11,7 +11,7 @@ function global_initialization()
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2003-2015 Dynare Team
% Copyright (C) 2003-2016 Dynare Team
%
% This file is part of Dynare.
%
@ -510,12 +510,12 @@ M_.Correlation_matrix = [];
M_.Correlation_matrix_ME = [];
M_.parameter_used_with_lead_lag = false;
M_.xref1.params = {};
M_.xref1.param = {};
M_.xref1.endo = {};
M_.xref1.exo = {};
M_.xref1.exo_det = {};
M_.xref2.params = {};
M_.xref2.param = {};
M_.xref2.endo = {};
M_.xref2.exo = {};
M_.xref2.exo_det = {};

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2003-2015 Dynare Team
* Copyright (C) 2003-2016 Dynare Team
*
* This file is part of Dynare.
*
@ -269,28 +269,37 @@ ModelTree::computeRevXref(map<int, set<int> > &xrefset, const set<int> &eiref, i
void
ModelTree::writeXrefs(ostream &output) const
{
output << "M_.xref1.param = cell(1, M_.eq_nbr);" << endl
<< "M_.xref1.endo = cell(1, M_.eq_nbr);" << endl
<< "M_.xref1.exo = cell(1, M_.eq_nbr);" << endl
<< "M_.xref1.exo_det = cell(1, M_.eq_nbr);" << endl
<< "M_.xref2.param = cell(1, M_.eq_nbr);" << endl
<< "M_.xref2.endo = cell(1, M_.eq_nbr);" << endl
<< "M_.xref2.exo = cell(1, M_.eq_nbr);" << endl
<< "M_.xref2.exo_det = cell(1, M_.eq_nbr);" << endl;
int i = 1;
for (map<int, ExprNode::EquationInfo>::const_iterator it = xrefs.begin();
it != xrefs.end(); it++)
it != xrefs.end(); it++, i++)
{
output << "M_.xref1.params{end+1} = [ ";
output << "M_.xref1.param{" << i << "} = [ ";
for (set<int>::const_iterator it1 = it->second.param.begin();
it1 != it->second.param.end(); it1++)
output << symbol_table.getTypeSpecificID(*it1) + 1 << " ";
output << "];" << endl;
output << "M_.xref1.endo{end+1} = [ ";
output << "M_.xref1.endo{" << i << "} = [ ";
for (set<int>::const_iterator it1 = it->second.endo.begin();
it1 != it->second.endo.end(); it1++)
output << symbol_table.getTypeSpecificID(*it1) + 1 << " ";
output << "];" << endl;
output << "M_.xref1.exo{end+1} = [ ";
output << "M_.xref1.exo{" << i << "} = [ ";
for (set<int>::const_iterator it1 = it->second.exo.begin();
it1 != it->second.exo.end(); it1++)
output << symbol_table.getTypeSpecificID(*it1) + 1 << " ";
output << "];" << endl;
output << "M_.xref1.exo_det{end+1} = [ ";
output << "M_.xref1.exo_det{" << i << "} = [ ";
for (set<int>::const_iterator it1 = it->second.exo_det.begin();
it1 != it->second.exo_det.end(); it1++)
output << symbol_table.getTypeSpecificID(*it1) + 1 << " ";