From 0376f7f1733f560b5ec96eb49a4430ae2f2f4840 Mon Sep 17 00:00:00 2001 From: Houtan Bastani <houtan@dynare.org> Date: Wed, 12 Sep 2018 11:56:53 +0200 Subject: [PATCH] fix bugs in creation of AR/EC matrices --- src/DynamicModel.cc | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/DynamicModel.cc b/src/DynamicModel.cc index 0ed546ae..ebb3d71c 100644 --- a/src/DynamicModel.cc +++ b/src/DynamicModel.cc @@ -3716,7 +3716,8 @@ DynamicModel::fillVarModelTableFromOrigModel(StaticModel &static_model) const void DynamicModel::fillAutoregressiveMatrix(map<string, map<tuple<int, int, int>, expr_t>> &ARr, bool is_trend_component_model) const { - auto eqnums = is_trend_component_model ? trend_component_model_table.getEqNums() : var_model_table.getEqNums(); + auto eqnums = is_trend_component_model ? + trend_component_model_table.getNonTrendEqNums() : var_model_table.getEqNums(); for (const auto & it : eqnums) { int i = 0; @@ -3855,17 +3856,13 @@ DynamicModel::fillTrendComponentModelTable() const void DynamicModel::fillErrorComponentMatrix(map<string, map<tuple<int, int, int>, expr_t>> &ECr) const { - for (const auto & it : trend_component_model_table.getEqNums()) + for (const auto & it : trend_component_model_table.getNonTrendEqNums()) { - vector<int> nontrend_lhs; - vector<int> lhsv = trend_component_model_table.getLhs(it.first); - for (int trend_it : trend_component_model_table.getTrendEqNums(it.first)) - nontrend_lhs.push_back(lhsv.at(distance(it.second.begin(), find(it.second.begin(), it.second.end(), trend_it)))); - int i = 0; map<tuple<int, int, int>, expr_t> EC; + vector<int> trend_lhs = trend_component_model_table.getTrendLhs(it.first); for (auto eqn : it.second) - equations[eqn]->get_arg2()->fillErrorCorrectionRow(i++, nontrend_lhs, EC); + equations[eqn]->get_arg2()->fillErrorCorrectionRow(i++, trend_lhs, EC); ECr[it.first] = EC; } } -- GitLab