diff --git a/preprocessor/DataTree.cc b/preprocessor/DataTree.cc index db60f58beb69db34073c8ff60a2e8903a9766dc2..f151fa3aa8be1e22c474189764e60c0a12a19587 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 07ff6e8101fe486310d2491a9b73af04e363b2ed..ee0673ec6d5a58c51a7f2febbf37a65c5846b74b 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 73e77048fc3a4e247569bd60c395418e0ef140c2..f072ff2b26be8ffb9f28ea24b29fb47a7c2824be 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(); }