diff --git a/parser.src/BlockTriangular.cc b/parser.src/BlockTriangular.cc
index ddc9bff9d..ffa586b64 100644
--- a/parser.src/BlockTriangular.cc
+++ b/parser.src/BlockTriangular.cc
@@ -384,7 +384,7 @@ BlockTriangular::getMax_Lead_Lag_B(int size, int* Equation, int *Variable, int *
void
-BlockTriangular::Allocate_Block(int size, int *count_Equ, int *count_Block, int type, Model_Block * ModelBlock, int* Table, int TableSize)
+BlockTriangular::Allocate_Block(int size, int *count_Equ, int *count_Block, int type, Model_Block * ModelBlock)
{
int i, j, k, l, ls, m, i_1, Lead, Lag, size_list_lead_var, first_count_equ, i1;
int *list_lead_var, *tmp_size, *tmp_var, *tmp_endo, nb_lead_lag_endo;
@@ -882,16 +882,16 @@ BlockTriangular::Normalize_and_BlockDecompose(bool* IM, Model_Block* ModelBlock,
Free_IM(p_First_IM);
count_Equ = count_Block = 0;
if (*prologue)
- Allocate_Block(*prologue, &count_Equ, &count_Block, PROLOGUE, ModelBlock, Table, TableSize);
+ Allocate_Block(*prologue, &count_Equ, &count_Block, PROLOGUE, ModelBlock);
for(j = 0;j < res->n_sets;j++)
{
if(res->sets_f[res->ordered[j]] == res->sets_s[res->ordered[j]])
- Allocate_Block(res->sets_f[res->ordered[j]] - res->sets_s[res->ordered[j]] + 1, &count_Equ, &count_Block, PROLOGUE, ModelBlock, Table, TableSize);
+ Allocate_Block(res->sets_f[res->ordered[j]] - res->sets_s[res->ordered[j]] + 1, &count_Equ, &count_Block, PROLOGUE, ModelBlock);
else
- Allocate_Block(res->sets_f[res->ordered[j]] - res->sets_s[res->ordered[j]] + 1, &count_Equ, &count_Block, SIMULTANS, ModelBlock, Table, TableSize);
+ Allocate_Block(res->sets_f[res->ordered[j]] - res->sets_s[res->ordered[j]] + 1, &count_Equ, &count_Block, SIMULTANS, ModelBlock);
}
if (*epilogue)
- Allocate_Block(*epilogue, &count_Equ, &count_Block, EPILOGUE, ModelBlock, Table, TableSize);
+ Allocate_Block(*epilogue, &count_Equ, &count_Block, EPILOGUE, ModelBlock);
return 0;
}
@@ -984,16 +984,16 @@ BlockTriangular::Normalize_and_BlockDecompose(bool* IM, Model_Block* ModelBlock,
Free_IM(p_First_IM);
count_Equ = count_Block = 0;
if (*prologue)
- Allocate_Block(*prologue, &count_Equ, &count_Block, PROLOGUE, ModelBlock, Table, TableSize);
+ Allocate_Block(*prologue, &count_Equ, &count_Block, PROLOGUE, ModelBlock);
for(j = 0;j < res->n_sets;j++)
{
if(res->sets_f[res->ordered[j]] == res->sets_s[res->ordered[j]])
- Allocate_Block(res->sets_f[res->ordered[j]] - res->sets_s[res->ordered[j]] + 1, &count_Equ, &count_Block, PROLOGUE, ModelBlock, Table, TableSize);
+ Allocate_Block(res->sets_f[res->ordered[j]] - res->sets_s[res->ordered[j]] + 1, &count_Equ, &count_Block, PROLOGUE, ModelBlock);
else
- Allocate_Block(res->sets_f[res->ordered[j]] - res->sets_s[res->ordered[j]] + 1, &count_Equ, &count_Block, SIMULTANS, ModelBlock, Table, TableSize);
+ Allocate_Block(res->sets_f[res->ordered[j]] - res->sets_s[res->ordered[j]] + 1, &count_Equ, &count_Block, SIMULTANS, ModelBlock);
}
if (*epilogue)
- Allocate_Block(*epilogue, &count_Equ, &count_Block, EPILOGUE, ModelBlock, Table, TableSize);
+ Allocate_Block(*epilogue, &count_Equ, &count_Block, EPILOGUE, ModelBlock);
return 0;
}
@@ -1188,11 +1188,3 @@ BlockTriangular::Normalize_and_BlockDecompose_Static_0_Model(const jacob_map &j_
for(i = 0;i < endo_nbr;i++)
cout << "Block=" << Index_Equ_IM[i].block << " Equ=" << Index_Equ_IM[i].index << " Var= " << Index_Var_IM[i].index << " " << symbol_table.getNameByID(eEndogenous, Index_Var_IM[i].index) << "\n";
}
-
-void
-BlockTriangular::SetVariableTable(int *Table, int Size, int HSize)
-{
- BlockTriangular::Table = Table;
- TableSize = Size;
-}
-
diff --git a/parser.src/ExprNode.cc b/parser.src/ExprNode.cc
index 14da6ee00..f3b36bbe9 100644
--- a/parser.src/ExprNode.cc
+++ b/parser.src/ExprNode.cc
@@ -190,7 +190,7 @@ VariableNode::VariableNode(DataTree &datatree_arg, int symb_id_arg, Type type_ar
|| type == eExogenousDet
|| type == eExogenous
|| type == eRecursiveVariable)
- var_id = datatree.variable_table.AddVariable(datatree.symbol_table.getNameByID(type, symb_id), lag);
+ var_id = datatree.variable_table.addVariable(type, symb_id, lag);
else
var_id = -1;
@@ -288,7 +288,7 @@ VariableNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
{
case oMatlabDynamicModel:
case oCDynamicModel:
- i = datatree.variable_table.getPrintIndex(var_id) + OFFSET(output_type);
+ i = datatree.variable_table.getSortID(var_id) + OFFSET(output_type);
output << "y" << LPAR(output_type) << i << RPAR(output_type);
break;
case oMatlabStaticModel:
diff --git a/parser.src/ModelTree.cc b/parser.src/ModelTree.cc
index abb815495..6f2ebf49f 100644
--- a/parser.src/ModelTree.cc
+++ b/parser.src/ModelTree.cc
@@ -52,10 +52,11 @@ ModelTree::equation_number() const
}
void
-ModelTree::writeDerivative(ostream &output, int eq, int var, int lag, ExprNodeOutputType output_type,
- const temporary_terms_type &temporary_terms) const
+ModelTree::writeDerivative(ostream &output, int eq, int symb_id, int lag,
+ ExprNodeOutputType output_type,
+ const temporary_terms_type &temporary_terms) const
{
- first_derivatives_type::const_iterator it = first_derivatives.find(make_pair(eq, variable_table.getmVariableSelector(var, lag)));
+ first_derivatives_type::const_iterator it = first_derivatives.find(make_pair(eq, variable_table.getID(eEndogenous, symb_id, lag)));
if (it != first_derivatives.end())
(it->second)->writeOutput(output, output_type, temporary_terms);
else
@@ -63,9 +64,9 @@ ModelTree::writeDerivative(ostream &output, int eq, int var, int lag, ExprNodeOu
}
void
-ModelTree::compileDerivative(ofstream &code_file, int eq, int var, int lag, ExprNodeOutputType output_type, map_idx_type map_idx) const
+ModelTree::compileDerivative(ofstream &code_file, int eq, int symb_id, int lag, ExprNodeOutputType output_type, map_idx_type map_idx) const
{
- first_derivatives_type::const_iterator it = first_derivatives.find(make_pair(eq, variable_table.getmVariableSelector(var, lag)));
+ first_derivatives_type::const_iterator it = first_derivatives.find(make_pair(eq, variable_table.getID(eEndogenous, symb_id, lag)));
if (it != first_derivatives.end())
{
/*NodeID Id = it->second;*/
@@ -305,7 +306,7 @@ ModelTree::computeTemporaryTermsOrdered(int order, Model_Block *ModelBlock)
{
eq=ModelBlock->Block_List[j].IM_lead_lag[m].Equ_Index[i];
var=ModelBlock->Block_List[j].IM_lead_lag[m].Var_Index[i];
- it=first_derivatives.find(make_pair(eq,variable_table.getmVariableSelector(var,lag)));
+ it=first_derivatives.find(make_pair(eq,variable_table.getID(eEndogenous, var,lag)));
it->second->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, j, ModelBlock, map_idx);
}
}
@@ -318,7 +319,7 @@ ModelTree::computeTemporaryTermsOrdered(int order, Model_Block *ModelBlock)
{
eq=ModelBlock->Block_List[j].IM_lead_lag[m].Equ_Index[i];
var=ModelBlock->Block_List[j].IM_lead_lag[m].Var_Index[i];
- it=first_derivatives.find(make_pair(eq,variable_table.getmVariableSelector(var,0)));
+ it=first_derivatives.find(make_pair(eq,variable_table.getID(eEndogenous,var,0)));
it->second->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, j, ModelBlock, map_idx);
}
}
@@ -326,7 +327,7 @@ ModelTree::computeTemporaryTermsOrdered(int order, Model_Block *ModelBlock)
{
eq=ModelBlock->Block_List[j].Equation[0];
var=ModelBlock->Block_List[j].Variable[0];
- it=first_derivatives.find(make_pair(eq,variable_table.getmVariableSelector(var,0)));
+ it=first_derivatives.find(make_pair(eq,variable_table.getID(eEndogenous,var,0)));
it->second->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, j, ModelBlock, map_idx);
}
}
@@ -347,7 +348,7 @@ void
ModelTree::writeModelEquationsOrdered_C(ostream &output, Model_Block *ModelBlock) const
{
int i,j,k,m;
- string sModel, tmp_s;
+ string tmp_s;
ostringstream tmp_output;
NodeID lhs=NULL, rhs=NULL;
BinaryOpNode *eq_node;
@@ -435,8 +436,8 @@ ModelTree::writeModelEquationsOrdered_C(ostream &output, Model_Block *ModelBlock
// The equations
for(i = 0;i < ModelBlock->Block_List[j].Size;i++)
{
- sModel = symbol_table.getNameByID(eEndogenous, ModelBlock->Block_List[j].Variable[i]) ;
- ModelBlock->Block_List[j].Variable_Sorted[i] = variable_table.getID(sModel, 0);
+ ModelBlock->Block_List[j].Variable_Sorted[i] = variable_table.getID(eEndogenous, ModelBlock->Block_List[j].Variable[i], 0);
+ string sModel = symbol_table.getNameByID(eEndogenous, ModelBlock->Block_List[j].Variable[i]) ;
output << " //equation " << ModelBlock->Block_List[j].Equation[i] << " variable : " <<
sModel << " (" << ModelBlock->Block_List[j].Variable[i] << ")\n";
if (!lhs_rhs_done)
@@ -585,7 +586,7 @@ void
ModelTree::writeModelEquationsOrdered_M(ostream &output, Model_Block *ModelBlock, const string &dynamic_basename) const
{
int i,j,k,m;
- string sModel, tmp_s, sps;
+ string tmp_s, sps;
ostringstream tmp_output, global_output;
NodeID lhs=NULL, rhs=NULL;
BinaryOpNode *eq_node;
@@ -703,8 +704,8 @@ ModelTree::writeModelEquationsOrdered_M(ostream &output, Model_Block *ModelBlock
// The equations
for(i = 0;i < ModelBlock->Block_List[j].Size;i++)
{
- sModel = symbol_table.getNameByID(eEndogenous, ModelBlock->Block_List[j].Variable[i]) ;
- ModelBlock->Block_List[j].Variable_Sorted[i] = variable_table.getID(sModel, 0);
+ ModelBlock->Block_List[j].Variable_Sorted[i] = variable_table.getID(eEndogenous, ModelBlock->Block_List[j].Variable[i], 0);
+ string sModel = symbol_table.getNameByID(eEndogenous, ModelBlock->Block_List[j].Variable[i]) ;
output << sps << " " << interfaces::comment() << "equation " << ModelBlock->Block_List[j].Equation[i] << " variable : " <<
sModel << " (" << ModelBlock->Block_List[j].Variable[i] << ")\n";
if (!lhs_rhs_done)
@@ -865,7 +866,7 @@ void
ModelTree::writeModelStaticEquationsOrdered_M(ostream &output, Model_Block *ModelBlock, const string &static_basename) const
{
int i,j,k,m, var, eq;
- string sModel, tmp_s, sps;
+ string tmp_s, sps;
ostringstream tmp_output, global_output;
NodeID lhs=NULL, rhs=NULL;
BinaryOpNode *eq_node;
@@ -993,8 +994,8 @@ ModelTree::writeModelStaticEquationsOrdered_M(ostream &output, Model_Block *Mode
// The equations
for(i = 0;i < ModelBlock->Block_List[j].Size;i++)
{
- sModel = symbol_table.getNameByID(eEndogenous, ModelBlock->Block_List[j].Variable[i]) ;
- ModelBlock->Block_List[j].Variable_Sorted[i] = variable_table.getID(sModel, 0);
+ ModelBlock->Block_List[j].Variable_Sorted[i] = variable_table.getID(eEndogenous, ModelBlock->Block_List[j].Variable[i], 0);
+ string sModel = symbol_table.getNameByID(eEndogenous, ModelBlock->Block_List[j].Variable[i]) ;
output << sps << " " << interfaces::comment() << "equation " << ModelBlock->Block_List[j].Equation[i] << " variable : " <<
sModel << " (" << ModelBlock->Block_List[j].Variable[i] << ")\n";
if (!lhs_rhs_done)
@@ -1157,7 +1158,7 @@ ModelTree::writeModelEquationsCodeOrdered(const string file_name, const Model_Bl
};
int i,j,k,m, v, ModelBlock_Aggregated_Count, k0, k1;
- string sModel, tmp_s;
+ string tmp_s;
ostringstream tmp_output;
ofstream code_file;
NodeID lhs=NULL, rhs=NULL;
@@ -1298,8 +1299,7 @@ ModelTree::writeModelEquationsCodeOrdered(const string file_name, const Model_Bl
// The equations
for(i = 0;i < ModelBlock->Block_List[j].Size;i++)
{
- sModel = symbol_table.getNameByID(eEndogenous, ModelBlock->Block_List[j].Variable[i]) ;
- ModelBlock->Block_List[j].Variable_Sorted[i] = variable_table.getID(sModel, 0);
+ ModelBlock->Block_List[j].Variable_Sorted[i] = variable_table.getID(eEndogenous, ModelBlock->Block_List[j].Variable[i], 0);
if (!lhs_rhs_done)
{
eq_node = equations[ModelBlock->Block_List[j].Equation[i]];
@@ -3517,14 +3517,16 @@ ModelTree::writeOutput(ostream &output) const
// Loop on periods
for(int lag = -variable_table.max_endo_lag; lag <= variable_table.max_endo_lead; lag++)
{
- // Getting name of symbol
- string name = symbol_table.getNameByID(eEndogenous, endoID);
- // and its variableID if exists with current period
- int varID = variable_table.getID(name, lag);
- if (varID >= 0)
- output << " " << variable_table.getPrintIndex(varID) + 1;
- else
- output << " 0";
+ // Print variableID if exists with current period, otherwise print 0
+ try
+ {
+ int varID = variable_table.getID(eEndogenous, endoID, lag);
+ output << " " << variable_table.getSortID(varID) + 1;
+ }
+ catch(VariableTable::UnknownVariableKeyException &e)
+ {
+ output << " 0";
+ }
}
output << ";";
}
@@ -3633,7 +3635,7 @@ ModelTree::BlockLinear(Model_Block *ModelBlock)
{
int eq=ModelBlock->Block_List[j].IM_lead_lag[ll].Equ_Index[i];
int var=ModelBlock->Block_List[j].IM_lead_lag[ll].Var_Index[i];
- first_derivatives_type::const_iterator it=first_derivatives.find(make_pair(eq,variable_table.getmVariableSelector(var,0)));
+ first_derivatives_type::const_iterator it=first_derivatives.find(make_pair(eq,variable_table.getID(eEndogenous,var,0)));
if (it!= first_derivatives.end())
{
NodeID Id = it->second;
@@ -3661,7 +3663,7 @@ ModelTree::BlockLinear(Model_Block *ModelBlock)
{
int eq=ModelBlock->Block_List[j].IM_lead_lag[m].Equ_Index[i];
int var=ModelBlock->Block_List[j].IM_lead_lag[m].Var_Index[i];
- first_derivatives_type::const_iterator it=first_derivatives.find(make_pair(eq,variable_table.getmVariableSelector(var,k1)));
+ first_derivatives_type::const_iterator it=first_derivatives.find(make_pair(eq,variable_table.getID(eEndogenous,var,k1)));
NodeID Id = it->second;
if (it!= first_derivatives.end())
{
@@ -3692,9 +3694,7 @@ ModelTree::computingPass(const eval_context_type &eval_context)
cout << equations.size() << " equation(s) found" << endl;
// Sorting variable table
- variable_table.Sort();
-
- variable_table.setmVariableSelector();
+ variable_table.sort();
// Determine derivation order
int order = 1;
@@ -3709,10 +3709,6 @@ ModelTree::computingPass(const eval_context_type &eval_context)
if (mode == eSparseDLLMode || mode == eSparseMode)
{
jacob_map j_m;
- int Size;
- int HSize;
- int *Table=variable_table.GetVariableTable(&Size,&HSize);
-
evaluateJacobian(eval_context, &j_m);
@@ -3721,7 +3717,6 @@ ModelTree::computingPass(const eval_context_type &eval_context)
cout << "The gross incidence matrix \n";
block_triangular.Print_IM( symbol_table.endo_nbr);
}
- block_triangular.SetVariableTable(Table, Size, HSize);
block_triangular.Normalize_and_BlockDecompose_Static_0_Model(j_m);
BlockLinear(block_triangular.ModelBlock);
diff --git a/parser.src/VariableTable.cc b/parser.src/VariableTable.cc
index d60ffd342..c9e4af892 100644
--- a/parser.src/VariableTable.cc
+++ b/parser.src/VariableTable.cc
@@ -17,9 +17,6 @@
* along with Dynare. If not, see .
*/
-#include
-#include
-
#include "VariableTable.hh"
VariableTable::VariableTable(const SymbolTable &symbol_table_arg) :
@@ -34,22 +31,23 @@ VariableTable::VariableTable(const SymbolTable &symbol_table_arg) :
}
int
-VariableTable::AddVariable(const string &iName, int iLag)
+VariableTable::addVariable(Type type, int symb_id, int lag)
{
- // Testing if variable exists in VariableTable
- int lVariableID = getID(iName,iLag);
- if (lVariableID != -1)
- return lVariableID;
+ if (sorted_ids_table.size() != 0)
+ throw AlreadySortedException();
- lVariableID = mVariableIndex.size();
- // Making variable struct and key
- varKey key = make_pair(iName, iLag);
- // Pushing variable on VariableTable
- mVariableTable[key] = lVariableID;
- mVariableIndex.push_back(key);
+ var_key_type key = make_pair(make_pair(type, lag), symb_id);
+
+ // Testing if variable already exists
+ variable_table_type::const_iterator it = variable_table.find(key);
+ if (it != variable_table.end())
+ return it->second;
+
+ int var_id = size();
+
+ variable_table[key] = var_id;
+ inv_variable_table[var_id] = key;
- // Setting dynamic variables numbers
- Type type = getType(lVariableID);
if (type == eEndogenous)
var_endo_nbr++;
if (type == eExogenous)
@@ -58,132 +56,53 @@ VariableTable::AddVariable(const string &iName, int iLag)
var_exo_det_nbr++;
// Setting maximum and minimum lags
- if (max_lead < iLag)
- max_lead = iLag;
- else if (-max_lag > iLag)
- max_lag = -iLag;
+ if (max_lead < lag)
+ max_lead = lag;
+ else if (-max_lag > lag)
+ max_lag = -lag;
switch(type)
{
case eEndogenous:
- if (max_endo_lead < iLag)
- max_endo_lead = iLag;
- else if (-max_endo_lag > iLag)
- max_endo_lag = -iLag;
+ if (max_endo_lead < lag)
+ max_endo_lead = lag;
+ else if (-max_endo_lag > lag)
+ max_endo_lag = -lag;
break;
case eExogenous:
- if (max_exo_lead < iLag)
- max_exo_lead = iLag;
- else if (-max_exo_lag > iLag)
- max_exo_lag = -iLag;
+ if (max_exo_lead < lag)
+ max_exo_lead = lag;
+ else if (-max_exo_lag > lag)
+ max_exo_lag = -lag;
break;
case eExogenousDet:
- if (max_exo_det_lead < iLag)
- max_exo_det_lead = iLag;
- else if (-max_exo_det_lag > iLag)
- max_exo_det_lag = -iLag;
+ if (max_exo_det_lead < lag)
+ max_exo_det_lead = lag;
+ else if (-max_exo_det_lag > lag)
+ max_exo_det_lag = -lag;
break;
case eRecursiveVariable:
- if (max_recur_lead < iLag)
- max_recur_lead = iLag;
- else if (-max_recur_lag > iLag)
- max_recur_lag = -iLag;
+ if (max_recur_lead < lag)
+ max_recur_lead = lag;
+ else if (-max_recur_lag > lag)
+ max_recur_lag = -lag;
break;
default:
;
}
- return lVariableID;
+ return var_id;
}
void
-VariableTable::Sort()
+VariableTable::sort()
{
- // Trivial case where no ordering is necessary
- if (mVariableIndex.size() == 1)
- {
- mSortedVariableID.push_back(0);
- mPrintFormatIndex.push_back(0);
- return;
- }
+ if (sorted_ids_table.size() != 0)
+ throw AlreadySortedException();
- /* The type of key for lexicographic ordering over variables:
- the key is equal to (type, lag, symbol_id) */
- typedef pair > lexicographic_key_type;
+ int sorted_id = 0;
+ sorted_ids_table.resize(size());
- // Construct the vector matching keys to their varIDs
- vector > VarToSort;
- for (unsigned int varID = 0; varID < mVariableIndex.size(); varID++)
- {
- Type type = getType(varID);
- int symbolID = getSymbolID(varID);
- int lag = mVariableIndex[varID].second;
- VarToSort.push_back(make_pair(make_pair(type, make_pair(lag, symbolID)), varID));
- }
-
- // Sort variables using the lexicographic ordering
- sort(VarToSort.begin(), VarToSort.end());
-
- // Fill mSortedVariableID and mPrintFormatIndex
- mSortedVariableID.resize(VarToSort.size());
- mPrintFormatIndex.resize(VarToSort.size());
- Type type = getType(VarToSort[0].second);
- int index = 0;
- for (unsigned int sortedID = 0; sortedID < VarToSort.size(); sortedID++)
- {
- int varID = VarToSort[sortedID].second;
- mSortedVariableID[varID] = sortedID;
- if (type == getType(varID))
- {
- mPrintFormatIndex[varID] = index;
- index++;
- }
- else
- {
- mPrintFormatIndex[varID] = 0;
- type = getType(varID);
- index = 1;
- }
- }
-}
-
-int*
-VariableTable::GetVariableTable(int* Size, int* HSize)
-{
- int* Table;
- varKey key;
- int variable,id, ind;
- (*Size)=0;
- for (id=0; id < (int) mVariableIndex.size(); id++)
- {
- key = mVariableIndex[id];
- variable = mVariableTable[key];
- if(getType(variable)==eEndogenous)
- (*Size)++;
- }
- (*HSize)=4;
- Table=(int*)malloc((*Size)*(*HSize)*sizeof(*Table));
- ind=0;
- for (id=0; id < (int) mVariableIndex.size(); id++)
- {
- key = mVariableIndex[id];
- variable = mVariableTable[key];
- if (getType(variable)==eEndogenous)
- {
- Table[ind*(*HSize)]= getSymbolID(id);
- Table[ind*(*HSize)+1]= key.second;
- Table[ind*(*HSize)+2]= mPrintFormatIndex[id];
- Table[ind*(*HSize)+3]= mSortedVariableID[id];
- ind++;
- }
- }
- return(Table);
-}
-
-int
-VariableTable::getIDS(int id, int lead_lag) const
-{
- varKey key;
- key=mVariableIndex[id];
- map::const_iterator it = mVariableTable.find(key);
- return(it->second);
+ for(variable_table_type::const_iterator it = variable_table.begin();
+ it != variable_table.end(); it++)
+ sorted_ids_table[it->second] = sorted_id++;
}
diff --git a/parser.src/include/BlockTriangular.hh b/parser.src/include/BlockTriangular.hh
index 550e768da..c4a68f5f6 100644
--- a/parser.src/include/BlockTriangular.hh
+++ b/parser.src/include/BlockTriangular.hh
@@ -83,9 +83,8 @@ public:
void getMax_Lead_Lag(int var, int equ, int *lead, int *lag);
void getMax_Lead_Lag_B(int size, int* Equation, int *Variable, int *lead, int *lag);
void swap_IM_c(bool *SIM, int pos1, int pos2, int pos3, simple* Index_Var_IM, simple* Index_Equ_IM, int n);
- void Allocate_Block(int size, int *count_Equ, int *count_Block, int type, Model_Block * ModelBlock, int* Table, int TableSize);
+ void Allocate_Block(int size, int *count_Equ, int *count_Block, int type, Model_Block * ModelBlock);
void Free_Block(Model_Block* ModelBlock);
- void SetVariableTable(int *Table,int Size,int HSize);
string getnamebyID(Type type, int id);
List_IM *First_IM ;
List_IM *Last_IM ;
@@ -94,8 +93,7 @@ public:
int prologue, epilogue;
int Model_Max_Lead, Model_Max_Lag, periods;
bool bt_verbose;
- int endo_nbr, TableSize;
- int* Table;
+ int endo_nbr;
Model_Block* ModelBlock;
inline static std::string BlockType0(int type)
{
diff --git a/parser.src/include/ModelTree.hh b/parser.src/include/ModelTree.hh
index c0696462f..1e4fbcea3 100644
--- a/parser.src/include/ModelTree.hh
+++ b/parser.src/include/ModelTree.hh
@@ -87,9 +87,9 @@ private:
//! Computes derivatives of ModelTree
void derive(int order);
//! Write derivative of an equation w.r. to a variable
- void writeDerivative(ostream &output, int eq, int var, int lag, ExprNodeOutputType output_type, const temporary_terms_type &temporary_terms) const;
+ void writeDerivative(ostream &output, int eq, int symb_id, int lag, ExprNodeOutputType output_type, const temporary_terms_type &temporary_terms) const;
//! Write derivative code of an equation w.r. to a variable
- void compileDerivative(ofstream &code_file, int eq, int var, int lag, ExprNodeOutputType output_type, map_idx_type map_idx) const;
+ void compileDerivative(ofstream &code_file, int eq, int symb_id, int lag, ExprNodeOutputType output_type, map_idx_type map_idx) const;
//! Computes temporary terms
void computeTemporaryTerms(int order);
void computeTemporaryTermsOrdered(int order, Model_Block *ModelBlock);
diff --git a/parser.src/include/SymbolTable.hh b/parser.src/include/SymbolTable.hh
index 304b4eac1..135360aa8 100644
--- a/parser.src/include/SymbolTable.hh
+++ b/parser.src/include/SymbolTable.hh
@@ -29,7 +29,7 @@ using namespace std;
#include
//! Enumeration of possible symbol types
-/*! Be careful not to change the order of the enumeration, it matters for VariableTable (at least up to eParameter) */
+/*! Warning: do not to change the order of the enumeration, it matters for VariableTable (at least ensure that eEndogenous is the first one) */
enum Type
{
eEndogenous = 0, //!< Endogenous
@@ -56,14 +56,11 @@ private:
//! A symbol is represented by a pair (type, id)
typedef pair symbol_type;
- //! Type for map: symbol_name -> (type, id)
typedef map symbol_table_type;
//! Maps strings to pairs (type,id)
symbol_table_type symbol_table;
- //! Type for map: (type, id) -> symbol_name
typedef map inv_symbol_table_type;
-
//! Maps pairs (type, id) to names
inv_symbol_table_type name_table;
//! Maps pairs (type, id) to TeX names
@@ -128,7 +125,6 @@ public:
inline int getID(const string &name) const throw (UnknownSymbolNameException);
//! Write output of this class
void writeOutput(ostream &output) const;
-
};
inline bool
diff --git a/parser.src/include/VariableTable.hh b/parser.src/include/VariableTable.hh
index a7022adca..49d59cb5a 100644
--- a/parser.src/include/VariableTable.hh
+++ b/parser.src/include/VariableTable.hh
@@ -23,34 +23,30 @@
using namespace std;
#include