From 8bedce78cea3d293ca2e711c33653d552607d3b5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien.villemot@ens.fr>
Date: Mon, 20 Sep 2010 18:30:00 +0200
Subject: [PATCH] K-order DLL: make it compatible with changes introduced in
 648c3cd177a32ac30b1f0504a322496e28932452 (cherry picked from commit
 d7754ca2888d9813c5e3fa2ae528c251a0d7a4fa)

---
 mex/sources/k_order_perturbation/dynamic_dll.cc        | 10 ++++++----
 mex/sources/k_order_perturbation/dynamic_dll.hh        |  5 +++--
 .../k_order_perturbation/k_order_perturbation.cc       |  2 +-
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/mex/sources/k_order_perturbation/dynamic_dll.cc b/mex/sources/k_order_perturbation/dynamic_dll.cc
index 001ee69493..5760b29604 100644
--- a/mex/sources/k_order_perturbation/dynamic_dll.cc
+++ b/mex/sources/k_order_perturbation/dynamic_dll.cc
@@ -27,8 +27,8 @@
  * <model>_dynamic () function
  **************************************/
 DynamicModelDLL::DynamicModelDLL(const string &modName, const int y_length, const int j_cols,
-                                 const int n_max_lag, const int n_exog, const string &sExt) throw (DynareException) :
-  length(y_length), jcols(j_cols), nMax_lag(n_max_lag), nExog(n_exog)
+                                 const int n_max_lag, const int n_exog, const Vector &ySteady_arg, const string &sExt) throw (DynareException) :
+  length(y_length), jcols(j_cols), nMax_lag(n_max_lag), nExog(n_exog), ySteady(ySteady_arg)
 {
   string fName;
 #if !defined(__CYGWIN32__) && !defined(_WIN32)
@@ -97,7 +97,8 @@ void
 DynamicModelDLL::eval(double *y, double *x, int nb_row_x, double *params,
                       int it_, double *residual, double *g1, double *g2, double *g3)
 {
-  Dynamic(y, x, nb_row_x, params, it_, residual, g1, g2, g3);
+  double *steady_state = const_cast<double *>(ySteady.base());
+  Dynamic(y, x, nb_row_x, params, steady_state, it_, residual, g1, g2, g3);
 }
 
 void
@@ -124,8 +125,9 @@ DynamicModelDLL::eval(const Vector &y, const TwoDMatrix &x, const  Vector *modPa
   double *dy = const_cast<double *>(y.base());
   double *dx = const_cast<double *>(x.base());
   double *dbParams = const_cast<double *>(modParams->base());
+  double *steady_state = const_cast<double *>(ySteady.base());
 
-  Dynamic(dy, dx, nExog, dbParams, it_, dresidual, dg1, dg2, dg3);
+  Dynamic(dy, dx, nExog, dbParams, steady_state, it_, dresidual, dg1, dg2, dg3);
 }
 
 void
diff --git a/mex/sources/k_order_perturbation/dynamic_dll.hh b/mex/sources/k_order_perturbation/dynamic_dll.hh
index 10b6615ae9..efed398d93 100644
--- a/mex/sources/k_order_perturbation/dynamic_dll.hh
+++ b/mex/sources/k_order_perturbation/dynamic_dll.hh
@@ -30,7 +30,7 @@
 
 // <model>_Dynamic DLL pointer
 typedef void  (*DynamicFn)
-(double *y, double *x, int nb_row_x, double *params,
+(double *y, double *x, int nb_row_x, double *params, double *steady_state,
  int it_, double *residual, double *g1, double *g2, double *g3);
 
 /**
@@ -46,6 +46,7 @@ private:
   const int jcols;  // tot num var t-1, t and t+1 instances + exogs = Num of Jacobian columns
   const int nMax_lag; // no of lags
   const int nExog; // no of exogenous
+  const Vector &ySteady;
 #if defined(_WIN32) || defined(__CYGWIN32__)
   HINSTANCE dynamicHinstance;  // DLL instance pointer in Windows
 #else
@@ -55,7 +56,7 @@ private:
 public:
   // construct and load Dynamic model DLL
   DynamicModelDLL(const string &fname, const int length, const int jcols,
-                  const int nMax_lag, const int nExog, const string &sExt) throw (DynareException);
+                  const int nMax_lag, const int nExog, const Vector &ySteady_arg, const string &sExt) throw (DynareException);
   virtual ~DynamicModelDLL();
 
   // evaluate Dynamic model DLL
diff --git a/mex/sources/k_order_perturbation/k_order_perturbation.cc b/mex/sources/k_order_perturbation/k_order_perturbation.cc
index ba1de66b8e..2082a2472f 100644
--- a/mex/sources/k_order_perturbation/k_order_perturbation.cc
+++ b/mex/sources/k_order_perturbation/k_order_perturbation.cc
@@ -195,7 +195,7 @@ extern "C" {
         std::string jName(fName); //params.basename);
         jName += ".jnl";
         Journal journal(jName.c_str());
-        DynamicModelDLL dynamicDLL(fName, nEndo, jcols, nMax_lag, nExog, dfExt);
+        DynamicModelDLL dynamicDLL(fName, nEndo, jcols, nMax_lag, nExog, ySteady, dfExt);
 
         // intiate tensor library
         tls.init(kOrder, nStat+2*nPred+3*nBoth+2*nForw+nExog);
-- 
GitLab