diff --git a/preprocessor/ComputingTasks.cc b/preprocessor/ComputingTasks.cc index d856b1ad2..e792360a2 100644 --- a/preprocessor/ComputingTasks.cc +++ b/preprocessor/ComputingTasks.cc @@ -340,17 +340,13 @@ VarRestrictionsStatement::writeOutput(ostream &output, const string &basename, b for (crossequation_restrictions_t::const_iterator it = crossequation_restrictions.begin(); it != crossequation_restrictions.end(); it++, idx++, nrestrictions++) { - output << Mstr << "crossequation_restriction{" << idx << "}.eq1 = '" - << symbol_table.getName(it->first.first) << "';" << endl - << Mstr << "crossequation_restriction{" << idx << "}.eq2 = '" - << symbol_table.getName(it->first.second) << "';" << endl - << Mstr << "crossequation_restriction{" << idx << "}.val = " - << it->second.second << ";" << endl; + output << Mstr << "crossequation_restriction{" << idx << "}.val = " + << it->second << ";" << endl; - var_restriction_eq_crosseq_t ls = it->second.first.first; + var_restriction_eq_crosseq_t ls = it->first.first; output << Mstr << "crossequation_restriction{" << idx << "}.lseq = '" << symbol_table.getName(ls.first.first) << "';" << endl - << Mstr << "crossequation_restriction{" << idx << "}.ls2 = '" + << Mstr << "crossequation_restriction{" << idx << "}.lsvar = '" << symbol_table.getName(ls.first.second.first) << "';" << endl << Mstr << "crossequation_restriction{" << idx << "}.lslag = " << ls.first.second.second << ";" << endl @@ -358,12 +354,12 @@ VarRestrictionsStatement::writeOutput(ostream &output, const string &basename, b ls.second->writeOutput(output); output << ";" << endl; - var_restriction_eq_crosseq_t rs = it->second.first.second; + var_restriction_eq_crosseq_t rs = it->first.second; if (rs.first.first >= 0) { output << Mstr << "crossequation_restriction{" << idx << "}.rseq = '" << symbol_table.getName(rs.first.first) << "';" << endl - << Mstr << "crossequation_restriction{" << idx << "}.rs2 = '" + << Mstr << "crossequation_restriction{" << idx << "}.rsvar = '" << symbol_table.getName(rs.first.second.first) << "';" << endl << Mstr << "crossequation_restriction{" << idx << "}.rslag = " << rs.first.second.second << ";" << endl diff --git a/preprocessor/ComputingTasks.hh b/preprocessor/ComputingTasks.hh index 326f28261..94a0ecfb3 100644 --- a/preprocessor/ComputingTasks.hh +++ b/preprocessor/ComputingTasks.hh @@ -134,7 +134,7 @@ private: const map > exclusion_restrictions; typedef map, double> > equation_restrictions_t; const equation_restrictions_t equation_restrictions; - typedef map, pair, double> > crossequation_restrictions_t; + typedef vector, double> > crossequation_restrictions_t; const crossequation_restrictions_t crossequation_restrictions; const map, double> covariance_number_restriction; const map, pair > covariance_pair_restriction; diff --git a/preprocessor/DynareBison.yy b/preprocessor/DynareBison.yy index 8e8f9d4f8..11e2506e7 100644 --- a/preprocessor/DynareBison.yy +++ b/preprocessor/DynareBison.yy @@ -380,9 +380,9 @@ restrictions_list : restrictions_list restriction restriction : EXCLUSION LAG INT_NUMBER ';' restriction_exclusion_equation_list { driver.add_VAR_exclusion_restriction($3); } | RESTRICTION EQUATION '(' symbol ')' restriction_equation_equality ';' - { driver.add_VAR_restriction_equation_or_crossequation_final($4, NULL); } - | RESTRICTION CROSSEQUATIONS '(' symbol COMMA symbol ')' restriction_crossequation_equality ';' - { driver.add_VAR_restriction_equation_or_crossequation_final($4, $6); } + { driver.add_VAR_restriction_equation_or_crossequation_final($4); } + | RESTRICTION CROSSEQUATIONS restriction_crossequation_equality ';' + { driver.add_VAR_restriction_equation_or_crossequation_final(NULL); } | RESTRICTION COVARIANCE '(' symbol COMMA symbol ')' EQUAL number ';' { driver.add_VAR_covariance_number_restriction($4, $6, $9); } | RESTRICTION COVARIANCE '(' symbol COMMA symbol ')' EQUAL '(' symbol COMMA symbol ')' ';' diff --git a/preprocessor/ParsingDriver.cc b/preprocessor/ParsingDriver.cc index 2e1c5a2a2..9fd948870 100644 --- a/preprocessor/ParsingDriver.cc +++ b/preprocessor/ParsingDriver.cc @@ -576,18 +576,16 @@ ParsingDriver::multiply_arg2_by_neg_one() } void -ParsingDriver::add_VAR_restriction_equation_or_crossequation_final(string *name1, string *name2) +ParsingDriver::add_VAR_restriction_equation_or_crossequation_final(string *name) { - int symb_id1 = mod_file->symbol_table.getID(*name1); - if (name2 == NULL) - equation_restrictions[symb_id1] = var_restriction_equation_or_crossequation; - else + if (name != NULL) { - int symb_id2 = name2 == NULL ? -1 : mod_file->symbol_table.getID(*name2); - crossequation_restrictions[make_pair(symb_id1, symb_id2)] = var_restriction_equation_or_crossequation; - delete name2; + int symb_id = mod_file->symbol_table.getID(*name); + equation_restrictions[symb_id] = var_restriction_equation_or_crossequation; + delete name; } - delete name1; + else + crossequation_restrictions.push_back(var_restriction_equation_or_crossequation); } void diff --git a/preprocessor/ParsingDriver.hh b/preprocessor/ParsingDriver.hh index c6ff4cfdd..0198f52db 100644 --- a/preprocessor/ParsingDriver.hh +++ b/preprocessor/ParsingDriver.hh @@ -272,7 +272,7 @@ public: vector var_restriction_eq_or_crosseq; pair, double> var_restriction_equation_or_crossequation; map, double> > equation_restrictions; - map, pair, double> > crossequation_restrictions; + vector, double> > crossequation_restrictions; //! > covariance restrictions map, double> covariance_number_restriction; map, pair > covariance_pair_restriction; @@ -789,7 +789,7 @@ public: void add_VAR_restriction_eq_or_crosseq(expr_t expr); void add_VAR_restriction_equation_or_crossequation(string *numberstr); void multiply_arg2_by_neg_one(); - void add_VAR_restriction_equation_or_crossequation_final(string *name1, string *name2); + void add_VAR_restriction_equation_or_crossequation_final(string *name); void add_VAR_covariance_number_restriction(string *name1, string *name2, string *valuestr); void add_VAR_covariance_pair_restriction(string *name11, string *name12, string *name21, string *name22); //! Runs VAR estimation process