diff --git a/src/CodeInterpreter.hh b/src/CodeInterpreter.hh index 9a4066c3ebbac12d3352823c25b98aa9faf95c12..bbaeb147bf272ba77315380b8a35aba949d599ae 100644 --- a/src/CodeInterpreter.hh +++ b/src/CodeInterpreter.hh @@ -1730,14 +1730,14 @@ public: # ifdef DEBUGL mexPrintf("FLDZ = %d size = %d\n", FLDZ, sizeof(FLDZ_)); # endif - tags_liste.push_back(make_pair(FLDZ, code)); + tags_liste.emplace_back(FLDZ, code); code += sizeof(FLDZ_); break; case FEND: # ifdef DEBUGL mexPrintf("FEND\n"); # endif - tags_liste.push_back(make_pair(FEND, code)); + tags_liste.emplace_back(FEND, code); code += sizeof(FEND_); done = true; break; @@ -1745,203 +1745,203 @@ public: # ifdef DEBUGL mexPrintf("FENDBLOCK\n"); # endif - tags_liste.push_back(make_pair(FENDBLOCK, code)); + tags_liste.emplace_back(FENDBLOCK, code); code += sizeof(FENDBLOCK_); break; case FENDEQU: # ifdef DEBUGL mexPrintf("FENDEQU\n"); # endif - tags_liste.push_back(make_pair(FENDEQU, code)); + tags_liste.emplace_back(FENDEQU, code); code += sizeof(FENDEQU_); break; case FCUML: # ifdef DEBUGL mexPrintf("FCUML\n"); # endif - tags_liste.push_back(make_pair(FCUML, code)); + tags_liste.emplace_back(FCUML, code); code += sizeof(FCUML_); break; case FDIMT: # ifdef DEBUGL mexPrintf("FDIMT = %d size = %d\n", FDIMT, sizeof(FDIMT_)); # endif - tags_liste.push_back(make_pair(FDIMT, code)); + tags_liste.emplace_back(FDIMT, code); code += sizeof(FDIMT_); break; case FDIMST: # ifdef DEBUGL mexPrintf("FDIMST\n"); # endif - tags_liste.push_back(make_pair(FDIMST, code)); + tags_liste.emplace_back(FDIMST, code); code += sizeof(FDIMST_); break; case FNUMEXPR: # ifdef DEBUGL mexPrintf("FNUMEXPR\n"); # endif - tags_liste.push_back(make_pair(FNUMEXPR, code)); + tags_liste.emplace_back(FNUMEXPR, code); code += sizeof(FNUMEXPR_); break; case FLDC: # ifdef DEBUGL mexPrintf("FLDC\n"); # endif - tags_liste.push_back(make_pair(FLDC, code)); + tags_liste.emplace_back(FLDC, code); code += sizeof(FLDC_); break; case FLDU: # ifdef DEBUGL mexPrintf("FLDU\n"); # endif - tags_liste.push_back(make_pair(FLDU, code)); + tags_liste.emplace_back(FLDU, code); code += sizeof(FLDU_); break; case FLDSU: # ifdef DEBUGL mexPrintf("FLDSU\n"); # endif - tags_liste.push_back(make_pair(FLDSU, code)); + tags_liste.emplace_back(FLDSU, code); code += sizeof(FLDSU_); break; case FLDR: # ifdef DEBUGL mexPrintf("FLDR\n"); # endif - tags_liste.push_back(make_pair(FLDR, code)); + tags_liste.emplace_back(FLDR, code); code += sizeof(FLDR_); break; case FLDT: # ifdef DEBUGL mexPrintf("FLDT\n"); # endif - tags_liste.push_back(make_pair(FLDT, code)); + tags_liste.emplace_back(FLDT, code); code += sizeof(FLDT_); break; case FLDST: # ifdef DEBUGL mexPrintf("FLDST\n"); # endif - tags_liste.push_back(make_pair(FLDST, code)); + tags_liste.emplace_back(FLDST, code); code += sizeof(FLDST_); break; case FSTPT: # ifdef DEBUGL mexPrintf("FSTPT = %d size = %d\n", FSTPT, sizeof(FSTPT_)); # endif - tags_liste.push_back(make_pair(FSTPT, code)); + tags_liste.emplace_back(FSTPT, code); code += sizeof(FSTPT_); break; case FSTPST: # ifdef DEBUGL mexPrintf("FSTPST\n"); # endif - tags_liste.push_back(make_pair(FSTPST, code)); + tags_liste.emplace_back(FSTPST, code); code += sizeof(FSTPST_); break; case FSTPR: # ifdef DEBUGL mexPrintf("FSTPR\n"); # endif - tags_liste.push_back(make_pair(FSTPR, code)); + tags_liste.emplace_back(FSTPR, code); code += sizeof(FSTPR_); break; case FSTPU: # ifdef DEBUGL mexPrintf("FSTPU\n"); # endif - tags_liste.push_back(make_pair(FSTPU, code)); + tags_liste.emplace_back(FSTPU, code); code += sizeof(FSTPU_); break; case FSTPSU: # ifdef DEBUGL mexPrintf("FSTPSU\n"); # endif - tags_liste.push_back(make_pair(FSTPSU, code)); + tags_liste.emplace_back(FSTPSU, code); code += sizeof(FSTPSU_); break; case FSTPG: # ifdef DEBUGL mexPrintf("FSTPG\n"); # endif - tags_liste.push_back(make_pair(FSTPG, code)); + tags_liste.emplace_back(FSTPG, code); code += sizeof(FSTPG_); break; case FSTPG2: # ifdef DEBUGL mexPrintf("FSTPG2\n"); # endif - tags_liste.push_back(make_pair(FSTPG2, code)); + tags_liste.emplace_back(FSTPG2, code); code += sizeof(FSTPG2_); break; case FSTPG3: # ifdef DEBUGL mexPrintf("FSTPG3\n"); # endif - tags_liste.push_back(make_pair(FSTPG3, code)); + tags_liste.emplace_back(FSTPG3, code); code += sizeof(FSTPG3_); break; case FUNARY: # ifdef DEBUGL mexPrintf("FUNARY\n"); # endif - tags_liste.push_back(make_pair(FUNARY, code)); + tags_liste.emplace_back(FUNARY, code); code += sizeof(FUNARY_); break; case FBINARY: # ifdef DEBUGL mexPrintf("FBINARY\n"); # endif - tags_liste.push_back(make_pair(FBINARY, code)); + tags_liste.emplace_back(FBINARY, code); code += sizeof(FBINARY_); break; case FTRINARY: # ifdef DEBUGL mexPrintf("FTRINARY\n"); # endif - tags_liste.push_back(make_pair(FTRINARY, code)); + tags_liste.emplace_back(FTRINARY, code); code += sizeof(FTRINARY_); break; case FOK: # ifdef DEBUGL mexPrintf("FOK\n"); # endif - tags_liste.push_back(make_pair(FOK, code)); + tags_liste.emplace_back(FOK, code); code += sizeof(FOK_); break; case FLDVS: # ifdef DEBUGL mexPrintf("FLDVS\n"); # endif - tags_liste.push_back(make_pair(FLDVS, code)); + tags_liste.emplace_back(FLDVS, code); code += sizeof(FLDVS_); break; case FLDSV: # ifdef DEBUGL mexPrintf("FLDSV\n"); # endif - tags_liste.push_back(make_pair(FLDSV, code)); + tags_liste.emplace_back(FLDSV, code); code += sizeof(FLDSV_); break; case FSTPSV: # ifdef DEBUGL mexPrintf("FSTPSV\n"); # endif - tags_liste.push_back(make_pair(FSTPSV, code)); + tags_liste.emplace_back(FSTPSV, code); code += sizeof(FSTPSV_); break; case FLDV: # ifdef DEBUGL mexPrintf("FLDV\n"); # endif - tags_liste.push_back(make_pair(FLDV, code)); + tags_liste.emplace_back(FLDV, code); code += sizeof(FLDV_); break; case FSTPV: # ifdef DEBUGL mexPrintf("FSTPV\n"); # endif - tags_liste.push_back(make_pair(FSTPV, code)); + tags_liste.emplace_back(FSTPV, code); code += sizeof(FSTPV_); break; case FBEGINBLOCK: @@ -1954,7 +1954,7 @@ public: code = fbegin_block->load(code); begin_block.push_back(tags_liste.size()); - tags_liste.push_back(make_pair(FBEGINBLOCK, fbegin_block)); + tags_liste.emplace_back(FBEGINBLOCK, fbegin_block)); nb_blocks++; } break; @@ -1962,14 +1962,14 @@ public: # ifdef DEBUGL mexPrintf("FJMPIFEVAL\n"); # endif - tags_liste.push_back(make_pair(FJMPIFEVAL, code)); + tags_liste.emplace_back(FJMPIFEVAL, code); code += sizeof(FJMPIFEVAL_); break; case FJMP: # ifdef DEBUGL mexPrintf("FJMP\n"); # endif - tags_liste.push_back(make_pair(FJMP, code)); + tags_liste.emplace_back(FJMP, code); code += sizeof(FJMP_); break; case FCALL: @@ -1981,7 +1981,7 @@ public: code = fcall->load(code); - tags_liste.push_back(make_pair(FCALL, fcall)); + tags_liste.emplace_back(FCALL, fcall)); # ifdef DEBUGL mexPrintf("FCALL finish\n"); mexEvalString("drawnow;"); mexPrintf("-- *code=%d\n", *code); mexEvalString("drawnow;"); @@ -1992,56 +1992,56 @@ public: # ifdef DEBUGL mexPrintf("FPUSH\n"); # endif - tags_liste.push_back(make_pair(FPUSH, code)); + tags_liste.emplace_back(FPUSH, code); code += sizeof(FPUSH_); break; case FPOP: # ifdef DEBUGL mexPrintf("FPOP\n"); # endif - tags_liste.push_back(make_pair(FPOP, code)); + tags_liste.emplace_back(FPOP, code); code += sizeof(FPOP_); break; case FLDTEF: # ifdef DEBUGL mexPrintf("FLDTEF\n"); # endif - tags_liste.push_back(make_pair(FLDTEF, code)); + tags_liste.emplace_back(FLDTEF, code); code += sizeof(FLDTEF_); break; case FSTPTEF: # ifdef DEBUGL mexPrintf("FSTPTEF\n"); # endif - tags_liste.push_back(make_pair(FSTPTEF, code)); + tags_liste.emplace_back(FSTPTEF, code); code += sizeof(FSTPTEF_); break; case FLDTEFD: # ifdef DEBUGL mexPrintf("FLDTEFD\n"); # endif - tags_liste.push_back(make_pair(FLDTEFD, code)); + tags_liste.emplace_back(FLDTEFD, code); code += sizeof(FLDTEFD_); break; case FSTPTEFD: # ifdef DEBUGL mexPrintf("FSTPTEFD\n"); # endif - tags_liste.push_back(make_pair(FSTPTEFD, code)); + tags_liste.emplace_back(FSTPTEFD, code); code += sizeof(FSTPTEFD_); break; case FLDTEFDD: # ifdef DEBUGL mexPrintf("FLDTEFDD\n"); # endif - tags_liste.push_back(make_pair(FLDTEFDD, code)); + tags_liste.emplace_back(FLDTEFDD, code); code += sizeof(FLDTEFDD_); break; case FSTPTEFDD: # ifdef DEBUGL mexPrintf("FSTPTEFDD\n"); # endif - tags_liste.push_back(make_pair(FSTPTEFDD, code)); + tags_liste.emplace_back(FSTPTEFDD, code); code += sizeof(FSTPTEFDD_); break; default: diff --git a/src/ComputingTasks.cc b/src/ComputingTasks.cc index 73a3f158729300ee62ab0fc0546a0dd31af1b442..f9ba331a0fdabbaf6891ed0fdebc95d40bb0d3bd 100644 --- a/src/ComputingTasks.cc +++ b/src/ComputingTasks.cc @@ -379,7 +379,7 @@ PacModelStatement::getPacModelInfoForPacExpectation(pair<string, pair<string, pa int growth_symb_id = -1; if (!growth.empty()) growth_symb_id = symbol_table.getID(growth); - pac_model_info = make_pair(name, make_pair(var_name, make_pair(discount, make_pair(growth_symb_id, undiff)))); + pac_model_info = { name, { var_name, { discount, { growth_symb_id, undiff } } }}; } VarModelStatement::VarModelStatement(SymbolList symbol_list_arg, @@ -407,7 +407,7 @@ VarModelStatement::getVarModelInfo(string &var_model_name, else { auto it = options_list.num_options.find("var.order"); - var_model_info[name] = make_pair(symbol_list, atoi(it->second.c_str())); + var_model_info[name] = { symbol_list, atoi(it->second.c_str()) }; } } @@ -3134,7 +3134,7 @@ MarkovSwitchingStatement::MarkovSwitchingStatement(OptionsList options_list_arg) exit(EXIT_FAILURE); } - if (restriction_map.find(make_pair(from_regime, to_regime)) != + if (restriction_map.find({ from_regime, to_regime }) != restriction_map.end()) { cerr << "ERROR: two restrictions were given for: " << from_regime << ", " @@ -3149,7 +3149,7 @@ MarkovSwitchingStatement::MarkovSwitchingStatement(OptionsList options_list_arg) << " must be less than 1" << endl; exit(EXIT_FAILURE); } - restriction_map[make_pair(from_regime, to_regime)] = transition_probability; + restriction_map[{ from_regime, to_regime }] = transition_probability; } catch (const bad_lexical_cast &) { @@ -3189,10 +3189,10 @@ MarkovSwitchingStatement::checkPass(ModFileStructure &mod_file_struct, WarningCo 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()) + if (restriction_map.find({ row+1, col+1 }) != restriction_map.end()) { - row_trans_prob_sum[row] += restriction_map[make_pair(row+1, col+1)]; - col_trans_prob_sum[col] += restriction_map[make_pair(row+1, col+1)]; + row_trans_prob_sum[row] += restriction_map[{ row+1, col+1 }]; + col_trans_prob_sum[col] += restriction_map[{ row+1, col+1 }]; } else { diff --git a/src/DataTree.cc b/src/DataTree.cc index 7793e42005d9831a13ad0677fed9db8d02b30a01..2bd4ff11a878f861863b278a785a94e26d6512a1 100644 --- a/src/DataTree.cc +++ b/src/DataTree.cc @@ -65,7 +65,7 @@ DataTree::AddNonNegativeConstant(const string &value) VariableNode * DataTree::AddVariableInternal(int symb_id, int lag) { - auto it = variable_node_map.find(make_pair(symb_id, lag)); + auto it = variable_node_map.find({ symb_id, lag }); if (it != variable_node_map.end()) return it->second; else @@ -506,7 +506,7 @@ DataTree::AddVarExpectation(const int symb_id, const int forecast_horizon, const { assert(symbol_table.getType(symb_id) == eEndogenous); - auto it = var_expectation_node_map.find(make_pair(model_name, make_pair(symb_id, forecast_horizon))); + auto it = var_expectation_node_map.find({ model_name, { symb_id, forecast_horizon } }); if (it != var_expectation_node_map.end()) return it->second; @@ -548,7 +548,7 @@ DataTree::AddExternalFunction(int symb_id, const vector<expr_t> &arguments) { assert(symbol_table.getType(symb_id) == eExternalFunction); - auto it = external_function_node_map.find(make_pair(arguments, symb_id)); + auto it = external_function_node_map.find({ arguments, symb_id }); if (it != external_function_node_map.end()) return it->second; @@ -561,8 +561,7 @@ DataTree::AddFirstDerivExternalFunction(int top_level_symb_id, const vector<expr assert(symbol_table.getType(top_level_symb_id) == eExternalFunction); auto it - = first_deriv_external_function_node_map.find(make_pair(make_pair(arguments, input_index), - top_level_symb_id)); + = first_deriv_external_function_node_map.find({ { arguments, input_index }, top_level_symb_id }); if (it != first_deriv_external_function_node_map.end()) return it->second; @@ -575,9 +574,8 @@ DataTree::AddSecondDerivExternalFunction(int top_level_symb_id, const vector<exp assert(symbol_table.getType(top_level_symb_id) == eExternalFunction); auto it - = second_deriv_external_function_node_map.find(make_pair(make_pair(arguments, - make_pair(input_index1, input_index2)), - top_level_symb_id)); + = second_deriv_external_function_node_map.find({ { arguments, { input_index1, input_index2 } }, + top_level_symb_id }); if (it != second_deriv_external_function_node_map.end()) return it->second; diff --git a/src/DataTree.hh b/src/DataTree.hh index 39b49af84ff8307e96e73e75aafb828a642e9eea..e6537631fe2d479f6e10dd1099ba8ed41c760759 100644 --- a/src/DataTree.hh +++ b/src/DataTree.hh @@ -330,7 +330,7 @@ inline expr_t DataTree::AddUnaryOp(UnaryOpcode op_code, expr_t arg, int arg_exp_info_set, int param1_symb_id, int param2_symb_id, const string &adl_param_name, const vector<int> &adl_lags) { // If the node already exists in tree, share it - auto it = unary_op_node_map.find(make_pair(make_pair(arg, op_code), make_pair(make_pair(arg_exp_info_set, make_pair(param1_symb_id, param2_symb_id)), make_pair(adl_param_name, adl_lags)))); + auto it = unary_op_node_map.find({ { arg, op_code }, { { arg_exp_info_set, { param1_symb_id, param2_symb_id } }, { adl_param_name, adl_lags } } }); if (it != unary_op_node_map.end()) return it->second; @@ -355,7 +355,7 @@ DataTree::AddUnaryOp(UnaryOpcode op_code, expr_t arg, int arg_exp_info_set, int inline expr_t DataTree::AddBinaryOp(expr_t arg1, BinaryOpcode op_code, expr_t arg2, int powerDerivOrder) { - auto it = binary_op_node_map.find(make_pair(make_pair(make_pair(arg1, arg2), powerDerivOrder), op_code)); + auto it = binary_op_node_map.find({ { { arg1, arg2 }, powerDerivOrder }, op_code }); if (it != binary_op_node_map.end()) return it->second; @@ -376,7 +376,7 @@ DataTree::AddBinaryOp(expr_t arg1, BinaryOpcode op_code, expr_t arg2, int powerD inline expr_t DataTree::AddTrinaryOp(expr_t arg1, TrinaryOpcode op_code, expr_t arg2, expr_t arg3) { - auto it = trinary_op_node_map.find(make_pair(make_pair(make_pair(arg1, arg2), arg3), op_code)); + auto it = trinary_op_node_map.find({ { { arg1, arg2 }, arg3 }, op_code }); if (it != trinary_op_node_map.end()) return it->second; diff --git a/src/DynamicModel.cc b/src/DynamicModel.cc index 80c51724e48397050b97d966eb50f07c879bc559..2a90ad2c29b41a785c30cbedc015e8ab65131b84 100644 --- a/src/DynamicModel.cc +++ b/src/DynamicModel.cc @@ -62,7 +62,7 @@ DynamicModel::AddVariable(int symb_id, int lag) void DynamicModel::compileDerivative(ofstream &code_file, unsigned int &instruction_number, int eq, int symb_id, int lag, const map_idx_t &map_idx) const { - auto it = first_derivatives.find(make_pair(eq, getDerivID(symbol_table.getID(eEndogenous, symb_id), lag))); + auto it = first_derivatives.find({ eq, getDerivID(symbol_table.getID(eEndogenous, symb_id), lag) }); if (it != first_derivatives.end()) (it->second)->compile(code_file, instruction_number, false, temporary_terms, map_idx, true, false); else @@ -75,7 +75,7 @@ DynamicModel::compileDerivative(ofstream &code_file, unsigned int &instruction_n void DynamicModel::compileChainRuleDerivative(ofstream &code_file, unsigned int &instruction_number, int eqr, int varr, int lag, const map_idx_t &map_idx) const { - auto it = first_chain_rule_derivatives.find(make_pair(eqr, make_pair(varr, lag))); + auto it = first_chain_rule_derivatives.find({ eqr, { varr, lag } }); if (it != first_chain_rule_derivatives.end()) (it->second)->compile(code_file, instruction_number, false, temporary_terms, map_idx, true, false); else @@ -256,7 +256,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const unsigned int prev_var, count_col, count_col_endo, count_col_exo, count_col_exo_det, count_col_other_endo; map<pair<int, pair<int, int>>, expr_t> tmp_block_endo_derivative; for (auto it = blocks_derivatives[block].begin(); it != (blocks_derivatives[block]).end(); it++) - tmp_block_endo_derivative[make_pair(it->second.first, make_pair(it->first.second, it->first.first))] = it->second.second; + tmp_block_endo_derivative[{ it->second.first, { it->first.second, it->first.first } }] = it->second.second; prev_var = 999999999; prev_lag = -9999999; count_col_endo = 0; @@ -273,7 +273,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const } map<pair<int, pair<int, int>>, expr_t> tmp_block_exo_derivative; for (auto it = derivative_exo[block].begin(); it != (derivative_exo[block]).end(); it++) - tmp_block_exo_derivative[make_pair(it->first.first, make_pair(it->first.second.second, it->first.second.first))] = it->second; + tmp_block_exo_derivative[{ it->first.first, { it->first.second.second, it->first.second.first } }] = it->second; prev_var = 999999999; prev_lag = -9999999; count_col_exo = 0; @@ -290,7 +290,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const } map<pair<int, pair<int, int>>, expr_t> tmp_block_exo_det_derivative; for (auto it = derivative_exo_det[block].begin(); it != (derivative_exo_det[block]).end(); it++) - tmp_block_exo_det_derivative[make_pair(it->first.first, make_pair(it->first.second.second, it->first.second.first))] = it->second; + tmp_block_exo_det_derivative[{ it->first.first, { it->first.second.second, it->first.second.first } }] = it->second; prev_var = 999999999; prev_lag = -9999999; count_col_exo_det = 0; @@ -307,7 +307,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const } map<pair<int, pair<int, int>>, expr_t> tmp_block_other_endo_derivative; for (auto it = derivative_other_endo[block].begin(); it != (derivative_other_endo[block]).end(); it++) - tmp_block_other_endo_derivative[make_pair(it->first.first, make_pair(it->first.second.second, it->first.second.first))] = it->second; + tmp_block_other_endo_derivative[{ it->first.first, { it->first.second.second, it->first.second.first } }] = it->second; prev_var = 999999999; prev_lag = -9999999; count_col_other_endo = 0; @@ -840,9 +840,9 @@ DynamicModel::writeModelEquationsCode(string &file_name, const string &bin_basen unsigned int var = symbol_table.getTypeSpecificID(symb); int lag = getLagByDerivID(deriv_id); if (getTypeByDerivID(deriv_id) == eEndogenous) - first_derivatives_reordered_endo[make_pair(lag, make_pair(var, eq))] = first_derivative.second; + first_derivatives_reordered_endo[{ lag, make_pair(var, eq) }] = first_derivative.second; else if (getTypeByDerivID(deriv_id) == eExogenous || getTypeByDerivID(deriv_id) == eExogenousDet) - first_derivatives_reordered_exo[make_pair(make_pair(lag, getTypeByDerivID(deriv_id)), make_pair(var, eq))] = first_derivative.second; + first_derivatives_reordered_exo[{ { lag, getTypeByDerivID(deriv_id) }, { var, eq } }] = first_derivative.second; } int prev_var = -1; int prev_lag = -999999999; @@ -937,7 +937,7 @@ DynamicModel::writeModelEquationsCode(string &file_name, const string &bin_basen fnumexpr.write(code_file, instruction_number); if (!derivatives[eq].size()) derivatives[eq].clear(); - derivatives[eq].push_back(make_pair(make_pair(var, lag), count_u)); + derivatives[eq].emplace_back(make_pair(var, lag), count_u); d1->compile(code_file, instruction_number, false, temporary_terms, map_idx, true, false); FSTPU_ fstpu(count_u); @@ -1110,16 +1110,16 @@ DynamicModel::writeModelEquationsCode_Block(string &file_name, const string &bin } map<pair<int, pair<int, int>>, expr_t> tmp_block_endo_derivative; for (auto it = blocks_derivatives[block].begin(); it != (blocks_derivatives[block]).end(); it++) - tmp_block_endo_derivative[make_pair(it->second.first, make_pair(it->first.second, it->first.first))] = it->second.second; + tmp_block_endo_derivative[{ it->second.first, { it->first.second, it->first.first } }] = it->second.second; map<pair<int, pair<int, int>>, expr_t> tmp_exo_derivative; for (auto it = derivative_exo[block].begin(); it != (derivative_exo[block]).end(); it++) - tmp_exo_derivative[make_pair(it->first.first, make_pair(it->first.second.second, it->first.second.first))] = it->second; + tmp_exo_derivative[{ it->first.first, { it->first.second.second, it->first.second.first } }] = it->second; map<pair<int, pair<int, int>>, expr_t> tmp_exo_det_derivative; for (auto it = derivative_exo_det[block].begin(); it != (derivative_exo_det[block]).end(); it++) - tmp_exo_det_derivative[make_pair(it->first.first, make_pair(it->first.second.second, it->first.second.first))] = it->second; + tmp_exo_det_derivative[{ it->first.first, { it->first.second.second, it->first.second.first } }] = it->second; map<pair<int, pair<int, int>>, expr_t> tmp_other_endo_derivative; for (auto it = derivative_other_endo[block].begin(); it != (derivative_other_endo[block]).end(); it++) - tmp_other_endo_derivative[make_pair(it->first.first, make_pair(it->first.second.second, it->first.second.first))] = it->second; + tmp_other_endo_derivative[{ it->first.first, { it->first.second.second, it->first.second.first } }] = it->second; int prev_var = -1; int prev_lag = -999999999; int count_col_endo = 0; @@ -3121,7 +3121,7 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de count_lead_lag_incidence = 0; dynamic_jacob_map_t reordered_dynamic_jacobian; for (const auto & it : blocks_derivatives[block]) - reordered_dynamic_jacobian[make_pair(it.second.first, make_pair(it.first.second, it.first.first))] = it.second.second; + reordered_dynamic_jacobian[{ it.second.first, { it.first.second, it.first.first } }] = it.second.second; output << "block_structure.block(" << block+1 << ").lead_lag_incidence = [];\n"; int last_var = -1; vector<int> local_state_var; @@ -3195,7 +3195,7 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de for (int i = 0; i < block_size; i++) { unsigned int eq = getBlockEquationID(block, i); - auto it = derivative_other_endo[block].find(make_pair(lag, make_pair(eq, other_endogenou))); + auto it = derivative_other_endo[block].find({ lag, { eq, other_endogenou } }); if (it != derivative_other_endo[block].end()) { count_lead_lag_incidence++; @@ -3243,7 +3243,7 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de int symb = getSymbIDByDerivID(deriv_id); int var = symbol_table.getTypeSpecificID(symb); int lag = getLagByDerivID(deriv_id); - lag_row_incidence[make_pair(lag, make_pair(eq, var))] = 1; + lag_row_incidence[{ lag, { eq, var } }] = 1; } } int prev_lag = -1000000; @@ -3304,7 +3304,7 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de { vector<int>::const_iterator it_state_equ = find(state_equ.begin(), state_equ.end(), getBlockEquationID(block, it->first.first)+1); if (it_state_equ != state_equ.end()) - row_state_var_incidence.insert(make_pair(it_state_equ - state_equ.begin(), it_state_var - state_var.begin())); + row_state_var_incidence.emplace(it_state_equ - state_equ.begin(), it_state_var - state_var.begin()); } } @@ -3336,7 +3336,7 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de } set<pair<int, int>> col_state_var_incidence; for (const auto & row_state_var_incidence_it : row_state_var_incidence) - col_state_var_incidence.insert(make_pair(row_state_var_incidence_it.second, row_state_var_incidence_it.first)); + col_state_var_incidence.emplace(row_state_var_incidence_it.second, row_state_var_incidence_it.first); auto col_state_var_incidence_it = col_state_var_incidence.begin(); diag = true; int nb_diag_c = 0; @@ -3474,7 +3474,7 @@ DynamicModel::collect_first_order_derivatives_endogenous() int eq = first_derivative.first.first; int var = symbol_table.getTypeSpecificID(getSymbIDByDerivID(first_derivative.first.second)); int lag = getLagByDerivID(first_derivative.first.second); - endo_derivatives[make_pair(eq, make_pair(var, lag))] = first_derivative.second; + endo_derivatives[{ eq, { var, lag } }] = first_derivative.second; } } return endo_derivatives; @@ -3950,7 +3950,7 @@ DynamicModel::computingPass(bool jacobianExo, bool hessian, bool thirdDerivative { equation_block[equation_reordered[k]] = i; int l = variable_reordered[k]; - variable_block_lead_lag[l] = make_pair(i, make_pair(variable_lag_lead[l].first, variable_lag_lead[l].second)); + variable_block_lead_lag[l] = { i, { variable_lag_lead[l].first, variable_lag_lead[l].second } }; k++; } } @@ -4092,10 +4092,10 @@ DynamicModel::get_Derivatives(int block) for (int var = 0; var < block_size; var++) { int varr = getBlockVariableID(block, var); - if (dynamic_jacobian.find(make_pair(lag, make_pair(eqr, varr))) != dynamic_jacobian.end()) + if (dynamic_jacobian.find({ lag, { eqr, varr } }) != dynamic_jacobian.end()) { bool OK = true; - map<pair<pair<int, pair<int, int>>, pair<int, int>>, int>::const_iterator its = Derivatives.find(make_pair(make_pair(lag, make_pair(eq, var)), make_pair(eqr, varr))); + map<pair<pair<int, pair<int, int>>, pair<int, int>>, int>::const_iterator its = Derivatives.find({ { lag, { eq, var } }, { eqr, varr } }); if (its != Derivatives.end()) { if (its->second == 2) @@ -4106,10 +4106,10 @@ DynamicModel::get_Derivatives(int block) { if (getBlockEquationType(block, eq) == E_EVALUATE_S && eq < block_nb_recursive) //It's a normalized equation, we have to recompute the derivative using chain rule derivative function - Derivatives[make_pair(make_pair(lag, make_pair(eq, var)), make_pair(eqr, varr))] = 1; + Derivatives[{ { lag, { eq, var } }, { eqr, varr } }] = 1; else //It's a feedback equation we can use the derivatives - Derivatives[make_pair(make_pair(lag, make_pair(eq, var)), make_pair(eqr, varr))] = 0; + Derivatives[{ { lag, { eq, var } }, { eqr, varr } }] = 0; } if (var < block_nb_recursive) { @@ -4118,8 +4118,8 @@ DynamicModel::get_Derivatives(int block) { int varrs = getBlockVariableID(block, vars); //A new derivative needs to be computed using the chain rule derivative function (a feedback variable appears in a recursive equation) - if (Derivatives.find(make_pair(make_pair(lag, make_pair(var, vars)), make_pair(eqs, varrs))) != Derivatives.end()) - Derivatives[make_pair(make_pair(lag, make_pair(eq, vars)), make_pair(eqr, varrs))] = 2; + if (Derivatives.find({ { lag, { var, vars } }, { eqs, varrs } }) != Derivatives.end()) + Derivatives[{ { lag, { eq, vars } }, { eqr, varrs } }] = 2; } } } @@ -4163,17 +4163,17 @@ DynamicModel::computeChainRuleJacobian(blocks_derivatives_t &blocks_endo_derivat int eqr = it_l.second.first; int varr = it_l.second.second; if (Deriv_type == 0) - first_chain_rule_derivatives[make_pair(eqr, make_pair(varr, lag))] = first_derivatives[make_pair(eqr, getDerivID(symbol_table.getID(eEndogenous, varr), lag))]; + first_chain_rule_derivatives[{ eqr, { varr, lag } }] = first_derivatives[{ eqr, getDerivID(symbol_table.getID(eEndogenous, varr), lag) }]; else if (Deriv_type == 1) - first_chain_rule_derivatives[make_pair(eqr, make_pair(varr, lag))] = (equation_type_and_normalized_equation[eqr].second)->getChainRuleDerivative(getDerivID(symbol_table.getID(eEndogenous, varr), lag), recursive_variables); + first_chain_rule_derivatives[{ eqr, { varr, lag } }] = (equation_type_and_normalized_equation[eqr].second)->getChainRuleDerivative(getDerivID(symbol_table.getID(eEndogenous, varr), lag), recursive_variables); else if (Deriv_type == 2) { if (getBlockEquationType(block, eq) == E_EVALUATE_S && eq < block_nb_recursives) - first_chain_rule_derivatives[make_pair(eqr, make_pair(varr, lag))] = (equation_type_and_normalized_equation[eqr].second)->getChainRuleDerivative(getDerivID(symbol_table.getID(eEndogenous, varr), lag), recursive_variables); + first_chain_rule_derivatives[{ eqr, { varr, lag } }] = (equation_type_and_normalized_equation[eqr].second)->getChainRuleDerivative(getDerivID(symbol_table.getID(eEndogenous, varr), lag), recursive_variables); else - first_chain_rule_derivatives[make_pair(eqr, make_pair(varr, lag))] = equations[eqr]->getChainRuleDerivative(getDerivID(symbol_table.getID(eEndogenous, varr), lag), recursive_variables); + first_chain_rule_derivatives[{ eqr, { varr, lag } }] = equations[eqr]->getChainRuleDerivative(getDerivID(symbol_table.getID(eEndogenous, varr), lag), recursive_variables); } - tmp_derivatives.push_back(make_pair(make_pair(eq, var), make_pair(lag, first_chain_rule_derivatives[make_pair(eqr, make_pair(varr, lag))]))); + tmp_derivatives.emplace_back(make_pair(eq, var), make_pair(lag, first_chain_rule_derivatives[{ eqr, { varr, lag } }])); } blocks_endo_derivatives[block] = tmp_derivatives; } @@ -4203,11 +4203,11 @@ DynamicModel::collect_block_first_order_derivatives() derivative_other_endo = vector<derivative_t>(nb_blocks); derivative_exo = vector<derivative_t>(nb_blocks); derivative_exo_det = vector<derivative_t>(nb_blocks); - endo_max_leadlag_block = vector<pair<int, int>>(nb_blocks, make_pair(0, 0)); - other_endo_max_leadlag_block = vector<pair<int, int>>(nb_blocks, make_pair(0, 0)); - exo_max_leadlag_block = vector<pair<int, int>>(nb_blocks, make_pair(0, 0)); - exo_det_max_leadlag_block = vector<pair<int, int>>(nb_blocks, make_pair(0, 0)); - max_leadlag_block = vector<pair<int, int>>(nb_blocks, make_pair(0, 0)); + endo_max_leadlag_block = vector<pair<int, int>>(nb_blocks, { 0, 0 }); + other_endo_max_leadlag_block = vector<pair<int, int>>(nb_blocks, { 0, 0 }); + exo_max_leadlag_block = vector<pair<int, int>>(nb_blocks, { 0, 0 }); + exo_det_max_leadlag_block = vector<pair<int, int>>(nb_blocks, { 0, 0 }); + max_leadlag_block = vector<pair<int, int>>(nb_blocks, { 0, 0 }); for (auto & first_derivative : first_derivatives) { int eq = first_derivative.first.first; @@ -4224,19 +4224,19 @@ DynamicModel::collect_block_first_order_derivatives() if (block_eq == block_var) { if (lag < 0 && lag < -endo_max_leadlag_block[block_eq].first) - endo_max_leadlag_block[block_eq] = make_pair(-lag, endo_max_leadlag_block[block_eq].second); + endo_max_leadlag_block[block_eq] = { -lag, endo_max_leadlag_block[block_eq].second }; if (lag > 0 && lag > endo_max_leadlag_block[block_eq].second) - endo_max_leadlag_block[block_eq] = make_pair(endo_max_leadlag_block[block_eq].first, lag); + endo_max_leadlag_block[block_eq] = { endo_max_leadlag_block[block_eq].first, lag }; tmp_derivative = derivative_endo[block_eq]; - tmp_derivative[make_pair(lag, make_pair(eq, var))] = first_derivatives[make_pair(eq, getDerivID(symbol_table.getID(eEndogenous, var), lag))]; + tmp_derivative[{ lag, { eq, var } }] = first_derivatives[{ eq, getDerivID(symbol_table.getID(eEndogenous, var), lag) }]; derivative_endo[block_eq] = tmp_derivative; } else { if (lag < 0 && lag < -other_endo_max_leadlag_block[block_eq].first) - other_endo_max_leadlag_block[block_eq] = make_pair(-lag, other_endo_max_leadlag_block[block_eq].second); + other_endo_max_leadlag_block[block_eq] = { -lag, other_endo_max_leadlag_block[block_eq].second }; if (lag > 0 && lag > other_endo_max_leadlag_block[block_eq].second) - other_endo_max_leadlag_block[block_eq] = make_pair(other_endo_max_leadlag_block[block_eq].first, lag); + other_endo_max_leadlag_block[block_eq] = { other_endo_max_leadlag_block[block_eq].first, lag }; tmp_derivative = derivative_other_endo[block_eq]; { map< int, map<int, int>>::const_iterator it = block_other_endo_index.find(block_eq); @@ -4252,7 +4252,7 @@ DynamicModel::collect_block_first_order_derivatives() } } } - tmp_derivative[make_pair(lag, make_pair(eq, var))] = first_derivatives[make_pair(eq, getDerivID(symbol_table.getID(eEndogenous, var), lag))]; + tmp_derivative[{ lag, { eq, var } }] = first_derivatives[{ eq, getDerivID(symbol_table.getID(eEndogenous, var), lag) }]; derivative_other_endo[block_eq] = tmp_derivative; lag_var = other_endo_block[block_eq]; if (lag_var.find(lag) == lag_var.end()) @@ -4263,9 +4263,9 @@ DynamicModel::collect_block_first_order_derivatives() break; case eExogenous: if (lag < 0 && lag < -exo_max_leadlag_block[block_eq].first) - exo_max_leadlag_block[block_eq] = make_pair(-lag, exo_max_leadlag_block[block_eq].second); + exo_max_leadlag_block[block_eq] = { -lag, exo_max_leadlag_block[block_eq].second }; if (lag > 0 && lag > exo_max_leadlag_block[block_eq].second) - exo_max_leadlag_block[block_eq] = make_pair(exo_max_leadlag_block[block_eq].first, lag); + exo_max_leadlag_block[block_eq] = { exo_max_leadlag_block[block_eq].first, lag }; tmp_derivative = derivative_exo[block_eq]; { map< int, map<int, int>>::const_iterator it = block_exo_index.find(block_eq); @@ -4281,7 +4281,7 @@ DynamicModel::collect_block_first_order_derivatives() } } } - tmp_derivative[make_pair(lag, make_pair(eq, var))] = first_derivatives[make_pair(eq, getDerivID(symbol_table.getID(eExogenous, var), lag))]; + tmp_derivative[{ lag, { eq, var } }] = first_derivatives[{ eq, getDerivID(symbol_table.getID(eExogenous, var), lag) }]; derivative_exo[block_eq] = tmp_derivative; lag_var = exo_block[block_eq]; if (lag_var.find(lag) == lag_var.end()) @@ -4291,9 +4291,9 @@ DynamicModel::collect_block_first_order_derivatives() break; case eExogenousDet: if (lag < 0 && lag < -exo_det_max_leadlag_block[block_eq].first) - exo_det_max_leadlag_block[block_eq] = make_pair(-lag, exo_det_max_leadlag_block[block_eq].second); + exo_det_max_leadlag_block[block_eq] = { -lag, exo_det_max_leadlag_block[block_eq].second }; if (lag > 0 && lag > exo_det_max_leadlag_block[block_eq].second) - exo_det_max_leadlag_block[block_eq] = make_pair(exo_det_max_leadlag_block[block_eq].first, lag); + exo_det_max_leadlag_block[block_eq] = { exo_det_max_leadlag_block[block_eq].first, lag }; tmp_derivative = derivative_exo_det[block_eq]; { map< int, map<int, int>>::const_iterator it = block_det_exo_index.find(block_eq); @@ -4309,7 +4309,7 @@ DynamicModel::collect_block_first_order_derivatives() } } } - tmp_derivative[make_pair(lag, make_pair(eq, var))] = first_derivatives[make_pair(eq, getDerivID(symbol_table.getID(eExogenous, var), lag))]; + tmp_derivative[{ lag, { eq, var } }] = first_derivatives[{ eq, getDerivID(symbol_table.getID(eExogenous, var), lag) }]; derivative_exo_det[block_eq] = tmp_derivative; lag_var = exo_det_block[block_eq]; if (lag_var.find(lag) == lag_var.end()) @@ -4321,9 +4321,9 @@ DynamicModel::collect_block_first_order_derivatives() break; } if (lag < 0 && lag < -max_leadlag_block[block_eq].first) - max_leadlag_block[block_eq] = make_pair(-lag, max_leadlag_block[block_eq].second); + max_leadlag_block[block_eq] = { -lag, max_leadlag_block[block_eq].second }; if (lag > 0 && lag > max_leadlag_block[block_eq].second) - max_leadlag_block[block_eq] = make_pair(max_leadlag_block[block_eq].first, lag); + max_leadlag_block[block_eq] = { max_leadlag_block[block_eq].first, lag }; } } @@ -4802,7 +4802,7 @@ DynamicModel::getSymbIDByDerivID(int deriv_id) const noexcept(false) int DynamicModel::getDerivID(int symb_id, int lag) const noexcept(false) { - auto it = deriv_id_table.find(make_pair(symb_id, lag)); + auto it = deriv_id_table.find({ symb_id, lag }); if (it == deriv_id_table.end()) throw UnknownDerivIDException(); else @@ -4836,7 +4836,7 @@ DynamicModel::computeDynJacobianCols(bool jacobianExo) switch (type) { case eEndogenous: - ordered_dyn_endo[make_pair(lag, tsid)] = deriv_id; + ordered_dyn_endo[{ lag, tsid }] = deriv_id; break; case eExogenous: // At this point, dynJacobianColsNbr contains the number of dynamic endogenous diff --git a/src/ExprNode.cc b/src/ExprNode.cc index 3c9cc7bd528d4969297310fff697e0a287508cde..eea2b83f128ae3396debd17ac5ffac58ed5d98fd 100644 --- a/src/ExprNode.cc +++ b/src/ExprNode.cc @@ -142,7 +142,7 @@ ExprNode::collectEndogenous(set<pair<int, int>> &result) const set<pair<int, int>> symb_ids; collectDynamicVariables(eEndogenous, symb_ids); for (const auto & symb_id : symb_ids) - result.insert(make_pair(datatree.symbol_table.getTypeSpecificID(symb_id.first), symb_id.second)); + result.emplace(datatree.symbol_table.getTypeSpecificID(symb_id.first), symb_id.second); } void @@ -151,7 +151,7 @@ ExprNode::collectExogenous(set<pair<int, int>> &result) const set<pair<int, int>> symb_ids; collectDynamicVariables(eExogenous, symb_ids); for (const auto & symb_id : symb_ids) - result.insert(make_pair(datatree.symbol_table.getTypeSpecificID(symb_id.first), symb_id.second)); + result.emplace(datatree.symbol_table.getTypeSpecificID(symb_id.first), symb_id.second); } void @@ -177,7 +177,7 @@ pair<int, expr_t > ExprNode::normalizeEquation(int var_endo, vector<pair<int, pair<expr_t, expr_t>>> &List_of_Op_RHS) const { /* nothing to do */ - return (make_pair(0, (expr_t) nullptr)); + return { 0, nullptr }; } void @@ -414,7 +414,7 @@ pair<int, expr_t > NumConstNode::normalizeEquation(int var_endo, vector<pair<int, pair<expr_t, expr_t>>> &List_of_Op_RHS) const { /* return the numercial constant */ - return (make_pair(0, datatree.AddNonNegativeConstant(datatree.num_constants.get(id)))); + return { 0, datatree.AddNonNegativeConstant(datatree.num_constants.get(id)) }; } expr_t @@ -676,7 +676,7 @@ VariableNode::VariableNode(DataTree &datatree_arg, int symb_id_arg, int lag_arg) lag(lag_arg) { // Add myself to the variable map - datatree.variable_node_map[make_pair(symb_id, lag)] = this; + datatree.variable_node_map[{ symb_id, lag }] = this; // It makes sense to allow a lead/lag on parameters: during steady state calibration, endogenous and parameters can be swapped assert(type != eExternalFunction @@ -1160,7 +1160,7 @@ void VariableNode::collectDynamicVariables(SymbolType type_arg, set<pair<int, int>> &result) const { if (type == type_arg) - result.insert(make_pair(symb_id, lag)); + result.emplace(symb_id, lag); if (type == eModelLocalVariable) datatree.local_variables_table[symb_id]->collectDynamicVariables(type_arg, result); } @@ -1184,16 +1184,16 @@ VariableNode::normalizeEquation(int var_endo, vector<pair<int, pair<expr_t, expr { if (datatree.symbol_table.getTypeSpecificID(symb_id) == var_endo && lag == 0) /* the endogenous variable */ - return (make_pair(1, (expr_t) nullptr)); + return { 1, nullptr }; else - return (make_pair(0, datatree.AddVariableInternal(symb_id, lag))); + return { 0, datatree.AddVariableInternal(symb_id, lag) }; } else { if (type == eParameter) - return (make_pair(0, datatree.AddVariableInternal(symb_id, 0))); + return { 0, datatree.AddVariableInternal(symb_id, 0) }; else - return (make_pair(0, datatree.AddVariableInternal(symb_id, lag))); + return { 0, datatree.AddVariableInternal(symb_id, lag) }; } } @@ -1265,16 +1265,16 @@ VariableNode::computeXrefs(EquationInfo &ei) const switch (type) { case eEndogenous: - ei.endo.insert(make_pair(symb_id, lag)); + ei.endo.emplace(symb_id, lag); break; case eExogenous: - ei.exo.insert(make_pair(symb_id, lag)); + ei.exo.emplace(symb_id, lag); break; case eExogenousDet: - ei.exo_det.insert(make_pair(symb_id, lag)); + ei.exo_det.emplace(symb_id, lag); break; case eParameter: - ei.param.insert(make_pair(symb_id, 0)); + ei.param.emplace(symb_id, 0); break; case eTrend: case eLogTrend: @@ -1842,10 +1842,8 @@ UnaryOpNode::UnaryOpNode(DataTree &datatree_arg, UnaryOpcode op_code_arg, const adl_lags(move(adl_lags_arg)) { // Add myself to the unary op map - datatree.unary_op_node_map[make_pair(make_pair(arg, op_code), - make_pair(make_pair(expectation_information_set, - make_pair(param1_symb_id, param2_symb_id)), - make_pair(adl_param_name, adl_lags)))] = this; + datatree.unary_op_node_map[{ { arg, op_code }, + { { expectation_information_set, { param1_symb_id, param2_symb_id } }, { adl_param_name, adl_lags } } }] = this; } void @@ -2145,12 +2143,12 @@ UnaryOpNode::computeTemporaryTerms(map<expr_t, pair<int, NodeTreeReference>> &re auto it = reference_count.find(this2); if (it == reference_count.end()) { - reference_count[this2] = make_pair(1, tr); + reference_count[this2] = { 1, tr }; arg->computeTemporaryTerms(reference_count, temp_terms_map, is_matlab, tr); } else { - reference_count[this2] = make_pair(it->second.first + 1, it->second.second); + reference_count[this2] = { it->second.first + 1, it->second.second }; if (reference_count[this2].first * cost(temp_terms_map, is_matlab) > MIN_COST(is_matlab)) temp_terms_map[reference_count[this2].second].insert(this2); } @@ -2169,7 +2167,7 @@ UnaryOpNode::computeTemporaryTerms(map<expr_t, int> &reference_count, if (it == reference_count.end()) { reference_count[this2] = 1; - first_occurence[this2] = make_pair(Curr_block, equation); + first_occurence[this2] = { Curr_block, equation }; arg->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, Curr_block, v_temporary_terms, equation); } else @@ -2694,7 +2692,7 @@ UnaryOpNode::normalizeEquation(int var_endo, vector<pair<int, pair<expr_t, expr_ expr_t New_expr_t = res.second; if (is_endogenous_present == 2) /* The equation could not be normalized and the process is given-up*/ - return (make_pair(2, (expr_t) nullptr)); + return { 2, nullptr }; else if (is_endogenous_present) /* The argument of the function contains the current values of the endogenous variable associated to the equation. In order to normalized, we have to apply the invert function to the RHS.*/ @@ -2702,67 +2700,67 @@ UnaryOpNode::normalizeEquation(int var_endo, vector<pair<int, pair<expr_t, expr_ switch (op_code) { case oUminus: - List_of_Op_RHS.emplace_back(oUminus, make_pair((expr_t) nullptr, (expr_t) nullptr)); - return (make_pair(1, (expr_t) nullptr)); + List_of_Op_RHS.emplace_back(oUminus, make_pair(nullptr, nullptr)); + return { 1, nullptr }; case oExp: - List_of_Op_RHS.emplace_back(oLog, make_pair((expr_t) nullptr, (expr_t) nullptr)); - return (make_pair(1, (expr_t) nullptr)); + List_of_Op_RHS.emplace_back(oLog, make_pair(nullptr, nullptr)); + return { 1, nullptr }; case oLog: - List_of_Op_RHS.emplace_back(oExp, make_pair((expr_t) nullptr, (expr_t) nullptr)); - return (make_pair(1, (expr_t) nullptr)); + List_of_Op_RHS.emplace_back(oExp, make_pair(nullptr, nullptr)); + return { 1, nullptr }; case oLog10: - List_of_Op_RHS.emplace_back(oPower, make_pair((expr_t) nullptr, datatree.AddNonNegativeConstant("10"))); - return (make_pair(1, (expr_t) nullptr)); + List_of_Op_RHS.emplace_back(oPower, make_pair(nullptr, datatree.AddNonNegativeConstant("10"))); + return { 1, nullptr }; case oCos: - List_of_Op_RHS.emplace_back(oAcos, make_pair((expr_t) nullptr, (expr_t) nullptr)); - return (make_pair(1, (expr_t) nullptr)); + List_of_Op_RHS.emplace_back(oAcos, make_pair(nullptr, nullptr)); + return { 1, nullptr }; case oSin: - List_of_Op_RHS.emplace_back(oAsin, make_pair((expr_t) nullptr, (expr_t) nullptr)); - return (make_pair(1, (expr_t) nullptr)); + List_of_Op_RHS.emplace_back(oAsin, make_pair(nullptr, nullptr)); + return { 1, nullptr }; case oTan: - List_of_Op_RHS.emplace_back(oAtan, make_pair((expr_t) nullptr, (expr_t) nullptr)); - return (make_pair(1, (expr_t) nullptr)); + List_of_Op_RHS.emplace_back(oAtan, make_pair(nullptr, nullptr)); + return { 1, nullptr }; case oAcos: - List_of_Op_RHS.emplace_back(oCos, make_pair((expr_t) nullptr, (expr_t) nullptr)); - return (make_pair(1, (expr_t) nullptr)); + List_of_Op_RHS.emplace_back(oCos, make_pair(nullptr, nullptr)); + return { 1, nullptr }; case oAsin: - List_of_Op_RHS.emplace_back(oSin, make_pair((expr_t) nullptr, (expr_t) nullptr)); - return (make_pair(1, (expr_t) nullptr)); + List_of_Op_RHS.emplace_back(oSin, make_pair(nullptr, nullptr)); + return { 1, nullptr }; case oAtan: - List_of_Op_RHS.emplace_back(oTan, make_pair((expr_t) nullptr, (expr_t) nullptr)); - return (make_pair(1, (expr_t) nullptr)); + List_of_Op_RHS.emplace_back(oTan, make_pair(nullptr, nullptr)); + return { 1, nullptr }; case oCosh: - List_of_Op_RHS.emplace_back(oAcosh, make_pair((expr_t) nullptr, (expr_t) nullptr)); - return (make_pair(1, (expr_t) nullptr)); + List_of_Op_RHS.emplace_back(oAcosh, make_pair(nullptr, nullptr)); + return { 1, nullptr }; case oSinh: - List_of_Op_RHS.emplace_back(oAsinh, make_pair((expr_t) nullptr, (expr_t) nullptr)); - return (make_pair(1, (expr_t) nullptr)); + List_of_Op_RHS.emplace_back(oAsinh, make_pair(nullptr, nullptr)); + return { 1, nullptr }; case oTanh: - List_of_Op_RHS.emplace_back(oAtanh, make_pair((expr_t) nullptr, (expr_t) nullptr)); - return (make_pair(1, (expr_t) nullptr)); + List_of_Op_RHS.emplace_back(oAtanh, make_pair(nullptr, nullptr)); + return { 1, nullptr }; case oAcosh: - List_of_Op_RHS.emplace_back(oCosh, make_pair((expr_t) nullptr, (expr_t) nullptr)); - return (make_pair(1, (expr_t) nullptr)); + List_of_Op_RHS.emplace_back(oCosh, make_pair(nullptr, nullptr)); + return { 1, nullptr }; case oAsinh: - List_of_Op_RHS.emplace_back(oSinh, make_pair((expr_t) nullptr, (expr_t) nullptr)); - return (make_pair(1, (expr_t) nullptr)); + List_of_Op_RHS.emplace_back(oSinh, make_pair(nullptr, nullptr)); + return { 1, nullptr }; case oAtanh: - List_of_Op_RHS.emplace_back(oTanh, make_pair((expr_t) nullptr, (expr_t) nullptr)); - return (make_pair(1, (expr_t) nullptr)); + List_of_Op_RHS.emplace_back(oTanh, make_pair(nullptr, nullptr)); + return { 1, nullptr }; case oSqrt: - List_of_Op_RHS.emplace_back(oPower, make_pair((expr_t) nullptr, datatree.Two)); - return (make_pair(1, (expr_t) nullptr)); + List_of_Op_RHS.emplace_back(oPower, make_pair(nullptr, datatree.Two)); + return { 1, nullptr }; case oAbs: - return (make_pair(2, (expr_t) nullptr)); + return { 2, nullptr }; case oSign: - return (make_pair(2, (expr_t) nullptr)); + return { 2, nullptr }; case oSteadyState: - return (make_pair(2, (expr_t) nullptr)); + return { 2, nullptr }; case oErf: - return (make_pair(2, (expr_t) nullptr)); + return { 2, nullptr }; default: cerr << "Unary operator not handled during the normalization process" << endl; - return (make_pair(2, (expr_t) nullptr)); // Could not be normalized + return { 2, nullptr }; // Could not be normalized } } else @@ -2771,50 +2769,50 @@ UnaryOpNode::normalizeEquation(int var_endo, vector<pair<int, pair<expr_t, expr_ switch (op_code) { case oUminus: - return (make_pair(0, datatree.AddUMinus(New_expr_t))); + return { 0, datatree.AddUMinus(New_expr_t) }; case oExp: - return (make_pair(0, datatree.AddExp(New_expr_t))); + return { 0, datatree.AddExp(New_expr_t) }; case oLog: - return (make_pair(0, datatree.AddLog(New_expr_t))); + return { 0, datatree.AddLog(New_expr_t) }; case oLog10: - return (make_pair(0, datatree.AddLog10(New_expr_t))); + return { 0, datatree.AddLog10(New_expr_t) }; case oCos: - return (make_pair(0, datatree.AddCos(New_expr_t))); + return { 0, datatree.AddCos(New_expr_t) }; case oSin: - return (make_pair(0, datatree.AddSin(New_expr_t))); + return { 0, datatree.AddSin(New_expr_t) }; case oTan: - return (make_pair(0, datatree.AddTan(New_expr_t))); + return { 0, datatree.AddTan(New_expr_t) }; case oAcos: - return (make_pair(0, datatree.AddAcos(New_expr_t))); + return { 0, datatree.AddAcos(New_expr_t) }; case oAsin: - return (make_pair(0, datatree.AddAsin(New_expr_t))); + return { 0, datatree.AddAsin(New_expr_t) }; case oAtan: - return (make_pair(0, datatree.AddAtan(New_expr_t))); + return { 0, datatree.AddAtan(New_expr_t) }; case oCosh: - return (make_pair(0, datatree.AddCosh(New_expr_t))); + return { 0, datatree.AddCosh(New_expr_t) }; case oSinh: - return (make_pair(0, datatree.AddSinh(New_expr_t))); + return { 0, datatree.AddSinh(New_expr_t) }; case oTanh: - return (make_pair(0, datatree.AddTanh(New_expr_t))); + return { 0, datatree.AddTanh(New_expr_t) }; case oAcosh: - return (make_pair(0, datatree.AddAcosh(New_expr_t))); + return { 0, datatree.AddAcosh(New_expr_t) }; case oAsinh: - return (make_pair(0, datatree.AddAsinh(New_expr_t))); + return { 0, datatree.AddAsinh(New_expr_t) }; case oAtanh: - return (make_pair(0, datatree.AddAtanh(New_expr_t))); + return { 0, datatree.AddAtanh(New_expr_t) }; case oSqrt: - return (make_pair(0, datatree.AddSqrt(New_expr_t))); + return { 0, datatree.AddSqrt(New_expr_t) }; case oAbs: - return (make_pair(0, datatree.AddAbs(New_expr_t))); + return { 0, datatree.AddAbs(New_expr_t) }; case oSign: - return (make_pair(0, datatree.AddSign(New_expr_t))); + return { 0, datatree.AddSign(New_expr_t) }; case oSteadyState: - return (make_pair(0, datatree.AddSteadyState(New_expr_t))); + return { 0, datatree.AddSteadyState(New_expr_t) }; case oErf: - return (make_pair(0, datatree.AddErf(New_expr_t))); + return { 0, datatree.AddErf(New_expr_t) }; default: cerr << "Unary operator not handled during the normalization process" << endl; - return (make_pair(2, (expr_t) nullptr)); // Could not be normalized + return { 2, nullptr }; // Could not be normalized } } cerr << "UnaryOpNode::normalizeEquation: impossible case" << endl; @@ -3456,7 +3454,7 @@ BinaryOpNode::BinaryOpNode(DataTree &datatree_arg, const expr_t arg1_arg, op_code(op_code_arg), powerDerivOrder(0) { - datatree.binary_op_node_map[make_pair(make_pair(make_pair(arg1, arg2), powerDerivOrder), op_code)] = this; + datatree.binary_op_node_map[{ { { arg1, arg2 }, powerDerivOrder }, op_code }] = this; } BinaryOpNode::BinaryOpNode(DataTree &datatree_arg, const expr_t arg1_arg, @@ -3468,7 +3466,7 @@ BinaryOpNode::BinaryOpNode(DataTree &datatree_arg, const expr_t arg1_arg, powerDerivOrder(powerDerivOrder_arg) { assert(powerDerivOrder >= 0); - datatree.binary_op_node_map[make_pair(make_pair(make_pair(arg1, arg2), powerDerivOrder), op_code)] = this; + datatree.binary_op_node_map[{ { { arg1, arg2 }, powerDerivOrder }, op_code }] = this; } void @@ -3806,7 +3804,7 @@ BinaryOpNode::computeTemporaryTerms(map<expr_t, pair<int, NodeTreeReference>> &r { // If this node has never been encountered, set its ref count to one, // and travel through its children - reference_count[this2] = make_pair(1, tr); + reference_count[this2] = { 1, tr }; arg1->computeTemporaryTerms(reference_count, temp_terms_map, is_matlab, tr); arg2->computeTemporaryTerms(reference_count, temp_terms_map, is_matlab, tr); } @@ -3815,7 +3813,7 @@ BinaryOpNode::computeTemporaryTerms(map<expr_t, pair<int, NodeTreeReference>> &r /* If the node has already been encountered, increment its ref count and declare it as a temporary term if it is too costly (except if it is an equal node: we don't want them as temporary terms) */ - reference_count[this2] = make_pair(it->second.first + 1, it->second.second);; + reference_count[this2] = { it->second.first + 1, it->second.second };; if (reference_count[this2].first * cost(temp_terms_map, is_matlab) > MIN_COST(is_matlab) && op_code != oEqual) temp_terms_map[reference_count[this2].second].insert(this2); @@ -3835,7 +3833,7 @@ BinaryOpNode::computeTemporaryTerms(map<expr_t, int> &reference_count, if (it == reference_count.end()) { reference_count[this2] = 1; - first_occurence[this2] = make_pair(Curr_block, equation); + first_occurence[this2] = { Curr_block, equation }; arg1->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, Curr_block, v_temporary_terms, equation); arg2->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, Curr_block, v_temporary_terms, equation); } @@ -4408,9 +4406,9 @@ BinaryOpNode::normalizeEquation(int var_endo, vector<pair<int, pair<expr_t, expr /* If the two expressions contains the current value of the endogenous variable associated to the equation the equation could not be normalized and the process is given-up.*/ if (is_endogenous_present_1 == 2 || is_endogenous_present_2 == 2) - return (make_pair(2, (expr_t) nullptr)); + return { 2, nullptr }; else if (is_endogenous_present_1 && is_endogenous_present_2) - return (make_pair(2, (expr_t) nullptr)); + return { 2, nullptr }; else if (is_endogenous_present_1) /*If the current values of the endogenous variable associated to the equation is present only in the first operand of the expression, we try to normalize the equation*/ { @@ -4465,80 +4463,80 @@ BinaryOpNode::normalizeEquation(int var_endo, vector<pair<int, pair<expr_t, expr if (!is_endogenous_present_1 && !is_endogenous_present_2) { List_of_Op_RHS.emplace_back(oMinus, make_pair(datatree.AddPlus(expr_t_1, expr_t_2), (expr_t) nullptr)); - return (make_pair(0, datatree.AddPlus(expr_t_1, expr_t_2))); + return { 0, datatree.AddPlus(expr_t_1, expr_t_2) }; } else if (is_endogenous_present_1 && is_endogenous_present_2) - return (make_pair(1, (expr_t) nullptr)); + return { 1, nullptr }; else if (!is_endogenous_present_1 && is_endogenous_present_2) { List_of_Op_RHS.emplace_back(oMinus, make_pair(expr_t_1, (expr_t) nullptr)); - return (make_pair(1, expr_t_1)); + return { 1, expr_t_1 }; } else if (is_endogenous_present_1 && !is_endogenous_present_2) { List_of_Op_RHS.emplace_back(oMinus, make_pair(expr_t_2, (expr_t) nullptr)); - return (make_pair(1, expr_t_2)); + return { 1, expr_t_2 }; } break; case oMinus: if (!is_endogenous_present_1 && !is_endogenous_present_2) { List_of_Op_RHS.emplace_back(oMinus, make_pair(datatree.AddMinus(expr_t_1, expr_t_2), (expr_t) nullptr)); - return (make_pair(0, datatree.AddMinus(expr_t_1, expr_t_2))); + return { 0, datatree.AddMinus(expr_t_1, expr_t_2) }; } else if (is_endogenous_present_1 && is_endogenous_present_2) - return (make_pair(1, (expr_t) nullptr)); + return { 1, nullptr }; else if (!is_endogenous_present_1 && is_endogenous_present_2) { List_of_Op_RHS.emplace_back(oUminus, make_pair((expr_t) nullptr, (expr_t) nullptr)); List_of_Op_RHS.emplace_back(oMinus, make_pair(expr_t_1, (expr_t) nullptr)); - return (make_pair(1, expr_t_1)); + return { 1, expr_t_1 }; } else if (is_endogenous_present_1 && !is_endogenous_present_2) { List_of_Op_RHS.emplace_back(oPlus, make_pair(expr_t_2, (expr_t) nullptr)); - return (make_pair(1, datatree.AddUMinus(expr_t_2))); + return { 1, datatree.AddUMinus(expr_t_2) }; } break; case oTimes: if (!is_endogenous_present_1 && !is_endogenous_present_2) - return (make_pair(0, datatree.AddTimes(expr_t_1, expr_t_2))); + return { 0, datatree.AddTimes(expr_t_1, expr_t_2) }; else if (!is_endogenous_present_1 && is_endogenous_present_2) { List_of_Op_RHS.emplace_back(oDivide, make_pair(expr_t_1, (expr_t) nullptr)); - return (make_pair(1, expr_t_1)); + return { 1, expr_t_1 }; } else if (is_endogenous_present_1 && !is_endogenous_present_2) { List_of_Op_RHS.emplace_back(oDivide, make_pair(expr_t_2, (expr_t) nullptr)); - return (make_pair(1, expr_t_2)); + return { 1, expr_t_2 }; } else - return (make_pair(1, (expr_t) nullptr)); + return { 1, nullptr }; break; case oDivide: if (!is_endogenous_present_1 && !is_endogenous_present_2) - return (make_pair(0, datatree.AddDivide(expr_t_1, expr_t_2))); + return { 0, datatree.AddDivide(expr_t_1, expr_t_2) }; else if (!is_endogenous_present_1 && is_endogenous_present_2) { List_of_Op_RHS.emplace_back(oDivide, make_pair((expr_t) nullptr, expr_t_1)); - return (make_pair(1, expr_t_1)); + return { 1, expr_t_1 }; } else if (is_endogenous_present_1 && !is_endogenous_present_2) { List_of_Op_RHS.emplace_back(oTimes, make_pair(expr_t_2, (expr_t) nullptr)); - return (make_pair(1, expr_t_2)); + return { 1, expr_t_2 }; } else - return (make_pair(1, (expr_t) nullptr)); + return { 1, nullptr }; break; case oPower: if (!is_endogenous_present_1 && !is_endogenous_present_2) - return (make_pair(0, datatree.AddPower(expr_t_1, expr_t_2))); + return { 0, datatree.AddPower(expr_t_1, expr_t_2) }; else if (is_endogenous_present_1 && !is_endogenous_present_2) { List_of_Op_RHS.emplace_back(oPower, make_pair(datatree.AddDivide(datatree.One, expr_t_2), (expr_t) nullptr)); - return (make_pair(1, (expr_t) nullptr)); + return { 1, (expr_t) nullptr }; } else if (!is_endogenous_present_1 && is_endogenous_present_2) { @@ -4547,86 +4545,78 @@ BinaryOpNode::normalizeEquation(int var_endo, vector<pair<int, pair<expr_t, expr List_of_Op_RHS.emplace_back(oLog, make_pair((expr_t) nullptr, (expr_t) nullptr)); /* Second computes f(X) = ln(RHS) / ln(a)*/ List_of_Op_RHS.emplace_back(oDivide, make_pair((expr_t) nullptr, datatree.AddLog(expr_t_1))); - return (make_pair(1, (expr_t) nullptr)); + return { 1, (expr_t) nullptr }; } break; case oEqual: if (!is_endogenous_present_1 && !is_endogenous_present_2) { - return (make_pair(0, - datatree.AddEqual(datatree.AddVariable(datatree.symbol_table.getID(eEndogenous, var_endo), 0), datatree.AddMinus(expr_t_2, expr_t_1)) - )); + return { 0, datatree.AddEqual(datatree.AddVariable(datatree.symbol_table.getID(eEndogenous, var_endo), 0), datatree.AddMinus(expr_t_2, expr_t_1)) }; } else if (is_endogenous_present_1 && is_endogenous_present_2) { - return (make_pair(0, - datatree.AddEqual(datatree.AddVariable(datatree.symbol_table.getID(eEndogenous, var_endo), 0), datatree.Zero) - )); + return { 0, datatree.AddEqual(datatree.AddVariable(datatree.symbol_table.getID(eEndogenous, var_endo), 0), datatree.Zero) }; } else if (!is_endogenous_present_1 && is_endogenous_present_2) { - return (make_pair(0, - datatree.AddEqual(datatree.AddVariable(datatree.symbol_table.getID(eEndogenous, var_endo), 0), /*datatree.AddUMinus(expr_t_1)*/ expr_t_1) - )); + return { 0, datatree.AddEqual(datatree.AddVariable(datatree.symbol_table.getID(eEndogenous, var_endo), 0), /*datatree.AddUMinus(expr_t_1)*/ expr_t_1) }; } else if (is_endogenous_present_1 && !is_endogenous_present_2) { - return (make_pair(0, - datatree.AddEqual(datatree.AddVariable(datatree.symbol_table.getID(eEndogenous, var_endo), 0), expr_t_2) - )); + return { 0, datatree.AddEqual(datatree.AddVariable(datatree.symbol_table.getID(eEndogenous, var_endo), 0), expr_t_2) }; } break; case oMax: if (!is_endogenous_present_1 && !is_endogenous_present_2) - return (make_pair(0, datatree.AddMax(expr_t_1, expr_t_2))); + return { 0, datatree.AddMax(expr_t_1, expr_t_2) }; else - return (make_pair(1, (expr_t) nullptr)); + return { 1, (expr_t) nullptr }; break; case oMin: if (!is_endogenous_present_1 && !is_endogenous_present_2) - return (make_pair(0, datatree.AddMin(expr_t_1, expr_t_2))); + return { 0, datatree.AddMin(expr_t_1, expr_t_2) }; else - return (make_pair(1, (expr_t) nullptr)); + return { 1, (expr_t) nullptr }; break; case oLess: if (!is_endogenous_present_1 && !is_endogenous_present_2) - return (make_pair(0, datatree.AddLess(expr_t_1, expr_t_2))); + return { 0, datatree.AddLess(expr_t_1, expr_t_2) }; else - return (make_pair(1, (expr_t) nullptr)); + return { 1, (expr_t) nullptr }; break; case oGreater: if (!is_endogenous_present_1 && !is_endogenous_present_2) - return (make_pair(0, datatree.AddGreater(expr_t_1, expr_t_2))); + return { 0, datatree.AddGreater(expr_t_1, expr_t_2) }; else - return (make_pair(1, (expr_t) nullptr)); + return { 1, (expr_t) nullptr }; break; case oLessEqual: if (!is_endogenous_present_1 && !is_endogenous_present_2) - return (make_pair(0, datatree.AddLessEqual(expr_t_1, expr_t_2))); + return { 0, datatree.AddLessEqual(expr_t_1, expr_t_2) }; else - return (make_pair(1, (expr_t) nullptr)); + return { 1, (expr_t) nullptr }; break; case oGreaterEqual: if (!is_endogenous_present_1 && !is_endogenous_present_2) - return (make_pair(0, datatree.AddGreaterEqual(expr_t_1, expr_t_2))); + return { 0, datatree.AddGreaterEqual(expr_t_1, expr_t_2) }; else - return (make_pair(1, (expr_t) nullptr)); + return { 1, (expr_t) nullptr }; break; case oEqualEqual: if (!is_endogenous_present_1 && !is_endogenous_present_2) - return (make_pair(0, datatree.AddEqualEqual(expr_t_1, expr_t_2))); + return { 0, datatree.AddEqualEqual(expr_t_1, expr_t_2) }; else - return (make_pair(1, (expr_t) nullptr)); + return { 1, (expr_t) nullptr }; break; case oDifferent: if (!is_endogenous_present_1 && !is_endogenous_present_2) - return (make_pair(0, datatree.AddDifferent(expr_t_1, expr_t_2))); + return { 0, datatree.AddDifferent(expr_t_1, expr_t_2) }; else - return (make_pair(1, (expr_t) nullptr)); + return { 1, (expr_t) nullptr }; break; default: cerr << "Binary operator not handled during the normalization process" << endl; - return (make_pair(2, (expr_t) nullptr)); // Could not be normalized + return { 2, (expr_t) nullptr }; // Could not be normalized } // Suppress GCC warning cerr << "BinaryOpNode::normalizeEquation: impossible case" << endl; @@ -5026,7 +5016,7 @@ BinaryOpNode::walkPacParametersHelper(const expr_t arg1, const expr_t arg2, set<pair<int, int>> endogs; arg2->collectDynamicVariables(eEndogenous, endogs); if (endogs.size() == 1) - ar_params_and_vars.insert(make_pair(*(params.begin()), *(endogs.begin()))); + ar_params_and_vars.emplace(*(params.begin()), *(endogs.begin())); else if (endogs.size() >= 2) { auto *testarg2 = dynamic_cast<BinaryOpNode *>(arg2); @@ -5037,10 +5027,10 @@ BinaryOpNode::walkPacParametersHelper(const expr_t arg1, const expr_t arg2, if (test_arg1 != nullptr && test_arg2 != nullptr && lhs.first != -1) { test_arg1->collectDynamicVariables(eEndogenous, endogs); - ec_params_and_vars.insert(make_pair(*(params.begin()), *(endogs.begin()))); + ec_params_and_vars.emplace(*(params.begin()), *(endogs.begin())); endogs.clear(); test_arg2->collectDynamicVariables(eEndogenous, endogs); - ec_params_and_vars.insert(make_pair(*(params.begin()), *(endogs.begin()))); + ec_params_and_vars.emplace(*(params.begin()), *(endogs.begin())); } } } @@ -5121,7 +5111,7 @@ TrinaryOpNode::TrinaryOpNode(DataTree &datatree_arg, const expr_t arg1_arg, arg3(arg3_arg), op_code(op_code_arg) { - datatree.trinary_op_node_map[make_pair(make_pair(make_pair(arg1, arg2), arg3), op_code)] = this; + datatree.trinary_op_node_map[{ { { arg1, arg2 }, arg3 }, op_code }] = this; } void @@ -5309,7 +5299,7 @@ TrinaryOpNode::computeTemporaryTerms(map<expr_t, pair<int, NodeTreeReference>> & { // If this node has never been encountered, set its ref count to one, // and travel through its children - reference_count[this2] = make_pair(1, tr); + reference_count[this2] = { 1, tr }; arg1->computeTemporaryTerms(reference_count, temp_terms_map, is_matlab, tr); arg2->computeTemporaryTerms(reference_count, temp_terms_map, is_matlab, tr); arg3->computeTemporaryTerms(reference_count, temp_terms_map, is_matlab, tr); @@ -5318,7 +5308,7 @@ TrinaryOpNode::computeTemporaryTerms(map<expr_t, pair<int, NodeTreeReference>> & { // If the node has already been encountered, increment its ref count // and declare it as a temporary term if it is too costly - reference_count[this2] = make_pair(it->second.first + 1, it->second.second);; + reference_count[this2] = { it->second.first + 1, it->second.second };; if (reference_count[this2].first * cost(temp_terms_map, is_matlab) > MIN_COST(is_matlab)) temp_terms_map[reference_count[this2].second].insert(this2); } @@ -5337,7 +5327,7 @@ TrinaryOpNode::computeTemporaryTerms(map<expr_t, int> &reference_count, if (it == reference_count.end()) { reference_count[this2] = 1; - first_occurence[this2] = make_pair(Curr_block, equation); + first_occurence[this2] = { Curr_block, equation }; arg1->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, Curr_block, v_temporary_terms, equation); arg2->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, Curr_block, v_temporary_terms, equation); arg3->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, Curr_block, v_temporary_terms, equation); @@ -5588,9 +5578,9 @@ TrinaryOpNode::normalizeEquation(int var_endo, vector<pair<int, pair<expr_t, exp bool is_endogenous_present_3 = res.first; expr_t expr_t_3 = res.second; if (!is_endogenous_present_1 && !is_endogenous_present_2 && !is_endogenous_present_3) - return (make_pair(0, datatree.AddNormcdf(expr_t_1, expr_t_2, expr_t_3))); + return { 0, datatree.AddNormcdf(expr_t_1, expr_t_2, expr_t_3) }; else - return (make_pair(1, (expr_t) nullptr)); + return { 1, (expr_t) nullptr }; } expr_t @@ -6283,7 +6273,7 @@ AbstractExternalFunctionNode::differentiateForwardVars(const vector<string> &sub bool AbstractExternalFunctionNode::alreadyWrittenAsTefTerm(int the_symb_id, const deriv_node_temp_terms_t &tef_terms) const { - auto it = tef_terms.find(make_pair(the_symb_id, arguments)); + auto it = tef_terms.find({ the_symb_id, arguments }); if (it != tef_terms.end()) return true; return false; @@ -6292,7 +6282,7 @@ AbstractExternalFunctionNode::alreadyWrittenAsTefTerm(int the_symb_id, const der int AbstractExternalFunctionNode::getIndxInTefTerms(int the_symb_id, const deriv_node_temp_terms_t &tef_terms) const noexcept(false) { - auto it = tef_terms.find(make_pair(the_symb_id, arguments)); + auto it = tef_terms.find({ the_symb_id, arguments }); if (it != tef_terms.end()) return it->second; throw UnknownFunctionNameAndArgs(); @@ -6451,9 +6441,9 @@ AbstractExternalFunctionNode::normalizeEquation(int var_endo, vector<pair<int, p V_expr_t.push_back(V_arguments[V_arguments.size()-1].second); } if (!present) - return (make_pair(0, datatree.AddExternalFunction(symb_id, V_expr_t))); + return { 0, datatree.AddExternalFunction(symb_id, V_expr_t) }; else - return (make_pair(1, (expr_t) nullptr)); + return { 1, (expr_t) nullptr }; } void @@ -6525,7 +6515,7 @@ ExternalFunctionNode::ExternalFunctionNode(DataTree &datatree_arg, AbstractExternalFunctionNode(datatree_arg, symb_id_arg, arguments_arg) { // Add myself to the external function map - datatree.external_function_node_map[make_pair(arguments, symb_id)] = this; + datatree.external_function_node_map[{ arguments, symb_id }] = this; } expr_t @@ -6552,7 +6542,7 @@ ExternalFunctionNode::computeTemporaryTerms(map<expr_t, int> &reference_count, { expr_t this2 = const_cast<ExternalFunctionNode *>(this); temporary_terms.insert(this2); - first_occurence[this2] = make_pair(Curr_block, equation); + first_occurence[this2] = { Curr_block, equation }; v_temporary_terms[Curr_block][equation].insert(this2); } @@ -6607,7 +6597,7 @@ ExternalFunctionNode::compileExternalFunctionOutput(ostream &CompileCode, unsign if (!alreadyWrittenAsTefTerm(symb_id, tef_terms)) { - tef_terms[make_pair(symb_id, arguments)] = (int) tef_terms.size(); + tef_terms[{ symb_id, arguments }] = (int) tef_terms.size(); int indx = getIndxInTefTerms(symb_id, tef_terms); int second_deriv_symb_id = datatree.external_functions_table.getSecondDerivSymbID(symb_id); assert(second_deriv_symb_id != eExtFunSetButNoNameProvided); @@ -6700,7 +6690,7 @@ ExternalFunctionNode::writeExternalFunctionOutput(ostream &output, ExprNodeOutpu if (!alreadyWrittenAsTefTerm(symb_id, tef_terms)) { - tef_terms[make_pair(symb_id, arguments)] = (int) tef_terms.size(); + tef_terms[{ symb_id, arguments }] = (int) tef_terms.size(); int indx = getIndxInTefTerms(symb_id, tef_terms); int second_deriv_symb_id = datatree.external_functions_table.getSecondDerivSymbID(symb_id); assert(second_deriv_symb_id != eExtFunSetButNoNameProvided); @@ -6777,7 +6767,7 @@ ExternalFunctionNode::writeJsonExternalFunctionOutput(vector<string> &efout, if (!alreadyWrittenAsTefTerm(symb_id, tef_terms)) { - tef_terms[make_pair(symb_id, arguments)] = (int) tef_terms.size(); + tef_terms[{ symb_id, arguments }] = (int) tef_terms.size(); int indx = getIndxInTefTerms(symb_id, tef_terms); int second_deriv_symb_id = datatree.external_functions_table.getSecondDerivSymbID(symb_id); assert(second_deriv_symb_id != eExtFunSetButNoNameProvided); @@ -6848,7 +6838,7 @@ FirstDerivExternalFunctionNode::FirstDerivExternalFunctionNode(DataTree &datatre inputIndex(inputIndex_arg) { // Add myself to the first derivative external function map - datatree.first_deriv_external_function_node_map[make_pair(make_pair(arguments, inputIndex), symb_id)] = this; + datatree.first_deriv_external_function_node_map[{ { arguments, inputIndex }, symb_id }] = this; } void @@ -6861,7 +6851,7 @@ FirstDerivExternalFunctionNode::computeTemporaryTerms(map<expr_t, int> &referenc { expr_t this2 = const_cast<FirstDerivExternalFunctionNode *>(this); temporary_terms.insert(this2); - first_occurence[this2] = make_pair(Curr_block, equation); + first_occurence[this2] = { Curr_block, equation }; v_temporary_terms[Curr_block][equation].insert(this2); } @@ -7048,7 +7038,7 @@ FirstDerivExternalFunctionNode::writeExternalFunctionOutput(ostream &output, Exp } else { - tef_terms[make_pair(first_deriv_symb_id, arguments)] = (int) tef_terms.size(); + tef_terms[{ first_deriv_symb_id, arguments }] = (int) tef_terms.size(); int indx = getIndxInTefTerms(first_deriv_symb_id, tef_terms); stringstream ending; ending << "_tefd_def_" << indx; @@ -7074,7 +7064,7 @@ FirstDerivExternalFunctionNode::writeExternalFunctionOutput(ostream &output, Exp << datatree.symbol_table.getName(symb_id) << "'," << inputIndex << ",{"; else { - tef_terms[make_pair(first_deriv_symb_id, arguments)] = (int) tef_terms.size(); + tef_terms[{ first_deriv_symb_id, arguments }] = (int) tef_terms.size(); output << "TEFD_def_" << getIndxInTefTerms(first_deriv_symb_id, tef_terms) << " = " << datatree.symbol_table.getName(first_deriv_symb_id) << "("; } @@ -7117,7 +7107,7 @@ FirstDerivExternalFunctionNode::writeJsonExternalFunctionOutput(vector<string> & << ", \"value\": \"" << datatree.symbol_table.getName(symb_id) << "("; else { - tef_terms[make_pair(first_deriv_symb_id, arguments)] = (int) tef_terms.size(); + tef_terms[{ first_deriv_symb_id, arguments }] = (int) tef_terms.size(); ef << "{\"first_deriv_external_function\": {" << "\"external_function_term\": \"TEFD_def_" << getIndxInTefTerms(first_deriv_symb_id, tef_terms) << "\"" << ", \"analytic_derivative\": true" @@ -7159,7 +7149,7 @@ FirstDerivExternalFunctionNode::compileExternalFunctionOutput(ostream &CompileCo } else { - tef_terms[make_pair(first_deriv_symb_id, arguments)] = (int) tef_terms.size(); + tef_terms[{ first_deriv_symb_id, arguments }] = (int) tef_terms.size(); int indx = getIndxInTefTerms(symb_id, tef_terms); int second_deriv_symb_id = datatree.external_functions_table.getSecondDerivSymbID(symb_id); assert(second_deriv_symb_id != eExtFunSetButNoNameProvided); @@ -7234,7 +7224,7 @@ SecondDerivExternalFunctionNode::SecondDerivExternalFunctionNode(DataTree &datat inputIndex2(inputIndex2_arg) { // Add myself to the second derivative external function map - datatree.second_deriv_external_function_node_map[make_pair(make_pair(arguments, make_pair(inputIndex1, inputIndex2)), symb_id)] = this; + datatree.second_deriv_external_function_node_map[{ { arguments, { inputIndex1, inputIndex2 } }, symb_id }] = this; } void @@ -7247,7 +7237,7 @@ SecondDerivExternalFunctionNode::computeTemporaryTerms(map<expr_t, int> &referen { expr_t this2 = const_cast<SecondDerivExternalFunctionNode *>(this); temporary_terms.insert(this2); - first_occurence[this2] = make_pair(Curr_block, equation); + first_occurence[this2] = { Curr_block, equation }; v_temporary_terms[Curr_block][equation].insert(this2); } @@ -7405,7 +7395,7 @@ SecondDerivExternalFunctionNode::writeExternalFunctionOutput(ostream &output, Ex } else { - tef_terms[make_pair(second_deriv_symb_id, arguments)] = (int) tef_terms.size(); + tef_terms[{ second_deriv_symb_id, arguments }] = (int) tef_terms.size(); int indx = getIndxInTefTerms(second_deriv_symb_id, tef_terms); stringstream ending; ending << "_tefdd_def_" << indx; @@ -7433,7 +7423,7 @@ SecondDerivExternalFunctionNode::writeExternalFunctionOutput(ostream &output, Ex << inputIndex1 << "," << inputIndex2 << ",{"; else { - tef_terms[make_pair(second_deriv_symb_id, arguments)] = (int) tef_terms.size(); + tef_terms[{ second_deriv_symb_id, arguments }] = (int) tef_terms.size(); output << "TEFDD_def_" << getIndxInTefTerms(second_deriv_symb_id, tef_terms) << " = " << datatree.symbol_table.getName(second_deriv_symb_id) << "("; } @@ -7477,7 +7467,7 @@ SecondDerivExternalFunctionNode::writeJsonExternalFunctionOutput(vector<string> << ", \"value\": \"" << datatree.symbol_table.getName(symb_id) << "("; else { - tef_terms[make_pair(second_deriv_symb_id, arguments)] = (int) tef_terms.size(); + tef_terms[{ second_deriv_symb_id, arguments }] = (int) tef_terms.size(); ef << "{\"second_deriv_external_function\": {" << "\"external_function_term\": \"TEFDD_def_" << getIndxInTefTerms(second_deriv_symb_id, tef_terms) << "\"" << ", \"analytic_derivative\": true" @@ -7569,7 +7559,7 @@ VarExpectationNode::VarExpectationNode(DataTree &datatree_arg, model_name(model_name_arg), yidx(-1) { - datatree.var_expectation_node_map[make_pair(model_name, make_pair(symb_id, forecast_horizon))] = this; + datatree.var_expectation_node_map[{ model_name, { symb_id, forecast_horizon } }] = this; } void @@ -7590,7 +7580,7 @@ VarExpectationNode::computeTemporaryTerms(map<expr_t, int> &reference_count, { expr_t this2 = const_cast<VarExpectationNode *>(this); temporary_terms.insert(this2); - first_occurence[this2] = make_pair(Curr_block, equation); + first_occurence[this2] = { Curr_block, equation }; v_temporary_terms[Curr_block][equation].insert(this2); } @@ -7772,7 +7762,7 @@ VarExpectationNode::compile(ostream &CompileCode, unsigned int &instruction_numb pair<int, expr_t > VarExpectationNode::normalizeEquation(int var_endo, vector<pair<int, pair<expr_t, expr_t>>> &List_of_Op_RHS) const { - return make_pair(0, datatree.AddVariableInternal(symb_id, 0)); + return { 0, datatree.AddVariableInternal(symb_id, 0) }; } expr_t @@ -7979,7 +7969,7 @@ PacExpectationNode::computeTemporaryTerms(map<expr_t, int> &reference_count, { expr_t this2 = const_cast<PacExpectationNode *>(this); temporary_terms.insert(this2); - first_occurence[this2] = make_pair(Curr_block, equation); + first_occurence[this2] = { Curr_block, equation }; v_temporary_terms[Curr_block][equation].insert(this2); } @@ -8220,7 +8210,7 @@ pair<int, expr_t > PacExpectationNode::normalizeEquation(int var_endo, vector<pair<int, pair<expr_t, expr_t>>> &List_of_Op_RHS) const { //COME BACK - return make_pair(0, const_cast<PacExpectationNode *>(this)); + return { 0, const_cast<PacExpectationNode *>(this) }; } expr_t diff --git a/src/ModFile.cc b/src/ModFile.cc index e3a80645fa1a6de98cf711f6099bd7bbe8fc6d50..334de1e69f3a1ac510c337fbd2dcb9f51f26b8e9 100644 --- a/src/ModFile.cc +++ b/src/ModFile.cc @@ -399,9 +399,7 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, const vms->fillVarModelInfoFromEquations(eqnumber, lhs, rhs, nonstationary, diff, orig_diff_var, max_lag); var_model_info_pac_expectation[var_model_name] = - make_pair(make_pair(make_pair(lhs, lhs_expr_t), - make_pair(diff, orig_diff_var)), - make_pair(make_pair(max_lag, nonstationary), eqnumber)); + { { { lhs, lhs_expr_t }, { diff, orig_diff_var } }, { { max_lag, nonstationary }, eqnumber } }; } auto *pms = dynamic_cast<PacModelStatement *>(*it); if (pms != nullptr) diff --git a/src/ModelTree.cc b/src/ModelTree.cc index 01aed7d9da8f98fd49a1f4fa56a1cc946b35d026..379728dcc6a948592fc38aa908526f7987d60f45 100644 --- a/src/ModelTree.cc +++ b/src/ModelTree.cc @@ -166,7 +166,7 @@ ModelTree::computeNonSingularNormalization(jacob_map_t &contemporaneous_jacobian int suppress = 0; for (auto & iter : normalized_contemporaneous_jacobian) if (fabs(iter.second) > max(current_cutoff, cutoff)) - tmp_normalized_contemporaneous_jacobian[make_pair(iter.first.first, iter.first.second)] = iter.second; + tmp_normalized_contemporaneous_jacobian[{ iter.first.first, iter.first.second }] = iter.second; else suppress++; @@ -193,7 +193,7 @@ ModelTree::computeNonSingularNormalization(jacob_map_t &contemporaneous_jacobian endo.clear(); equations[i]->collectEndogenous(endo); for (const auto & it : endo) - tmp_normalized_contemporaneous_jacobian[make_pair(i, it.first)] = 1; + tmp_normalized_contemporaneous_jacobian[{ i, it.first }] = 1; } check = computeNormalization(tmp_normalized_contemporaneous_jacobian, true); if (check) @@ -201,16 +201,16 @@ ModelTree::computeNonSingularNormalization(jacob_map_t &contemporaneous_jacobian // Update the jacobian matrix for (jacob_map_t::const_iterator it = tmp_normalized_contemporaneous_jacobian.begin(); it != tmp_normalized_contemporaneous_jacobian.end(); it++) { - if (static_jacobian.find(make_pair(it->first.first, it->first.second)) == static_jacobian.end()) - static_jacobian[make_pair(it->first.first, it->first.second)] = 0; - if (dynamic_jacobian.find(make_pair(0, make_pair(it->first.first, it->first.second))) == dynamic_jacobian.end()) - dynamic_jacobian[make_pair(0, make_pair(it->first.first, it->first.second))] = nullptr; - if (contemporaneous_jacobian.find(make_pair(it->first.first, it->first.second)) == contemporaneous_jacobian.end()) - contemporaneous_jacobian[make_pair(it->first.first, it->first.second)] = 0; + if (static_jacobian.find({ it->first.first, it->first.second }) == static_jacobian.end()) + static_jacobian[{ it->first.first, it->first.second }] = 0; + if (dynamic_jacobian.find({ 0, { it->first.first, it->first.second } }) == dynamic_jacobian.end()) + dynamic_jacobian[{ 0, { it->first.first, it->first.second } }] = nullptr; + if (contemporaneous_jacobian.find({ it->first.first, it->first.second }) == contemporaneous_jacobian.end()) + contemporaneous_jacobian[{ it->first.first, it->first.second }] = 0; try { - 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; + if (first_derivatives.find({ it->first.first, getDerivID(symbol_table.getID(eEndogenous, it->first.second), 0) }) == first_derivatives.end()) + first_derivatives[{ it->first.first, getDerivID(symbol_table.getID(eEndogenous, it->first.second), 0) }] = Zero; } catch (DataTree::UnknownDerivIDException &e) { @@ -244,10 +244,10 @@ ModelTree::computeNormalizedEquations(multimap<int, int> &endo2eqs) const set<pair<int, int>> endo; equations[i]->get_arg2()->collectEndogenous(endo); - if (endo.find(make_pair(symbol_table.getTypeSpecificID(symb_id), 0)) != endo.end()) + if (endo.find({ symbol_table.getTypeSpecificID(symb_id), 0 }) != endo.end()) continue; - endo2eqs.insert(make_pair(symbol_table.getTypeSpecificID(symb_id), (int) i)); + endo2eqs.emplace(symbol_table.getTypeSpecificID(symb_id), (int) i); cout << "Endogenous " << symbol_table.getName(symb_id) << " normalized in equation " << (i+1) << endl; } } @@ -288,20 +288,20 @@ ModelTree::evaluateAndReduceJacobian(const eval_context_t &eval_context, jacob_m { if (verbose) cout << "the coefficient related to variable " << var << " with lag " << lag << " in equation " << eq << " is equal to " << val << " and is set to 0 in the incidence matrix (size=" << symbol_table.endo_nbr() << ")" << endl; - jacobian_elements_to_delete.insert(make_pair(eq, deriv_id)); + jacobian_elements_to_delete.emplace(eq, deriv_id); } else { if (lag == 0) { nb_elements_contemparenous_Jacobian++; - contemporaneous_jacobian[make_pair(eq, var)] = val; + contemporaneous_jacobian[{ eq, var }] = val; } - if (static_jacobian.find(make_pair(eq, var)) != static_jacobian.end()) - static_jacobian[make_pair(eq, var)] += val; + if (static_jacobian.find({ eq, var }) != static_jacobian.end()) + static_jacobian[{ eq, var }] += val; else - static_jacobian[make_pair(eq, var)] = val; - dynamic_jacobian[make_pair(lag, make_pair(eq, var))] = Id; + static_jacobian[{ eq, var }] = val; + dynamic_jacobian[{ lag, { eq, var } }] = Id; } } } @@ -450,13 +450,13 @@ ModelTree::equationTypeDetermination(const map<pair<int, pair<int, int>>, expr_t eq_node = equations[eq]; lhs = eq_node->get_arg1(); Equation_Simulation_Type = E_SOLVE; - auto derivative = first_order_endo_derivatives.find(make_pair(eq, make_pair(var, 0))); + auto derivative = first_order_endo_derivatives.find({ eq, { var, 0 } }); pair<bool, expr_t> res; if (derivative != first_order_endo_derivatives.end()) { set<pair<int, int>> result; derivative->second->collectEndogenous(result); - auto d_endo_variable = result.find(make_pair(var, 0)); + auto d_endo_variable = result.find({ var, 0 }); //Determine whether the equation could be evaluated rather than to be solved if (lhs->isVariableNodeEqualTo(eEndogenous, Index_Var_IM[i], 0) && derivative->second->isNumConstNodeEqualTo(1)) { @@ -478,7 +478,7 @@ ModelTree::equationTypeDetermination(const map<pair<int, pair<int, int>>, expr_t } } } - V_Equation_Simulation_Type[eq] = make_pair(Equation_Simulation_Type, dynamic_cast<BinaryOpNode *>(res.second)); + V_Equation_Simulation_Type[eq] = { Equation_Simulation_Type, dynamic_cast<BinaryOpNode *>(res.second) }; } return (V_Equation_Simulation_Type); } @@ -487,8 +487,8 @@ void ModelTree::getVariableLeadLagByBlock(const dynamic_jacob_map_t &dynamic_jacobian, const vector<int> &components_set, int nb_blck_sim, lag_lead_vector_t &equation_lead_lag, lag_lead_vector_t &variable_lead_lag, const vector<int> &equation_reordered, const vector<int> &variable_reordered) const { int nb_endo = symbol_table.endo_nbr(); - variable_lead_lag = lag_lead_vector_t(nb_endo, make_pair(0, 0)); - equation_lead_lag = lag_lead_vector_t(nb_endo, make_pair(0, 0)); + variable_lead_lag = lag_lead_vector_t(nb_endo, { 0, 0 }); + equation_lead_lag = lag_lead_vector_t(nb_endo, { 0, 0 }); vector<int> variable_blck(nb_endo), equation_blck(nb_endo); for (int i = 0; i < nb_endo; i++) { @@ -516,13 +516,13 @@ ModelTree::getVariableLeadLagByBlock(const dynamic_jacob_map_t &dynamic_jacobian if (variable_blck[i_1] == equation_blck[j_1]) { if (lag > variable_lead_lag[i_1].second) - variable_lead_lag[i_1] = make_pair(variable_lead_lag[i_1].first, lag); + variable_lead_lag[i_1] = { variable_lead_lag[i_1].first, lag }; if (lag < -variable_lead_lag[i_1].first) - variable_lead_lag[i_1] = make_pair(-lag, variable_lead_lag[i_1].second); + variable_lead_lag[i_1] = { -lag, variable_lead_lag[i_1].second }; if (lag > equation_lead_lag[j_1].second) - equation_lead_lag[j_1] = make_pair(equation_lead_lag[j_1].first, lag); + equation_lead_lag[j_1] = { equation_lead_lag[j_1].first, lag }; if (lag < -equation_lead_lag[j_1].first) - equation_lead_lag[j_1] = make_pair(-lag, equation_lead_lag[j_1].second); + equation_lead_lag[j_1] = { -lag, equation_lead_lag[j_1].second }; } } } @@ -556,7 +556,7 @@ ModelTree::computeBlockDecompositionAndFeedbackVariablesForEachBlock(const jacob endo.clear(); equations[i]->collectEndogenous(endo); for (const auto & it : endo) - tmp_normalized_contemporaneous_jacobian[make_pair(i, it.first)] = 1; + tmp_normalized_contemporaneous_jacobian[{ i, it.first }] = 1; } } @@ -576,7 +576,7 @@ ModelTree::computeBlockDecompositionAndFeedbackVariablesForEachBlock(const jacob // Compute strongly connected components int num = strong_components(G2, endo2block_map); - blocks = vector<pair<int, int>>(num, make_pair(0, 0)); + blocks = vector<pair<int, int>>(num, { 0, 0 }); // Create directed acyclic graph associated to the strongly connected components using DirectedGraph = adjacency_list<vecS, vecS, directedS>; @@ -838,7 +838,7 @@ ModelTree::reduceBlocksAndTypeDetermination(const dynamic_jacob_map_t &dynamic_j int curr_lag = it.second; auto it1 = find(variable_reordered.begin()+first_count_equ, variable_reordered.begin()+(first_count_equ+Blck_Size), curr_variable); if (it1 != variable_reordered.begin()+(first_count_equ+Blck_Size)) - if (dynamic_jacobian.find(make_pair(curr_lag, make_pair(equation_reordered[count_equ], curr_variable))) != dynamic_jacobian.end()) + if (dynamic_jacobian.find({ curr_lag, { equation_reordered[count_equ], curr_variable } }) != dynamic_jacobian.end()) { if (curr_lag > Lead) Lead = curr_lag; @@ -891,10 +891,10 @@ ModelTree::reduceBlocksAndTypeDetermination(const dynamic_jacob_map_t &dynamic_j { for (int j = first_equation; j < first_equation+c_Size; j++) { - auto it = dynamic_jacobian.find(make_pair(-1, make_pair(equation_reordered[eq], variable_reordered[j]))); + auto it = dynamic_jacobian.find({ -1, { equation_reordered[eq], variable_reordered[j] } }); if (it != dynamic_jacobian.end()) is_lag = true; - it = dynamic_jacobian.find(make_pair(+1, make_pair(equation_reordered[eq], variable_reordered[j]))); + it = dynamic_jacobian.find({ +1, { equation_reordered[eq], variable_reordered[j] } }); if (it != dynamic_jacobian.end()) is_lead = true; } @@ -905,33 +905,33 @@ ModelTree::reduceBlocksAndTypeDetermination(const dynamic_jacob_map_t &dynamic_j //merge the current block with the previous one BlockSimulationType c_Type = (block_type_size_mfs[block_type_size_mfs.size()-1]).first.first; c_Size++; - block_type_size_mfs[block_type_size_mfs.size()-1] = make_pair(make_pair(c_Type, first_equation), make_pair(c_Size, c_Size)); + block_type_size_mfs[block_type_size_mfs.size()-1] = { { c_Type, first_equation }, { c_Size, c_Size } }; if (block_lag_lead[block_type_size_mfs.size()-1].first > Lag) Lag = block_lag_lead[block_type_size_mfs.size()-1].first; if (block_lag_lead[block_type_size_mfs.size()-1].second > Lead) Lead = block_lag_lead[block_type_size_mfs.size()-1].second; - block_lag_lead[block_type_size_mfs.size()-1] = make_pair(Lag, Lead); + block_lag_lead[block_type_size_mfs.size()-1] = { Lag, Lead }; pair< pair< unsigned int, unsigned int>, pair<unsigned int, unsigned int>> tmp = block_col_type[block_col_type.size()-1]; - block_col_type[block_col_type.size()-1] = make_pair(make_pair(tmp.first.first+l_n_static, tmp.first.second+l_n_forward), make_pair(tmp.second.first+l_n_backward, tmp.second.second+l_n_mixed)); + block_col_type[block_col_type.size()-1] = { { tmp.first.first+l_n_static, tmp.first.second+l_n_forward }, { tmp.second.first+l_n_backward, tmp.second.second+l_n_mixed } }; } else { - block_type_size_mfs.push_back(make_pair(make_pair(Simulation_Type, eq), make_pair(Blck_Size, MFS_Size))); - block_lag_lead.push_back(make_pair(Lag, Lead)); + block_type_size_mfs.emplace_back(make_pair(Simulation_Type, eq), make_pair(Blck_Size, MFS_Size)); + block_lag_lead.emplace_back(Lag, Lead); block_col_type.emplace_back(make_pair(l_n_static, l_n_forward), make_pair(l_n_backward, l_n_mixed)); } } else { - block_type_size_mfs.push_back(make_pair(make_pair(Simulation_Type, eq), make_pair(Blck_Size, MFS_Size))); - block_lag_lead.push_back(make_pair(Lag, Lead)); + block_type_size_mfs.emplace_back(make_pair(Simulation_Type, eq), make_pair(Blck_Size, MFS_Size)); + block_lag_lead.emplace_back(Lag, Lead); block_col_type.emplace_back(make_pair(l_n_static, l_n_forward), make_pair(l_n_backward, l_n_mixed)); } } else { - block_type_size_mfs.push_back(make_pair(make_pair(Simulation_Type, eq), make_pair(Blck_Size, MFS_Size))); - block_lag_lead.push_back(make_pair(Lag, Lead)); + block_type_size_mfs.emplace_back(make_pair(Simulation_Type, eq), make_pair(Blck_Size, MFS_Size)); + block_lag_lead.emplace_back(Lag, Lead); block_col_type.emplace_back(make_pair(l_n_static, l_n_forward), make_pair(l_n_backward, l_n_mixed)); } prev_Type = Simulation_Type; @@ -965,7 +965,7 @@ ModelTree::BlockLinear(const blocks_derivatives_t &blocks_derivatives, const vec { for (int l = 0; l < block_size; l++) { - if (endogenous.find(make_pair(variable_reordered[first_variable_position+l], 0)) != endogenous.end()) + if (endogenous.find({ variable_reordered[first_variable_position+l], 0 }) != endogenous.end()) { blocks_linear[block] = false; goto the_end; @@ -987,7 +987,7 @@ ModelTree::BlockLinear(const blocks_derivatives_t &blocks_derivatives, const vec { for (int l = 0; l < block_size; l++) { - if (endogenous.find(make_pair(variable_reordered[first_variable_position+l], lag)) != endogenous.end()) + if (endogenous.find({ variable_reordered[first_variable_position+l], lag }) != endogenous.end()) { blocks_linear[block] = false; goto the_end; @@ -1025,7 +1025,7 @@ ModelTree::writeDerivative(ostream &output, int eq, int symb_id, int lag, ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms) const { - auto it = first_derivatives.find(make_pair(eq, getDerivID(symb_id, lag))); + auto it = first_derivatives.find({ eq, getDerivID(symb_id, lag) }); if (it != first_derivatives.end()) (it->second)->writeOutput(output, output_type, temporary_terms, {}); else @@ -1042,7 +1042,7 @@ ModelTree::computeJacobian(const set<int> &vars) expr_t d1 = equations[eq]->getDerivative(var); if (d1 == Zero) continue; - first_derivatives[make_pair(eq, var)] = d1; + first_derivatives[{ eq, var }] = d1; ++NNZDerivatives[0]; } } @@ -1067,7 +1067,7 @@ ModelTree::computeHessian(const set<int> &vars) expr_t d2 = d1->getDerivative(var2); if (d2 == Zero) continue; - second_derivatives[make_pair(eq, make_pair(var1, var2))] = d2; + second_derivatives[{ eq, { var1, var2 } }] = d2; if (var2 == var1) ++NNZDerivatives[1]; else @@ -1099,7 +1099,7 @@ ModelTree::computeThirdDerivatives(const set<int> &vars) expr_t d3 = d2->getDerivative(var3); if (d3 == Zero) continue; - third_derivatives[make_pair(eq, make_pair(var1, make_pair(var2, var3)))] = d3; + third_derivatives[{ eq, { var1, { var2, var3 } } }] = d3; if (var3 == var2 && var2 == var1) ++NNZDerivatives[2]; else if (var3 == var2 || var2 == var1) @@ -1131,7 +1131,7 @@ ModelTree::computeTemporaryTerms(bool is_matlab) { VariableNode *v = AddVariable(used_local_var); temporary_terms_mlv[v] = local_variables_table.find(used_local_var)->second; - reference_count[v] = make_pair(MIN_COST(is_matlab)+1, eResiduals); + reference_count[v] = { MIN_COST(is_matlab)+1, eResiduals }; } map<NodeTreeReference, temporary_terms_t> temp_terms_map; @@ -1779,7 +1779,7 @@ ModelTree::addNonstationaryVariables(vector<int> nonstationary_vars, bool log_de throw TrendException(symbol_table.getName(nonstationary_vars.back())); else { - nonstationary_symbols_map[nonstationary_vars.back()] = make_pair(log_deflator, deflator); + nonstationary_symbols_map[nonstationary_vars.back()] = { log_deflator, deflator }; nonstationary_vars.pop_back(); } } @@ -1839,7 +1839,7 @@ ModelTree::computeParamsDerivatives(int paramsDerivsOrder) expr_t d1 = equations[eq]->getDerivative(param); if (d1 == Zero) continue; - residuals_params_derivatives[make_pair(eq, param)] = d1; + residuals_params_derivatives[{ eq, param }] = d1; } if (paramsDerivsOrder == 2) @@ -1853,7 +1853,7 @@ ModelTree::computeParamsDerivatives(int paramsDerivsOrder) expr_t d2 = d1->getDerivative(param); if (d2 == Zero) continue; - residuals_params_second_derivatives[make_pair(eq, make_pair(param1, param))] = d2; + residuals_params_second_derivatives[{ eq, { param1, param } }] = d2; } for (first_derivatives_t::const_iterator it2 = first_derivatives.begin(); @@ -1866,7 +1866,7 @@ ModelTree::computeParamsDerivatives(int paramsDerivsOrder) expr_t d2 = d1->getDerivative(param); if (d2 == Zero) continue; - jacobian_params_derivatives[make_pair(eq, make_pair(var, param))] = d2; + jacobian_params_derivatives[{ eq, { var, param } }] = d2; } if (paramsDerivsOrder == 2) @@ -1882,7 +1882,7 @@ ModelTree::computeParamsDerivatives(int paramsDerivsOrder) expr_t d2 = d1->getDerivative(param); if (d2 == Zero) continue; - jacobian_params_second_derivatives[make_pair(eq, make_pair(var, make_pair(param1, param)))] = d2; + jacobian_params_second_derivatives[{ eq, { var, { param1, param } } }] = d2; } for (second_derivatives_t::const_iterator it2 = second_derivatives.begin(); @@ -1896,7 +1896,7 @@ ModelTree::computeParamsDerivatives(int paramsDerivsOrder) expr_t d2 = d1->getDerivative(param); if (d2 == Zero) continue; - hessian_params_derivatives[make_pair(eq, make_pair(var1, make_pair(var2, param)))] = d2; + hessian_params_derivatives[{ eq, { var1, { var2, param } } }] = d2; } } } diff --git a/src/ModelTree.hh b/src/ModelTree.hh index d90b1ea45006ccabf665f31c1729c8af3800ccdd..6b959acb86adfd2f10ad563ff3d4667d2a05400a 100644 --- a/src/ModelTree.hh +++ b/src/ModelTree.hh @@ -288,7 +288,7 @@ protected: inline void setBlockLeadLag(int block, int max_lag, int max_lead) { - block_lag_lead[block] = make_pair(max_lag, max_lead); + block_lag_lead[block] = { max_lag, max_lead }; }; //! Return the type of equation (equation_number) belonging to the block block_number diff --git a/src/ParsingDriver.cc b/src/ParsingDriver.cc index d4f183cc7e72152783194ff7803316610369881b..9ad42584b0290fccd2ca68599bb62ab3a5c1c74e 100644 --- a/src/ParsingDriver.cc +++ b/src/ParsingDriver.cc @@ -612,7 +612,7 @@ ParsingDriver::add_VAR_restriction_coeff(string *name1, string *name2, string *l int symb_id2 = name2 == nullptr ? -1 : mod_file->symbol_table.getID(*name2); int lag = atoi(lagstr->c_str()); - var_restriction_coeff = make_pair(symb_id1, make_pair(symb_id2, lag)); + var_restriction_coeff = { symb_id1, { symb_id2, lag } }; delete name1; if (name2 != nullptr) @@ -632,13 +632,9 @@ ParsingDriver::add_VAR_restriction_equation_or_crossequation(string *numberstr) assert(var_restriction_eq_or_crosseq.size() > 0 && var_restriction_eq_or_crosseq.size() < 3); double number = atof(numberstr->c_str()); if (var_restriction_eq_or_crosseq.size() == 1) - var_restriction_equation_or_crossequation = make_pair(make_pair(var_restriction_eq_or_crosseq[0], - make_pair(make_pair(-1, make_pair(-1, -1)), (expr_t) nullptr)), - number); + var_restriction_equation_or_crossequation = { { var_restriction_eq_or_crosseq[0], { { -1, { -1, -1 } }, (expr_t) nullptr } }, number }; else - var_restriction_equation_or_crossequation = make_pair(make_pair(var_restriction_eq_or_crosseq[0], - var_restriction_eq_or_crosseq[1]), - number); + var_restriction_equation_or_crossequation = { { var_restriction_eq_or_crosseq[0], var_restriction_eq_or_crosseq[1] }, number }; var_restriction_eq_or_crosseq.clear(); } @@ -648,7 +644,7 @@ ParsingDriver::multiply_arg2_by_neg_one() assert(var_restriction_eq_or_crosseq.size() == 2); expr_t exprtm1 = add_times(var_restriction_eq_or_crosseq[1].second, add_uminus(add_non_negative_constant(new string("-1")))); - var_restriction_eq_or_crosseq[1] = make_pair(var_restriction_eq_or_crosseq[1].first, exprtm1); + var_restriction_eq_or_crosseq[1] = { var_restriction_eq_or_crosseq[1].first, exprtm1 }; } void @@ -679,7 +675,7 @@ ParsingDriver::add_VAR_covariance_number_restriction(string *name1, string *name int symb_id1 = mod_file->symbol_table.getID(*name1); int symb_id2 = mod_file->symbol_table.getID(*name2); double value = atof(valuestr->c_str()); - covariance_number_restriction[make_pair(symb_id1, symb_id2)] = value; + covariance_number_restriction[{ symb_id1, symb_id2 }] = value; delete name1; delete name2; delete valuestr; @@ -692,7 +688,7 @@ ParsingDriver::add_VAR_covariance_pair_restriction(string *name11, string *name1 int symb_id12 = mod_file->symbol_table.getID(*name12); int symb_id21 = mod_file->symbol_table.getID(*name21); int symb_id22 = mod_file->symbol_table.getID(*name22); - covariance_pair_restriction[make_pair(symb_id11, symb_id12)] = make_pair(symb_id21, symb_id22); + covariance_pair_restriction[{ symb_id11, symb_id12 }] = { symb_id21, symb_id22 }; delete name11; delete name12; delete name21; @@ -762,7 +758,7 @@ ParsingDriver::init_val(string *name, expr_t rhs) && type != eExogenousDet) error("initval/endval: " + *name + " should be an endogenous or exogenous variable"); - init_values.push_back(make_pair(symb_id, rhs)); + init_values.emplace_back(symb_id, rhs); delete name; } @@ -824,7 +820,7 @@ ParsingDriver::homotopy_val(string *name, expr_t val1, expr_t val2) && type != eExogenousDet) error("homotopy_val: " + *name + " should be a parameter or exogenous variable"); - homotopy_values.push_back(make_pair(symb_id, make_pair(val1, val2))); + homotopy_values.emplace_back(symb_id, make_pair(val1, val2)); delete name; } @@ -1492,7 +1488,7 @@ ParsingDriver::option_num(const string &name_option, string *opt1, string *opt2) != options_list.paired_num_options.end()) error("option " + name_option + " declared twice"); - options_list.paired_num_options[name_option] = make_pair(*opt1, *opt2); + options_list.paired_num_options[name_option] = { *opt1, *opt2 }; delete opt1; delete opt2; } @@ -1779,7 +1775,7 @@ ParsingDriver::set_subsamples(string *name1, string *name2) mod_file->addStatement(new SubsamplesStatement(*name1, *name2, subsample_declaration_map, mod_file->symbol_table)); - subsample_declarations[make_pair(*name1, *name2)] = subsample_declaration_map; + subsample_declarations[{ *name1, *name2 }] = subsample_declaration_map; subsample_declaration_map.clear(); delete name1; delete name2; @@ -1795,7 +1791,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({ *from_name1, *from_name2 }) == subsample_declarations.end()) { string err = *from_name1; if (!from_name2->empty()) @@ -1806,8 +1802,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[{ *to_name1, *to_name2 }] + = subsample_declarations[{ *from_name1, *from_name2 }]; delete to_name1; delete to_name2; @@ -1829,7 +1825,7 @@ ParsingDriver::set_subsample_name_equal_to_date_range(string *name, string *date { if (subsample_declaration_map.find(*name) != subsample_declaration_map.end()) error("Symbol " + *name + " may only be assigned once in a SUBSAMPLE statement"); - subsample_declaration_map[*name] = make_pair(*date1, *date2); + subsample_declaration_map[*name] = { *date1, *date2 }; delete name; delete date1; delete date2; @@ -1856,10 +1852,10 @@ ParsingDriver::check_subsample_declaration_exists(string *name1, string *name2, if (!name2->empty()) check_symbol_existence(*name2); - subsample_declarations_t::const_iterator it = subsample_declarations.find(make_pair(*name1, *name2)); + subsample_declarations_t::const_iterator it = subsample_declarations.find({ *name1, *name2 }); if (it == subsample_declarations.end()) { - it = subsample_declarations.find(make_pair(*name2, *name1)); + it = subsample_declarations.find({ *name2, *name1 }); if (it == subsample_declarations.end()) { string err = *name1; @@ -2305,7 +2301,7 @@ ParsingDriver::add_mc_filename(string *filename, string *prior) for (auto & it : filename_list) if (it.first == *filename) error("model_comparison: filename " + *filename + " declared twice"); - filename_list.push_back(make_pair(*filename, *prior)); + filename_list.emplace_back(*filename, *prior); delete filename; delete prior; } @@ -3124,13 +3120,13 @@ pair<bool, double> ParsingDriver::is_there_one_integer_argument() const { if (stack_external_function_args.top().size() != 1) - return make_pair(false, 0); + return { false, 0 }; auto *numNode = dynamic_cast<NumConstNode *>(stack_external_function_args.top().front()); auto *unaryNode = dynamic_cast<UnaryOpNode *>(stack_external_function_args.top().front()); if (numNode == nullptr && unaryNode == nullptr) - return make_pair(false, 0); + return { false, 0 }; eval_context_t ectmp; double model_var_arg; @@ -3142,12 +3138,12 @@ ParsingDriver::is_there_one_integer_argument() const } catch (ExprNode::EvalException &e) { - return make_pair(false, 0); + return { false, 0 }; } } else if (unaryNode->get_op_code() != oUminus) - return make_pair(false, 0); + return { false, 0 }; else { try @@ -3156,13 +3152,13 @@ ParsingDriver::is_there_one_integer_argument() const } catch (ExprNode::EvalException &e) { - return make_pair(false, 0); + return { false, 0 }; } } if (model_var_arg != floor(model_var_arg)) - return make_pair(false, 0); - return make_pair(true, model_var_arg); + return { false, 0 }; + return { true, model_var_arg }; } expr_t diff --git a/src/StaticModel.cc b/src/StaticModel.cc index 0a0e017385976d739277ea086573dc71a16169d7..82690507a467eef88a1d289403f2bae138b124e5 100644 --- a/src/StaticModel.cc +++ b/src/StaticModel.cc @@ -46,7 +46,7 @@ StaticModel::StaticModel(SymbolTable &symbol_table_arg, void StaticModel::compileDerivative(ofstream &code_file, unsigned int &instruction_number, int eq, int symb_id, map_idx_t &map_idx, temporary_terms_t temporary_terms) const { - auto it = first_derivatives.find(make_pair(eq, getDerivID(symbol_table.getID(eEndogenous, symb_id), 0))); + auto it = first_derivatives.find({ eq, getDerivID(symbol_table.getID(eEndogenous, symb_id), 0) }); if (it != first_derivatives.end()) (it->second)->compile(code_file, instruction_number, false, temporary_terms, map_idx, false, false); else @@ -59,7 +59,7 @@ StaticModel::compileDerivative(ofstream &code_file, unsigned int &instruction_nu void StaticModel::compileChainRuleDerivative(ofstream &code_file, unsigned int &instruction_number, int eqr, int varr, int lag, map_idx_t &map_idx, temporary_terms_t temporary_terms) const { - auto it = first_chain_rule_derivatives.find(make_pair(eqr, make_pair(varr, lag))); + auto it = first_chain_rule_derivatives.find({ eqr, { varr, lag } }); if (it != first_chain_rule_derivatives.end()) (it->second)->compile(code_file, instruction_number, false, temporary_terms, map_idx, false, false); else @@ -470,7 +470,7 @@ StaticModel::writeModelEquationsCode(const string file_name, const string bin_ba fnumexpr.write(code_file, instruction_number); if (!derivatives[eq].size()) derivatives[eq].clear(); - derivatives[eq].push_back(make_pair(var, count_u)); + derivatives[eq].emplace_back(var, count_u); d1->compile(code_file, instruction_number, false, temporary_terms, map_idx, false, false); @@ -537,7 +537,7 @@ StaticModel::writeModelEquationsCode(const string file_name, const string bin_ba fnumexpr.write(code_file, instruction_number); if (!derivatives[eq].size()) derivatives[eq].clear(); - derivatives[eq].push_back(make_pair(var, count_u)); + derivatives[eq].emplace_back(var, count_u); d1->compile(code_file, instruction_number, false, temporary_terms, map_idx, false, false); FSTPG2_ fstpg2(eq, var); @@ -1033,7 +1033,7 @@ StaticModel::collect_first_order_derivatives_endogenous() int eq = first_derivative.first.first; int var = symbol_table.getTypeSpecificID(getSymbIDByDerivID(first_derivative.first.second)); int lag = 0; - endo_derivatives[make_pair(eq, make_pair(var, lag))] = first_derivative.second; + endo_derivatives[{ eq, { var, lag } }] = first_derivative.second; } } return endo_derivatives; @@ -2140,7 +2140,7 @@ StaticModel::writeOutput(ostream &output, bool block) const int symb = getSymbIDByDerivID(deriv_id); int var = symbol_table.getTypeSpecificID(symb); //int lag = getLagByDerivID(deriv_id); - row_incidence[make_pair(eq, var)] = 1; + row_incidence[{ eq, var }] = 1; } } output << "M_.block_structure_stat.incidence.sparse_IM = ["; @@ -2211,10 +2211,10 @@ StaticModel::get_Derivatives(int block) for (int var = 0; var < block_size; var++) { int varr = getBlockVariableID(block, var); - if (dynamic_jacobian.find(make_pair(lag, make_pair(eqr, varr))) != dynamic_jacobian.end()) + if (dynamic_jacobian.find({ lag, { eqr, varr } }) != dynamic_jacobian.end()) { bool OK = true; - map<pair<pair<int, pair<int, int>>, pair<int, int>>, int>::const_iterator its = Derivatives.find(make_pair(make_pair(lag, make_pair(eq, var)), make_pair(eqr, varr))); + map<pair<pair<int, pair<int, int>>, pair<int, int>>, int>::const_iterator its = Derivatives.find({ { lag, { eq, var } }, { eqr, varr } }); if (its != Derivatives.end()) { if (its->second == 2) @@ -2225,10 +2225,10 @@ StaticModel::get_Derivatives(int block) { if (getBlockEquationType(block, eq) == E_EVALUATE_S && eq < block_nb_recursive) //It's a normalized equation, we have to recompute the derivative using chain rule derivative function - Derivatives[make_pair(make_pair(lag, make_pair(eq, var)), make_pair(eqr, varr))] = 1; + Derivatives[{ { lag, { eq, var } }, { eqr, varr } }] = 1; else //It's a feedback equation we can use the derivatives - Derivatives[make_pair(make_pair(lag, make_pair(eq, var)), make_pair(eqr, varr))] = 0; + Derivatives[{ { lag, { eq, var } }, { eqr, varr } }] = 0; } if (var < block_nb_recursive) { @@ -2237,8 +2237,8 @@ StaticModel::get_Derivatives(int block) { int varrs = getBlockVariableID(block, vars); //A new derivative needs to be computed using the chain rule derivative function (a feedback variable appears in a recursive equation) - if (Derivatives.find(make_pair(make_pair(lag, make_pair(var, vars)), make_pair(eqs, varrs))) != Derivatives.end()) - Derivatives[make_pair(make_pair(lag, make_pair(eq, vars)), make_pair(eqr, varrs))] = 2; + if (Derivatives.find({ { lag, { var, vars } }, { eqs, varrs } }) != Derivatives.end()) + Derivatives[{ { lag, { eq, vars } }, { eqr, varrs } }] = 2; } } } @@ -2285,17 +2285,17 @@ StaticModel::computeChainRuleJacobian(blocks_derivatives_t &blocks_derivatives) int eqr = it_l.second.first; int varr = it_l.second.second; if (Deriv_type == 0) - first_chain_rule_derivatives[make_pair(eqr, make_pair(varr, lag))] = first_derivatives[make_pair(eqr, getDerivID(symbol_table.getID(eEndogenous, varr), lag))]; + first_chain_rule_derivatives[{ eqr, { varr, lag } }] = first_derivatives[{ eqr, getDerivID(symbol_table.getID(eEndogenous, varr), lag) }]; else if (Deriv_type == 1) - first_chain_rule_derivatives[make_pair(eqr, make_pair(varr, lag))] = (equation_type_and_normalized_equation[eqr].second)->getChainRuleDerivative(getDerivID(symbol_table.getID(eEndogenous, varr), lag), recursive_variables); + first_chain_rule_derivatives[{ eqr, { varr, lag } }] = (equation_type_and_normalized_equation[eqr].second)->getChainRuleDerivative(getDerivID(symbol_table.getID(eEndogenous, varr), lag), recursive_variables); else if (Deriv_type == 2) { if (getBlockEquationType(block, eq) == E_EVALUATE_S && eq < block_nb_recursives) - first_chain_rule_derivatives[make_pair(eqr, make_pair(varr, lag))] = (equation_type_and_normalized_equation[eqr].second)->getChainRuleDerivative(getDerivID(symbol_table.getID(eEndogenous, varr), lag), recursive_variables); + first_chain_rule_derivatives[{ eqr, { varr, lag } }] = (equation_type_and_normalized_equation[eqr].second)->getChainRuleDerivative(getDerivID(symbol_table.getID(eEndogenous, varr), lag), recursive_variables); else - first_chain_rule_derivatives[make_pair(eqr, make_pair(varr, lag))] = equations[eqr]->getChainRuleDerivative(getDerivID(symbol_table.getID(eEndogenous, varr), lag), recursive_variables); + first_chain_rule_derivatives[{ eqr, { varr, lag } }] = equations[eqr]->getChainRuleDerivative(getDerivID(symbol_table.getID(eEndogenous, varr), lag), recursive_variables); } - tmp_derivatives.push_back(make_pair(make_pair(eq, var), make_pair(lag, first_chain_rule_derivatives[make_pair(eqr, make_pair(varr, lag))]))); + tmp_derivatives.emplace_back(make_pair(eq, var), make_pair(lag, first_chain_rule_derivatives[make_pair(eqr, make_pair(varr, lag))])); } } else @@ -2317,9 +2317,8 @@ StaticModel::computeChainRuleJacobian(blocks_derivatives_t &blocks_derivatives) expr_t d1 = equations[eqr]->getChainRuleDerivative(getDerivID(symbol_table.getID(eEndogenous, varr), 0), recursive_variables); if (d1 == Zero) continue; - first_chain_rule_derivatives[make_pair(eqr, make_pair(varr, 0))] = d1; - tmp_derivatives.push_back( - make_pair(make_pair(eq, var), make_pair(0, first_chain_rule_derivatives[make_pair(eqr, make_pair(varr, 0))]))); + first_chain_rule_derivatives[{ eqr, { varr, 0 } }] = d1; + tmp_derivatives.emplace_back(make_pair(eq, var), make_pair(0, first_chain_rule_derivatives[make_pair(eqr, make_pair(varr, 0))])); } } } @@ -2345,8 +2344,8 @@ StaticModel::collect_block_first_order_derivatives() } } derivative_endo = vector<derivative_t>(nb_blocks); - endo_max_leadlag_block = vector<pair<int, int>>(nb_blocks, make_pair(0, 0)); - max_leadlag_block = vector<pair<int, int>>(nb_blocks, make_pair(0, 0)); + endo_max_leadlag_block = vector<pair<int, int>>(nb_blocks, { 0, 0 }); + max_leadlag_block = vector<pair<int, int>>(nb_blocks, { 0, 0 }); for (auto & first_derivative : first_derivatives) { int eq = first_derivative.first.first; @@ -2354,16 +2353,16 @@ StaticModel::collect_block_first_order_derivatives() int lag = 0; int block_eq = equation_2_block[eq]; int block_var = variable_2_block[var]; - max_leadlag_block[block_eq] = make_pair(0, 0); - max_leadlag_block[block_eq] = make_pair(0, 0); - endo_max_leadlag_block[block_eq] = make_pair(0, 0); - endo_max_leadlag_block[block_eq] = make_pair(0, 0); + max_leadlag_block[block_eq] = { 0, 0 }; + max_leadlag_block[block_eq] = { 0, 0 }; + endo_max_leadlag_block[block_eq] = { 0, 0 }; + endo_max_leadlag_block[block_eq] = { 0, 0 }; derivative_t tmp_derivative; lag_var_t lag_var; if (getTypeByDerivID(first_derivative.first.second) == eEndogenous && block_eq == block_var) { tmp_derivative = derivative_endo[block_eq]; - tmp_derivative[make_pair(lag, make_pair(eq, var))] = first_derivatives[make_pair(eq, getDerivID(symbol_table.getID(eEndogenous, var), lag))]; + tmp_derivative[{ lag, { eq, var } }] = first_derivatives[{ eq, getDerivID(symbol_table.getID(eEndogenous, var), lag) }]; derivative_endo[block_eq] = tmp_derivative; } } diff --git a/src/SteadyStateModel.cc b/src/SteadyStateModel.cc index 8de976a6caf8de32a4859cdd20ef4abc4749a0a9..74ff2394a7ad813bf3bf5694038888b6721681ce 100644 --- a/src/SteadyStateModel.cc +++ b/src/SteadyStateModel.cc @@ -193,7 +193,7 @@ SteadyStateModel::writeSteadyStateFile(const string &basename, bool ramsey_model output << "["; for (size_t j = 0; j < symb_ids.size(); j++) { - auto it = variable_node_map.find(make_pair(symb_ids[j], 0)); + auto it = variable_node_map.find({ symb_ids[j], 0 }); assert(it != variable_node_map.end()); dynamic_cast<ExprNode *>(it->second)->writeOutput(output, output_type); if (j < symb_ids.size()-1) @@ -254,7 +254,7 @@ SteadyStateModel::writeSteadyStateFileC(const string &basename, bool ramsey_mode output << " "; if (symb_ids.size() > 1) std::cout << "Error: in C, multiple returns are not permitted in steady_state_model" << std::endl; - auto it = variable_node_map.find(make_pair(symb_ids[0], 0)); + auto it = variable_node_map.find({ symb_ids[0], 0 }); assert(it != variable_node_map.end()); if (it->second->get_type() == eModFileLocalVariable) output << "double "; @@ -291,7 +291,7 @@ SteadyStateModel::writeJsonSteadyStateFile(ostream &output, bool transformComput if (j != 0) output << ","; auto it = - variable_node_map.find(make_pair(symb_ids[j], 0)); + variable_node_map.find({ symb_ids[j], 0 }); assert(it != variable_node_map.end()); output << "\""; dynamic_cast<ExprNode *>(it->second)->writeJsonOutput(output, {}, {}, false); diff --git a/src/macro/MacroDriver.cc b/src/macro/MacroDriver.cc index d490c7f1ae80271c98e766177035482bec4fa6d5..50899cc77be8fe2f450159c8c5ecfaac325659c9 100644 --- a/src/macro/MacroDriver.cc +++ b/src/macro/MacroDriver.cc @@ -110,7 +110,7 @@ MacroDriver::init_loop(const string &name, const MacroValue *value) noexcept(fal const auto *mv2 = dynamic_cast<const ArrayMV<string> *>(value); if (!mv1 && !mv2) throw MacroValue::TypeError("Argument of @#for loop must be an array expression"); - loop_stack.push(make_pair(name, make_pair(value, 0))); + loop_stack.emplace(name, make_pair(value, 0)); } bool