Fixed code indentation.

issue#70
Stéphane Adjemian (Charybdis) 2017-06-14 07:01:31 +02:00
parent 3eddd5ce88
commit 51feda7d02
35 changed files with 1325 additions and 1255 deletions

View File

@ -228,7 +228,7 @@ enum TrinaryOpcode
};
enum external_function_type
{
{
ExternalFunctionWithoutDerivative,
ExternalFunctionWithFirstDerivative,
ExternalFunctionWithFirstandSecondDerivative,
@ -236,7 +236,7 @@ enum external_function_type
ExternalFunctionFirstDerivative,
ExternalFunctionNumericalSecondDerivative,
ExternalFunctionSecondDerivative
};
};
enum PriorDistributions
{
@ -1467,7 +1467,7 @@ public:
is_linear = is_linear_arg; endo_nbr = endo_nbr_arg; Max_Lag = Max_Lag_arg; Max_Lead = Max_Lead_arg; u_count_int = u_count_int_arg;
nb_col_jacob = nb_col_jacob_arg;
det_exo_size = 0; exo_size = 0; other_endo_size = 0;
nb_col_det_exo_jacob = 0;nb_col_exo_jacob = 0;nb_col_other_endo_jacob = 0;
nb_col_det_exo_jacob = 0; nb_col_exo_jacob = 0; nb_col_other_endo_jacob = 0;
}
inline unsigned int
get_size()
@ -2025,4 +2025,3 @@ public:
#endif
#pragma pack(pop)
#endif

View File

