From 00f526dbb72aeda0847a187f48d7555147dd7342 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien.villemot@ens.fr>
Date: Thu, 7 Jun 2012 15:26:49 +0200
Subject: [PATCH] Generate derivs wrt params when anaytic_derivation=1

---
 preprocessor/ComputingTasks.cc | 5 +++++
 preprocessor/ModFile.cc        | 2 +-
 preprocessor/Statement.hh      | 2 ++
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/preprocessor/ComputingTasks.cc b/preprocessor/ComputingTasks.cc
index 39f3e1f1f..5e18a1129 100644
--- a/preprocessor/ComputingTasks.cc
+++ b/preprocessor/ComputingTasks.cc
@@ -293,6 +293,11 @@ EstimationStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsoli
   if (it != options_list.num_options.end() && it->second == "1")
     mod_file_struct.partial_information = true;
 
+  // Fill in mod_file_struct.estimation_analytic_derivation
+  it = options_list.num_options.find("analytic_derivation");
+  if (it != options_list.num_options.end() && it->second == "1")
+    mod_file_struct.estimation_analytic_derivation = true;
+
   it = options_list.num_options.find("dsge_var");
   if (it != options_list.num_options.end())
     // Ensure that irf_shocks & dsge_var have not both been passed
diff --git a/preprocessor/ModFile.cc b/preprocessor/ModFile.cc
index c6e3fa090..d05cc935f 100644
--- a/preprocessor/ModFile.cc
+++ b/preprocessor/ModFile.cc
@@ -403,7 +403,7 @@ ModFile::computingPass(bool no_tmp_terms)
                 }
               bool hessian = mod_file_struct.order_option >= 2 || mod_file_struct.identification_present;
               bool thirdDerivatives = mod_file_struct.order_option == 3;
-              bool paramsDerivatives = mod_file_struct.identification_present;
+              bool paramsDerivatives = mod_file_struct.identification_present || mod_file_struct.estimation_analytic_derivation;
               dynamic_model.computingPass(true, hessian, thirdDerivatives, paramsDerivatives, global_eval_context, no_tmp_terms, block, use_dll, byte_code);
             }
         }
diff --git a/preprocessor/Statement.hh b/preprocessor/Statement.hh
index 92b1ff19f..3847d3ccc 100644
--- a/preprocessor/Statement.hh
+++ b/preprocessor/Statement.hh
@@ -65,6 +65,8 @@ public:
   bool svar_identification_present;
   //! Whether an identification statement is present or the identification option of dynare_sensitivity statement is equal to one
   bool identification_present;
+  //! Whether the option analytic_derivation is given to estimation
+  bool estimation_analytic_derivation;
   //! Whether the option partial_information is given to stoch_simul/estimation/osr/ramsey_policy
   bool partial_information;
   //! Whether a shocks or mshocks block is present
-- 
GitLab