From d8dbc68e841a93b40d2a5005bd69bdd1cbb1778a Mon Sep 17 00:00:00 2001 From: Ferhat Mihoubi Date: Fri, 17 Dec 2010 14:21:35 +0100 Subject: [PATCH] - The function getPowerDeriv must end with an "end" instruction --- preprocessor/DataTree.cc | 16 +++++++++------- preprocessor/DynamicModel.cc | 3 ++- preprocessor/StaticModel.cc | 1 + 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/preprocessor/DataTree.cc b/preprocessor/DataTree.cc index db60f58be..f151fa3aa 100644 --- a/preprocessor/DataTree.cc +++ b/preprocessor/DataTree.cc @@ -651,13 +651,15 @@ DataTree::writePowerDeriv(ostream &output, bool use_dll) const << "% The k-th derivative of x^p" << endl << "%" << endl << "function dxp=getPowerDeriv(x,p,k)" << endl - << "if (abs(x) < " << NEAR_ZERO << ") && (p > 0) && (k >= p) && (abs(p - round(p)) < " << NEAR_ZERO << ")" << endl - << " dxp = 0;" << endl - << "else" << endl - << " dxp = x^(p-k);" << endl - << " for i=0:k-1" << endl - << " dxp = dxp*p;" << endl - << " p = p-1;" << endl + << " if (abs(x) < " << NEAR_ZERO << ") && (p > 0) && (k >= p) && (abs(p - round(p)) < " << NEAR_ZERO << ")" << endl + << " dxp = 0;" << endl + << " else" << endl + << " dxp = x^(p-k);" << endl + << " for i=0:k-1" << endl + << " dxp = dxp*p;" << endl + << " p = p-1;" << endl + << " end" << endl << " end" << endl << "end" << endl; + } diff --git a/preprocessor/DynamicModel.cc b/preprocessor/DynamicModel.cc index 07ff6e810..ee0673ec6 100644 --- a/preprocessor/DynamicModel.cc +++ b/preprocessor/DynamicModel.cc @@ -795,6 +795,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const default: break; } + output << "end" << endl; writePowerDeriv(output, false); output.close(); } @@ -2033,7 +2034,7 @@ DynamicModel::writeSparseDynamicMFile(const string &dynamic_basename, const stri open_par = false; mDynamicModelFile << " oo_.endo_simul = y';\n"; mDynamicModelFile << "return;\n"; - + mDynamicModelFile << "end" << endl; writePowerDeriv(mDynamicModelFile, false); mDynamicModelFile.close(); diff --git a/preprocessor/StaticModel.cc b/preprocessor/StaticModel.cc index 73e77048f..f072ff2b2 100644 --- a/preprocessor/StaticModel.cc +++ b/preprocessor/StaticModel.cc @@ -407,6 +407,7 @@ StaticModel::writeModelEquationsOrdered_M(const string &static_basename) const default: break; } + output << "end" << endl; writePowerDeriv(output, false); output.close(); }