@ -289,9 +289,9 @@ StochSimulStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsoli
it = options_list.num_options.find("hp_filter");
OptionsList::num_options_t::const_iterator it1 = options_list.num_options.find("bandpass.indicator");
OptionsList::num_options_t::const_iterator it2 = options_list.num_options.find("one_sided_hp_filter");
if ((it != options_list.num_options.end() && it1 != options_list.num_options.end()) ||
(it != options_list.num_options.end() && it2 != options_list.num_options.end()) ||
(it1 != options_list.num_options.end() && it2 != options_list.num_options.end()))
if ((it != options_list.num_options.end() && it1 != options_list.num_options.end())
|| (it != options_list.num_options.end() && it2 != options_list.num_options.end())
|| (it1 != options_list.num_options.end() && it2 != options_list.num_options.end()))
{
cerr << "ERROR: stoch_simul: can only use one of hp, one-sided hp, and bandpass filters"
<< endl;
@ -441,7 +441,7 @@ RamseyConstraintsStatement::RamseyConstraintsStatement(const SymbolTable &symbol
void
RamseyConstraintsStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings)
{
if ((mod_file_struct.ramsey_model_present != true) || ( mod_file_struct.ramsey_policy_present != true))
if ((mod_file_struct.ramsey_model_present != true) || (mod_file_struct.ramsey_policy_present != true))
cerr << "ramsey_constraints: can only be used with ramsey_model or ramsey_policy" << endl;
}
@ -454,7 +454,7 @@ RamseyConstraintsStatement::writeOutput(ostream &output, const string &basename,
if (it != constraints.begin())
output << ", ";
output << "{" << it->endo + 1 << ", '";
switch(it->code)
switch (it->code)
{
case oLess:
output << '<';
@ -490,7 +490,7 @@ RamseyConstraintsStatement::writeJsonOutput(ostream &output) const
if (it != constraints.begin())
output << ", ";
output << "{\"constraint\": \"" << symbol_table.getName(it->endo) << " ";
switch(it->code)
switch (it->code)
{
case oLess:
output << '<';
@ -827,15 +827,15 @@ EstimationStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsoli
exit(EXIT_FAILURE);
}
if (options_list.string_options.find("datafile") == options_list.string_options.end() &&
!mod_file_struct.estimation_data_statement_present)
if (options_list.string_options.find("datafile") == options_list.string_options.end()
&& !mod_file_struct.estimation_data_statement_present)
{
cerr << "ERROR: The estimation statement requires a data file to be supplied via the datafile option." << endl;
exit(EXIT_FAILURE);
}
if (options_list.string_options.find("mode_file") != options_list.string_options.end() &&
mod_file_struct.estim_params_use_calib)
if (options_list.string_options.find("mode_file") != options_list.string_options.end()
&& mod_file_struct.estim_params_use_calib)
{
cerr << "ERROR: The mode_file option of the estimation statement is incompatible with the use_calibration option of the estimated_params_init block." << endl;
exit(EXIT_FAILURE);
@ -1976,8 +1976,8 @@ MSSBVAREstimationStatement::checkPass(ModFileStructure &mod_file_struct, Warning
mod_file_struct.bvar_present = true;
if (options_list.num_options.find("ms.create_init") == options_list.num_options.end())
if (options_list.string_options.find("datafile") == options_list.string_options.end() ||
options_list.num_options.find("ms.initial_year") == options_list.num_options.end())
if (options_list.string_options.find("datafile") == options_list.string_options.end()
|| options_list.num_options.find("ms.initial_year") == options_list.num_options.end())
{
cerr << "ERROR: If you do not pass no_create_init to ms_estimation, "
<< "you must pass the datafile and initial_year options." << endl;
@ -2144,9 +2144,9 @@ MSSBVARIrfStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsoli
if (it != options_list.num_options.end())
filtered_probabilities_present = true;
if ((filtered_probabilities_present && regime_present) ||
(filtered_probabilities_present && regimes_present) ||
(regimes_present && regime_present))
if ((filtered_probabilities_present && regime_present)
|| (filtered_probabilities_present && regimes_present)
|| (regimes_present && regime_present))
{
cerr << "ERROR: You may only pass one of regime, regimes and "
<< "filtered_probabilities to ms_irf" << endl;
@ -2244,9 +2244,9 @@ MSSBVARVarianceDecompositionStatement::checkPass(ModFileStructure &mod_file_stru
if (it != options_list.num_options.end())
filtered_probabilities_present = true;
if ((filtered_probabilities_present && regime_present) ||
(filtered_probabilities_present && regimes_present) ||
(regimes_present && regime_present))
if ((filtered_probabilities_present && regime_present)
|| (filtered_probabilities_present && regimes_present)
|| (regimes_present && regime_present))
{
cerr << "ERROR: You may only pass one of regime, regimes and "
<< "filtered_probabilities to ms_variance_decomposition" << endl;
@ -2614,21 +2614,21 @@ MarkovSwitchingStatement::MarkovSwitchingStatement(const OptionsList &options_li
if (it_num != options_list.num_options.end())
{
using namespace boost;
OptionsList::num_options_t::const_iterator it_num_regimes =
options_list.num_options.find("ms.number_of_regimes");
OptionsList::num_options_t::const_iterator it_num_regimes
= options_list.num_options.find("ms.number_of_regimes");
assert(it_num_regimes != options_list.num_options.end());
int num_regimes = lexical_cast< int >(it_num_regimes->second);
vector<string> tokenizedRestrictions;
split(tokenizedRestrictions, it_num->second, is_any_of("["), token_compress_on);
for (vector<string>::iterator it = tokenizedRestrictions.begin();
it != tokenizedRestrictions.end(); it++ )
it != tokenizedRestrictions.end(); it++)
if (it->size() > 0)
{
vector<string> restriction;
split(restriction, *it, is_any_of("], "));
for (vector<string>::iterator it1 = restriction.begin();
it1 != restriction.end(); )
it1 != restriction.end();)
if (it1->empty())
restriction.erase(it1);
else
@ -2697,16 +2697,16 @@ MarkovSwitchingStatement::checkPass(ModFileStructure &mod_file_struct, WarningCo
if (it_num != options_list.num_options.end())
{
using namespace boost;
OptionsList::num_options_t::const_iterator it_num_regimes =
options_list.num_options.find("ms.number_of_regimes");
OptionsList::num_options_t::const_iterator it_num_regimes
= options_list.num_options.find("ms.number_of_regimes");
assert(it_num_regimes != options_list.num_options.end());
int num_regimes = lexical_cast< int >(it_num_regimes->second);
vector<double> col_trans_prob_sum (num_regimes, 0);
vector<double> row_trans_prob_sum (num_regimes, 0);
vector<bool> all_restrictions_in_row (num_regimes, true);
vector<bool> all_restrictions_in_col (num_regimes, true);
for (int row=0; row<num_regimes; row++)
for (int col=0; col<num_regimes; col++)
vector<double> col_trans_prob_sum(num_regimes, 0);
vector<double> row_trans_prob_sum(num_regimes, 0);
vector<bool> all_restrictions_in_row(num_regimes, true);
vector<bool> all_restrictions_in_col(num_regimes, true);
for (int row = 0; row < num_regimes; row++)
for (int col = 0; col < num_regimes; col++)
if (restriction_map.find(make_pair(row+1, col+1)) != restriction_map.end())
{
row_trans_prob_sum[row] += restriction_map[make_pair(row+1, col+1)];
@ -2718,7 +2718,7 @@ MarkovSwitchingStatement::checkPass(ModFileStructure &mod_file_struct, WarningCo
all_restrictions_in_col[col] = false;
}
for (int i=0; i<num_regimes; i++)
for (int i = 0; i < num_regimes; i++)
{
if (all_restrictions_in_row[i])
{
@ -2789,7 +2789,7 @@ MarkovSwitchingStatement::writeOutput(ostream &output, const string &basename, b
}
int restrictions_index = 0;
for (itR=restriction_map.begin(); itR != restriction_map.end(); itR++)
for (itR = restriction_map.begin(); itR != restriction_map.end(); itR++)
output << "options_.ms.ms_chain(" << itChain->second << ").restrictions("
<< ++restrictions_index << ") = {[" << itR->first.first << ", "
<< itR->first.second << ", " << itR->second << "]};" << endl;
@ -2800,8 +2800,8 @@ MarkovSwitchingStatement::writeCOutput(ostream &output, const string &basename)
{
output << endl;
OptionsList::num_options_t::const_iterator it =
options_list.num_options.find("ms.chain");
OptionsList::num_options_t::const_iterator it
= options_list.num_options.find("ms.chain");
assert(it != options_list.num_options.end());
output << "chain = " << it->second << ";" << endl;
@ -2823,17 +2823,17 @@ MarkovSwitchingStatement::writeCOutput(ostream &output, const string &basename)
vector<string> tokenizedDomain;
split(tokenizedDomain, it->second, is_any_of("[ ]"), token_compress_on);
for (vector<string>::iterator itvs = tokenizedDomain.begin();
itvs != tokenizedDomain.end(); itvs++ )
itvs != tokenizedDomain.end(); itvs++)
if (!itvs->empty())
output << "duration.push_back(" << *itvs << ");" << endl;
OptionsList::symbol_list_options_t::const_iterator itsl =
options_list.symbol_list_options.find("ms.parameters");
OptionsList::symbol_list_options_t::const_iterator itsl
= options_list.symbol_list_options.find("ms.parameters");
assert(itsl != options_list.symbol_list_options.end());
vector<string> parameters = itsl->second.get_symbols();
output << "parameters.clear();" << endl;
for (vector<string>::iterator itp = parameters.begin();
itp != parameters.end(); itp++ )
itp != parameters.end(); itp++)
output << "parameters.push_back(param_names[\"" << *itp << "\"]);" << endl;
output << "restriction_map.clear();" << endl;
@ -2887,11 +2887,11 @@ SvarStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation
it2 = options_list.string_options.find("ms.constants");
assert((it0 != options_list.string_options.end()
&& it1 == options_list.string_options.end()
&& it2 == options_list.string_options.end()) ||
(it0 == options_list.string_options.end()
&& it2 == options_list.string_options.end())
|| (it0 == options_list.string_options.end()
&& it1 != options_list.string_options.end()
&& it2 == options_list.string_options.end()) ||
(it0 == options_list.string_options.end()
&& it2 == options_list.string_options.end())
|| (it0 == options_list.string_options.end()
&& it1 == options_list.string_options.end()
&& it2 != options_list.string_options.end()));
}
@ -3006,15 +3006,15 @@ EstimationDataStatement::checkPass(ModFileStructure &mod_file_struct, WarningCon
exit(EXIT_FAILURE);
}
if ((options_list.string_options.find("file") == options_list.string_options.end()) &&
(options_list.string_options.find("series") == options_list.string_options.end()))
if ((options_list.string_options.find("file") == options_list.string_options.end())
&& (options_list.string_options.find("series") == options_list.string_options.end()))
{
cerr << "ERROR: The file or series option must be passed to the data statement." << endl;
exit(EXIT_FAILURE);
}
if ((options_list.string_options.find("file") != options_list.string_options.end()) &&
(options_list.string_options.find("series") != options_list.string_options.end()))
if ((options_list.string_options.find("file") != options_list.string_options.end())
&& (options_list.string_options.find("series") != options_list.string_options.end()))
{
cerr << "ERROR: The file and series options cannot be used simultaneously in the data statement." << endl;
exit(EXIT_FAILURE);
@ -3235,8 +3235,8 @@ JointPriorStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsoli
exit(EXIT_FAILURE);
}
if (options_list.num_options.find("mean") == options_list.num_options.end() &&
options_list.num_options.find("mode") == options_list.num_options.end())
if (options_list.num_options.find("mean") == options_list.num_options.end()
&& options_list.num_options.find("mode") == options_list.num_options.end())
{
cerr << "ERROR: You must pass at least one of mean and mode to the prior statement." << endl;
exit(EXIT_FAILURE);
@ -3259,13 +3259,13 @@ JointPriorStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsoli
void
JointPriorStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const
{
for (vector<string>::const_iterator it = joint_parameters.begin() ; it != joint_parameters.end(); it++)
for (vector<string>::const_iterator it = joint_parameters.begin(); it != joint_parameters.end(); it++)
output << "eifind = get_new_or_existing_ei_index('joint_parameter_prior_index', '"
<< *it << "', '');" << endl
<< "estimation_info.joint_parameter_prior_index(eifind) = {'" << *it << "'};" << endl;
output << "key = {[";
for (vector<string>::const_iterator it = joint_parameters.begin() ; it != joint_parameters.end(); it++)
for (vector<string>::const_iterator it = joint_parameters.begin(); it != joint_parameters.end(); it++)
output << "get_new_or_existing_ei_index('joint_parameter_prior_index', '" << *it << "', '') ..."
<< endl << " ";
output << "]};" << endl;
@ -3306,13 +3306,13 @@ JointPriorStatement::writeOutputHelper(ostream &output, const string &field, con
{
OptionsList::num_options_t::const_iterator itn = options_list.num_options.find(field);
output << lhs_field << "." << field << " = {";
if (field=="variance")
if (field == "variance")
output << "{";
if (itn != options_list.num_options.end())
output << itn->second;
else
output << "{}";
if (field=="variance")
if (field == "variance")
output << "}";
output << "};" << endl;
}
@ -3322,7 +3322,7 @@ JointPriorStatement::writeJsonOutput(ostream &output) const
{
output << "{\"statementName\": \"joint_prior\""
<< ", \"key\": [";
for (vector<string>::const_iterator it = joint_parameters.begin() ; it != joint_parameters.end(); it++)
for (vector<string>::const_iterator it = joint_parameters.begin(); it != joint_parameters.end(); it++)
{
if (it != joint_parameters.begin())
output << ", ";
@ -3337,7 +3337,7 @@ JointPriorStatement::writeJsonOutput(ostream &output) const
}
output << ", \"shape\": ";
switch(prior_shape)
switch (prior_shape)
{
case eBeta:
output << "\"beta\"";
@ -3396,16 +3396,16 @@ BasicPriorStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsoli
exit(EXIT_FAILURE);
}
if (options_list.num_options.find("mean") == options_list.num_options.end() &&
options_list.num_options.find("mode") == options_list.num_options.end())
if (options_list.num_options.find("mean") == options_list.num_options.end()
&& options_list.num_options.find("mode") == options_list.num_options.end())
{
cerr << "ERROR: You must pass at least one of mean and mode to the prior statement." << endl;
exit(EXIT_FAILURE);
}
OptionsList::num_options_t::const_iterator it_stdev = options_list.num_options.find("stdev");
if ((it_stdev == options_list.num_options.end() && variance == NULL) ||
(it_stdev != options_list.num_options.end() && variance != NULL))
if ((it_stdev == options_list.num_options.end() && variance == NULL)
|| (it_stdev != options_list.num_options.end() && variance != NULL))
{
cerr << "ERROR: You must pass exactly one of stdev and variance to the prior statement." << endl;
exit(EXIT_FAILURE);
@ -3533,7 +3533,7 @@ BasicPriorStatement::writeCDomain(ostream &output) const
vector<string> tokenizedDomain;
split(tokenizedDomain, it_num->second, is_any_of("[ ]"), token_compress_on);
for (vector<string>::iterator it = tokenizedDomain.begin();
it != tokenizedDomain.end(); it++ )
it != tokenizedDomain.end(); it++)
if (!it->empty())
output << "domain.push_back(" << *it << ");" << endl;
}
@ -3667,7 +3667,7 @@ StdPriorStatement::StdPriorStatement(const string &name_arg,
const PriorDistributions &prior_shape_arg,
const expr_t &variance_arg,
const OptionsList &options_list_arg,
const SymbolTable &symbol_table_arg ) :
const SymbolTable &symbol_table_arg) :
BasicPriorStatement(name_arg, subsample_name_arg, prior_shape_arg, variance_arg, options_list_arg),
symbol_table(symbol_table_arg)
{
@ -3724,7 +3724,7 @@ CorrPriorStatement::CorrPriorStatement(const string &name_arg1, const string &na
const PriorDistributions &prior_shape_arg,
const expr_t &variance_arg,
const OptionsList &options_list_arg,
const SymbolTable &symbol_table_arg ) :
const SymbolTable &symbol_table_arg) :
BasicPriorStatement(name_arg1, subsample_name_arg, prior_shape_arg, variance_arg, options_list_arg),
name1(name_arg2),
symbol_table(symbol_table_arg)
@ -3824,8 +3824,8 @@ PriorEqualStatement::PriorEqualStatement(const string &to_declaration_type_arg,
void
PriorEqualStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings)
{
if ((to_declaration_type != "par" && to_declaration_type != "std" && to_declaration_type != "corr") ||
(from_declaration_type != "par" && from_declaration_type != "std" && from_declaration_type != "corr"))
if ((to_declaration_type != "par" && to_declaration_type != "std" && to_declaration_type != "corr")
|| (from_declaration_type != "par" && from_declaration_type != "std" && from_declaration_type != "corr"))
{
cerr << "Internal Dynare Error" << endl;
exit(EXIT_FAILURE);
@ -3856,7 +3856,6 @@ PriorEqualStatement::writeOutput(ostream &output, const string &basename, bool m
else
get_base_name(symbol_table.getType(from_name1), rhs_field);
if (to_declaration_type == "corr")
lhs_field += "_corr";
@ -4045,7 +4044,7 @@ OptionsStatement::writeCOutput(ostream &output, const string &basename)
StdOptionsStatement::StdOptionsStatement(const string &name_arg,
const string &subsample_name_arg,
const OptionsList &options_list_arg,
const SymbolTable &symbol_table_arg ) :
const SymbolTable &symbol_table_arg) :
BasicOptionsStatement(name_arg, subsample_name_arg, options_list_arg),
symbol_table(symbol_table_arg)
{
@ -4095,7 +4094,7 @@ StdOptionsStatement::writeCOutput(ostream &output, const string &basename)
CorrOptionsStatement::CorrOptionsStatement(const string &name_arg1, const string &name_arg2,
const string &subsample_name_arg,
const OptionsList &options_list_arg,
const SymbolTable &symbol_table_arg ) :
const SymbolTable &symbol_table_arg) :
BasicOptionsStatement(name_arg1, subsample_name_arg, options_list_arg),
name1(name_arg2),
symbol_table(symbol_table_arg)
@ -4189,8 +4188,8 @@ OptionsEqualStatement::OptionsEqualStatement(const string &to_declaration_type_a
void
OptionsEqualStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings)
{
if ((to_declaration_type != "par" && to_declaration_type != "std" && to_declaration_type != "corr") ||
(from_declaration_type != "par" && from_declaration_type != "std" && from_declaration_type != "corr"))
if ((to_declaration_type != "par" && to_declaration_type != "std" && to_declaration_type != "corr")
|| (from_declaration_type != "par" && from_declaration_type != "std" && from_declaration_type != "corr"))
{
cerr << "Internal Dynare Error" << endl;
exit(EXIT_FAILURE);
@ -4236,7 +4235,6 @@ OptionsEqualStatement::writeOutput(ostream &output, const string &basename, bool
else
get_base_name(symbol_table.getType(from_name1), rhs_field);
if (to_declaration_type == "corr")
lhs_field += "_corr";

View File

@ -146,7 +146,8 @@ public:
class RamseyConstraintsStatement : public Statement
{
public:
struct Constraint {
struct Constraint
{
int endo;
BinaryOpcode code;
expr_t expression;
@ -455,7 +456,8 @@ public:
/*! \param model_tree_arg the model tree used to store the objective function.
It is owned by the PlannerObjectiveStatement, and will be deleted by its destructor */
PlannerObjectiveStatement(StaticModel *model_tree_arg);
virtual ~PlannerObjectiveStatement();
virtual
~PlannerObjectiveStatement();
/*! \todo check there are only endogenous variables at the current period in the objective
(no exogenous, no lead/lag) */
virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings);
@ -819,11 +821,11 @@ public:
virtual void writeJsonOutput(ostream &output) const;
};
class BasicPriorStatement : public Statement
{
public:
virtual ~BasicPriorStatement();
virtual
~BasicPriorStatement();
protected:
const string name;
const string subsample_name;
@ -932,7 +934,8 @@ public:
class BasicOptionsStatement : public Statement
{
public:
virtual ~BasicOptionsStatement();
virtual
~BasicOptionsStatement();
protected:
const string name;
const string subsample_name;

View File

@ -102,7 +102,7 @@ ConfigFile::getConfigFileInfo(const string &config_file)
if (config_file.empty())
{
string defaultConfigFile ("");
string defaultConfigFile("");
// Test OS and try to open default file
#if defined(_WIN32) || defined(__CYGWIN32__)
if (getenv("APPDATA") == NULL)
@ -158,7 +158,6 @@ ConfigFile::getConfigFileInfo(const string &config_file)
}
}
string name, computerName, port, userName, password, remoteDrive,
remoteDirectory, dynarePath, matlabOctavePath, operatingSystem,
global_init_file;
@ -271,7 +270,7 @@ ConfigFile::getConfigFileInfo(const string &config_file)
vector<string> tokenizedPath;
split(tokenizedPath, tokenizedLine.back(), is_any_of(":"), token_compress_on);
for (vector<string>::iterator it = tokenizedPath.begin();
it != tokenizedPath.end(); it++ )
it != tokenizedPath.end(); it++)
if (!it->empty())
{
trim(*it);
@ -375,7 +374,7 @@ ConfigFile::getConfigFileInfo(const string &config_file)
for (tokenizer<char_separator<char> >::iterator it = tokens.begin();
it != tokens.end(); it++)
{
string token (*it);
string token(*it);
if (token.compare("(") == 0)
{
begin_weight = true;
@ -525,10 +524,10 @@ void
ConfigFile::checkPass(WarningConsolidation &warnings) const
{
bool global_init_file_declared = false;
for (vector<Hook *>::const_iterator it = hooks.begin() ; it != hooks.end(); it++)
for (vector<Hook *>::const_iterator it = hooks.begin(); it != hooks.end(); it++)
{
const map <string, string> hookmap = (*it)->get_hooks();
for (map <string, string>::const_iterator mapit = hookmap.begin() ; mapit != hookmap.end(); mapit++)
for (map <string, string>::const_iterator mapit = hookmap.begin(); mapit != hookmap.end(); mapit++)
if (mapit->first.compare("global_init_file") == 0)
if (global_init_file_declared == true)
{
@ -686,10 +685,10 @@ vector<string>
ConfigFile::getIncludePaths() const
{
vector<string> include_paths;
for (vector<Path *>::const_iterator it = paths.begin() ; it != paths.end(); it++)
for (vector<Path *>::const_iterator it = paths.begin(); it != paths.end(); it++)
{
map <string, vector<string> > pathmap = (*it)->get_paths();
for (map <string, vector<string> >::const_iterator mapit = pathmap.begin() ; mapit != pathmap.end(); mapit++)
for (map <string, vector<string> >::const_iterator mapit = pathmap.begin(); mapit != pathmap.end(); mapit++)
for (vector<string>::const_iterator vecit = mapit->second.begin(); vecit != mapit->second.end(); vecit++)
include_paths.push_back(*vecit);
}
@ -699,10 +698,10 @@ ConfigFile::getIncludePaths() const
void
ConfigFile::writeHooks(ostream &output) const
{
for (vector<Hook *>::const_iterator it = hooks.begin() ; it != hooks.end(); it++)
for (vector<Hook *>::const_iterator it = hooks.begin(); it != hooks.end(); it++)
{
map <string, string> hookmap = (*it)->get_hooks();
for (map <string, string>::const_iterator mapit = hookmap.begin() ; mapit != hookmap.end(); mapit++)
for (map <string, string>::const_iterator mapit = hookmap.begin(); mapit != hookmap.end(); mapit++)
output << "options_." << mapit->first << " = '" << mapit->second << "';" << endl;
}
}

View File

@ -37,7 +37,11 @@ public:
private:
map<string, string> hooks;
public:
inline map<string, string>get_hooks() { return hooks; };
inline map<string, string>
get_hooks()
{
return hooks;
};
};
class Path
@ -48,7 +52,11 @@ public:
private:
map<string, vector<string> > paths;
public:
inline map<string, vector<string> >get_paths() { return paths; };
inline map<string, vector<string> >
get_paths()
{
return paths;
};
};
class SlaveNode

View File

@ -104,7 +104,8 @@ private:
public:
DataTree(SymbolTable &symbol_table_arg, NumericalConstants &num_constants_arg, ExternalFunctionsTable &external_functions_table_arg);
virtual ~DataTree();
virtual
~DataTree();
//! Some predefined constants
expr_t Zero, One, Two, MinusOne, NaN, Infinity, MinusInfinity, Pi;

View File

@ -1140,7 +1140,7 @@ DynamicModel::writeModelEquationsCode_Block(string &file_name, const string &bin
for (var_t::const_iterator it1 = it->second.begin(); it1 != it->second.end(); it1++)
{
count_col_det_exo++;
if (find (exo_det.begin(), exo_det.end(), *it1) == exo_det.end())
if (find(exo_det.begin(), exo_det.end(), *it1) == exo_det.end())
exo_det.push_back(*it1);
}
@ -1150,7 +1150,7 @@ DynamicModel::writeModelEquationsCode_Block(string &file_name, const string &bin
for (var_t::const_iterator it1 = it->second.begin(); it1 != it->second.end(); it1++)
{
count_col_exo++;
if (find (exo.begin(), exo.end(), *it1) == exo.end())
if (find(exo.begin(), exo.end(), *it1) == exo.end())
exo.push_back(*it1);
}
@ -1160,7 +1160,7 @@ DynamicModel::writeModelEquationsCode_Block(string &file_name, const string &bin
for (var_t::const_iterator it1 = it->second.begin(); it1 != it->second.end(); it1++)
{
count_col_other_endo++;
if (find (other_endo.begin(), other_endo.end(), *it1) == other_endo.end())
if (find(other_endo.begin(), other_endo.end(), *it1) == other_endo.end())
other_endo.push_back(*it1);
}
@ -1202,10 +1202,10 @@ DynamicModel::writeModelEquationsCode_Block(string &file_name, const string &bin
if (dynamic_cast<AbstractExternalFunctionNode *>(*it) != NULL)
(*it)->compileExternalFunctionOutput(code_file, instruction_number, false, tt2, map_idx, true, false, tef_terms);
FNUMEXPR_ fnumexpr(TemporaryTerm, (int) (map_idx.find((*it)->idx)->second));
FNUMEXPR_ fnumexpr(TemporaryTerm, (int)(map_idx.find((*it)->idx)->second));
fnumexpr.write(code_file, instruction_number);
(*it)->compile(code_file, instruction_number, false, tt2, map_idx, true, false, tef_terms);
FSTPT_ fstpt((int) (map_idx.find((*it)->idx)->second));
FSTPT_ fstpt((int)(map_idx.find((*it)->idx)->second));
fstpt.write(code_file, instruction_number);
// Insert current node into tt2
tt2.insert(*it);
@ -2772,7 +2772,7 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
int count_other_endogenous = 1;
for (set<int>::const_iterator it_other_endogenous = other_endogenous.begin(); it_other_endogenous != other_endogenous.end(); it_other_endogenous++)
{
for (vector<int>::const_iterator it=state_var.begin(); it != state_var.end(); it++)
for (vector<int>::const_iterator it = state_var.begin(); it != state_var.end(); it++)
{
//cout << "block = " << block+1 << " state_var = " << *it << " it_other_endogenous=" << *it_other_endogenous + 1 << "\n";
if (*it == *it_other_endogenous + 1)
@ -2815,7 +2815,7 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
}
else if (lag == 0)
{
if (find( local_state_var.begin(), local_state_var.end(), getBlockVariableID(block, it->first.second.first)+1) == local_state_var.end())
if (find(local_state_var.begin(), local_state_var.end(), getBlockVariableID(block, it->first.second.first)+1) == local_state_var.end())
{
local_stat_var.push_back(getBlockVariableID(block, it->first.second.first)+1);
n_static++;
@ -2830,7 +2830,7 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
}
else
{
if (find(local_stat_var.begin(), local_stat_var.end(),getBlockVariableID(block, it->first.second.first)+1) != local_stat_var.end())
if (find(local_stat_var.begin(), local_stat_var.end(), getBlockVariableID(block, it->first.second.first)+1) != local_stat_var.end())
n_static--;
n_forward++;
}
@ -2850,12 +2850,12 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
tmp_s.str("");
}
vector<int> inter_state_var;
for (vector<int>::const_iterator it_l=local_state_var.begin(); it_l != local_state_var.end(); it_l++)
for (vector<int>::const_iterator it=state_var.begin(); it != state_var.end(); it++)
for (vector<int>::const_iterator it_l = local_state_var.begin(); it_l != local_state_var.end(); it_l++)
for (vector<int>::const_iterator it = state_var.begin(); it != state_var.end(); it++)
if (*it == *it_l)
inter_state_var.push_back(it - state_var.begin()+1);
output << "block_structure.block(" << block+1 << ").sorted_col_dr_ghx = [";
for (vector<int>::const_iterator it=inter_state_var.begin(); it != inter_state_var.end(); it++)
for (vector<int>::const_iterator it = inter_state_var.begin(); it != inter_state_var.end(); it++)
output << *it << " ";
output << "];\n";
count_lead_lag_incidence = 0;
@ -2901,10 +2901,10 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
output << "];\n";
vector<int> variable_inv_reordered(nb_endo);
for (int i = 0; i< nb_endo; i++)
for (int i = 0; i < nb_endo; i++)
variable_inv_reordered[variable_reordered[i]] = i;
for (vector<int>::const_iterator it=state_var.begin(); it != state_var.end(); it++)
for (vector<int>::const_iterator it = state_var.begin(); it != state_var.end(); it++)
state_equ.push_back(equation_reordered[variable_inv_reordered[*it - 1]]+1);
map<pair< int, pair<int, int> >, int> lag_row_incidence;
@ -2982,7 +2982,6 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
row_state_var_incidence.insert(make_pair(it_state_equ - state_equ.begin(), it_state_var - state_var.begin()));
}
}
/*tmp_block_endo_derivative[make_pair(it->second.first, make_pair(it->first.second, it->first.first))] = it->second.second;
if (block == 0)
@ -2995,7 +2994,7 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
row_state_var_incidence.insert(make_pair(it_state_equ - state_equ.begin(), it_state_var - state_var.begin()));
}
}*/
set<pair<int,int> >::const_iterator row_state_var_incidence_it = row_state_var_incidence.begin();
set<pair<int, int> >::const_iterator row_state_var_incidence_it = row_state_var_incidence.begin();
bool diag = true;
int nb_diag_r = 0;
while (row_state_var_incidence_it != row_state_var_incidence.end() && diag)
@ -3010,10 +3009,10 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
}
}
set<pair<int,int> > col_state_var_incidence;
for(set<pair<int,int> >::const_iterator row_state_var_incidence_it = row_state_var_incidence.begin();row_state_var_incidence_it != row_state_var_incidence.end(); row_state_var_incidence_it++)
set<pair<int, int> > col_state_var_incidence;
for (set<pair<int, int> >::const_iterator row_state_var_incidence_it = row_state_var_incidence.begin(); row_state_var_incidence_it != row_state_var_incidence.end(); row_state_var_incidence_it++)
col_state_var_incidence.insert(make_pair(row_state_var_incidence_it->second, row_state_var_incidence_it->first));
set<pair<int,int> >::const_iterator col_state_var_incidence_it = col_state_var_incidence.begin();
set<pair<int, int> >::const_iterator col_state_var_incidence_it = col_state_var_incidence.begin();
diag = true;
int nb_diag_c = 0;
while (col_state_var_incidence_it != col_state_var_incidence.end() && diag)
@ -3027,7 +3026,7 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
nb_diag_c++;
}
}
nb_diag = min( nb_diag_r, nb_diag_c);
nb_diag = min(nb_diag_r, nb_diag_c);
row_state_var_incidence.clear();
col_state_var_incidence.clear();
}
@ -3042,7 +3041,6 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
output << modstruct << "n_diag = " << nb_diag << ";" << endl;
KF_index_file.write(reinterpret_cast<char *>(&nb_diag), sizeof(nb_diag));
typedef pair<int, pair<int, int > > index_KF;
vector<index_KF> v_index_KF;
for (int i = 0; i < n; i++)
@ -3050,7 +3048,7 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
for (int j = n_obs; j < n; j++)
{
int j1 = j - n_obs;
int j1_n_state = j1 * n_state - n_obs ;
int j1_n_state = j1 * n_state - n_obs;
if ((i < n_obs) || (i >= nb_diag + n_obs) || (j1 >= nb_diag))
for (int k = n_obs; k < i_nz_state_var[i]; k++)
{
@ -3085,7 +3083,7 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
}
output << modstruct << "state_var = [";
for (vector<int>::const_iterator it=state_var.begin(); it != state_var.end(); it++)
for (vector<int>::const_iterator it = state_var.begin(); it != state_var.end(); it++)
output << *it << " ";
output << "];" << endl;
}
@ -3101,21 +3099,21 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
output << modstruct << "maximum_endo_lag = " << max_endo_lag << ";" << endl
<< modstruct << "maximum_endo_lead = " << max_endo_lead << ";" << endl
<< outstruct << "steady_state = zeros(" << symbol_table.endo_nbr() << (julia ? ")" : ", 1);" ) << endl;
<< outstruct << "steady_state = zeros(" << symbol_table.endo_nbr() << (julia ? ")" : ", 1);") << endl;
output << modstruct << "maximum_exo_lag = " << max_exo_lag << ";" << endl
<< modstruct << "maximum_exo_lead = " << max_exo_lead << ";" << endl
<< outstruct << "exo_steady_state = zeros(" << symbol_table.exo_nbr() << (julia ? ")" : ", 1);" ) << endl;
<< outstruct << "exo_steady_state = zeros(" << symbol_table.exo_nbr() << (julia ? ")" : ", 1);") << endl;
if (symbol_table.exo_det_nbr())
{
output << modstruct << "maximum_exo_det_lag = " << max_exo_det_lag << ";" << endl
<< modstruct << "maximum_exo_det_lead = " << max_exo_det_lead << ";" << endl
<< outstruct << "exo_det_steady_state = zeros(" << symbol_table.exo_det_nbr() << (julia ? ")" : ", 1);" ) << endl;
<< outstruct << "exo_det_steady_state = zeros(" << symbol_table.exo_det_nbr() << (julia ? ")" : ", 1);") << endl;
}
output << modstruct << "params = " << (julia ? "fill(NaN, " : "NaN(")
<< symbol_table.param_nbr() << (julia ? ")" : ", 1);" ) << endl;
<< symbol_table.param_nbr() << (julia ? ")" : ", 1);") << endl;
if (compute_xrefs)
writeXrefs(output);
@ -3532,7 +3530,7 @@ DynamicModel::collect_block_first_order_derivatives()
int var = symbol_table.getTypeSpecificID(getSymbIDByDerivID(it2->first.second));
int lag = getLagByDerivID(it2->first.second);
int block_eq = equation_2_block[eq];
int block_var=0;
int block_var = 0;
derivative_t tmp_derivative;
lag_var_t lag_var;
switch (getTypeByDerivID(it2->first.second))
@ -4478,7 +4476,6 @@ DynamicModel::substituteLeadLagInternal(aux_var_t type, bool deterministic_model
equations[i] = substeq;
}
// Substitute in aux_equations
// Without this loop, the auxiliary equations in equations
// will diverge from those in aux_equations
@ -4724,7 +4721,7 @@ DynamicModel::dynamicOnlyEquationsNbr() const
}
#ifndef PRIVATE_BUFFER_SIZE
#define PRIVATE_BUFFER_SIZE 1024
# define PRIVATE_BUFFER_SIZE 1024
#endif
bool
@ -4785,10 +4782,10 @@ DynamicModel::isChecksumMatching(const string &basename) const
}
char private_buffer[PRIVATE_BUFFER_SIZE];
while(buffer)
while (buffer)
{
buffer.get(private_buffer,PRIVATE_BUFFER_SIZE);
result.process_bytes(private_buffer,strlen(private_buffer));
buffer.get(private_buffer, PRIVATE_BUFFER_SIZE);
result.process_bytes(private_buffer, strlen(private_buffer));
}
bool basename_dir_exists = false;
@ -4877,7 +4874,7 @@ DynamicModel::writeCOutput(ostream &output, const string &basename, bool block_d
output << "size_t zeta_static[" << zeta_static.size() << "] = {";
for (vector<int>::iterator i = zeta_static.begin(); i != zeta_static.end(); ++i)
{
if ( i != zeta_static.begin() )
if (i != zeta_static.begin())
output << ",";
output << *i;
}
@ -4886,7 +4883,7 @@ DynamicModel::writeCOutput(ostream &output, const string &basename, bool block_d
output << "size_t zeta_back[" << zeta_back.size() << "] = {";
for (vector<int>::iterator i = zeta_back.begin(); i != zeta_back.end(); ++i)
{
if ( i != zeta_back.begin() )
if (i != zeta_back.begin())
output << ",";
output << *i;
}
@ -4895,7 +4892,7 @@ DynamicModel::writeCOutput(ostream &output, const string &basename, bool block_d
output << "size_t zeta_fwrd[" << zeta_fwrd.size() << "] = {";
for (vector<int>::iterator i = zeta_fwrd.begin(); i != zeta_fwrd.end(); ++i)
{
if ( i != zeta_fwrd.begin() )
if (i != zeta_fwrd.begin())
output << ",";
output << *i;
}
@ -4904,7 +4901,7 @@ DynamicModel::writeCOutput(ostream &output, const string &basename, bool block_d
output << "size_t zeta_mixed[" << zeta_mixed.size() << "] = {";
for (vector<int>::iterator i = zeta_mixed.begin(); i != zeta_mixed.end(); ++i)
{
if ( i != zeta_mixed.begin() )
if (i != zeta_mixed.begin())
output << ",";
output << *i;
}
@ -5090,7 +5087,6 @@ DynamicModel::writeFirstDerivativesC_csr(const string &basename, bool cuda) cons
// this is always empty here, but needed by d1->writeOutput
deriv_node_temp_terms_t tef_terms;
// Indexing derivatives in column order
vector<derivative> D;
for (first_derivatives_t::const_iterator it = first_derivatives.begin();
@ -5103,7 +5099,7 @@ DynamicModel::writeFirstDerivativesC_csr(const string &basename, bool cuda) cons
SymbolType type = getTypeByDerivID(dynvar);
int tsid = symbol_table.getTypeSpecificID(symb_id);
int col_id;
switch(type)
switch (type)
{
case eEndogenous:
col_id = tsid+(lag+1)*symbol_table.endo_nbr();
@ -5118,16 +5114,16 @@ DynamicModel::writeFirstDerivativesC_csr(const string &basename, bool cuda) cons
std::cerr << "This case shouldn't happen" << std::endl;
exit(EXIT_FAILURE);
}
derivative deriv(col_id + eq*cols_nbr,col_id,eq,it->second);
derivative deriv(col_id + eq *cols_nbr, col_id, eq, it->second);
D.push_back(deriv);
}
sort(D.begin(), D.end(), derivative_less_than() );
sort(D.begin(), D.end(), derivative_less_than());
// writing sparse Jacobian
vector<int> row_ptr(equations.size());
fill(row_ptr.begin(),row_ptr.end(),0.0);
fill(row_ptr.begin(), row_ptr.end(), 0.0);
int k = 0;
for(vector<derivative>::const_iterator it = D.begin(); it != D.end(); ++it)
for (vector<derivative>::const_iterator it = D.begin(); it != D.end(); ++it)
{
row_ptr[it->row_nbr]++;
mDynamicModelFile << "col_ptr[" << k << "] "
@ -5142,7 +5138,7 @@ DynamicModel::writeFirstDerivativesC_csr(const string &basename, bool cuda) cons
// row_ptr must point to the relative address of the first element of the row
int cumsum = 0;
mDynamicModelFile << "int row_ptr_data[" << row_ptr.size() + 1 << "] = { 0";
for (vector<int>::iterator it=row_ptr.begin(); it != row_ptr.end(); ++it)
for (vector<int>::iterator it = row_ptr.begin(); it != row_ptr.end(); ++it)
{
cumsum += *it;
mDynamicModelFile << ", " << cumsum;
@ -5155,7 +5151,7 @@ DynamicModel::writeFirstDerivativesC_csr(const string &basename, bool cuda) cons
mDynamicModelFile.close();
}
void
void
DynamicModel::writeSecondDerivativesC_csr(const string &basename, bool cuda) const
{
@ -5211,22 +5207,22 @@ DynamicModel::writeSecondDerivativesC_csr(const string &basename, bool cuda) con
int col_nb = id1 * dynJacobianColsNbr + id2;
derivative deriv(col_nb + eq*hessianColsNbr,col_nb,eq,it->second);
derivative deriv(col_nb + eq *hessianColsNbr, col_nb, eq, it->second);
D.push_back(deriv);
if (id1 != id2)
{
col_nb = id2 * dynJacobianColsNbr + id1;
derivative deriv(col_nb + eq*hessianColsNbr,col_nb,eq,it->second);
derivative deriv(col_nb + eq *hessianColsNbr, col_nb, eq, it->second);
D.push_back(deriv);
}
}
sort(D.begin(), D.end(), derivative_less_than() );
sort(D.begin(), D.end(), derivative_less_than());
// Writing Hessian
vector<int> row_ptr(equations.size());
fill(row_ptr.begin(),row_ptr.end(),0.0);
fill(row_ptr.begin(), row_ptr.end(), 0.0);
int k = 0;
for(vector<derivative>::const_iterator it = D.begin(); it != D.end(); ++it)
for (vector<derivative>::const_iterator it = D.begin(); it != D.end(); ++it)
{
row_ptr[it->row_nbr]++;
mDynamicModelFile << "col_ptr[" << k << "] "
@ -5241,7 +5237,7 @@ DynamicModel::writeSecondDerivativesC_csr(const string &basename, bool cuda) con
// row_ptr must point to the relative address of the first element of the row
int cumsum = 0;
mDynamicModelFile << "row_ptr = [ 0";
for (vector<int>::iterator it=row_ptr.begin(); it != row_ptr.end(); ++it)
for (vector<int>::iterator it = row_ptr.begin(); it != row_ptr.end(); ++it)
{
cumsum += *it;
mDynamicModelFile << ", " << cumsum;
@ -5314,51 +5310,51 @@ DynamicModel::writeThirdDerivativesC_csr(const string &basename, bool cuda) cons
vector<long unsigned int> cols;
long unsigned int col_nb = id1 * hessianColsNbr + id2 * dynJacobianColsNbr + id3;
int thirdDColsNbr = hessianColsNbr*dynJacobianColsNbr;
derivative deriv(col_nb + eq*thirdDColsNbr,col_nb,eq,it->second);
derivative deriv(col_nb + eq *thirdDColsNbr, col_nb, eq, it->second);
D.push_back(deriv);
cols.push_back(col_nb);
col_nb = id1 * hessianColsNbr + id3 * dynJacobianColsNbr + id2;
if (find(cols.begin(),cols.end(),col_nb) == cols.end())
if (find(cols.begin(), cols.end(), col_nb) == cols.end())
{
derivative deriv(col_nb + eq*thirdDerivativesColsNbr,col_nb,eq,it->second);
derivative deriv(col_nb + eq *thirdDerivativesColsNbr, col_nb, eq, it->second);
D.push_back(deriv);
cols.push_back(col_nb);
}
col_nb = id2 * hessianColsNbr + id1 * dynJacobianColsNbr + id3;
if (find(cols.begin(),cols.end(),col_nb) == cols.end())
if (find(cols.begin(), cols.end(), col_nb) == cols.end())
{
derivative deriv(col_nb + eq*thirdDerivativesColsNbr,col_nb,eq,it->second);
derivative deriv(col_nb + eq *thirdDerivativesColsNbr, col_nb, eq, it->second);
D.push_back(deriv);
cols.push_back(col_nb);
}
col_nb = id2 * hessianColsNbr + id3 * dynJacobianColsNbr + id1;
if (find(cols.begin(),cols.end(),col_nb) == cols.end())
if (find(cols.begin(), cols.end(), col_nb) == cols.end())
{
derivative deriv(col_nb + eq*thirdDerivativesColsNbr,col_nb,eq,it->second);
derivative deriv(col_nb + eq *thirdDerivativesColsNbr, col_nb, eq, it->second);
D.push_back(deriv);
cols.push_back(col_nb);
}
col_nb = id3 * hessianColsNbr + id1 * dynJacobianColsNbr + id2;
if (find(cols.begin(),cols.end(),col_nb) == cols.end())
if (find(cols.begin(), cols.end(), col_nb) == cols.end())
{
derivative deriv(col_nb + eq*thirdDerivativesColsNbr,col_nb,eq,it->second);
derivative deriv(col_nb + eq *thirdDerivativesColsNbr, col_nb, eq, it->second);
D.push_back(deriv);
cols.push_back(col_nb);
}
col_nb = id3 * hessianColsNbr + id2 * dynJacobianColsNbr + id1;
if (find(cols.begin(),cols.end(),col_nb) == cols.end())
if (find(cols.begin(), cols.end(), col_nb) == cols.end())
{
derivative deriv(col_nb + eq*thirdDerivativesColsNbr,col_nb,eq,it->second);
derivative deriv(col_nb + eq *thirdDerivativesColsNbr, col_nb, eq, it->second);
D.push_back(deriv);
}
}
sort(D.begin(), D.end(), derivative_less_than() );
sort(D.begin(), D.end(), derivative_less_than());
vector<int> row_ptr(equations.size());
fill(row_ptr.begin(),row_ptr.end(),0.0);
fill(row_ptr.begin(), row_ptr.end(), 0.0);
int k = 0;
for(vector<derivative>::const_iterator it = D.begin(); it != D.end(); ++it)
for (vector<derivative>::const_iterator it = D.begin(); it != D.end(); ++it)
{
row_ptr[it->row_nbr]++;
mDynamicModelFile << "col_ptr[" << k << "] "
@ -5373,7 +5369,7 @@ DynamicModel::writeThirdDerivativesC_csr(const string &basename, bool cuda) cons
// row_ptr must point to the relative address of the first element of the row
int cumsum = 0;
mDynamicModelFile << "row_ptr = [ 0";
for (vector<int>::iterator it=row_ptr.begin(); it != row_ptr.end(); ++it)
for (vector<int>::iterator it = row_ptr.begin(); it != row_ptr.end(); ++it)
{
cumsum += *it;
mDynamicModelFile << ", " << cumsum;
@ -5441,7 +5437,6 @@ DynamicModel::writeCCOutput(ostream &output, const string &basename, bool block_
<< "NNZDerivatives.push_back(-1);" << endl;
}
void
DynamicModel::writeJsonOutput(ostream &output) const
{

View File

@ -543,14 +543,17 @@ public:
long unsigned int col_nbr;
unsigned int row_nbr;
expr_t value;
derivative(long unsigned int arg1, long unsigned int arg2, int arg3, expr_t arg4):
linear_address(arg1), col_nbr(arg2), row_nbr(arg3), value(arg4) {};
derivative(long unsigned int arg1, long unsigned int arg2, int arg3, expr_t arg4) :
linear_address(arg1), col_nbr(arg2), row_nbr(arg3), value(arg4)
{
};
};
class derivative_less_than
{
public:
bool operator()(const derivative & d1, const derivative & d2) const
bool
operator()(const derivative &d1, const derivative &d2) const
{
return d1.linear_address < d2.linear_address;
}

View File

@ -130,8 +130,8 @@ main(int argc, char **argv)
clear_all = false;
else if (strlen(argv[arg]) >= 19 && !strncmp(argv[arg], "params_derivs_order", 19))
{
if (strlen(argv[arg]) >= 22 || argv[arg][19] != '=' ||
!(argv[arg][20] == '0' || argv[arg][20] == '1' || argv[arg][20] == '2'))
if (strlen(argv[arg]) >= 22 || argv[arg][19] != '='
|| !(argv[arg][20] == '0' || argv[arg][20] == '1' || argv[arg][20] == '2'))
{
cerr << "Incorrect syntax for params_derivs_order option" << endl;
usage();
@ -228,12 +228,12 @@ main(int argc, char **argv)
size_t equal_index = string(argv[arg]).find('=');
if (equal_index != string::npos)
{
string key = string(argv[arg]).erase(equal_index).erase(0,2);
string key = string(argv[arg]).erase(equal_index).erase(0, 2);
defines[key] = string(argv[arg]).erase(0, equal_index+1);
}
else
{
string key = string(argv[arg]).erase(0,2);
string key = string(argv[arg]).erase(0, 2);
defines[key] = "1";
}
}
@ -245,7 +245,7 @@ main(int argc, char **argv)
<< "must not be separated from -I by whitespace." << endl;
usage();
}
path.push_back(string(argv[arg]).erase(0,2));
path.push_back(string(argv[arg]).erase(0, 2));
}
else if (strlen(argv[arg]) >= 6 && !strncmp(argv[arg], "output", 6))
{

View File

@ -107,7 +107,7 @@ ExprNode::collectVariables(SymbolType type, set<int> &result) const
set<pair<int, int> > symbs_lags;
collectDynamicVariables(type, symbs_lags);
transform(symbs_lags.begin(), symbs_lags.end(), inserter(result, result.begin()),
boost::bind(&pair<int,int>::first,_1));
boost::bind(&pair<int, int>::first, _1));
}
void
@ -537,7 +537,6 @@ NumConstNode::substituteStaticAuxiliaryVariable() const
return const_cast<NumConstNode *>(this);
}
VariableNode::VariableNode(DataTree &datatree_arg, int symb_id_arg, int lag_arg) :
ExprNode(datatree_arg),
symb_id(symb_id_arg),
@ -2660,7 +2659,7 @@ UnaryOpNode::substituteExoLag(subst_table_t &subst_table, vector<BinaryOpNode *>
expr_t
UnaryOpNode::substituteExpectation(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool partial_information_model) const
{
if (op_code==oExpectation)
if (op_code == oExpectation)
{
subst_table_t::iterator it = subst_table.find(const_cast<UnaryOpNode *>(this));
if (it != subst_table.end())
@ -4160,7 +4159,6 @@ BinaryOpNode::substituteExpectation(subst_table_t &subst_table, vector<BinaryOpN
return buildSimilarBinaryOpNode(arg1subst, arg2subst, datatree);
}
expr_t
BinaryOpNode::differentiateForwardVars(const vector<string> &subset, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const
{
@ -4877,7 +4875,6 @@ TrinaryOpNode::substituteExpectation(subst_table_t &subst_table, vector<BinaryOp
return buildSimilarTrinaryOpNode(arg1subst, arg2subst, arg3subst, datatree);
}
expr_t
TrinaryOpNode::differentiateForwardVars(const vector<string> &subset, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const
{

View File

@ -122,8 +122,8 @@ enum ExprNodeOutputType
#define MIN_COST(is_matlab) ((is_matlab) ? MIN_COST_MATLAB : MIN_COST_C)
//! Base class for expression nodes
class ExprNode
{
class ExprNode
{
friend class DataTree;
friend class DynamicModel;
friend class StaticModel;
@ -135,12 +135,12 @@ class ExprNode
friend class BinaryOpNode;
friend class TrinaryOpNode;
friend class AbstractExternalFunctionNode;
private:
private:
//! Computes derivative w.r. to a derivation ID (but doesn't store it in derivatives map)
/*! You shoud use getDerivative() to get the benefit of symbolic a priori and of caching */
virtual expr_t computeDerivative(int deriv_id) = 0;
protected:
protected:
//! Reference to the enclosing DataTree
DataTree &datatree;
@ -171,9 +171,10 @@ protected:
set<pair<int, int> > exo_det;
};
public:
public:
ExprNode(DataTree &datatree_arg);
virtual ~ExprNode();
virtual
~ExprNode();
//! Initializes data member non_null_derivatives
virtual void prepareForDerivation() = 0;
@ -460,7 +461,7 @@ public:
//! Substitute auxiliary variables by their expression in static model
virtual expr_t substituteStaticAuxiliaryVariable() const = 0;
};
};
//! Object used to compare two nodes (using their indexes)
struct ExprNodeLess
@ -563,7 +564,11 @@ public:
{
return symb_id;
};
int get_lag() const { return lag; };
int
get_lag() const
{
return lag;
};
virtual pair<int, expr_t> normalizeEquation(int symb_id_endo, vector<pair<int, pair<expr_t, expr_t> > > &List_of_Op_RHS) const;
virtual expr_t getChainRuleDerivative(int deriv_id, const map<int, expr_t> &recursive_variables);
virtual int maxEndoLead() const;

View File

@ -257,15 +257,15 @@ ModFile::checkPass(bool nostrict)
exit(EXIT_FAILURE);
}
if (dynamic_model.staticOnlyEquationsNbr() > 0 &&
(mod_file_struct.ramsey_model_present || mod_file_struct.discretionary_policy_present))
if (dynamic_model.staticOnlyEquationsNbr() > 0
&& (mod_file_struct.ramsey_model_present || mod_file_struct.discretionary_policy_present))
{
cerr << "ERROR: marking equations as [static] or [dynamic] is not possible with ramsey_model, ramsey_policy or discretionary_policy" << endl;
exit(EXIT_FAILURE);
}
if (stochastic_statement_present &&
(dynamic_model.isUnaryOpUsed(oSign)
if (stochastic_statement_present
&& (dynamic_model.isUnaryOpUsed(oSign)
|| dynamic_model.isUnaryOpUsed(oAbs)
|| dynamic_model.isBinaryOpUsed(oMax)
|| dynamic_model.isBinaryOpUsed(oMin)
@ -289,7 +289,7 @@ ModFile::checkPass(bool nostrict)
{
cerr << "ERROR: some estimated parameters (";
for (set<int>::const_iterator it = parameters_intersect.begin();
it != parameters_intersect.end(); )
it != parameters_intersect.end();)
{
cerr << symbol_table.getName(*it);
if (++it != parameters_intersect.end())
@ -553,8 +553,8 @@ ModFile::computingPass(bool no_tmp_terms, FileOutputType output, int params_deri
else // No computing task requested, compute derivatives up to 2nd order by default
dynamic_model.computingPass(true, true, false, none, global_eval_context, no_tmp_terms, block, use_dll, byte_code);
if ((linear && !mod_file_struct.ramsey_model_present && !dynamic_model.checkHessianZero()) ||
(linear && mod_file_struct.ramsey_model_present && !orig_ramsey_dynamic_model.checkHessianZero()))
if ((linear && !mod_file_struct.ramsey_model_present && !dynamic_model.checkHessianZero())
|| (linear && mod_file_struct.ramsey_model_present && !orig_ramsey_dynamic_model.checkHessianZero()))
{
map<int, string> eqs;
if (mod_file_struct.ramsey_model_present)
@ -744,7 +744,7 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
}
#if defined(_WIN32) || defined(__CYGWIN32__)
#if (defined(_MSC_VER) && _MSC_VER < 1700)
# if (defined(_MSC_VER) && _MSC_VER < 1700)
// If using USE_DLL with MSVC 10.0 or earlier, check that the user didn't use a function not supported by the compiler (because MSVC <= 10.0 doesn't comply with C99 standard)
if (use_dll && msvc)
{
@ -764,7 +764,7 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
exit(EXIT_FAILURE);
}
}
#endif
# endif
#endif
// Compile the dynamic MEX file for use_dll option
@ -867,7 +867,6 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
<< "end" << endl;
}
if (!no_log)
mOutputFile << "diary off" << endl;
@ -898,7 +897,7 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
void
ModFile::writeExternalFiles(const string &basename, FileOutputType output, LanguageOutputType language) const
{
switch(language)
switch (language)
{
case c:
writeExternalFilesC(basename, output);
@ -926,7 +925,6 @@ ModFile::writeExternalFilesC(const string &basename, FileOutputType output) cons
if (!no_static)
static_model.writeStaticFile(basename, false, false, true, false);
// static_model.writeStaticCFile(basename, block, byte_code, use_dll);
// static_model.writeParamsDerivativesFileC(basename, cuda);
// static_model.writeAuxVarInitvalC(mOutputFile, oMatlabOutsideModel, cuda);

View File

@ -41,7 +41,7 @@ using namespace std;
// for checksum computation
#ifndef PRIVATE_BUFFER_SIZE
#define PRIVATE_BUFFER_SIZE 1024
# define PRIVATE_BUFFER_SIZE 1024
#endif
//! The abstract representation of a "mod" file

View File

@ -212,7 +212,7 @@ ModelTree::computeNonSingularNormalization(jacob_map_t &contemporaneous_jacobian
if (first_derivatives.find(make_pair(it->first.first, getDerivID(symbol_table.getID(eEndogenous, it->first.second), 0))) == first_derivatives.end())
first_derivatives[make_pair(it->first.first, getDerivID(symbol_table.getID(eEndogenous, it->first.second), 0))] = Zero;
}
catch(DataTree::UnknownDerivIDException &e)
catch (DataTree::UnknownDerivIDException &e)
{
cerr << "The variable " << symbol_table.getName(symbol_table.getID(eEndogenous, it->first.second))
<< " does not appear at the current period (i.e. with no lead and no lag); this case is not handled by the 'block' option of the 'model' block." << endl;
@ -1125,10 +1125,10 @@ ModelTree::computeTemporaryTerms(bool is_matlab)
temporary_terms_g2.clear();
temporary_terms_g3.clear();
map<NodeTreeReference, temporary_terms_t> temp_terms_map;
temp_terms_map[eResiduals]=temporary_terms_res;
temp_terms_map[eFirstDeriv]=temporary_terms_g1;
temp_terms_map[eSecondDeriv]=temporary_terms_g2;
temp_terms_map[eThirdDeriv]=temporary_terms_g3;
temp_terms_map[eResiduals] = temporary_terms_res;
temp_terms_map[eFirstDeriv] = temporary_terms_g1;
temp_terms_map[eSecondDeriv] = temporary_terms_g2;
temp_terms_map[eThirdDeriv] = temporary_terms_g3;
for (vector<BinaryOpNode *>::iterator it = equations.begin();
it != equations.end(); it++)
@ -1386,17 +1386,17 @@ ModelTree::compileTemporaryTerms(ostream &code_file, unsigned int &instruction_n
(*it)->compileExternalFunctionOutput(code_file, instruction_number, false, tt2, map_idx, dynamic, steady_dynamic, tef_terms);
}
FNUMEXPR_ fnumexpr(TemporaryTerm, (int) (map_idx.find((*it)->idx)->second));
FNUMEXPR_ fnumexpr(TemporaryTerm, (int)(map_idx.find((*it)->idx)->second));
fnumexpr.write(code_file, instruction_number);
(*it)->compile(code_file, instruction_number, false, tt2, map_idx, dynamic, steady_dynamic, tef_terms);
if (dynamic)
{
FSTPT_ fstpt((int) (map_idx.find((*it)->idx)->second));
FSTPT_ fstpt((int)(map_idx.find((*it)->idx)->second));
fstpt.write(code_file, instruction_number);
}
else
{
FSTPST_ fstpst((int) (map_idx.find((*it)->idx)->second));
FSTPST_ fstpst((int)(map_idx.find((*it)->idx)->second));
fstpst.write(code_file, instruction_number);
}
// Insert current node into tt2
@ -1871,11 +1871,11 @@ ModelTree::computeParamsDerivativesTemporaryTerms()
map<expr_t, pair<int, NodeTreeReference > > reference_count;
params_derivs_temporary_terms.clear();
map<NodeTreeReference, temporary_terms_t> temp_terms_map;
temp_terms_map[eResidualsParamsDeriv]=params_derivs_temporary_terms_res;
temp_terms_map[eJacobianParamsDeriv]=params_derivs_temporary_terms_g1;
temp_terms_map[eResidualsParamsSecondDeriv]=params_derivs_temporary_terms_res2;
temp_terms_map[eJacobianParamsSecondDeriv]=params_derivs_temporary_terms_g12;
temp_terms_map[eHessianParamsDeriv]=params_derivs_temporary_terms_g2;
temp_terms_map[eResidualsParamsDeriv] = params_derivs_temporary_terms_res;
temp_terms_map[eJacobianParamsDeriv] = params_derivs_temporary_terms_g1;
temp_terms_map[eResidualsParamsSecondDeriv] = params_derivs_temporary_terms_res2;
temp_terms_map[eJacobianParamsSecondDeriv] = params_derivs_temporary_terms_g12;
temp_terms_map[eHessianParamsDeriv] = params_derivs_temporary_terms_g2;
for (first_derivatives_t::iterator it = residuals_params_derivatives.begin();
it != residuals_params_derivatives.end(); it++)
@ -1918,7 +1918,8 @@ ModelTree::computeParamsDerivativesTemporaryTerms()
params_derivs_temporary_terms_g2 = temp_terms_map[eHessianParamsDeriv];
}
bool ModelTree::isNonstationary(int symb_id) const
bool
ModelTree::isNonstationary(int symb_id) const
{
return (nonstationary_symbols_map.find(symb_id)
!= nonstationary_symbols_map.end());
@ -1928,7 +1929,7 @@ void
ModelTree::writeJsonModelEquations(ostream &output, bool residuals) const
{
deriv_node_temp_terms_t tef_terms;
vector<pair<string,string> > eqtags;
vector<pair<string, string> > eqtags;
temporary_terms_t tt_empty;
if (residuals)
output << endl << "\"residuals\":[" << endl;
@ -1986,7 +1987,7 @@ ModelTree::writeJsonModelEquations(ostream &output, bool residuals) const
{
output << ", \"tags\": {";
int i = 0;
for (vector<pair<string, string> >:: const_iterator it = eqtags.begin(); it != eqtags.end(); it++, i++)
for (vector<pair<string, string> >::const_iterator it = eqtags.begin(); it != eqtags.end(); it++, i++)
{
if (i != 0)
output << ", ";

View File

@ -128,7 +128,6 @@ protected:
*/
third_derivatives_t hessian_params_derivatives;
//! Temporary terms for the static/dynamic file (those which will be noted Txxxx)
temporary_terms_t temporary_terms;
temporary_terms_t temporary_terms_res;
@ -144,7 +143,6 @@ protected:
temporary_terms_t params_derivs_temporary_terms_g12;
temporary_terms_t params_derivs_temporary_terms_g2;
//! Trend variables and their growth factors
map<int, expr_t> trend_symbols_map;
@ -177,7 +175,7 @@ protected:
void computeTemporaryTerms(bool is_matlab);
//! Computes temporary terms for the file containing parameters derivatives
void computeParamsDerivativesTemporaryTerms();
//! Writes temporary terms
//! Writes temporary terms
void writeTemporaryTerms(const temporary_terms_t &tt, const temporary_terms_t &ttm1, ostream &output, ExprNodeOutputType output_type, deriv_node_temp_terms_t &tef_terms) const;
void writeJsonTemporaryTerms(const temporary_terms_t &tt, const temporary_terms_t &ttm1, ostream &output, deriv_node_temp_terms_t &tef_terms, string &concat) const;
//! Compiles temporary terms
@ -274,7 +272,8 @@ protected:
virtual unsigned int getBlockMaxLag(int block_number) const = 0;
//! Return the maximum lead in a block
virtual unsigned int getBlockMaxLead(int block_number) const = 0;
inline void setBlockLeadLag(int block, int max_lag, int max_lead)
inline void
setBlockLeadLag(int block, int max_lag, int max_lead)
{
block_lag_lead[block] = make_pair(max_lag, max_lead);
};

View File

@ -259,8 +259,8 @@ void
ParsingDriver::declare_statement_local_variable(string *name)
{
if (mod_file->symbol_table.exists(*name))
error("Symbol " + *name + " cannot be assigned within a statement " +
"while being assigned elsewhere in the modfile");
error("Symbol " + *name + " cannot be assigned within a statement "
+"while being assigned elsewhere in the modfile");
declare_symbol(name, eStatementDeclaredVariable, NULL, NULL);
delete name;
}
@ -366,7 +366,7 @@ ParsingDriver::add_model_variable(string *name)
{
// This could be endog or param too. Just declare something to continue parsing,
// knowing that processing will end at the end of parsing of the model block
declare_exogenous(new string (*name));
declare_exogenous(new string(*name));
undeclared_model_vars.insert(*name);
symb_id = mod_file->symbol_table.getID(*name);
}
@ -1213,7 +1213,7 @@ ParsingDriver::option_symbol_list(const string &name_option)
!= options_list.symbol_list_options.end())
error("option " + name_option + " declared twice");
if (name_option.compare("irf_shocks")==0)
if (name_option.compare("irf_shocks") == 0)
{
vector<string> shocks = symbol_list.get_symbols();
for (vector<string>::const_iterator it = shocks.begin();
@ -1222,7 +1222,7 @@ ParsingDriver::option_symbol_list(const string &name_option)
error("Variables passed to irf_shocks must be exogenous. Caused by: " + *it);
}
if (name_option.compare("ms.parameters")==0)
if (name_option.compare("ms.parameters") == 0)
{
vector<string> parameters = symbol_list.get_symbols();
for (vector<string>::const_iterator it = parameters.begin();
@ -1415,7 +1415,7 @@ ParsingDriver::copy_subsamples(string *to_name1, string *to_name2, string *from_
if (!from_name2->empty())
check_symbol_existence(*from_name2);
if (subsample_declarations.find(make_pair(*from_name1,*from_name2)) == subsample_declarations.end())
if (subsample_declarations.find(make_pair(*from_name1, *from_name2)) == subsample_declarations.end())
{
string err = *from_name1;
if (!from_name2->empty())
@ -1426,8 +1426,8 @@ ParsingDriver::copy_subsamples(string *to_name1, string *to_name2, string *from_
mod_file->addStatement(new SubsamplesEqualStatement(*to_name1, *to_name2, *from_name1, *from_name2,
mod_file->symbol_table));
subsample_declarations[make_pair(*to_name1, *to_name2)] =
subsample_declarations[make_pair(*from_name1, *from_name2)];
subsample_declarations[make_pair(*to_name1, *to_name2)]
= subsample_declarations[make_pair(*from_name1, *from_name2)];
delete to_name1;
delete to_name2;
@ -1461,7 +1461,7 @@ ParsingDriver::check_subsample_declaration_exists(string *name1, string *subsamp
if (subsample_name->empty())
return;
string *str_empty = new string ("");
string *str_empty = new string("");
check_subsample_declaration_exists(name1, str_empty, subsample_name);
delete str_empty;
}
@ -1480,7 +1480,7 @@ ParsingDriver::check_subsample_declaration_exists(string *name1, string *name2,
if (it == subsample_declarations.end())
{
it = subsample_declarations.find(make_pair(*name2, *name1));
if (it== subsample_declarations.end())
if (it == subsample_declarations.end())
{
string err = *name1;
if (!name2->empty())
@ -1494,7 +1494,6 @@ ParsingDriver::check_subsample_declaration_exists(string *name1, string *name2,
error("The subsample name " + *subsample_name + " was not previously declared in a subsample statement.");
}
void
ParsingDriver::set_prior(string *name, string *subsample_name)
{
@ -1509,9 +1508,9 @@ ParsingDriver::set_prior(string *name, string *subsample_name)
}
void
ParsingDriver::set_joint_prior(vector<string *>*symbol_vec)
ParsingDriver::set_joint_prior(vector<string *> *symbol_vec)
{
for (vector<string *>::const_iterator it=symbol_vec->begin(); it != symbol_vec->end(); it++)
for (vector<string *>::const_iterator it = symbol_vec->begin(); it != symbol_vec->end(); it++)
add_joint_parameter(*it);
mod_file->addStatement(new JointPriorStatement(joint_parameters, prior_shape, options_list));
joint_parameters.clear();
@ -1621,7 +1620,7 @@ ParsingDriver::check_symbol_is_endogenous_or_exogenous(string *name)
{
check_symbol_existence(*name);
int symb_id = mod_file->symbol_table.getID(*name);
switch(mod_file->symbol_table.getType(symb_id))
switch (mod_file->symbol_table.getType(symb_id))
{
case eEndogenous:
case eExogenous:
@ -2034,7 +2033,7 @@ ParsingDriver::ms_compute_probabilities()
void
ParsingDriver::ms_irf()
{
mod_file->addStatement(new MSSBVARIrfStatement(symbol_list,options_list));
mod_file->addStatement(new MSSBVARIrfStatement(symbol_list, options_list));
symbol_list.clear();
options_list.clear();
}
@ -2681,7 +2680,7 @@ ParsingDriver::add_model_var_or_external_function(string *function_name, bool in
if (rv.first)
{
// assume it's a lead/lagged variable
declare_exogenous(new string (*function_name));
declare_exogenous(new string(*function_name));
return add_model_variable(mod_file->symbol_table.getID(*function_name), (int) rv.second);
}
else
@ -2850,7 +2849,8 @@ ParsingDriver::add_moment_calibration_item(string *endo1, string *endo2, string
moment_calibration_constraints.push_back(c);
}
void ParsingDriver::end_moment_calibration()
void
ParsingDriver::end_moment_calibration()
{
mod_file->addStatement(new MomentCalibration(moment_calibration_constraints,
mod_file->symbol_table));
@ -2887,7 +2887,8 @@ ParsingDriver::add_irf_calibration_item(string *endo, string *periods, string *e
irf_calibration_constraints.push_back(c);
}
void ParsingDriver::end_irf_calibration()
void
ParsingDriver::end_irf_calibration()
{
mod_file->addStatement(new IrfCalibration(irf_calibration_constraints,
mod_file->symbol_table,
@ -2909,7 +2910,6 @@ ParsingDriver::histval_file(string *filename)
delete filename;
}
void
ParsingDriver::perfect_foresight_setup()
{
@ -2927,7 +2927,7 @@ ParsingDriver::perfect_foresight_solver()
void
ParsingDriver::prior_posterior_function(bool prior_func)
{
mod_file->addStatement(new PriorPosteriorFunctionStatement((bool)prior_func, options_list));
mod_file->addStatement(new PriorPosteriorFunctionStatement((bool) prior_func, options_list));
options_list.clear();
}
@ -2941,25 +2941,25 @@ ParsingDriver::add_ramsey_constraints_statement()
void
ParsingDriver::ramsey_constraint_add_less(const string *name, const expr_t rhs)
{
add_ramsey_constraint(name,oLess,rhs);
add_ramsey_constraint(name, oLess, rhs);
}
void
ParsingDriver::ramsey_constraint_add_greater(const string *name, const expr_t rhs)
{
add_ramsey_constraint(name,oGreater,rhs);
add_ramsey_constraint(name, oGreater, rhs);
}
void
ParsingDriver::ramsey_constraint_add_less_equal(const string *name, const expr_t rhs)
{
add_ramsey_constraint(name,oLessEqual,rhs);
add_ramsey_constraint(name, oLessEqual, rhs);
}
void
ParsingDriver::ramsey_constraint_add_greater_equal(const string *name, const expr_t rhs)
{
add_ramsey_constraint(name,oGreaterEqual,rhs);
add_ramsey_constraint(name, oGreaterEqual, rhs);
}
void
@ -2996,7 +2996,6 @@ ParsingDriver::add_shock_group_element(string *name)
delete name;
}
void
ParsingDriver::add_shock_group(string *name)
{

View File

@ -182,8 +182,8 @@ private:
//! Temporary storage for left/right handside of a restriction equation within an svar_identificaton block
bool svar_left_handside;
//! Temporary storage for current restriction number in svar_identification block
map<int,int> svar_Qi_restriction_nbr;
map<int,int> svar_Ri_restriction_nbr;
map<int, int> svar_Qi_restriction_nbr;
map<int, int> svar_Ri_restriction_nbr;
//! Stores undeclared model variables
set<string> undeclared_model_vars;
//! Temporary storage for restriction type
@ -239,7 +239,9 @@ private:
ostringstream model_errors;
public:
ParsingDriver(WarningConsolidation &warnings_arg, bool nostrict_arg) : warnings(warnings_arg), nostrict(nostrict_arg), model_error_encountered(false) { };
ParsingDriver(WarningConsolidation &warnings_arg, bool nostrict_arg) : warnings(warnings_arg), nostrict(nostrict_arg), model_error_encountered(false)
{
};
//! Starts parsing, and constructs the MOD file representation
/*! The returned pointer should be deleted after use */
@ -449,11 +451,11 @@ public:
//! Sets the prior for a parameter
void set_prior(string *arg1, string *arg2);
//! Sets the joint prior for a set of parameters
void set_joint_prior(vector<string *>*symbol_vec);
void set_joint_prior(vector<string *> *symbol_vec);
//! Adds a parameters to the list of joint parameters
void add_joint_parameter(string *name);
//! Adds the variance option to its temporary holding place
void set_prior_variance(expr_t variance=NULL);
void set_prior_variance(expr_t variance = NULL);
//! Copies the prior from_name to_name
void copy_prior(string *to_declaration_type, string *to_name1, string *to_name2, string *to_subsample_name,
string *from_declaration_type, string *from_name1, string *from_name2, string *from_subsample_name);
@ -534,7 +536,7 @@ public:
void run_load_params_and_steady_state(string *filename);
void run_save_params_and_steady_state(string *filename);
void run_identification();
void add_mc_filename(string *filename, string *prior = new string("1"));
void add_mc_filename(string *filename, string *prior = new string ("1"));
void run_model_comparison();
//! Begin a planner_objective statement
void begin_planner_objective();

View File

@ -151,7 +151,6 @@ ShocksStatement::writeOutput(ostream &output, const string &basename, bool minim
output << "M_.sigma_e_is_diagonal = 1;" << endl;
}
void
ShocksStatement::writeJsonOutput(ostream &output) const
{
@ -606,7 +605,7 @@ ShockGroupsStatement::writeOutput(ostream &output, const string &basename, bool
{
int i = 1;
bool unique_label = true;
for (vector<Group>::const_iterator it = shock_groups.begin(); it != shock_groups.end(); it++, unique_label=true)
for (vector<Group>::const_iterator it = shock_groups.begin(); it != shock_groups.end(); it++, unique_label = true)
{
for (vector<Group>::const_iterator it1 = it+1; it1 != shock_groups.end(); it1++)
if (it->name == it1->name)
@ -623,7 +622,7 @@ ShockGroupsStatement::writeOutput(ostream &output, const string &basename, bool
<< ".group" << i << ".label = '" << it->name << "';" << endl
<< "M_.shock_groups." << name
<< ".group" << i << ".shocks = {";
for ( vector<string>::const_iterator it1 = it->list.begin(); it1 != it->list.end(); it1++)
for (vector<string>::const_iterator it1 = it->list.begin(); it1 != it->list.end(); it1++)
output << " '" << *it1 << "'";
output << "};" << endl;
i++;

View File

@ -78,11 +78,13 @@ Statement::writeCOutput(ostream &output, const string &basename)
{
}
void Statement::writeJuliaOutput(ostream &output, const string &basename)
void
Statement::writeJuliaOutput(ostream &output, const string &basename)
{
}
void Statement::writeJsonOutput(ostream &output) const
void
Statement::writeJsonOutput(ostream &output) const
{
}
@ -105,7 +107,7 @@ NativeStatement::writeOutput(ostream &output, const string &basename, bool minim
sregex regex_dollar = sregex::compile("(\\$)"+date_regex);
string ns = regex_replace(native_statement, regex_lookbehind, "dates('$&')");
ns = regex_replace(ns, regex_dollar, "$2" ); //replace $DATE with DATE
ns = regex_replace(ns, regex_dollar, "$2"); //replace $DATE with DATE
output << ns << endl;
}
@ -182,9 +184,9 @@ OptionsList::writeOutput(ostream &output, const string &option_group) const
{
// Initialize option_group as an empty struct iff the field does not exist!
unsigned idx = option_group.find_last_of(".");
if (idx<UINT_MAX)
if (idx < UINT_MAX)
{
output << "if ~isfield(" << option_group.substr(0,idx) << ",'" << option_group.substr(idx+1) << "')" << endl;
output << "if ~isfield(" << option_group.substr(0, idx) << ",'" << option_group.substr(idx+1) << "')" << endl;
output << " " << option_group << " = struct();" << endl;
output << "end" << endl;
}
@ -241,12 +243,12 @@ OptionsList::writeJsonOutput(ostream &output) const
{
output << "\""<< it->first << "\": " << it->second;
it++;
if (it != num_options.end() ||
!(paired_num_options.empty() &&
string_options.empty() &&
date_options.empty() &&
symbol_list_options.empty() &&
vector_int_options.empty()))
if (it != num_options.end()
|| !(paired_num_options.empty()
&& string_options.empty()
&& date_options.empty()
&& symbol_list_options.empty()
&& vector_int_options.empty()))
output << ", ";
}
@ -255,11 +257,11 @@ OptionsList::writeJsonOutput(ostream &output) const
{
output << "\""<< it->first << "\": [" << it->second.first << " " << it->second.second << "]";
it++;
if (it != paired_num_options.end() ||
!(string_options.empty() &&
date_options.empty() &&
symbol_list_options.empty() &&
vector_int_options.empty()))
if (it != paired_num_options.end()
|| !(string_options.empty()
&& date_options.empty()
&& symbol_list_options.empty()
&& vector_int_options.empty()))
output << ", ";
}
@ -268,10 +270,10 @@ OptionsList::writeJsonOutput(ostream &output) const
{
output << "\""<< it->first << "\": \"" << it->second << "\"";
it++;
if (it != string_options.end() ||
!(date_options.empty() &&
symbol_list_options.empty() &&
vector_int_options.empty()))
if (it != string_options.end()
|| !(date_options.empty()
&& symbol_list_options.empty()
&& vector_int_options.empty()))
output << ", ";
}
@ -280,9 +282,9 @@ OptionsList::writeJsonOutput(ostream &output) const
{
output << "\""<< it->first << "\": \"" << it->second << "\"";
it++;
if (it != date_options.end() ||
!(symbol_list_options.empty() &&
vector_int_options.empty()))
if (it != date_options.end()
|| !(symbol_list_options.empty()
&& vector_int_options.empty()))
output << ", ";
}
@ -292,8 +294,8 @@ OptionsList::writeJsonOutput(ostream &output) const
output << "\""<< it->first << "\":";
it->second.writeJsonOutput(output);
it++;
if (it != symbol_list_options.end() ||
!vector_int_options.empty())
if (it != symbol_list_options.end()
|| !vector_int_options.empty())
output << ", ";
}

View File

@ -128,7 +128,8 @@ public:
class Statement
{
public:
virtual ~Statement();
virtual
~Statement();
//! Do some internal check, and fill the ModFileStructure class
/*! Don't forget to update ComputingTasks.hh, Shocks.hh and
NumericalInitialization.hh if you modify the signature of this

View File

@ -661,10 +661,10 @@ StaticModel::writeModelEquationsCode_Block(const string file_name, const string
if (dynamic_cast<AbstractExternalFunctionNode *>(*it) != NULL)
(*it)->compileExternalFunctionOutput(code_file, instruction_number, false, tt2, map_idx, false, false, tef_terms);
FNUMEXPR_ fnumexpr(TemporaryTerm, (int) (map_idx.find((*it)->idx)->second));
FNUMEXPR_ fnumexpr(TemporaryTerm, (int)(map_idx.find((*it)->idx)->second));
fnumexpr.write(code_file, instruction_number);
(*it)->compile(code_file, instruction_number, false, tt2, map_idx, false, false, tef_terms);
FSTPST_ fstpst((int) (map_idx.find((*it)->idx)->second));
FSTPST_ fstpst((int)(map_idx.find((*it)->idx)->second));
fstpst.write(code_file, instruction_number);
// Insert current node into tt2
tt2.insert(*it);
@ -854,12 +854,12 @@ StaticModel::writeModelEquationsCode_Block(const string file_name, const string
if (dynamic_cast<AbstractExternalFunctionNode *>(*it) != NULL)
(*it)->compileExternalFunctionOutput(code_file, instruction_number, false, tt3, map_idx2[block], false, false, tef_terms2);
FNUMEXPR_ fnumexpr(TemporaryTerm, (int) (map_idx2[block].find((*it)->idx)->second));
FNUMEXPR_ fnumexpr(TemporaryTerm, (int)(map_idx2[block].find((*it)->idx)->second));
fnumexpr.write(code_file, instruction_number);
(*it)->compile(code_file, instruction_number, false, tt3, map_idx2[block], false, false, tef_terms);
FSTPST_ fstpst((int) (map_idx2[block].find((*it)->idx)->second));
FSTPST_ fstpst((int)(map_idx2[block].find((*it)->idx)->second));
fstpst.write(code_file, instruction_number);
// Insert current node into tt2
tt3.insert(*it);
@ -1065,7 +1065,7 @@ StaticModel::computingPass(const eval_context_t &eval_context, bool no_tmp_terms
}
equations.clear();
copy(neweqs.begin(),neweqs.end(),back_inserter(equations));
copy(neweqs.begin(), neweqs.end(), back_inserter(equations));
// Compute derivatives w.r. to all endogenous, and possibly exogenous and exogenous deterministic
set<int> vars;
@ -1338,7 +1338,6 @@ StaticModel::writeStaticModel(ostream &StaticOutput, bool use_dll, bool julia) c
int id2 = getSymbIDByDerivID(var2);
int id3 = getSymbIDByDerivID(var3);
// Reference column number for the g3 matrix
int ref_col = id1 * hessianColsNbr + id2 * JacobianColsNbr + id3;
@ -1622,7 +1621,6 @@ StaticModel::writeStaticCFile(const string &func_name) const
output << "#define max(a, b) (((a) > (b)) ? (a) : (b))" << endl
<< "#define min(a, b) (((a) > (b)) ? (b) : (a))" << endl;
// Write function definition if oPowerDeriv is used
writePowerDerivCHeader(output);
writeNormcdfCHeader(output);
@ -1754,7 +1752,7 @@ StaticModel::writeStaticFile(const string &basename, bool block, bool bytecode,
chdir("..");
writeStaticBlockMFSFile(basename);
}
else if(use_dll)
else if (use_dll)
writeStaticCFile(basename);
else if (julia)
writeStaticJuliaFile(basename);
@ -2129,7 +2127,8 @@ StaticModel::writeAuxVarInitval(ostream &output, ExprNodeOutputType output_type)
}
}
void StaticModel::writeSetAuxiliaryVariables(const string &basename, const bool julia) const
void
StaticModel::writeSetAuxiliaryVariables(const string &basename, const bool julia) const
{
string func_name = basename + "_set_auxiliary_variables";
@ -2311,7 +2310,6 @@ StaticModel::writeParamsDerivativesFile(const string &basename, bool julia) cons
third_derivs1_output << ";" << endl;
}
ofstream paramsDerivsFile;
string filename = julia ? basename + "StaticParamsDerivs.jl" : basename + "_static_params_derivs.m";
paramsDerivsFile.open(filename.c_str(), ios::out | ios::binary);

View File

@ -224,12 +224,14 @@ public:
return (block_type_firstequation_size_mfs[block_number].second.first);
};
//! Return the number of exogenous variable in the block block_number
virtual unsigned int getBlockExoSize(int block_number) const
virtual unsigned int
getBlockExoSize(int block_number) const
{
return 0;
};
//! Return the number of colums in the jacobian matrix for exogenous variable in the block block_number
virtual unsigned int getBlockExoColSize(int block_number) const
virtual unsigned int
getBlockExoColSize(int block_number) const
{
return 0;
}

View File

@ -44,9 +44,17 @@ public:
//! Clears all content
void clear();
//! Get a copy of the string vector
vector<string> get_symbols() const { return symbols; };
vector<string>
get_symbols() const
{
return symbols;
};
//! Is Empty
int empty() const { return symbols.empty(); };
int
empty() const
{
return symbols.empty();
};
};
#endif

View File

@ -43,7 +43,7 @@ SymbolTable::SymbolTable() : frozen(false), size(0)
}
int
SymbolTable::addSymbol(const string &name, SymbolType type, const string &tex_name, const vector<pair<string * , string *> *> *partition_value) throw (AlreadyDeclaredException, FrozenException)
SymbolTable::addSymbol(const string &name, SymbolType type, const string &tex_name, const vector<pair<string *, string *> *> *partition_value) throw (AlreadyDeclaredException, FrozenException)
{
if (frozen)
throw FrozenException();
@ -228,7 +228,6 @@ SymbolTable::writeOutput(ostream &output) const throw (NotYetFrozenException)
<< "M_.exo_names_tex = char(M_.exo_names_tex, '" << getTeXName(exo_ids[id]) << "');" << endl
<< "M_.exo_names_long = char(M_.exo_names_long, '" << getLongName(exo_ids[id]) << "');" << endl;
map<string, map<int, string> > partitions = getPartitionsForType(eExogenous);
for (map<string, map<int, string> >::const_iterator it = partitions.begin();
it != partitions.end(); it++)
@ -483,7 +482,7 @@ SymbolTable::writeCOutput(ostream &output) const throw (NotYetFrozenException)
for (set<int>::const_iterator it = predetermined_variables.begin();
it != predetermined_variables.end(); it++)
{
if ( it != predetermined_variables.begin() )
if (it != predetermined_variables.begin())
output << ",";
output << getTypeSpecificID(*it);
}
@ -497,7 +496,7 @@ SymbolTable::writeCOutput(ostream &output) const throw (NotYetFrozenException)
for (vector<int>::const_iterator it = varobs.begin();
it != varobs.end(); it++)
{
if ( it != varobs.begin() )
if (it != varobs.begin())
output << ",";
output << getTypeSpecificID(*it);
}
@ -969,7 +968,7 @@ SymbolTable::writeJsonOutput(ostream &output) const
output << "\"endogenous\": ";
writeJsonVarVector(output, endo_ids);
output << ", \"exogenous\":" ;
output << ", \"exogenous\":";
writeJsonVarVector(output, exo_ids);
output << ", \"exogenous_deterministic\": ";

View File

@ -58,13 +58,41 @@ private:
expr_t expr_node; //! Auxiliary variable definition
public:
AuxVarInfo(int symb_id_arg, aux_var_t type_arg, int orig_symb_id, int orig_lead_lag, int equation_number_for_multiplier_arg, int information_set_arg, expr_t expr_node_arg);
int get_symb_id() const { return symb_id; };
aux_var_t get_type() const { return type; };
int get_orig_symb_id() const { return orig_symb_id; };
int get_orig_lead_lag() const { return orig_lead_lag; };
int get_equation_number_for_multiplier() const { return equation_number_for_multiplier; };
int get_information_set() const { return information_set; };
expr_t get_expr_node() const { return expr_node; } ;
int
get_symb_id() const
{
return symb_id;
};
aux_var_t
get_type() const
{
return type;
};
int
get_orig_symb_id() const
{
return orig_symb_id;
};
int
get_orig_lead_lag() const
{
return orig_lead_lag;
};
int
get_equation_number_for_multiplier() const
{
return equation_number_for_multiplier;
};
int
get_information_set() const
{
return information_set;
};
expr_t
get_expr_node() const
{
return expr_node;
};
};
//! Stores the symbol table
@ -250,7 +278,11 @@ public:
*/
int searchAuxiliaryVars(int orig_symb_id, int orig_lead_lag) const throw (SearchFailedException);
//! Returns the number of auxiliary variables
int AuxVarsSize() const { return aux_vars.size(); };
int
AuxVarsSize() const
{
return aux_vars.size();
};
//! Retruns expr_node for an auxiliary variable
expr_t getAuxiliaryVarsExprNode(int symb_id) const throw (SearchFailedException);
//! Tests if symbol already exists

View File

@ -20,8 +20,9 @@
#include "WarningConsolidation.hh"
#include <ostream>
WarningConsolidation&
operator<< (WarningConsolidation& wcc, const string &warning)
WarningConsolidation
&
operator<<(WarningConsolidation &wcc, const string &warning)
{
if (wcc.no_warn)
return wcc;
@ -31,8 +32,8 @@ operator<< (WarningConsolidation& wcc, const string &warning)
return wcc;
};
WarningConsolidation&
operator<< (WarningConsolidation& wcc, const Dynare::location& loc)
WarningConsolidation &
operator<<(WarningConsolidation &wcc, const Dynare::location &loc)
{
if (wcc.no_warn)
return wcc;
@ -54,8 +55,8 @@ operator<< (WarningConsolidation& wcc, const Dynare::location& loc)
return wcc;
};
WarningConsolidation&
operator<< (WarningConsolidation& wcc, ostream& (*pf) (ostream&))
WarningConsolidation &
operator<<(WarningConsolidation &wcc, ostream & (*pf)(ostream &))
{
if (wcc.no_warn)
return wcc;

View File

@ -34,16 +34,28 @@ private:
bool no_warn;
public:
WarningConsolidation(bool no_warn_arg) : no_warn(no_warn_arg) { };
~WarningConsolidation() { };
WarningConsolidation(bool no_warn_arg) : no_warn(no_warn_arg)
{
};
~WarningConsolidation()
{
};
//! Add A Warning to the StringStream
friend WarningConsolidation& operator<< (WarningConsolidation& wcc, const string &warning);
friend WarningConsolidation& operator<< (WarningConsolidation& wcc, const Dynare::location &loc);
friend WarningConsolidation& operator<< (WarningConsolidation& wcc, ostream& (*pf) (ostream&));
friend WarningConsolidation &operator<<(WarningConsolidation &wcc, const string &warning);
friend WarningConsolidation &operator<<(WarningConsolidation &wcc, const Dynare::location &loc);
friend WarningConsolidation &operator<<(WarningConsolidation &wcc, ostream & (*pf)(ostream &));
inline void addWarning(const string &w) { warnings << w; };
inline void addWarning(ostream& (*pf) (ostream&)) { warnings << pf; };
inline void
addWarning(const string &w)
{
warnings << w;
};
inline void
addWarning(ostream & (*pf)(ostream &))
{
warnings << pf;
};
//! Write Warnings to m file
void writeOutput(ostream &output) const;

View File

@ -55,14 +55,14 @@ MacroDriver::parse(const string &f, ostream &out, bool debug, bool no_line_macro
an @#endif or an @#endfor - but no newline - no longer trigger an error.
*/
stringstream file_with_endl;
for (map<string,string>::iterator it=defines.begin();
it!=defines.end(); it++)
for (map<string, string>::iterator it = defines.begin();
it != defines.end(); it++)
try
{
boost::lexical_cast<int>(it->second);
file_with_endl << "@#define " << it->first << " = " << it->second << endl;
}
catch(boost::bad_lexical_cast &)
catch (boost::bad_lexical_cast &)
{
file_with_endl << "@#define " << it->first << " = \"" << it->second << "\"" << endl;
}

View File

@ -177,12 +177,13 @@ public:
//! Constructor
MacroDriver();
//! Destructor
virtual ~MacroDriver();
virtual
~MacroDriver();
//! Starts parsing a file, returns output in out
/*! \param no_line_macro should we omit the @#line statements ? */
void parse(const string &f, ostream &out, bool debug, bool no_line_macro,
map<string,string> defines, vector<string> path);
map<string, string> defines, vector<string> path);
//! Name of main file being parsed
string file;

View File

@ -49,7 +49,8 @@ public:
{
};
MacroValue(MacroDriver &driver_arg);
virtual ~MacroValue();
virtual
~MacroValue();
//! Applies + operator
virtual const MacroValue *operator+(const MacroValue &mv) const throw (TypeError) = 0;
//! Applies unary + operator
@ -118,7 +119,8 @@ private:
const int value;
public:
IntMV(MacroDriver &driver, int value_arg);
virtual ~IntMV();
virtual
~IntMV();
//! Computes arithmetic addition
virtual const MacroValue *operator+(const MacroValue &mv) const throw (TypeError);
//! Unary plus
@ -158,7 +160,11 @@ public:
If mv2 < mv1, returns an empty range (for consistency with MATLAB).
*/
static const MacroValue *new_range(MacroDriver &driver, const MacroValue *mv1, const MacroValue *mv2) throw (TypeError);
inline int get_int_value() const { return value; };
inline int
get_int_value() const
{
return value;
};
};
//! Represents a string value in macro language
@ -170,7 +176,8 @@ private:
const string value;
public:
StringMV(MacroDriver &driver, const string &value_arg);
virtual ~StringMV();
virtual
~StringMV();
//! Computes string concatenation
virtual const MacroValue *operator+(const MacroValue &mv) const throw (TypeError);
virtual const MacroValue *operator==(const MacroValue &mv) const throw (TypeError);
@ -202,7 +209,8 @@ private:
const vector<T> values;
public:
ArrayMV(MacroDriver &driver, const vector<T> &values_arg);
virtual ~ArrayMV();
virtual
~ArrayMV();
//! Computes array concatenation
/*! Both array must be of same type */
virtual const MacroValue *operator+(const MacroValue &mv) const throw (TypeError);