From 17cfb42afe7d7e4c06d124a402975e1180ba05b9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Wed, 14 Dec 2022 12:05:12 +0100
Subject: [PATCH] Fix indexing in M_.endo_trends

It would use 0-based indexing, instead of 1-based.

Ref. dynare#1648

Closes: #109
(cherry picked from commit 2758f46c83f847fb56a5107b16a05300ee11dc70)
---
 src/DynamicModel.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/DynamicModel.cc b/src/DynamicModel.cc
index 6026e514..dd8f62ce 100644
--- a/src/DynamicModel.cc
+++ b/src/DynamicModel.cc
@@ -2994,13 +2994,13 @@ DynamicModel::writeDriverOutput(ostream &output, const string &basename, bool bl
       if (auto it = nonstationary_symbols_map.find(symb_id); it != nonstationary_symbols_map.end())
         {
           auto [is_log, deflator] = it->second;
-          output << "M_.endo_trends(" << i << ")."
+          output << "M_.endo_trends(" << i+1 << ")."
                  << (is_log ? "log_deflator" : "deflator") << " = '";
           deflator->writeJsonOutput(output, {}, {});
           output << "';" << endl;
 
           auto growth_factor = const_cast<DynamicModel *>(this)->AddDivide(deflator, deflator->decreaseLeadsLags(1))->removeTrendLeadLag(trend_symbols_map)->replaceTrendVar();
-          output << "M_.endo_trends(" << i << ")."
+          output << "M_.endo_trends(" << i+1 << ")."
                  << (is_log ? "log_growth_factor" : "growth_factor") << " = '";
           growth_factor->writeJsonOutput(output, {}, {});
           output << "';" << endl;
-- 
GitLab