From 34c6a28693edbe9d39c68d7e8227d12da7c7319a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Tue, 28 Mar 2023 14:49:28 +0200
Subject: [PATCH] Preprocessor update
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

– 🐛 Incorrect stochastic transformation with endo lead ⩾ 2 or exo lead ⩾ 1 in
  external functions
– New solution for solving the Ramsey steady state with Lagrange multipliers
  with lead or lag ⩾ 2. Now generates a dedicated file for derivatives of static
  model w.r.t. multipliers using chain rule derivation (#633, #1119, #1133)
– 🐛 Incorrect cost table used when computing temporary terms in static model
  with “use_dll”
– 🐛 Crash when writing the (static) set_auxiliary_variables file in the
  presence of external functions
---
 matlab/dyn_ramsey_static.m | 8 +++-----
 preprocessor               | 2 +-
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/matlab/dyn_ramsey_static.m b/matlab/dyn_ramsey_static.m
index f1ed495edf..8509c694cb 100644
--- a/matlab/dyn_ramsey_static.m
+++ b/matlab/dyn_ramsey_static.m
@@ -153,16 +153,14 @@ end
 % set multipliers and auxiliary variables that
 % depends on multipliers to 0 to compute residuals
 if (options_.bytecode)
-    [res, junk] = bytecode('static', xx, exo_ss, params, 'evaluate');
-    fJ = junk.g1;
+    res = bytecode('static', xx, exo_ss, params, 'evaluate');
 else
-    [res, T_order, T] = feval([fname '.sparse.static_resid'], xx, exo_ss, params);
-    fJ = feval([fname '.sparse.static_g1'], xx, exo_ss, params, M.static_g1_sparse_rowval, M.static_g1_sparse_colval, M.static_g1_sparse_colptr, T_order, T);
+    res = feval([fname '.sparse.static_resid'], xx, exo_ss, params);
 end
 % index of multipliers and corresponding equations
 % the auxiliary variables before the Lagrange multipliers are treated
 % as ordinary endogenous variables
-A = fJ(1:orig_endo_aux_nbr,orig_endo_nbr+find(aux_vars_type==6));
+A = feval([fname '.ramsey_multipliers_static_g1'], xx, exo_ss, params, M.ramsey_multipliers_static_g1_sparse_rowval, M.ramsey_multipliers_static_g1_sparse_colval, M.ramsey_multipliers_static_g1_sparse_colptr);
 y = res(1:orig_endo_aux_nbr);
 mult = -A\y;
 
diff --git a/preprocessor b/preprocessor
index bff80c0eaf..0169240f76 160000
--- a/preprocessor
+++ b/preprocessor
@@ -1 +1 @@
-Subproject commit bff80c0eaf39ba5c05be92900bbf09b16c7f9452
+Subproject commit 0169240f76532df6d507b01647e8576d1094e95d
-- 
GitLab