trunk preprocessor: renamed "Type" to "SymbolType" for the sake of clarity
git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@2166 ac1d8469-bf42-47a9-8791-bf33cf982152time-shift
parent
21914feb4f
commit
cc64a40ac7
|
@ -559,7 +559,7 @@ ObservationTrendsStatement::writeOutput(ostream &output, const string &basename)
|
|||
|
||||
for(it = trend_elements.begin(); it != trend_elements.end(); it++)
|
||||
{
|
||||
Type type = symbol_table.getType(it->first);
|
||||
SymbolType type = symbol_table.getType(it->first);
|
||||
if (type == eEndogenous)
|
||||
{
|
||||
output << "tmp1 = strmatch('" << it->first << "',options_.varobs,'exact');\n";
|
||||
|
|
|
@ -56,7 +56,7 @@ NodeID
|
|||
DataTree::AddVariable(const string &name, int lag)
|
||||
{
|
||||
int symb_id = symbol_table.getID(name);
|
||||
Type type = symbol_table.getType(name);
|
||||
SymbolType type = symbol_table.getType(name);
|
||||
|
||||
variable_node_map_type::iterator it = variable_node_map.find(make_pair(make_pair(symb_id, type), lag));
|
||||
if (it != variable_node_map.end())
|
||||
|
|
|
@ -164,7 +164,7 @@ NumConstNode::collectEndogenous(set<pair<int, int> > &result) const
|
|||
{
|
||||
}
|
||||
|
||||
VariableNode::VariableNode(DataTree &datatree_arg, int symb_id_arg, Type type_arg, int lag_arg) :
|
||||
VariableNode::VariableNode(DataTree &datatree_arg, int symb_id_arg, SymbolType type_arg, int lag_arg) :
|
||||
ExprNode(datatree_arg),
|
||||
symb_id(symb_id_arg),
|
||||
type(type_arg),
|
||||
|
|
|
@ -54,7 +54,7 @@ InitOrEndValStatement::writeInitValues(ostream &output) const
|
|||
const string &name = it->first;
|
||||
const NodeID expression = it->second;
|
||||
|
||||
Type type = symbol_table.getType(name);
|
||||
SymbolType type = symbol_table.getType(name);
|
||||
int id = symbol_table.getID(name) + 1;
|
||||
|
||||
if (type == eEndogenous)
|
||||
|
@ -144,7 +144,7 @@ HistValStatement::writeOutput(ostream &output, const string &basename) const
|
|||
const int &lag = it->first.second;
|
||||
const NodeID expression = it->second;
|
||||
|
||||
Type type = symbol_table.getType(name);
|
||||
SymbolType type = symbol_table.getType(name);
|
||||
int id = symbol_table.getID(name) + 1;
|
||||
|
||||
if (type == eEndogenous)
|
||||
|
@ -196,7 +196,7 @@ HomotopyStatement::writeOutput(ostream &output, const string &basename) const
|
|||
const NodeID expression1 = it->second.first;
|
||||
const NodeID expression2 = it->second.second;
|
||||
|
||||
const Type type = symbol_table.getType(name);
|
||||
const SymbolType type = symbol_table.getType(name);
|
||||
const int id = symbol_table.getID(name) + 1;
|
||||
|
||||
output << "options_.homotopy_values = vertcat(options_.homotopy_values, [ " << type << ", " << id << ", ";
|
||||
|
|
|
@ -102,7 +102,7 @@ ParsingDriver::warning(const string &m)
|
|||
}
|
||||
|
||||
void
|
||||
ParsingDriver::declare_symbol(string *name, Type type, string *tex_name)
|
||||
ParsingDriver::declare_symbol(string *name, SymbolType type, string *tex_name)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -162,7 +162,7 @@ NodeID
|
|||
ParsingDriver::add_model_variable(string *name, string *olag)
|
||||
{
|
||||
check_symbol_existence(*name);
|
||||
Type type = mod_file->symbol_table.getType(*name);
|
||||
SymbolType type = mod_file->symbol_table.getType(*name);
|
||||
int lag = atoi(olag->c_str());
|
||||
|
||||
if (type == eModFileLocalVariable)
|
||||
|
@ -271,7 +271,7 @@ void
|
|||
ParsingDriver::init_val(string *name, NodeID rhs)
|
||||
{
|
||||
check_symbol_existence(*name);
|
||||
Type type = mod_file->symbol_table.getType(*name);
|
||||
SymbolType type = mod_file->symbol_table.getType(*name);
|
||||
|
||||
if (type != eEndogenous
|
||||
&& type != eExogenous
|
||||
|
@ -305,7 +305,7 @@ void
|
|||
ParsingDriver::hist_val(string *name, string *lag, NodeID rhs)
|
||||
{
|
||||
check_symbol_existence(*name);
|
||||
Type type = mod_file->symbol_table.getType(*name);
|
||||
SymbolType type = mod_file->symbol_table.getType(*name);
|
||||
|
||||
if (type != eEndogenous
|
||||
&& type != eExogenous
|
||||
|
@ -328,7 +328,7 @@ void
|
|||
ParsingDriver::homotopy_val(string *name, NodeID val1, NodeID val2)
|
||||
{
|
||||
check_symbol_existence(*name);
|
||||
Type type = mod_file->symbol_table.getType(*name);
|
||||
SymbolType type = mod_file->symbol_table.getType(*name);
|
||||
|
||||
if (type != eParameter
|
||||
&& type != eExogenous
|
||||
|
@ -430,7 +430,7 @@ void
|
|||
ParsingDriver::add_det_shock(string *var)
|
||||
{
|
||||
check_symbol_existence(*var);
|
||||
Type type = mod_file->symbol_table.getType(*var);
|
||||
SymbolType type = mod_file->symbol_table.getType(*var);
|
||||
if (type != eExogenous && type != eExogenousDet)
|
||||
error("shocks: shocks can only be applied to exogenous variables");
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ SymbolTable::SymbolTable() : endo_nbr(0), exo_nbr(0), exo_det_nbr(0), recur_nbr(
|
|||
}
|
||||
|
||||
void
|
||||
SymbolTable::addSymbol(const string &name, Type type, const string &tex_name) throw (AlreadyDeclaredException)
|
||||
SymbolTable::addSymbol(const string &name, SymbolType type, const string &tex_name) throw (AlreadyDeclaredException)
|
||||
{
|
||||
if (exists(name))
|
||||
{
|
||||
|
@ -69,7 +69,7 @@ SymbolTable::addSymbol(const string &name, Type type, const string &tex_name) th
|
|||
break;
|
||||
}
|
||||
|
||||
symbol_type symbol(type, id);
|
||||
named_symbol_type symbol(type, id);
|
||||
symbol_table[name] = symbol;
|
||||
name_table[symbol] = name;
|
||||
tex_name_table[symbol] = tex_name;
|
||||
|
|
|
@ -33,7 +33,7 @@ VariableTable::VariableTable(const SymbolTable &symbol_table_arg) :
|
|||
}
|
||||
|
||||
int
|
||||
VariableTable::addVariable(Type type, int symb_id, int lag) throw (DynJacobianColsAlreadyComputedException)
|
||||
VariableTable::addVariable(SymbolType type, int symb_id, int lag) throw (DynJacobianColsAlreadyComputedException)
|
||||
{
|
||||
if (dyn_jacobian_cols_table.size() != 0)
|
||||
throw DynJacobianColsAlreadyComputedException();
|
||||
|
|
|
@ -66,7 +66,7 @@ enum BlockSimulationType
|
|||
|
||||
//! Enumeration of possible symbol types
|
||||
/*! Warning: do not to change existing values: the order matters for VariableTable (at least for endogenous and exogenous types), and the values matter for homotopy_setup command */
|
||||
enum Type
|
||||
enum SymbolType
|
||||
{
|
||||
eEndogenous = 0, //!< Endogenous
|
||||
eExogenous = 1, //!< Exogenous
|
||||
|
|
|
@ -62,7 +62,7 @@ protected:
|
|||
typedef map<int, NodeID> num_const_node_map_type;
|
||||
num_const_node_map_type num_const_node_map;
|
||||
//! Type (symbol_id, type, lag) used as key
|
||||
typedef map<pair<pair<int, Type>, int>, NodeID> variable_node_map_type;
|
||||
typedef map<pair<pair<int, SymbolType>, int>, NodeID> variable_node_map_type;
|
||||
variable_node_map_type variable_node_map;
|
||||
typedef map<pair<NodeID, int>, NodeID> unary_op_node_map_type;
|
||||
unary_op_node_map_type unary_op_node_map;
|
||||
|
|
|
@ -61,7 +61,7 @@ enum ExprNodeOutputType
|
|||
//! Type for evaluation contexts
|
||||
/*! The key is a pair (symbol id, symbol type)
|
||||
Lags are assumed to be null */
|
||||
typedef map<pair<int, Type>, double> eval_context_type;
|
||||
typedef map<pair<int, SymbolType>, double> eval_context_type;
|
||||
|
||||
/* Equal to 1 for Matlab langage, or to 0 for C language
|
||||
In Matlab, array indexes begin at 1, while they begin at 0 in C */
|
||||
|
@ -189,13 +189,13 @@ class VariableNode : public ExprNode
|
|||
private:
|
||||
//! Id from the symbol table
|
||||
const int symb_id;
|
||||
const Type type;
|
||||
const SymbolType type;
|
||||
const int lag;
|
||||
//! Id from the variable table (-1 if not a endogenous/exogenous/recursive)
|
||||
int var_id;
|
||||
virtual NodeID computeDerivative(int varID);
|
||||
public:
|
||||
VariableNode(DataTree &datatree_arg, int symb_id_arg, Type type_arg, int lag_arg);
|
||||
VariableNode(DataTree &datatree_arg, int symb_id_arg, SymbolType type_arg, int lag_arg);
|
||||
virtual void writeOutput(ostream &output, ExprNodeOutputType output_type, const temporary_terms_type &temporary_terms = temporary_terms_type()) const;
|
||||
virtual void collectEndogenous(set<pair<int, int> > &result) const;
|
||||
virtual double eval(const eval_context_type &eval_context) const throw (EvalException);
|
||||
|
|
|
@ -71,7 +71,7 @@ private:
|
|||
void check_symbol_existence(const string &name);
|
||||
|
||||
//! Helper to add a symbol declaration
|
||||
void declare_symbol(string *name, Type type, string *tex_name);
|
||||
void declare_symbol(string *name, SymbolType type, string *tex_name);
|
||||
|
||||
//! Creates option "optim_opt" in OptionsList if it doesn't exist, else add a comma, and adds the option name
|
||||
void optim_options_helper(const string &name);
|
||||
|
|
|
@ -41,13 +41,13 @@ class SymbolTable
|
|||
{
|
||||
private:
|
||||
//! A symbol is represented by a pair (type, id)
|
||||
typedef pair<Type, int> symbol_type;
|
||||
typedef pair<SymbolType, int> named_symbol_type;
|
||||
|
||||
typedef map<string, symbol_type> symbol_table_type;
|
||||
typedef map<string, named_symbol_type> symbol_table_type;
|
||||
//! Maps strings to pairs (type,id)
|
||||
symbol_table_type symbol_table;
|
||||
|
||||
typedef map<symbol_type, string> inv_symbol_table_type;
|
||||
typedef map<named_symbol_type, string> inv_symbol_table_type;
|
||||
//! Maps pairs (type, id) to names
|
||||
inv_symbol_table_type name_table;
|
||||
//! Maps pairs (type, id) to TeX names
|
||||
|
@ -67,10 +67,10 @@ public:
|
|||
{
|
||||
public:
|
||||
//! Symbol type
|
||||
Type type;
|
||||
SymbolType type;
|
||||
//! Symbol ID
|
||||
int id;
|
||||
UnknownSymbolIDException(Type type_arg, int id_arg) : type(type_arg), id(id_arg) {}
|
||||
UnknownSymbolIDException(SymbolType type_arg, int id_arg) : type(type_arg), id(id_arg) {}
|
||||
};
|
||||
//! Thrown when trying to declare a symbol twice
|
||||
class AlreadyDeclaredException
|
||||
|
@ -99,15 +99,15 @@ public:
|
|||
//! Number of unknown functions
|
||||
int unknown_function_nbr;
|
||||
//! Add a symbol
|
||||
void addSymbol(const string &name, Type type, const string &tex_name = "") throw (AlreadyDeclaredException);
|
||||
void addSymbol(const string &name, SymbolType type, const string &tex_name = "") throw (AlreadyDeclaredException);
|
||||
//! Tests if symbol already exists
|
||||
inline bool exists(const string &name) const;
|
||||
//! Get symbol name by type and ID
|
||||
inline string getNameByID(Type type, int id) const throw (UnknownSymbolIDException);
|
||||
inline string getNameByID(SymbolType type, int id) const throw (UnknownSymbolIDException);
|
||||
//! Get TeX name by type and ID
|
||||
inline string getTeXNameByID(Type type, int id) const throw (UnknownSymbolIDException);
|
||||
inline string getTeXNameByID(SymbolType type, int id) const throw (UnknownSymbolIDException);
|
||||
//! Get type by name
|
||||
inline Type getType(const string &name) const throw (UnknownSymbolNameException);
|
||||
inline SymbolType getType(const string &name) const throw (UnknownSymbolNameException);
|
||||
//! Get ID by name
|
||||
inline int getID(const string &name) const throw (UnknownSymbolNameException);
|
||||
//! Write output of this class
|
||||
|
@ -122,7 +122,7 @@ SymbolTable::exists(const string &name) const
|
|||
}
|
||||
|
||||
inline string
|
||||
SymbolTable::getNameByID(Type type, int id) const throw (UnknownSymbolIDException)
|
||||
SymbolTable::getNameByID(SymbolType type, int id) const throw (UnknownSymbolIDException)
|
||||
{
|
||||
inv_symbol_table_type::const_iterator iter = name_table.find(make_pair(type, id));
|
||||
if (iter != name_table.end())
|
||||
|
@ -132,7 +132,7 @@ SymbolTable::getNameByID(Type type, int id) const throw (UnknownSymbolIDExceptio
|
|||
}
|
||||
|
||||
inline string
|
||||
SymbolTable::getTeXNameByID(Type type, int id) const throw (UnknownSymbolIDException)
|
||||
SymbolTable::getTeXNameByID(SymbolType type, int id) const throw (UnknownSymbolIDException)
|
||||
{
|
||||
inv_symbol_table_type::const_iterator iter = tex_name_table.find(make_pair(type, id));
|
||||
if (iter != tex_name_table.end())
|
||||
|
@ -141,7 +141,7 @@ SymbolTable::getTeXNameByID(Type type, int id) const throw (UnknownSymbolIDExcep
|
|||
throw UnknownSymbolIDException(type, id);
|
||||
}
|
||||
|
||||
inline Type
|
||||
inline SymbolType
|
||||
SymbolTable::getType(const string &name) const throw (UnknownSymbolNameException)
|
||||
{
|
||||
symbol_table_type::const_iterator iter = symbol_table.find(name);
|
||||
|
|
|
@ -36,7 +36,7 @@ private:
|
|||
const SymbolTable &symbol_table;
|
||||
//! A variable is a tuple (type, lag, symbol_id)
|
||||
/*! Warning: don't change the order of elements in the tuple, since this determines the lexicographic ordering in computeDynJacobianCols() */
|
||||
typedef pair<pair<Type, int>, int> var_key_type;
|
||||
typedef pair<pair<SymbolType, int>, int> var_key_type;
|
||||
|
||||
typedef map<var_key_type, int> variable_table_type;
|
||||
//! Maps a tuple (type, lag, symbol_id) to a variable ID
|
||||
|
@ -81,9 +81,9 @@ public:
|
|||
class UnknownVariableKeyException
|
||||
{
|
||||
public:
|
||||
Type type;
|
||||
SymbolType type;
|
||||
int symb_id, lag;
|
||||
UnknownVariableKeyException(Type type_arg, int symb_id_arg, int lag_arg) : type(type_arg), symb_id(symb_id_arg), lag(lag_arg) {}
|
||||
UnknownVariableKeyException(SymbolType type_arg, int symb_id_arg, int lag_arg) : type(type_arg), symb_id(symb_id_arg), lag(lag_arg) {}
|
||||
};
|
||||
//! Thrown when trying to access an unknown variable by var_id
|
||||
class UnknownVariableIDException
|
||||
|
@ -103,15 +103,15 @@ public:
|
|||
};
|
||||
//! Adds a variable in the table, and returns its (newly allocated) variable ID
|
||||
/*! Also works if the variable already exists */
|
||||
int addVariable(Type type, int symb_id, int lag) throw (DynJacobianColsAlreadyComputedException);
|
||||
int addVariable(SymbolType type, int symb_id, int lag) throw (DynJacobianColsAlreadyComputedException);
|
||||
//! Return variable ID
|
||||
inline int getID(Type type, int symb_id, int lag) const throw (UnknownVariableKeyException);
|
||||
inline int getID(SymbolType type, int symb_id, int lag) const throw (UnknownVariableKeyException);
|
||||
//! Return lag of variable
|
||||
inline int getLag(int var_id) const throw (UnknownVariableIDException);
|
||||
//! Return symbol ID of variable
|
||||
inline int getSymbolID(int var_id) const throw (UnknownVariableIDException);
|
||||
//! Get variable type
|
||||
inline Type getType(int var_id) const throw (UnknownVariableIDException);
|
||||
inline SymbolType getType(int var_id) const throw (UnknownVariableIDException);
|
||||
//! Get number of variables
|
||||
inline int size() const;
|
||||
//! Get column index in dynamic jacobian
|
||||
|
@ -135,7 +135,7 @@ VariableTable::getDynJacobianCol(int var_id) const throw (DynJacobianColsNotYetC
|
|||
}
|
||||
|
||||
inline int
|
||||
VariableTable::getID(Type type, int symb_id, int lag) const throw (UnknownVariableKeyException)
|
||||
VariableTable::getID(SymbolType type, int symb_id, int lag) const throw (UnknownVariableKeyException)
|
||||
{
|
||||
variable_table_type::const_iterator it = variable_table.find(make_pair(make_pair(type, lag), symb_id));
|
||||
if (it == variable_table.end())
|
||||
|
@ -144,7 +144,7 @@ VariableTable::getID(Type type, int symb_id, int lag) const throw (UnknownVariab
|
|||
return it->second;
|
||||
}
|
||||
|
||||
inline Type
|
||||
inline SymbolType
|
||||
VariableTable::getType(int var_id) const throw (UnknownVariableIDException)
|
||||
{
|
||||
inv_variable_table_type::const_iterator it = inv_variable_table.find(var_id);
|
||||
|
|
Loading…
Reference in New Issue