From 968e411c3136c65a05d21994d3ba660c6992e4b1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Fri, 25 May 2018 15:19:33 +0200
Subject: [PATCH] Make indexing in temporary terms array ready for a
 (hypothetical future) implementation in C

---
 src/ExprNode.cc  | 2 +-
 src/ModelTree.cc | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/ExprNode.cc b/src/ExprNode.cc
index 105a9b60..f598b5db 100644
--- a/src/ExprNode.cc
+++ b/src/ExprNode.cc
@@ -121,7 +121,7 @@ ExprNode::checkIfTemporaryTermThenWrite(ostream &output, ExprNodeOutputType outp
         // It is the responsibility of the caller to ensure that all temporary terms have their index
         assert(it2 != temporary_terms_idxs.end());
         output << "T" << LEFT_ARRAY_SUBSCRIPT(output_type)
-               << it2->second
+               << it2->second + ARRAY_SUBSCRIPT_OFFSET(output_type)
                << RIGHT_ARRAY_SUBSCRIPT(output_type);
       }
   return true;
diff --git a/src/ModelTree.cc b/src/ModelTree.cc
index c3045139..998ae76e 100644
--- a/src/ModelTree.cc
+++ b/src/ModelTree.cc
@@ -1179,7 +1179,7 @@ ModelTree::computeTemporaryTerms(bool is_matlab)
   temporary_terms_g2  = temp_terms_map[eSecondDeriv];
   temporary_terms_g3  = temp_terms_map[eThirdDeriv];
 
-  int idx = 1;
+  int idx = 0;
   for (map<expr_t, expr_t>::const_iterator it = temporary_terms_mlv.begin();
        it != temporary_terms_mlv.end(); it++)
     temporary_terms_idxs[it->first] = idx++;
-- 
GitLab